// Global Functions -- modified 07.29.03 by SB

// Standard window.open script.
function WinOpen(height,width,url)
{
	window.open(
	url,
	"RegHelp",
	"toolbar=no,location=no,resizable=yes,scrollbars=yes,status=no,height="+height+",width="+width);
}

// WinOpenFullAttr allows you to specifiy window attributes in addition to height and width.
// popname: window name
// fullattr: toolbar=no,location=no,resizable=yes,scrollbars=yes,status=no.  Remove any trailing commas in function call!
function WinOpenFullAttr(height,width,url,popname,fullattr)
{
	window.open(
	url,
	popname,
	fullattr + "," + "height=" + height + ",width=" + width);
}

// Newsletter popup
// this is the newsletter popup

function newsPopup ()
{
	resultWindow = "http://www.hbo.com/newsletter/processing.html";
	window.open(resultWindow,'popup','width=360,height=400,toolbar=no,location=no,resizable=no,scrollbars=no,status=yes,left=10,top=10,screenX=10,screenY=10');
}

// this is the chat new login popup -- see stephanie 5195

function chatPopup ()
{
	resultWindow = "http://www.hbo.com/corpinfo/processing_login.html";
	window.open(resultWindow,'chat','width=625,height=500,toolbar=no,location=no,resizable=no,scrollbars=yes,status=yes,left=10,top=10,screenX=10,screenY=10');
}

// this is the chat new login popup -- see stephanie 5195

function loginPopup (URL)
{
	window.open(URL,'login','width=625,height=500,toolbar=no,location=no,resizable=no,scrollbars=yes,status=yes,left=10,top=10,screenX=10,screenY=10');
}

// this is the chat new login popup -- see stephanie 5195

function gamePopup (URL)
{
	window.open(URL,'game','width=800,height=570,toolbar=no,location=no,resizable=no,scrollbars=yes,status=yes,left=10,top=10,screenX=10,screenY=10');
}

// this is the boxing event login popup -- same as above, just different window size

function boxingPopup (URL)
{
	window.open(URL,'game','width=600,height=475,toolbar=no,location=no,resizable=no,scrollbars=yes,status=yes,left=10,top=10,screenX=10,screenY=10');
}

// every window on HBO.com should be named MAIN so that the store and login can be redirected back to the parent window...

window.name = "MAIN";


// the following scripts are used to read the login cookie and display the header

function getCookie (name) {
var dcookie = document.cookie;
var cname = name + "=";
var clen = dcookie.length;
var cbegin = 0;
        while (cbegin < clen) {
        var vbegin = cbegin + cname.length;
                if (dcookie.substring(cbegin, vbegin) == cname) {
                var vend = dcookie.indexOf (";", vbegin);
                        if (vend == -1) vend = clen;
                return unescape(dcookie.substring(vbegin, vend));
                }
        cbegin = dcookie.indexOf(" ", cbegin) + 1;
                if (cbegin == 0) break;
        }
return null;
}

var hbo_username = getCookie("logged_in_user");


function registerPop()
{
	window.open('https://www.hbo.com/apps/login/UserRegistration.do?ro=103234&ows=103271&tws=103271&activity_type_id=AIMQRYD2&survey_id=XTRAND2&pFlow=1','login','width=625,height=500,toolbar=no,location=no,resizable=no,scrollbars=yes,status=yes,left=10,top=10,screenX=10,screenY=10');
}

function signinPop()
{
	window.open('https://www.hbo.com/apps/login/secure/LogMeIn.do?ro=103234&ows=103270&tws=103270&activity_type_id=AIMQRYD2&survey_id=XTRAND2&pFlow=2','login','width=625,height=500,toolbar=no,location=no,resizable=no,scrollbars=yes,status=yes,left=10,top=10,screenX=10,screenY=10');
}

function profilePop()
{
	window.open('https://www.hbo.com/apps/login/secure/ProfileAtAGlance.do?ro=103258&ows=103270&tws=103270&survey_id=XTRAND2&activity_type_id=AIMQRYD2&pFlow=2','login','width=625,height=500,toolbar=no,location=no,resizable=no,scrollbars=yes,status=yes,left=10,top=10,screenX=10,screenY=10');
}


function writeCookie (cookieName, cookieValue, expiry)
{
	var expDate = new Date();

	expDate.setTime (expDate.getTime() + expiry);
	document.cookie = cookieName + "=" + escape (cookieValue) + "; expires=" + expDate.toGMTString() + "; path=/";
}


function deleteCookie (name) {
var expireNow = new Date();
document.cookie = name + "=" +
"; expires=Thu, 01-Jan-70 00:00:01 GMT" +  "; path=/";
window.location.reload();
}