var isIE = /MSIE (\d+\.\d+);/.test(navigator.userAgent);
$(document).ready(function() {
		$(".rateLatestMovie ul li a").hover(
      function () {
		//alert($(this).attr("id").substring(4,($(this).attr("id").length )));
        p = $(this).attr("id").substring(4,($(this).attr("id").length ));
		for(j=1;j<=p;j++)
			{
				if(isIE) $(".rateLatestMovie ul li a#rate" + j).css({ backgroundPositionY : "-31px" });
				else $(".rateLatestMovie ul li a#rate" + j).css({ backgroundPosition : "0 -31px" });
			}
      }, 
      function () {
        p = $(this).attr("id").substring(4,($(this).attr("id").length ));
		for(j=1;j<=p;j++)
			{
				if(isIE) $(".rateLatestMovie ul li a#rate" + j).css({ backgroundPositionY : "0px" });
				else $(".rateLatestMovie ul li a#rate" + j).css({ backgroundPosition : "0 0px" });
			}
      }
    );
});

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_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }

  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

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_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 MM_validateForm() { //v4.0

  var i,field,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; field=args[i+1]; val=MM_findObj(args[i]);
    if (val) { 
	if (field!='') nm=field; else nm=val.name;
	if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function display(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,status=0,menubar=0,resizable=1,width=650,height=420');");
}

function bookmark(url, title) {
  netscape="Netscape User's hit CTRL+D to add a bookmark to this site."
  if(window.sidebar){ // Firefox
	window.sidebar.addPanel(title, url,'');
  }else if(window.opera){ //Opera
	var a = document.createElement("A");
	a.rel = "sidebar";
	a.title = title;
	a.href = url;
	a.click();
  } else if(document.all){ //IE
	window.external.AddFavorite(url, title);
  } else if (navigator.appName=='Netscape')	{
		alert(netscape);
  }
}

function rateWindow(scene,rate) {
  wndRate = window.open('http://content.porneffect.com/rate.php?lid='+scene+'&r='+rate,'MAS_rate','width=300,height=130,left='+(screen.availWidth-300)/2+',top='+(screen.availHeight-130)/2);
  wndRate.focus();
}

//Tour thumbs rotating
var RotatingThumbs = {
	interval	: 800,
	timer		: null,
	img			: null,
	origSRC		: '',
	thumbs		: [],
	current		: 0,
	
	rotate : function(img,thumbIDs)
	{
		return true; //DISABLING ROTATION !!!
		
		if ( this.timer )
			window.clearTimeout(this.timer);
			
		img.onmouseout = function() {
			RotatingThumbs.img.onload = function(){};
			RotatingThumbs.img.onmouseout = function(){};
			window.clearTimeout(RotatingThumbs.timer);
			RotatingThumbs.img.src = RotatingThumbs.origSRC;

			for ( var i=0; i<RotatingThumbs.thumbs.length; i++ )
				delete RotatingThumbs.thumbs[i];
		};
		img.onload = function() {
			window.clearTimeout(RotatingThumbs.timer);			
			RotatingThumbs.timer = window.setTimeout(RotatingThumbs.pump, RotatingThumbs.interval);
		};

		this.img = img;
		this.origSRC = img.src;
	
		var base = img.src.replace('small.jpg','');
		base = base.substr(0,base.length-1);
	
		thumbIDs = thumbIDs.split(',');
		this.thumbs = [];
		
		for ( var i=0; i<thumbIDs.length; i++ )
			if ( thumbIDs[i] )
			{
				var preload = new Image();
				preload.src = base + thumbIDs[i] + 'small.jpg';
				this.thumbs.push(preload);
			}
				
		if ( this.thumbs.length == 1 )
			return;
		
		this.current = 0;
		this.pump();
	},
	
	pump : function()
	{
		if ( ++RotatingThumbs.current >= RotatingThumbs.thumbs.length )
			RotatingThumbs.current = 0;
		
		RotatingThumbs.img.src = RotatingThumbs.thumbs[RotatingThumbs.current].src;
	}
}

function closebox(name){
	document.getElementById(name).style.display = 'none';
}
