// ----------------------------------------------------------------------------
//	functions.js
//	
//	Javascript functions with no other homve.  Unknown why nexus 
//	created this as separate file
//	
// ----------------------------------------------------------------------------
//	History
//		02/17/04	Previous nexus development
//		02/17/04	KAM	Code Reform; added temporary(?) javascript globals to
//						support AOL secure mode change
//		02/18/04	KAM Revised approach to AOL secure mode -- now use 
//						JS globals -- parms unchanged to launch
//		09/21/06  WCC Changes made to prevent problems when ISP Cycle IPs
//		10/08/08  WCC Added Gift Card Changes
// ----------------------------------------------------------------------------
var onlineBoxOffice=null;
dontOpenOBO=false;

function IsNumeric(sText)
{
    var ValidChars = "0123456789.";
    var IsNumber=true;
    var Char;

    for (i = 0; i < sText.length && IsNumber == true; i++)
    {
	Char = sText.charAt(i);
	if (ValidChars.indexOf(Char) == -1)
        {
	 IsNumber = false;
	}
    }
    return IsNumber;
}


//	Test launch -- remove when problem solved
//function launchOnlineBoxOffice(prodID,override){
function testlaunchOnlineBoxOffice(prodID,override){
	alert('strHTTPprefix = ' + strHTTPprefix);
	alert('strHTTPSprefix = ' + strHTTPSprefix);
	alert('iOBOSecure  = ' + iOBOSecure);
	alert('prodID = ' + prodID);
	alert('override = ' + override);
	address='onlineBoxOffice/goOBO.aspx?reset=1&prodID=' + prodID;
	if(override != null) {
		address = override;
		}
	if (iOBOSecure > 0) {
		address = strHTTPSprefix + address;
		}
	alert('Final Address: ' + address);
}

//	Modified Original -- s/b live once problem is solved
//function waslaunchOnlineBoxOffice(prodID,override){
function launchOnlineBoxOffice(prodID,override){
	leftPosition = (screen.width) ? (screen.width - 514) / 2 : 0;
	topPosition  = (screen.height)? (screen.height - 550) / 2 :0;
	if(!dontOpenOBO){
		try{
		dontOpenOBO=true;
		//launch online box office
		if(onlineBoxOffice != null && !onlineBoxOffice.closed){
			onlineBoxOffice.focus();
			onlineBoxOffice.alert('There is already a session of the Online Box Office in use. To start a new one you must first close the current session.');
			}
		else	{
			onlineBoxOffice = window.open('','onlineBoxOffice','width=514,height=550,left='+leftPosition+', top='+topPosition+',toolbar=0,menubar=0,status=1,scrollbars=1');
			if(onlineBoxOffice.location == 'about:blank' || 
				onlineBoxOffice.location=='/')	{
				address = 'onlineBoxOffice/goOBO.aspx?reset=1&prodID='+prodID;
				if(override != null){
					address=override;
					}
				if (iOBOSecure > 0) {
					address = strHTTPSprefix + address;
					}
				onlineBoxOffice=window.open(address,'onlineBoxOffice','width=514,height=550,toolbar=0,menubar=0,status=1,scrollbars=1');
				}
			else	{
				//Reverse the order???
				onlineBoxOffice.alert('There is already a session of the Online Box Office in use. To start a new one you must first close the current session.');
				onlineBoxOffice.focus();
				}
			}
			setTimeout("fixOBOOpen()", 1000)
		}catch(e){
			dontOpenOBO=false;
			alert('There is already a session of the Online Box Office in use or you may have pop-ups blocked on your computer.  To launch the Online Box Office, you must first close the current session or disable your pop-up blocker.');

		}
	}		
}

function fixOBOOpen()	{
	dontOpenOBO=false;
}

//	Disables the right click -- can we ge more annoying??
function click(e){
//	if(document.all){
//		if(event.button==2){
//			alert('The right click has been disabled.')
//			return false;
//		}
//	}
//	if (document.layers){
//		if(e.which ==3){
//			alert('The right click has been disabled.');
//			return false;
//		}
//	}
}

if(document.layers){
	document.captureEvents(Event.MOUSEDOWN);
}

document.onmousedown=click;

