function addDVD(theItem, subid, title){
	//Add a DVD to a subs Portfolio

	//get the text of the button to determine our action
    var linkText = document.getElementById(theItem).innerHTML;
		//alert (linkText);
	if ((linkText == "Add DVD") || (linkText == "Pre-Order")){
		if (linkText == "Pre-Order") {
			document.getElementById(theItem).innerHTML="Saved";
		} else {
			document.getElementById(theItem).innerHTML="In List";
		}
		thePage = '../skins/header.aspx?x=add&s='+subid+'&t='+title;
		
		if (navigator.userAgent.indexOf('MSIE') > -1)
		{
		//alert("IE");
			document.all.ifrHead.src = thePage;
		}
		else
		{
		//alert("NON IE");
			document.getElementById("ifrHead").src = thePage;
		}
	} else {
		window.location = "../mylist/index.aspx"
	}
}


function starsRate(theItem, subid, title, rat){
	//need to call asp to update the db
	thePage = '../skins/header.aspx?x=rat&s='+subid+'&t='+title+'&r='+rat
	if (navigator.userAgent.indexOf('MSIE') > -1)
	{
		document.all.ifrHead.src = thePage;
	}
	else
	{
		document.getElementById("ifrHead").src = thePage;
	}
	//document.all.ifrHead.src = thePage
	//document.getElementById("ifrHead").src = thePage;
	
	document.getElementById(theItem + "_txtStarsC").value = "r";
	document.getElementById(theItem + "_txtStarsN").value = rat;
	
	starImg = theItem + "_imgStar1";
	resetStars(starImg)
}

function noopOnOff(noopImg){
	starImg = Left(noopImg, noopImg.length-7) + "imgStar1";
	starNo = 0;
	if (Right(document.getElementById(noopImg).src, 12) == "noop_off.gif"){
		document.getElementById(noopImg).src = getTheImgSrc(noopImg) + "noop_on.gif"	
		starsOnOff(starImg, starNo)
	} else {
		document.getElementById(noopImg).src = getTheImgSrc(noopImg) + "noop_off.gif"
		resetStars(starImg);
	}
}

function starsOnOff(starImg, starNo){
	//alert(starImg + " - " + starNo)
	//starImg = Left(starImg, starImg.length-1);
	var theImgSrc = getTheImgSrc(starImg)
	var theStar
	
	for (i=1;i<=5;i++){
		theStar = Left(starImg, starImg.length-1) + i;
		if (i<=starNo){
			document.getElementById(theStar).src = theImgSrc + "red.gif";
		} else {
			document.getElementById(theStar).src = theImgSrc + "star.gif";
		}
	}
}
function resetStars(starImg){
	var theImgSrc = getTheImgSrc(starImg)
	
	var strFld = Left(starImg, starImg.length-8)
	var col = document.getElementById(strFld + "txtStarsC").value
	var no = document.getElementById(strFld + "txtStarsN").value
	if (no=="") no=0;
	
	var imgOn = theImgSrc
	var imgOff = theImgSrc + "star.gif"
	if (col=="r") {imgOn+="red.gif"} else {imgOn+="yellow.gif"} 
	
	for (i=1; i<=5; i++){
		theStar = Left(starImg, starImg.length-1) + i;
		if (i<=no){
			document.getElementById(theStar).src = imgOn;
		} else {
			document.getElementById(theStar).src = imgOff;
		}
	}
}

function getTheImgSrc(starImg){
	var theImgSrc = "";
	theImgSrc = document.getElementById(starImg).src
	
	if (Right(document.getElementById(starImg).src, 8) == "star.gif"){
		theImgSrc = Left(theImgSrc, theImgSrc.length-8);
	} else if (Right(document.getElementById(starImg).src, 10) == "yellow.gif"){
		theImgSrc = Left(theImgSrc, theImgSrc.length-10);
	} else if (Right(document.getElementById(starImg).src, 12) == "noop_off.gif"){
		theImgSrc = Left(theImgSrc, theImgSrc.length-12);
	} else if (Right(document.getElementById(starImg).src, 11) == "noop_on.gif"){
		theImgSrc = Left(theImgSrc, theImgSrc.length-11);
	} else if (Right(document.getElementById(starImg).src, 7) == "add.gif"){
		theImgSrc = Left(theImgSrc, theImgSrc.length-7);
	} else if (Right(document.getElementById(starImg).src, 10) == "remove.gif"){
		theImgSrc = Left(theImgSrc, theImgSrc.length-10);
	} else {
		theImgSrc = Left(theImgSrc, theImgSrc.length-7);
	}
	return theImgSrc;
}

function bodyFocus(){
	/* Removed by Richard 21/10/2008
	if (document.getElementById("Header_txtEmail")==null){
		document.getElementById("Header_txtSearch").focus();
		document.getElementById("Header_txtSearch").select();
	} else {
		document.getElementById("Header_txtEmail").focus()
	}
	*/
}

function fldFocus(theFld){
	//alert("focusing " + theFld);
	if (theFld='s'){
		document.getElementById("Header_btnSearch").focus();
	} else {
		document.getElementById("Header_imbGoLogin").focus();
	}
}
function popUpCalendar(ctlName, ctlType) 
{
	//var datCDate = document.forms[0].elements[ctlName].value;
	var datCDate = document.getElementById(ctlName).value;
	//alert(datCDate);
	var PopupWindow=null;
	settings='width=300,height=350,location=no,menubar=no,toolbar=no,status=no,scrollbars=no,resizable=yes,dependent=no';
	PopupWindow=window.open('../includes/calendar.aspx?Ctl='+ctlName+'&cDate='+datCDate+'&type='+ctlType,'DatePicker',settings); 
	PopupWindow.focus();
}

function chkBrowser() {
	document.frmCheck.appName.value = navigator.appName;
	document.frmCheck.appVersion.value = navigator.appVersion;
	document.frmCheck.appAgent.value = navigator.userAgent;
	document.frmCheck.appCode.value = navigator.appCodeName;
	//document.frmCheck.platform.value = navigator.platform + " ~ " + navigator.oscpu;
	document.frmCheck.cookies.value = navigator.cookieEnabled;
	//document.frmCheck.vendor.value = navigator.vendor + " ~ " + navigator.vendorSub;
	document.frmCheck.submit();
}

function cc() { 
	/* check for a cookie */ 
	if (document.cookie == "") { 
	/* if a cookie is not found - alert user - change cookieexists field value to false */ 
		alert("COOKIES need to be enabled!"); 
	/* If the user has Cookies disabled an alert will let him know that cookies need to be enabled to log on.*/ 
		document.Form1.cookieexists.value ="false" 
	} else { 
	/* this sets the value to true and nothing else will happen, the user will be able to log on*/ 
		document.Form1.cookieexists.value ="true" 
	} 
} 
/* Set a cookie to be sure that one exists. Note that this is outside the function*/ 
document.cookie = 'killme' + escape('nothing') // --> </script>


function Right(str, n){ if (n <= 0) return ""; else if (n > String(str).length) return str; else { var iLen = String(str).length; return String(str).substring(iLen, iLen - n); } }
function Left(str, n){ if (n <= 0) return ""; else if (n > String(str).length) return str; else return String(str).substring(0,n); }

function OpenAllo()
{
	params = "left=163,top=0,scrollbars=yes,resizable=yes,menubar=yes,resize=yes,statusbar=yes,toolbar=yes,location=yes,width=800,height=600";
	windowHandle=window.open("http://www.allocine.co.uk","allocine",params);
	windowHandle.focus();
	if (!windowHandle.opener)
		windowHandle.opener = self;
}


//*********************************************************************************************************************
// the functions for showing hints

// Title: Tigra Hints
// URL: http://www.softcomplex.com/products/tigra_hints/
// Version: 1.3
// Date: 09/03/2003 (mm/dd/yyyy)
// Note: Permission given to use this script in ANY kind of applications if
//    header lines are left unchanged.

var THintsS = [];
function THints (o_cfg, items) {
	this.n_id = THintsS.length;
	THintsS[this.n_id] = this;
	this.top = o_cfg.top ? o_cfg.top : 0;
	this.left = o_cfg.left ? o_cfg.left : 0;
	this.n_dl_show = o_cfg.show_delay;
	this.n_dl_hide = o_cfg.hide_delay;
	this.b_wise = o_cfg.wise;
	this.b_follow = o_cfg.follow;
	this.x = 0;
	this.y = 0;
	this.divs = [];
	this.iframes = [];
	this.show  = TTipShow;
	this.showD = TTipShowD;
	this.hide = TTipHide;
	this.move = TTipMove;
	// register the object in global collection
	this.n_id = THintsS.length;
	THintsS[this.n_id] = this;
	// filter Netscape 4.x out
	if (document.layers) return;
	var b_IE = navigator.userAgent.indexOf('MSIE') > -1,
	s_tag = ['<iframe frameborder="0" scrolling="No" id="TTifip%name%" style="visibility:hidden;position:absolute;top:0px;left:0px;',   b_IE ? 'width:1px;height:1px;' : '', o_cfg['z-index'] != null ? 'z-index:' + o_cfg['z-index'] : '', '" width=1 height=1></iframe><div id="TTip%name%" style="visibility:hidden;position:absolute;top:0px;left:0px;',   b_IE ? 'width:1px;height:1px;' : '', o_cfg['z-index'] != null ? 'z-index:' + o_cfg['z-index'] : '', '"><table cellpadding="0" cellspacing="0" border="0"><tr><td class="', o_cfg.css, '" nowrap>%text%</td></tr></table></div>'].join('');


	this.getElem = 
		function (id) { return document.all ? document.all[id] : document.getElementById(id); };
	this.showElem = 
		function (id, hide) { 
		this.divs[id].o_css.visibility = hide ? 'hidden' : 'visible'; 
		this.iframes[id].o_css.visibility = hide ? 'hidden' : 'visible'; 
		};
	this.getWinSz = window.innerHeight != null 
		? function (b_hight) { return b_hight ? innerHeight : innerWidth; }
		: function (b_hight) { return document.body[b_hight ? 'clientHeight' : 'clientWidth']; };	
	this.getWinSc = window.innerHeight != null 
		? function (b_hight) { return b_hight ? pageYOffset : pageXOffset; }
		: function (b_hight) { return document.body[b_hight ? 'scrollTop' : 'scrollLeft']; };	
	if (window.opera) {
		this.getSize = function (id, b_hight) { 
			return this.divs[id].o_css[b_hight ? 'pixelHeight' : 'pixelWidth']
		};
		document.onmousemove = function () {
			for (var n_i in THintsS) {
				THintsS[n_i].x = event.clientX;
				THintsS[n_i].y = event.clientY;
				if (THintsS[n_i].b_follow && THintsS[n_i].visible) 
					THintsS[n_i].move(THintsS[n_i].visible);
			}
			return true;
		};
	}
	else {
		this.getSize = function (id, b_hight) { 
			return this.divs[id].o_obj[b_hight ? 'offsetHeight' : 'offsetWidth'] 
		};
		document.onmousemove = b_IE
		? function () {
			for (var n_i in THintsS) {
				THintsS[n_i].x = event.clientX + document.body.scrollLeft;
				THintsS[n_i].y = event.clientY + document.body.scrollTop;
				if (THintsS[n_i].b_follow && THintsS[n_i].visible) 
					THintsS[n_i].move(THintsS[n_i].visible);
			}
			return true;
		} 
		: function (e) {
			for (var n_i in THintsS) {
				THintsS[n_i].x = e.pageX;
				THintsS[n_i].y = e.pageY;
				if (THintsS[n_i].b_follow && THintsS[n_i].visible) 
					THintsS[n_i].move(THintsS[n_i].visible)
			}
			return true;
		};
	}
	for (i in items) {
		document.write (s_tag.replace(/%text%/g, items[i]).replace(/%name%/g, i));
		this.divs[i] = { 'o_obj' : this.getElem('TTip' + i) };
		this.divs[i].o_css = this.divs[i].o_obj.style;
		this.iframes[i] = { 'o_obj' : this.getElem('TTifip' + i) };
		this.iframes[i].o_css = this.iframes[i].o_obj.style;
		
	}
}
function TTipShow (id) {
	if (document.layers) return;
	this.hide();
	if (this.divs[id]) {
		if (this.n_dl_show) this.divs[id].timer = setTimeout('THintsS[' + this.n_id + '].showD("' + id + '")', this.n_dl_show);
		else this.showD(id);
		this.visible = id;
	}
}

function TTipShowD (id) {
	this.move(id);
	this.showElem(id);
	if (this.n_dl_hide) this.timer = setTimeout("THintsS[" + this.n_id + "].hide()", this.n_dl_hide);
}

function TTipMove (id) {
	var n_x = this.x + this.left, n_y = this.y + this.top;
	if (this.b_wise) {
		var n_w = this.getSize(id), n_h = this.getSize(id, true),
		n_win_w = this.getWinSz(), n_win_h = this.getWinSz(true),
		n_win_l = this.getWinSc(), n_win_t = this.getWinSc(true);
		if (n_x + n_w > n_win_w + n_win_l) n_x = n_win_w + n_win_l - n_w;
		if (n_x < n_win_l) n_x = n_win_l;
		if (n_y + n_h > n_win_h + n_win_t) n_y = n_win_h + n_win_t - n_h;
		if (n_y < n_win_t) n_y = n_win_t;
	}
	this.divs[id].o_css.left = n_x;
	this.divs[id].o_css.top = n_y;
	this.iframes[id].o_css.left = n_x;
	this.iframes[id].o_css.top = n_y;
	this.iframes[id].o_css.height = n_h-this.top;
	this.iframes[id].o_css.width = this.getSize(id, false)-this.left;
}

function TTipHide () {
	if (this.timer) clearTimeout(this.timer);
	if (this.visible != null) {
		if (this.divs[this.visible].timer) clearTimeout(this.divs[this.visible].timer);
		setTimeout('THintsS[' + this.n_id + '].showElem("' + this.visible + '", true)', 10);
		this.visible = null;
	}
}

// the config stuff for the hints
//the config stuff

var HINTS_CFG = {
	'top'        : 5, // a vertical offset of a hint from mouse pointer
	'left'       : 5, // a horizontal offset of a hint from mouse pointer
	'css'        : 'hintsClass', // a style class name for all hints, TD object
	'show_delay' : 100, // a delay between object mouseover and hint appearing
	'hide_delay' : 5000, // a delay between hint appearing and hint hiding
	'wise'       : true,
	'follow'     : true,
	'z-index'    : 0 // a z-index for all hint layers
},


HINTS_ITEMS = {
	'Long Wait':'<div class="hint">There is in extremely high demand, limited availability and/or<br />A very long wait for this movie. The wait time in this instance<br />Is generally less than 4 months, but this could be longer, if,<br />For example, the movie is out of print or we are otherwise<br />Unable to secure additional copies.</div>',
	'Medium Wait':'<div class="hint">Title currently in high demand, a likely two to four week delay</div>',
	'Short Wait':'<div class="hint">Good chance it&#039;s available now, but short delay possible.</div>',
	'Now':'<div class="hint">Ready when you are!</div>'
};

var myHint = new THints (HINTS_CFG, HINTS_ITEMS);
