
function startpage() {
	if (document.getElementById("minicartspan")) {
	//	document.getElementById("minicartspan").innerHTML = runasync("UserControls/minicartasync.aspx")
	}
}



player = ""

cnnavapp = navigator.appName
cnnavver = navigator.appVersion

function fiximages() {//replaces missing boxart images with a default 'no image available'
 if (document.getElementById("promotd244").childNodes[0].childNodes[0]) {if (document.getElementById("promotd244").childNodes[0].childNodes[0].tagName=="IMG") {	if (!document.getElementById("promotd244").childNodes[0].childNodes[0].complete) {document.getElementById("promotd244").childNodes[0].childNodes[0].src="img/spacer.gif"} }}
 allboxart = document.getElementsByTagName("IMG")
 for (i=0;i<allboxart.length;i++) {
  if (allboxart[i].width==65 && allboxart[i].className=="boxart" && !allboxart[i].complete) {allboxart[i].src="img/boxart/65/_noimage_65.gif"}
  if (allboxart[i].width==95 && allboxart[i].className=="boxart" && !allboxart[i].complete) {allboxart[i].src="img/boxart/95/_noimage_95.gif"}
  if (allboxart[i].width==175 && allboxart[i].className=="boxart" && !allboxart[i].complete) {allboxart[i].src="img/boxart/175/_noimage_175.gif"}
 }
}


function streamok() {
	cnnavigator = cnnavapp+cnnavver
	if ((cnnavigator.indexOf("MSIE")!=-1||cnnavigator.indexOf("Internet Explorer")!=-1)&&cnnavigator.indexOf("Windows")!=-1) {return true}
	if ((navigator.userAgent.toLowerCase().indexOf("firefox")!=-1) || (navigator.userAgent.toLowerCase().indexOf("Netscape5.0")!=-1)&&(cnnavigator.indexOf("Windows")!=-1)) {return true}
	
	return false
}


function togglegraphics(thisevt) {
	if (thisevt.innerHTML == "Turn Graphics OFF") {
		thisevt.innerHTML = "Turn Graphics ON";boxartmode = "none"
	} else {
		thisevt.innerHTML = "Turn Graphics OFF";boxartmode = "block"
	}
	tds = document.getElementsByTagName("TD")
	for (i=0;i<tds.length;i++) {if (tds[i].className=="boxarttd") {tds[i].style.display=boxartmode}}
}

function openplayer(skuid,bitrate) {
	if (streamok()) {
		//url = 'http://' + window.location.host
		//try {if (basePath){url += basePath} else {url += '/'}}catch(e){url += '/'}
		//url += 'wmp.aspx'
		url = 'wmp.aspx'
		player = window.open(url + "?skuid="+skuid+"&bitrate="+bitrate,"cnstreamingplayer","channelmode=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0,width=529,height=386,top=10,left=10")
	} else {
		location.href="wrongbrowser.aspx"
	}

}
function openfreeplayer(skuid,bitrate) {
	if (streamok()) {
//		url = 'http://' + window.location.host
//		try {if (basePath){url += basePath} else {url += '/'}}catch(e){url += '/'}
//		url += 'wmpfree.aspx'
        url = 'wmpfree.aspx'
		try {
			freeplayer.playmovie(skuid,0,9999999,false,300)
		} catch(e) {
			freeplayer = window.open(url + "?skuid="+skuid+"&bitrate=300","cnstreamingplayer","channelmode=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0,width=529,height=386,top=10,left=10")
		}
	} else {
		location.href="wrongbrowser.aspx"
	}

}
function opendownload(skuid) {
	if (streamok()) {
		//url = 'http://' + window.location.host
		//try {if (basePath){url += basePath} else {url += '/'}}catch(e){url += '/'}
		url = 'downloader.aspx'

		downloader = window.open(url + "?skuid="+skuid,"cndownload","channelmode=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0,width=530,height=486,top=10,left=10")
	} else {
		location.href="wrongbrowser.aspx"
	}
}

//used just to return dl url without opening new window
function returnDL_URL(skuid) {

		url = 'http://' + window.location.host
		try {if (basePath){url += basePath} else {url += '/'}}catch(e){url += '/'}
		url += 'downloader.aspx'

		return (url + "?skuid="+skuid)

}



function openpopup(thisurl,thisname) {
	popup = window.open(thisurl,thisname,"channelmode=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0,width=529,height=386,top=10,left=10")
}

function resizewin() {
	try {
			window.resizeTo(document.getElementById("popupwindowresizeDiv").offsetWidth+10,document.getElementById("popupwindowresizeDiv").offsetHeight+29)
			self.focus()
		} catch(e) {
			window.resizeTo(document.getElementById("popupwindowresizeDiv").offsetWidth,document.getElementById("popupwindowresizeDiv").offsetHeight)
			self.focus()
		}
}


//validate cancellation page
function validateCancelSub()
			{
				if (frmMain.all.tbCancelReason.value == '')
				{
					alert('Please fill in a cancellation reason');
					frmMain.all.tbCancelReason.focus();
					return false;
				}

				return true;
			}


//check the validity of a user entered email
function validEmail(email) {
	invalidChars = " /:,;"

	if (email == "") {		// cannot be empty
		return false
	}
	for (i=0; i<invalidChars.length; i++) {	// does it contain any invalid characters?
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false
		}
	}
	atPos = email.indexOf("@",1)		// there must be one "@" symbol
	if (atPos == -1) {
		return false
	}
	if (email.indexOf("@",atPos+1) != -1) {	// and only one "@" symbol
		return false
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {					// and at least one "." after the "@"
		return false
	}
	if (periodPos+3 > email.length)	{		// must be at least 2 characters after the "."
		return false
	}
	return true
}



//bookmark
var bookmarkurl="http://www.cinemanow.com"
var bookmarktitle="CinemaNow.com - Watch Movies Here!"
function addbookmark(){
	window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

function onKeyPressed(submitButton){
	//if (!e) {var e = window.event;} else {e = evtKey}
	e = evtKey
	if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)){
		submitButton.click();
		return false;
	} else {
		return true;
	};
}
var evtKey = null;
document.onkeydown = registerStroke;
document.onkeypres = registerStroke;
document.onkeyup = registerStroke;
function registerStroke(e)
{
	if (!e) e = window.event;
	evtKey = e
	return true;
}


function isCanadaPostCode(entry){ // CANADIAN CODES ONLY
strlen = entry.length; if (strlen != 6) {return false;}
entry=entry.toUpperCase();        // in case of lowercase characters
// Check for legal characters in string - note index starts at zero
if ('ABCEHJKLMNPRSTVXY'.indexOf(entry.charAt(0)) < 0) {return false;}
if ('0123456789'.indexOf(entry.charAt(1)) < 0) {return false;}
if ('ABCDEFGHJKLMNPQRSTUVWXYZ'.indexOf(entry.charAt(2)) < 0) {return false;}
if ('0123456789'.indexOf(entry.charAt(3)) < 0) {return false;}
if ('ABCDEFGHJKLMNPQRSTUVWXYZ'.indexOf(entry.charAt(4)) < 0) {return false;}
if ('0123456789'.indexOf(entry.charAt(5)) < 0) {return false;}
return true; }

function doMiniSearch(q,restrict,grpID,cpt,device){
q = escape(trim(q))
if (q.length>1){
query = new QueryString();
try {url=basePath}catch(e){url=''}
url += 'SearchResults.aspx?q=' + q;
if (restrict && grpID) {
url += '&grpID=' + grpID;
if (cpt) {url += '&cpt=' + cpt;}
if (device) {url += '&device=' + device;}
} else {
url += '&grpID=0';
url += '&noExpand=1';
}
url += '&page=1';

window.location.href = url
}else{alert('Please fill in a search phrase, that is more than 1 letter.')}
}


//- TitleList Control - //
function OnSortChange(obj){
	window.location.href = obj.options[obj.selectedIndex].value
}
function OnPageChange(obj){
	window.location.href = obj.options[obj.selectedIndex].value
}
function ChangeGraphics(obj){
	if (GetCookie("TextOnly")=="True"){
		//turn on grphics
		SetCookie("TextOnly","False");
		obj.innerHTML = "Turn Graphics OFF";
		HideShowBoxart("block")
	} else {
		//turn off
		SetCookie("TextOnly","True");
		obj.innerHTML = "Turn Graphics ON";
		HideShowBoxart("none")
	}

}
function HideShowBoxart(boxartmode){
	tds = document.getElementsByTagName("TD")
	for (i=0;i<tds.length;i++) {if (tds[i].className=="boxarttd") {tds[i].style.display=boxartmode}}
}
//-------------------- //
function gethex(num) {hex="0123456789ABCDEF";return hex.substr(num/16,1)+hex.substr((num&15),1)}
function getdec(num) {hex="0123456789ABCDEF";return hex.indexOf(num.substr(0,1))*16+hex.indexOf(num.substr(1,1))}

//-------------------------------------
//Asynchronous client-server javascript

function asyncobj(){
	if (String(navigator.appName).indexOf("Microsoft Internet Explorer")!=-1) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		return new XMLHttpRequest();
	}
}

function runasync(command){
	async.open('get',command);
	async.onreadystatechange = getasync
	async.send(null);
}

function getasync(){
	if (async.readyState == 4) {
		thisasync = async.responseText;
		return thisasync;
	}
}

async = asyncobj()

colshow = 0
function goright(goamt) {
if (colshow==1) {return}
fx('scrolldiv',10,false,null,'left,0,-'+goamt)
fx('gorightimg',10,false,null,'opacity,100,30')
fx('goleftimg',10,false,null,'opacity,30,100')
colshow = 1
}

function goleft(goamt) {
if (colshow==0) {return}
fx('scrolldiv',10,false,null,'left,-'+goamt+',0')
fx('gorightimg',10,false,null,'opacity,30,100')
fx('goleftimg',10,false,null,'opacity,100,30')
colshow = 0
}


//------------------------------------//

document.write('<META HTTP-EQUIV="imagetoolbar" CONTENT="no">')






