function toggleDiv(divid){
    var baseId = divid.substring(4,5000);
    var linkId = 'l'+baseId;
     if(document.getElementById(divid).style.display == 'none'){
      document.getElementById(divid).style.display = 'block';
      document.getElementById(linkId).style.fontWeight = 'bold';
      document.getElementById("bot1"+baseId).style.borderBottom = '1px solid #000';
      document.getElementById("bot2"+baseId).style.borderBottom = '1px solid #000';
      document.getElementById("bot3"+baseId).style.borderBottom = '1px solid #000';
      document.getElementById("bot4"+baseId).style.borderBottom = '1px solid #000';
      document.getElementById("bot5"+baseId).style.borderBottom = '1px solid #000';
      document.getElementById("bot6"+baseId).style.borderBottom = '1px solid #000';
      document.getElementById("bot7"+baseId).style.borderBottom = '1px solid #000';
      getMovie(divid);      
    }else{
      document.getElementById(linkId).style.fontWeight = 'normal';
      document.getElementById("bot1"+baseId).style.borderBottom = 'none';
      document.getElementById("bot2"+baseId).style.borderBottom = 'none';
      document.getElementById("bot3"+baseId).style.borderBottom = 'none';
      document.getElementById("bot4"+baseId).style.borderBottom = 'none';
      document.getElementById("bot5"+baseId).style.borderBottom = 'none';
      document.getElementById("bot6"+baseId).style.borderBottom = 'none';
      document.getElementById("bot7"+baseId).style.borderBottom = 'none';
      document.getElementById(divid).style.display = 'none';
    }
  }

function getMovie(id){
	document.getElementById(id).innerHTML = "<img class=loader src='loading2.gif'/>";
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
		document.getElementById(id).innerHTML = ajaxRequest.responseText;
		}
	}
        var nid = id.substring(4,5000);
	var queryString = "?id=" + nid;
	ajaxRequest.open("GET", "getMovie.php" + queryString, true);
	ajaxRequest.send(null); 
}

function getTrivia(id){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
		document.getElementById(id).innerHTML = ajaxRequest.responseText;
		}
	}
	var queryString = "?imdbid=" + id;
	ajaxRequest.open("GET", "getTrivia.php" + queryString, true);
	ajaxRequest.send(null); 
}

function watchDvd(id,imdbid,watchTitle){
	var ajaxRequest;  // The variable that makes Ajax possible!
        var viewId;
        viewId = "view"+id;
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
		document.getElementById(viewId).innerHTML = ajaxRequest.responseText;
		}
	}
	var queryString = "?id=" + id + "&imdbid=" + imdbid + "&watchTitle=" + watchTitle;
	ajaxRequest.open("GET", "watchDvd.php" + queryString, true);
	ajaxRequest.send(null); 
}



function $(v) { return(document.getElementById(v)); }
function $S(v) { return($(v).style); }
function agent(v) { return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); }
function isset(v) { return((typeof(v)=='undefined' || v.length==0)?false:true); }
function XYwin(v) { var z=agent('msie')?Array(document.body.clientHeight,document.body.clientWidth):Array(window.innerHeight,window.innerWidth); return(isset(v)?z[v]:z); }

function sexyTOG() { document.onclick=function(){ $S('sexyBG').display='none'; $S('sexyBOX').display='none'; document.onclick=function(){}; }; }
function sexyBOX(v,b) { setTimeout("sexyTOG()",100); $S('sexyBG').height=XYwin(0)+'px'; $S('sexyBG').display='block'; $('sexyBOX').innerHTML=v; $S('sexyBOX').left=Math.round((XYwin(1)-b)/2)+'px'; $S('sexyBOX').width=b+'px'; $S('sexyBOX').display='block'; }
