﻿// players.js  '855','480'
    //var baseURL = "http://dev.globovision.batanga.com";
    //var baseURL = "http://globovision.batanga.com";
    //alert(document.location.hostname);
    var baseURL="http://"+document.location.hostname;
    if (!(/batanga\.com/gi.test(baseURL)))
        baseURL = "http://globovision.batanga.com";
    //alert(baseURL);
	function openPlayerExtract(sPresentationType, sGuid) 
	{
		openPlayer(sPresentationType, sGuid);
		return false;
	}

	function openPlayer(sPresentationType, sGuid) 
	{
		var strPath;
		var strName;
		var strWidth;
		var strHeight;
		var strTest;
		var intCount;

		strPath = baseURL+'/Player/default.asp?guid=' + sGuid + '&presType=' + sPresentationType;

		strName = 'PNIPlayerWindow';

		strWidth = '855';
		strHeight = '580';
		
		wh = popUpWindow(strPath, strName, strWidth, strHeight);

		blockURL = baseURL+"/popupblocker/blockDetected.asp?sPresentationType=" + sPresentationType + "&sGuid=" + sGuid;
		if (wh == null) {
			document.location = blockURL;
		} else {
			try {
				wh.focus ();
			} catch (er) {
				document.location = blockURL;
			}
		}
	}
	
	function openPlayerCategory(sPresentationType, sGuid, sCategory) 
	{
		var strPath;
		var strName;
		var strWidth;
		var strHeight;
		var strTest;
		var intCount;

		strPath = baseURL+'/Player/default.asp?guid=' + sGuid + '&presType=' + sPresentationType + '&cat=' + sCategory;

		strName = 'PNIPlayerWindow';

		strWidth = '790';
		strHeight = '546';
		
		wh = popUpWindow(strPath, strName, strWidth, strHeight);

		blockURL = baseURL+"/popupblocker/blockDetected.asp?sPresentationType=" + sPresentationType + "&sGuid=" + sGuid + "&sCategory=" + sCategory;
		if (wh == null) {
			document.location = blockURL;
		} else {
			try {
				wh.focus ();
			} catch (er) {
				document.location = blockURL;
			}
		}
	}
		
	function openLink(strUrl)
	{
		document.open(strUrl, '', '', '');
	}

	function popUpWindow(url, name, width, height) {

		var left 
		var top 
		left = getCenteredLeft('789') - 5;
		top = getCenteredTop('545') - 12;

		// Build the param string.
		var params = "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0";
		params += ",width=" + width;
		params += ",height=" + height;
		params += ",left=" + left;
		params += ",top=" + top;
		params += ",screenX=" + left; // for Netscape.
		params += ",screenY=" + top;
		// Open the window. Set the opener property if it's missing. And return the window handle.

		var wh = window.open(url, name, params);
		//if (wh.opener == null) wh.opener = window;
		return wh;
	}
		
	function getWinLeft(name) {
		// Look for a cookie named "coords-" + name.
		// The cookie should be formatted as "left:top".
		// Split and return the value. If there's no cookie, return null.
		var v;
		var coords;
		if ((v = getCookie('coords-' + name)) != null) {
			coords = v.split(':');
			return (parseInt(coords[0]));
		} else {
			return (null);
		}
	}

	function getWinTop(name) {
		// Look for a cookie named "coords-" + name.
		// The cookie should be formatted as "left:top".
		// Split and return the value.  If there's no cookie, return null.
		var v;
		var coords;
		if ((v = getCookie('coords-' + name)) != null) {
			coords = v.split(':');
			return (parseInt(coords[1]));
		} else {
			return (null);
		}
	}

	function getCenteredLeft(width) {
		var sw = screen.availWidth;
		if (sw > 0) return (Math.floor((sw - width) / 2));
		else return (0);
	}

	function getCenteredTop(height) {
		var sh = screen.availHeight;
		if (sh > 0) return (Math.floor((sh - height) / 2));
		else return (0);
	}