var is_nav4up;
var is_ie4up;

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];}
}

function detectBrowser() {
	// *** BROWSER TYPE ***
	var agt=navigator.userAgent.toLowerCase();
	var is_major = parseInt(navigator.appVersion);
	var is_minor = parseFloat(navigator.appVersion);
	var is_ie   = (agt.indexOf("msie") != -1);
	is_ie4up  = (is_ie  && (is_major >= 4) && (navigator.appVersion.indexOf("PPC") == -1) );
}

function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function XMLRemote(url) {
    var objData=new ActiveXObject("Msxml2.XMLHTTP.3.0");

    objData.Open('Get',url, false);
    objData.Send();
    return objData.ResponseText;
}

function fillDiv(url){
	document.getElementById('myDiv').innerHTML=tempData.document.body.innerHTML;
	return true;
}

function pMO(performer) {
    $().mousemove(function(e) {
        positionTooltip(e);
    });
    $("#myDiv").load("/performer.aspx?id=" + performer);
    $("#myDiv").slideDown("fast");
	
}

function tMO2(title) {

    $().mousemove(function(e) {
        positionTooltip(e);
    });
    $("#myDiv").load("/title.aspx?img=0&id=" + title);
    $("#myDiv").slideDown("fast");
	
}

function tMO(title) {
    $().mousemove(function(e) {
        positionTooltip(e);
    });
    $("#myDiv").load("/title.aspx?img=0&id=" + title);
    $("#myDiv").slideDown("fast");
}

function turnoff() {
    $("#myDiv").slideUp("fast");
    $("#myDiv").text("");

}

function positionTooltip(event) {
    var tPosX = event.pageX + 5;
    var tPosY = event.pageY + 10;
    $('#myDiv').css({ top: tPosY, left: tPosX });
};


function fO() {
    turnoff();
}

function fetishOff() {
	if (getCookie("ToolTip") != 0) {
		document.getElementById('myDiv').InnerHTML = "";
		writetxt(0)
	}
}

var dofade=false;     // ENABLES FADE-IN EFFECT FOR IE4+ AND NS6 ONLY
var center=false;     // CENTERS THE BOX UNER THE MOUSE, OTHERWISE DISPLAYS BOX TO THE RIGHT OF THE MOUSE
var centertext=false; // CENTERS THE TEXT INSIDE THE BOX. YOU CAN'T SIMPLY DO THIS VIA STYLE BECAUSE OF NS4.
var flag=true;        // OTHERWISE, TEXT IS LEFT-JUSTIFIED. 


////////////////////////////// NO NEED TO EDIT BEYOND THIS POINT //////////////////////////////////////


function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

var NS4 = (navigator.appName.indexOf("Netscape")>=0 && !document.getElementById)? true : false;
var IE4 = (document.all && !document.getElementById)? true : false;
var IE5 = (document.getElementById && document.all)? true : false;
var NS6 = (document.getElementById && navigator.appName.indexOf("Netscape")>=0 )? true: false;
var W3C = (document.getElementById)? true : false;
var w_y, w_x, myDiv, boxheight, boxwidth;
var ishover=false;
var isloaded=false;
var ieop=0;
var op_id=0;

function getwindowdims(){
w_y=(NS4||NS6||window.opera)? window.innerHeight : (IE5||IE4)? document.body.clientHeight : 0;
w_x=(NS4||NS6||window.opera)? window.innerWidth : (IE5||IE4)? document.body.clientWidth : 0;
}

function getboxwidth(){
if(NS4)boxwidth=(myDiv.document.width)? myDiv.document.width : myDiv.clip.width;
if(NS6)boxwidth=(myDiv.style.width)? parseInt(myDiv.style.width) : parseInt(myDiv.offsetWidth);
}

function getboxheight(){
if(NS4)boxheight=(myDiv.document.height)? myDiv.document.height : myDiv.clip.height;
if(NS6)boxheight=parseInt(myDiv.offsetHeight);
}

function movemyDiv(x,y){
if(NS4)myDiv.moveTo(x,y);
if(W3C||IE4){
//myDiv.style.left=x+'px';
//myDiv.style.top=y+'px';
}}

function getpagescrolly(){
if(NS4||NS6)return window.pageYOffset;
if(IE5||IE4)return ietruebody().scrollTop;
}

function getpagescrollx(){
if(NS4||NS6)return window.pageXOffset;
if(IE5||IE4)return ietruebody().scrollLeft;
}

function writeindiv(text){
if(NS4){
myDiv.document.open();
myDiv.document.write(text);
myDiv.document.close();
}
if(W3C||IE4)myDiv.innerHTML=text;
}

//**** END UTILITY FUNCTIONS ****//

function fillDiv(){
	document.getElementById('myDiv').innerHTML=tempData.document.body.innerHTML;
	return true;
}
    
function writetxt(file){
if(isloaded){
	if(file!=0){
		ishover=true;
		//file = "/performerpop/" + performer + ".html"
		if (file.indexOf('title.aspx') != -1) {
		document.getElementById('myDiv').innerHTML = "<iframe frameborder=0 hspace=0 vspace=0 marginheight=0 marginwidth=0 scrolling=no src='" + file + "' style=left:0px; top:0px; background-color:#FFFFFF;  width=300px; height=125px; font-family:verdana; color:#000000; padding: 0px; margin: 0px;></iframe>";
		}
		
		if (file.indexOf('performer.aspx') != -1) {
		document.getElementById('myDiv').innerHTML = "<iframe frameborder=0 hspace=0 vspace=0 marginheight=0 marginwidth=0 scrolling=no src='" + file + "' style=left:0px; top:0px; background-color:#FFFFFF;  height= 95px; width=180px; font-family:verdana; color:#000000; padding: 0px; margin: 0px;></iframe>";
		}

		getboxheight();		
		
		if((W3C || IE4) && dofade){
		ieop=0;
		incropacity();
		}}else{
		if(NS4)myDiv.visibility="hide";
		if(IE4||W3C){
			if(dofade)clearTimeout(op_id);
			myDiv.style.visibility="hidden";
		}
		writeindiv('');
		ishover=false;
		}
	}
}

function incropacity(){
if(ieop<=100){
ieop+=7;
if(IE4 || IE5)myDiv.style.filter="alpha(opacity="+ieop+")";
if(NS6)myDiv.style.MozOpacity=ieop/100;
op_id=setTimeout('incropacity()', 3);
}}

function moveobj(evt){
if(isloaded && ishover){
margin=(IE4||IE5)? 1 : 23;
if(NS6)if(document.height+27-window.innerHeight<0)margin=15;
if(NS4)if(document.height-window.innerHeight<0)margin=10;
//mx=(NS4||NS6)? evt.pageX : (IE5||IE4)? event.clientX : 0;
//my=(NS4||NS6)? evt.pageY : (IE5||IE4)? event.clientY : 0;
if (NS4){
mx=evt.pageX
my=evt.pageY
}
else if (NS6){
mx=evt.clientX
my=evt.clientY
}
else if (IE5){
mx=event.clientX
my=event.clientY
}
else if (IE4){
mx=0
my=0
}

if(NS4){
mx-=getpagescrollx();
my-=getpagescrolly();
}
xoff=(center)? mx-boxwidth/2 : mx+5;
yoff=(my+boxheight+30-getpagescrolly()+margin>=w_y)? -15-boxheight: 30;
movemyDiv( Math.min(w_x-boxwidth-margin , Math.max(2,xoff))+getpagescrollx() , my+yoff+getpagescrolly());
if(NS4)myDiv.visibility="show";
if(W3C||IE4)myDiv.style.visibility="visible";
}}

if(NS4)document.captureEvents(Event.MOUSEMOVE);
document.onmousemove=moveobj;
window.onload=function(){
  myDiv=(NS4)? document.layers['myDiv'] : (IE4)? document.all['myDiv'] : (W3C)? document.getElementById('myDiv') : null;
  getboxwidth();
  getboxheight();
  getwindowdims();
  isloaded=true;
  if((W3C || IE4) && centertext)myDiv.style.textAlign="center";
  if(IE4 || IE5 && dofade)myDiv.style.filter="alpha(opacity=0)";
  }
window.onresize=getwindowdims;


function ajaxStart(){
		var xmlHttp;
		
		try
	{
		// firefox, opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();		
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
			alert("Your Browser does not support AJAX!");
			return false;
			}
		}
	}
		
	return xmlHttp;
	
	}
	
	
	    function addToFavorites(){
            
    var xmlHttp = ajaxStart();
    
    var btn = document.getElementById("btn");
	
	xmlHttp.onreadystatechange=function(){
	    if(xmlHttp.readyState == 4)
	    {	
	        var rsptext = xmlHttp.responseText;
	                
	        //alert(rsptext);
	        	        
	        btn.disabled="true";
	        btn.value = "added to your favorites";
	        
	    }else{
			
			btn.disabled="true";
			btn.value = "loading...";
	    }
	    	    
	}
	
	var redirectto = "addtofavorites.aspx?"
	
	//set our variables to use in the calling page
	
	var obj = document.getElementById("tbEntityID");
	redirectto = redirectto + "eid=" + obj.value;
	
	  
	obj = document.getElementById("tbEntityType");
	redirectto = redirectto + "&etype=" + obj.value + "";
		
	obj = document.getElementById("tbEntityName");
	redirectto = redirectto + "&ename='" + obj.value + "'";
			
	//call the web page
	xmlHttp.open("GET", redirectto, true);	
	xmlHttp.send(null);
	
    }//end of function
    
    function addToFavoritesByParam(sender, entityid, entityname, entitytype){
    
    var xmlHttp = ajaxStart();
    
    //var btn = document.getElementById(btnId);
	
	xmlHttp.onreadystatechange=function(){
	    if(xmlHttp.readyState == 4)
	    {	
	        var rsptext = xmlHttp.responseText;
	       
	        //alert(rsptext); 
	        sender.disabled="true";
	        sender.value = "Favorite";
	        	        
	    }else{			
			sender.disabled="true";		
	    }
	    	    
	}
	
	var redirectto = "addtofavorites.aspx?"
	
	//set our variables to use in the calling page
		
	redirectto = redirectto + "eid=" + entityid;
	
	redirectto = redirectto + "&etype=" + entitytype + "";
		
	redirectto = redirectto + "&ename=" + entityname + "";
			
	//call the web page
	xmlHttp.open("GET", redirectto, true);	
	xmlHttp.send(null);
	
    }

    function jsRedirect(strLocation){
		window.location = strLocation;
    }
    
    function hideTitleDescription(){
        document.getElementById('TitleDescription').style.display = "none";
        document.getElementById('show').style.display = "block";
        document.getElementById('hide').style.display = "none";
     }  

    function showTitleDescription(){
        document.getElementById('TitleDescription').style.display = "block";
        document.getElementById('show').style.display = "none";
        document.getElementById('hide').style.display = "block";
    }
