// Global Dropdown Menu


var openMenu = null;
var openGlass = null;
var canMenuBeClosed = true;
var menuTop =  null;
var menuBottom = null;
var menuLeft = null;
var menuRight = null;
var wWidth = null;
//var oGlass = null;
//var oCont = null;
//var oBody = null;
//var oFoot = null;
//var oHead = null;
//var oTotoX = null;
//var oTotoY = null;
var oQList = 'qList';
var p_oQNoCont = 'qNoTitles';
var oQListDrag = 'qListDrag';
var oQOpenArr = 'qOpen'
var p_bOpenMiniQue = false; // used from add/remove dvd titles button and from show mini que to either open or close mini list
var p_oMiniQue = null;
var p_QNoTitlesMessage = 'Your list does not contain any titles.'
var ourDomain = "http://www.cinemaparadiso.co.uk/";
var bfi = "Shared/Images/BFIImages/";
var cov = "Covers/";
var oNoInList = 'noinlist'
var lMovieDVDID = 0;

var movieDesc = "rental-dvds/rent-dvd-uk.aspx?val=";
if (String(window.location).indexOf("Movies") > -1)
	{
	var movieDesc = "Movies/MovieDescription.aspx?val=";
	}
	
var bIE = false;
var bOPERA = false;

if (navigator.userAgent.indexOf("MSIE") > -1){
		bIE =  true;
	} 
if (navigator.userAgent.indexOf("Opera") > -1){
		bOPERA = true;
	}
	
function showMenu(id, objPos, left){
	if(document.getElementById){

			hideMenu('cmbLetterMenu')
			hideMenu('cmbYearsMenu')
			hideMenu('cmbRatingMenu')
			hideMenu('cmbSubtitleMenu')
			hideMenu('cmbClassMenu')
			document.onmousemove = null;
			openMenu = id;
			canMenuBeClosed = false
	
			var x = 0;
			var y = 0;
			
			if (left==true){
				setElementProperty(id, 'display', 'block');
				x = getElementRight(objPos) - getElementWidth(id);
			}
			else{
			x = getElementLeft(objPos);
			}
			y = getElementBottom(objPos) + 2;
			
			
			wWidth = document.body.offsetWidth;
			document.onmousemove = getMousePosition;
			
			setElementProperty(id, 'display', 'block');
			setElementProperty(id, 'left', x + "px");
			setElementProperty(id, 'top', y + "px");
		
	}
}

// ==================================================================================
// Mini List section
// ==================================================================================
	var oMouseX = 0;
	var oMouseY = 0;
	var oPos = null;
	var intTimerID;
	var intTimer2ID;
	var oEvent;

function showQList(){
	if(document.getElementById){
		//eraseCookie(oQListDrag); // To be removed Sets advert to appear every time
		
		// If the Mini List is not opened then first check if
		// there are any titles in customers list by checking the customer
		// Info box values. If there are no films in list there is no need 
		// for mini list to be displayed
	
		var ooNoInList = typeElement(oNoInList);
		if (ooNoInList) {
			if (parseInt(ooNoInList.innerHTML) == 0){
				alert(p_QNoTitlesMessage);
				return false;
			}
		}
				
		if (!p_oMiniQue) {
			p_bOpenMiniQue = true;
			p_oMiniQue = typeElement(oQList); // set what list we are working with
			GetMiniQ(); // get mini list data 
			return true;
		}
		
		//  Close Mini list
		if (p_oMiniQue) {
			closeMiniQ ();
			return false;
		}
	}
}

function openMiniQ(){
	// this function opens mini list by using
	// sepecial effects. It also changes the open/close 
	// button and hides the Mini List summary info box
	
	typeElement(oQOpenArr).className = 'arrUp';
	setElementProperty(p_oQNoCont, 'display', 'none');
	Effect.SlideDown(oQList,{duration:1.0})
	
	// If the advert on how to change the position in the queue
	// has not been hidden by the user, then show it
	if (!readCookie(oQListDrag)){
		Effect.SlideDown(oQListDrag,{duration:1.0});
	}
	return true;
}

function closeMiniQ(){

	// this function closes mini list by using
	// sepecial effects. It also changes the open/close 
	// button and shows the Mini List summary info box
	typeElement(oQOpenArr).className = 'arrDown';
	Effect.SlideUp(p_oMiniQue,{duration:1.0});
	
	// If the advert on how to change the position in the queue
	// has not been hidden by the user, then show it
	if (!readCookie(oQListDrag)){
		Effect.SlideUp(oQListDrag,{duration:1.0});
	}
	// Show Mini list summary box
	Effect.Appear(p_oQNoCont);
	p_oMiniQue = null; // set that no mini list is open
	return true;
}

function GetMiniQ(){
	// Gets the mini list data from database
	
	var ooNoInList = typeElement(oNoInList);
	if (ooNoInList) {
		if (parseInt(ooNoInList.innerHTML) == 0){
			closeMiniQ();
			return false;
		}
	}
	if (AjaxMethods.GetMiniQ(7, GetMiniQ_CallBack))	{
			
		}
	else {
		alert("No Data Found");
			return false;
	}
}
function GetMiniQ_CallBack(response){
	
	// The function returnes HTML code as it should appear
	// in the formatted HTML element and place it straight to 
	// DVD box. It also sets the bulleted list dragable
	// so the user can change position of the movie titles
	// The function opens the mini list if it is closed and if
	// it has been requested to be opened
	
	var oDiv = typeElement(oQList);
	if (response.error != null){    
		alert(response.error); 
		window.status = ''
		return false;
	}  

	if (response.value == "") {
		oDiv.innerHTML = "";
		window.status = ''
		closeMiniQ();
		return false;
	}
					
	var oUL = null
	var sULLists = '';
	oDiv.innerHTML = "";
	oDiv.innerHTML = response.value;	
								
	Sortable.create('myQ1',{containment:['myQ1','myQ2'], dropOnEmpty:true, ghosting:false,constraint:false,hoverclass:'over',
	onUpdate:function(sortable){updateMiniQ(Sortable.serialize(sortable)); new Effect.Highlight(p_oMiniQue.id,{});}});
	Sortable.create('myQ2',{containment:['myQ1','myQ2'], dropOnEmpty:true, ghosting:false,constraint:false,hoverclass:'over',
	onUpdate:function(sortable){''}});
  
	if (p_bOpenMiniQue == true){ 
		openMiniQ();
	} else {
		if (!p_oMiniQue) { 
			setElementProperty(oQList, 'display', 'none');
		}
	}

}

function updateMiniQ(s) {
	if (s){
		if (AjaxMethods.UpdateMiniQ(s, updateMiniQ_CallBack))	{
						
			}
		else {
			alert("No Data Found");
				return false;
		}
	}
}
	
function updateMiniQ_CallBack(response){
	//if the server side code threw an exception
	if (response.error != null){    
		alert(response.error); //we should probably do better than this
		window.status = ''
		return false;
	}  

	//if we didn't get what we expect, or didn't get any matches  
	if (response.value == "") {
		alert("Action Failed");
		window.status = ''
		return false;
	}
	p_bOpenMiniQue = false;				
	GetMiniQ();
    
    					
}

function hideQListDrop(){
	createCookie(oQListDrag,1,1000);
	Effect.SlideUp(oQListDrag,{duration:1.0})
}

//=======================================================================
// End of Mini List section
//=======================================================================

var p_MsgID = 0;

function closeMessage(msgID) {
	p_MsgID = msgID
	if (msgID){
		if (AjaxMethods.CloseMessage(msgID, closeMessage_CallBack))	{
						
			}
	}
}
	
function closeMessage_CallBack(response){
	if (response.error != null){    
		alert(response.error); 
		window.status = ''
		return false;
	}  
	//Effect.SlideUp('div'+p_MsgID,{duration:1.0})
	setElementProperty('div'+p_MsgID, 'display', 'none');
    
    					
}
function getMousePosition(event){
	var x, y;
	if(window.event){
		x = window.event.clientX;
		y = window.event.clientY;
		if (document.documentElement && document.documentElement.scrollTop){
			y+=document.documentElement.scrollTop;
		} else if(self.pageYOffset){

		} else {
			y+=document.body.scrollTop;
		}
	} else {
		x = event.pageX;
		y = event.pageY;
	}
	

	if(openMenu != null){
		var testInside = isInside(x, y, openMenu);
		if((wWidth != document.body.offsetWidth) || (!testInside && canMenuBeClosed == true)){
			
			hideMenu(openMenu);
		}
		if(testInside){
			canMenuBeClosed = true;
		}
	}
	oMouseX = x;
	oMouseY = y;
	
}
function isInside(xMouse, yMouse, id){

	menuLeft = menuLeft == null ? getElementLeft(id) : menuLeft;
	menuRight = menuRight == null ? getElementRight(id) : menuRight;
	menuTop = menuTop == null ? getElementTop(id) : menuTop;
	menuBottom = menuBottom == null ? getElementBottom(id) : menuBottom;
		
	if( (id != null) && (xMouse >= menuLeft - 10) && (xMouse <= menuRight + 10) && (yMouse >= menuTop - 10) && (yMouse <= menuBottom + 10) ){
		return true;
	} else {
		return false;
	}
}


function hideMenu(id){
	setElementProperty(id, 'display', 'none');
	setElementProperty(id, 'top', '-500');
	setElementProperty(id, 'left', '-500');
	document.onmousemove = null;
	window.status = "";
	openMenu = null;
	menuTop = null;
	menuBottom = null;
	menuLeft = null;
	menuRight = null;
	wWidth = null;
}

function getElementLeft(id) {
	var x = 0;
	var menuDiv = typeElement(id);
	while (menuDiv != null) {
		x+= menuDiv.offsetLeft;
		menuDiv = menuDiv.offsetParent;
	}
	return parseInt(x);
}

function getElementRight(id){
	return getElementLeft(id) + getElementWidth(id);
}

function getElementBottom(id){
	return getElementTop(id) + getElementHeight(id);
}

function getElementHeight(id){
	var menuDiv = typeElement(id);
	return parseInt(menuDiv.offsetHeight);
}

function getElementWidth(id){
	var menuDiv = typeElement(id);
	return parseInt(menuDiv.offsetWidth);
}

function getElementTop(id) {
	var y = 0;
	var menuDiv = typeElement(id);
	while (menuDiv != null) {
		y+= menuDiv.offsetTop;
		menuDiv = menuDiv.offsetParent;
	}
	return parseInt(y);
}

function typeElement(id) {
	var type = null;
	if(typeof(id) == "object"){
		type = id;
	} else {
		type = document.getElementById(id);
	}
	return (type);
}


function setElementProperty(id, id_property, id_value){
	var menuDiv = typeElement(id);
	if((menuDiv != null) && (menuDiv.style != null)){
		menuDiv = menuDiv.style;
		menuDiv[ id_property ] = id_value;
	}
}

function getElementProperty(id, id_property){
	var menuDiv = typeElement(id);
	if((menuDiv != null) && (menuDiv.style != null)){
		menuDiv = menuDiv.style;
		return menuDiv[ id_property ];
	}
}

function getScrollTop(id){
	var scTop=0;
	if (document.documentElement && document.documentElement.scrollTop){
		scTop=document.documentElement.scrollTop;		
	} else if(self.pageYOffset){
		scTop=self.pageYOffset;
	} else {
		scTop=document.body.scrollTop;
	}
	return scTop
}

function loadXMLDoc(xml){
	// code for Mozilla, etc.
	if (document.implementation.createDocument){
		// Mozilla, create a new DOMParser 
		var parser = new DOMParser(); 
		xmlDoc = parser.parseFromString(xml, "application/xml"); 
	}
	// code for IE
	else if (window.ActiveXObject){
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
		if (xmlDoc) {
		xmlDoc.async="false";
		xmlDoc.loadXML(xml);
		}
	}
	return xmlDoc;
}

	

	
function createCookie(name,value,days){
	if (days){
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name){
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i<ca.length;i++){
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name){
	createCookie(name,"",-1);
}

var openedRelated = null;
var rMovieID = 0;
var prLink = '';
function showRelated(movieID, rLink){
	if(document.getElementById){
		var related = "related" + movieID 
		clearTimeout(intTimerID);
		hideMenu(openMenu);
		if (typeElement(rLink).innerHTML == 'Close') {
			//Effect.toggle(related,'slide')
			Effect.SlideUp(related,{duration:1.0})
			typeElement(rLink).innerHTML = 'Show Related';
		} else{
			openedRelated = related;
			if (getRelatedMovies(movieID)){
				typeElement(rLink).innerHTML = 'Close';
			}	
		}
	}
}

function getRelatedMovies(movieID){
	if (!movieID == "") {
		rMovieID = movieID;
		if (AjaxMethods.GetRelated(movieID, getRelatedMovies_CallBack)){
				return true;
		}
		else {
			return false;
		}
	}
}

function getRelatedMovies_CallBack(response){

	//if the server side code threw an exception
	if (response.error != null){    
		alert(response.error);
		window.status = ''
		return false;
	}  

	//if we didn't get what we expect, or didn't get any matches  
	if (response.value == "") {
		alert("Action Failed");
		window.status = ''
		return false;
	}
	
	var oDiv = typeElement(openedRelated);
	var str = '';
	var xml = loadXMLDoc(response.value);
	
	//alert(xmlDoc);
	
	str = "<table class=\"bt\" border=\"0\" width=\"100%\" cellspacing=\"3\" cellpadding=\"3\">"
	str += "<tr>"
	str += "<td  align=\"center\" colspan=\"4\">";
	str += "<STRONG>Members also enjoyed these films ...</STRONG>"
	str += "</td>"
	str += "</tr>"
	
	str += "<tr>"
	for (i=0; i<4;i++){
	str += getRelatedTitles(getRMD(xml, "Movie", i), getRMD(xml, "RelatedID", i), getRMD(xml, "Cover", i));
	}	
	str += "</tr>"
	str += "<tr>"
	for (i=0; i<4;i++){
	str += getRelatedImages(getRMD(xml, "Movie", i), getRMD(xml, "RelatedID", i), getRMD(xml, "Cover", i));
	}		
	str += "</tr>"
	//str += "<tr>"
	//for (i=0; i<4;i++){
	//str += getRelatedAdd(getRMD(xml, "Movie", i), getRMD(xml, "RelatedID", i), getRMD(xml, "Cover", i));
	//}		
	//str += "</tr>"
	str += "<tr>"
	str += "<td align=\"right\" class=\"prDesRMSeeMore\" colspan=\"4\">";
	str += "<a href=\""+ourDomain+movieDesc+rMovieID+"&lnk=related&act=7\">See More >>></a>";
	str += "</td>"
	str += "</tr>"
	str += "</table>"
	
	oDiv.innerHTML = str;
	
	//setElementProperty(odiv, 'top', '0px')
	Effect.SlideDown(oDiv.id,{duration:1.0})
	//Effect.toggle(oDiv.id,'slide')
	return true;
									
}
function getRMD(xml, detail, idx){
	 return  xml.getElementsByTagName(detail)[idx].firstChild.data
}
function getShortenName(sMovie){
	var sName = '';
    if (sMovie.length > 18) {
		sName = sMovie.substr(0, 18);
		sName = sName.substring(0, sName.lastIndexOf(" ")) + " ..."
		return sName;
	}
	else{
		return sMovie;
	}
}
function getRelatedTitles(name, id, cover){

	var s = "";
	s = "<td align=\"center\">"
	s += "<DIV class=\"prDesRMTitle\">"
	s += "<A href=\"" +ourDomain+movieDesc+id+"\">"
	s += "<span title=\""+name+"\">"+getShortenName(name)+"</span>"
	s += "</A>"
	s += "</DIV>"
	s += "</td>"
	//alert ();
	return s;
}
function getRelatedImages(name, id, cover){

	var s = "";
	s = "<td align=\"center\">"
	s += "<A href=\"" +ourDomain+movieDesc+id+"\">"
	s += "<IMG ID=\"img"+id+id+"\" onmouseover=\"showTotoPop(event,'TotoContainer', this, '"+id+"');\" onmouseout=\"hideTotoPop();\" class=\"Images60x85\" alt='' src=\""+ ourDomain+cov+cover+"\">"
	//s += "<IMG ID=\"img"+id+id+"\" class=\"Images60x85\" alt='' src=\""+ ourDomain+cov+cover+"\">"
	s += "</A>"
	s += "</td>"
	//alert ();
	return s;
}

// =========================================================================================
// Add remove DVDs from customers list
// =========================================================================================

// 1 - Add DVD ' UserID, DVDID
// 2 - Add Movie ' UserID, MovieID
// 3 - Remove DVD ' UserID, DVDID
// 4 - Remove Movie ' UserID, MovieID
// 5 - Reserve DVD

var locRD = 0;
var changeImage = true;
var sStyleCur = '';
var _spanId = null;


function AddFlashDVD(mId, sStyle, lnkID) {
	
		if (AjaxMethods.AddDVD(mId, sStyle, lnkID, addDVDFlash_CallBack)){
				
		}
		else  {
			alert("No value provided.");
			return false;
		}
}
function addDVDFlash_CallBack(response){


  if (response.error != null){    
    alert(response.error); 
    window.status = ''
    return false;
  }  

  if (response.value == "") {
    //alert("Action Failed");
    window.status = ''
    return false;
  }
   if (response.value == "-100") {
    alert("To add Blu-Ray and HD DVDs to your list, your account need to be enabled for this format.\nPlease go to My Account and under membership click 'Enable or Disable Blu-Ray and HD DVD'");
    return false;
  }
 
  return true;
}

function AddDVD(mId, spanId, lnkID) {
		var sStyle = typeElement(spanId).className;
		lMovieDVDID = mId;
		sStyleCur = sStyle
		_spanId = spanId;
		
		if (sStyle.indexOf('_s') != -1) {
			typeElement(_spanId).className = 'lstWait_s';
		}else{
			typeElement(_spanId).className = 'lstWait';
		}
		
		if (AjaxMethods.AddDVD(lMovieDVDID, sStyle, lnkID, addDVD_CallBack)){
				
		}
		else  {
			alert("No value provided.");
			return false;
		}
}

function addDVD_CallBack(response){

// This function is called from the AJAX menthod and provides the 
// user with the information of what happened for the call back
// It also set the following on the page if the elements exists
// 1) Replaces the click button image by setting 
//    related CSS style
// 2) Calls function to update number of DVDs in Users list
// The response returnes the number of rows affected which is 

 var totalNoInList = 0;
	
  if (response.error != null){    
    alert(response.error); 
    window.status = ''
    return false;
  }  

  if (response.value == "") {
    alert("Action Failed");
    window.status = ''
    return false;
  }
   if (response.value == "-100") {
    alert("To add Blu-Ray and HD DVDs to your list, your account need to be enabled for this format.\nPlease go to My Account and under membership click 'Enable or Disable Blu-Ray and HD DVD'");
    typeElement(_spanId).className = sStyleCur
    window.status = ''
    return false;
  }
 
  // Set number of DVDs in Customer Info on top of
  // each page
 	
     
   if (response.value == 0){
		alert("There has been a problem adding this title to your list.\nTry again and if the problem persist please contact us.");
		return false;
		window.status = ''
	}

	if (changeImage == true){
			var sStyle = sStyleCur;
			if (sStyle.indexOf('InQ') != -1) {
				sStyle = sStyle.replace('InQ', '');
				totalNoInList += - parseInt(response.value);
			}else{
				sStyle +='InQ'
				totalNoInList += + parseInt(response.value);
			}
			typeElement(_spanId).className = sStyle
			window.status = ''
	}
	if ((sStyle != 'lstRes') && (sStyle != 'lstResInQ')) {
			p_bOpenMiniQue = false;
			setNumberOdDVDsInList (totalNoInList);
			if (p_oMiniQue) {
				GetMiniQ();
			} 
			
	}
	
  return true;
}
function setNumberOdDVDsInList(n){
	// If the mini list box exist in the current page then
	// update then get current number of DVDs in customers list
	// and update it with the input value
	var oNoT = typeElement(p_oQNoCont);
	if (oNoT) {
		var o = new Effect.Highlight(p_oQNoCont)
		var oNoDVDs = oNoT.childNodes[1];
		oNoDVDs.innerHTML =  parseInt(oNoDVDs.innerHTML) +n;
	}
	
	// If the customer info box on the top of the page 
	// exists then get current number of DVDs in customers list
	// and update it with the input value
	var noInList = typeElement(oNoInList);
	if (noInList){
		noInList.innerHTML = parseInt(noInList.innerHTML) + n;
	}

}
function removeDVD(ID){
	lMovieDVDID = ID;
	
	changeImage = false;
	if (ID && sID){
		if (AjaxMethods.AddDVD(lMovieDVDID, 3, 0, 0, addDVD_CallBack)){
				
			}
		else  {
			alert("No rating value provided.");
			return false;
		}
	}
}

var p_desCont = '';

function showHelpDiv(groupID, desCont){
	if(document.getElementById){
			p_desCont = desCont;
		if (AjaxMethods.getHelpDiv(groupID, getHelpDiv_CallBack))	{
				
			}
		else {
			alert("No Data Found");
				return false;
		}
	}
}

function getHelpDiv_CallBack(response){
	
	if (response.error != null){    
		alert(response.error); 
		window.status = ''
		return false;
	}  

	if (response.value == "") {
		window.status = ''
		return false;
	}
					
	oDivIn = typeElement(p_desCont)
	oDivIn.innerHTML = response.value;
		
		 					
}

//function showMemb(topicID, left, objPos){
//	if(document.getElementById){
//			document.onmousemove = null;
//			isLeft = left;
//			oPos = objPos;
//			openMenu = "Q"
//			if (AjaxMethods.GetHelpTopicMem(topicID, GetHelpTopic_CallBack)){
//				
//			}
//			else {
//				alert("No Data Found");
//					return false;
///			}
//	}
//}


function showHelp(topicID, objPos, left){
	if(document.getElementById){
			document.onmousemove = null;
			isLeft = left;
			oPos = objPos;
			openMenu = "Q"
			GetHelpTopic(topicID);
	}
}

function GetHelpTopic(topicID){
		if (AjaxMethods.GetHelpTopic(topicID, GetHelpTopic_CallBack))	{
				
			}
		else {
			alert("No Data Found");
				return false;
		}
}

function GetHelpTopic_CallBack(response){
	
	if (response.error != null){    
		alert(response.error); 
		window.status = ''
		return false;
	}  

	if (response.value == "") {
		window.status = ''
		return false;
	}
					
	oDivIn = typeElement(openMenu)
	oDivIn.innerHTML = response.value;
		
	var x = 0;
	var y = 0;
	
	if (isLeft==true){
		x = getElementRight(oPos) - 309;
	}
	else{
	x = getElementLeft(oPos);
	}
	y = getElementBottom(oPos);
		
	wWidth = document.body.offsetWidth;
	document.onmousemove = getMousePosition;
		
	setElementProperty(openMenu, 'left', x + "px");
	setElementProperty(openMenu, 'top', y + "px");
	setElementProperty(openMenu, 'display', 'block');
	 					
}

var oVoteMsg = "";
var oVote = 0;

function voteReview(ReviewID, ssID, vote, lbl){
  if (ReviewID){
	oVoteMsg = lbl;
	oVote = vote;
    if (AjaxMethods.VoteReview(ReviewID, ssID, vote, voteReview_CallBack)){

	}
  } 
  else {
    alert("No voting value provided.");
  }
}

//callback we told Ajax.Net to pass the response tos
function voteReview_CallBack(response){
  if (response.error != null)  {    
    alert(response.error); 
    return false;
  }  
  
  if (!response.value || response.value.length == 0) {
    alert("Action Failed");
    return false;
  }
  if (typeElement(oVoteMsg)){
	var sMsg
	if (oVote == 0) {
		sMsg = "not helpful"
	} else {
		sMsg = "helpful"
	}
	typeElement(oVoteMsg).innerHTML = "You found this review "  + sMsg;
  }
  return true;
}


//===================================================================
//Buy Movies
p_MoiveID = null;

function addToBasket(MovieID){
	//eraseCookie('basketId')
	//return
  if (MovieID){
	if (!readCookie('basketId')){
		p_MoiveID = MovieID
		if (AjaxMethods.CreateBasketID(createBasketId_CallBack)){

		}
	} else {
		if (AjaxMethods.AddToBasket(MovieID, readCookie('basketId'), addRemoveBasket_CallBack)){

		}
	}
  } 
  else {
    alert("Action Failed!");
  }
}

//callback we told Ajax.Net to pass the response tos
function createBasketId_CallBack(response){
  if (response.error != null)  {    
    alert(response.error); 
    return false;
  }  
  
  if (!response.value || response.value.length == 0) {
    alert("Action Failed!");
    return false;
  }
  createCookie('basketId',response.value,6);
  addToBasket(p_MoiveID)
}


function addRemoveBasket_CallBack(response){
    var basket = typeElement('sbBaskCont');
    
    if (basket) {
		basket.innerHTML = response.value;
    }
  }

function removeFromBasket(MovieID, BasketID){
  if (MovieID){
		if (AjaxMethods.RemoveFromBasket(MovieID, BasketID, addRemoveBasket_CallBack)){

		}
  } 
  else {
    alert("Action Failed!");
  }
}


function positionMiniQ(page, q){

	var posX = pageWidth();

	setElementProperty('panMiniQ', 'left', posX + "px");
	//window.onresize = setEnd;
	 
}



function quickLinks(q, a, e, n) {

	for(var i=0;i<n+1;i++){
		setElementProperty(a+i, 'display', 'none');
		setElementProperty(q+i, 'backgroundColor', 'transparent');
	}
	setElementProperty(a+e, 'display', 'block');
	setElementProperty(q+e, 'backgroundColor', '#fbfbca');
	
}

function submitFormHead() {
        txtSearch = typeElement('txtSearch');
        try {
			    if (!txtSearch.value || !txtSearch.value == ' Titles, actors, directors') {
					document.FormHead.submit();
			    }
					else
			    {
			   return false;
			    }
			}
        catch(e)
			{
				return false;
			}
 }  

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/* Adverts on the site*/
function hideAd(o, ad){
	createCookie(ad,1,1000);
	Effect.toggle(o,'appear')
	eraseCookie('ctrRecoFriend.ascx')
	eraseCookie('ctrWriteReview.ascx')
  return true;
}
function onkey()
       {
		if (window.event.keyCode==13)
			{
				try {
					var b = Form1.WhichButton.value
					document.all[b].focus();}
				catch(e)
				{
					return true;
				}
			}
		}