if ( (typeof( auth ) != "undefined") && auth == true)
{
	var loggedin = true;
}
else
{
	var loggedin = false;
};

var actualSize = 0;

window.onresize = function()
{
	if (actualSize == 4)
	{
		setFlashSize(4);
	}
	
	if( (typeof( is3D ) != 'undefined') )
	{
		if(is3D != 1)
		{
			checkFullScreen();
		}
	}
};

function setFlashWidth(newW)
{
	if (newW < 721)
	{
		document.getElementById('container').style.width = "721px";	
	}
	else
	{
		document.getElementById('container').style.width = newW+13+"px";
	}
	
	if ( document.getElementById('freechat_flashdiv_priv') )
	{
		document.getElementById('freechat_flashdiv_priv').style.width = newW+"px";
	}
	else
	{
		document.getElementById('freechat_flashdiv').style.width = newW+"px";
	}
	
	document.getElementById('flash').style.width = newW+"px";
};

function setFlashHeight(newH)
{
	if ( document.getElementById('freechat_flashdiv_priv') )
	{
		document.getElementById('freechat_flashdiv_priv').style.height = newH+"px";
	}
	else
	{
		document.getElementById('freechat_flashdiv').style.height = newH+"px";
	}
		
	document.getElementById('flash').style.height = newH+"px";
	if (document.getElementById('opera_elb') != undefined)
	{
		document.getElementById('opera_elb').style.height = newH+"px";
	}
};

function checkFullScreen()
{
	var screenW = screen.width;
	var screenH = screen.height;

	var flashObj = getFlashMovieObject("opera_elb") || getFlashMovieObject("flash");
	
	if (typeof(flashObj) != "object")
	{
		return false;
	}
	
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' )
	{
		/* Non-IE */
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		/* IE 6+ in 'standards compliant mode' */
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
		/* IE 4 compatible */
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	
	if ( window.fullScreen != undefined && navigator.userAgent.toString( ).indexOf("Firefox/2") == -1 )
	{
		flashObj.changeFullScreen( window.fullScreen );
	}
	else if ( myHeight >= screenH - 30 && myWidth >= screenW - 20 )
	{
		flashObj.changeFullScreen( true );
	}
	else if (navigator.userAgent.toString().indexOf("MSIE 6" ) == -1 )
	{
		if (typeof(flashObj.changeFullScreen) == "function")
		{
			flashObj.changeFullScreen( false );
		}
	}
};

function getFlashMovieObject(movieName)
{
	if (window.document[movieName])
	{
		return window.document[movieName];
	}
	if (navigator.appName.indexOf("Microsoft Internet")==-1)
	{
		if (document.embeds && document.embeds[movieName])
		{
			return document.embeds[movieName];
		}
	}
	else /* if (navigator.appName.indexOf("Microsoft Internet")!=-1) */
	{
		return document.getElementById(movieName);
	}
};

function notloggedin(session_name, sid, event)
{
	toolTipComponent.show({ text: myrating_tooltip, url1: "buycredit.php?"+session_name+"="+sid, url2: "login.php", button1: signup, button2: login, button3: cancel});
};

function info3d(session_name, sid, event)
{
	toolTipComponent2.show({ text: cam3d_tooltip, url: serverlink+"live3d.php", button1:  visit_3dinfo, button2: cancel}); 
};

function jsCheck()
{
	return true;
};

function handleClick()
{

	return true;
	
	if (history.length > 1)
	{
		history.back();
		return false;
	}
	
	return true;
};

function getURLParam(strParamName)
{
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 )
  {
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ )
    {
      if (	aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 )
      {
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return unescape(strReturn);
};

function votePerformer()
{
	newwin2 = window.open('vote_popup.php?'+session_name+'='+sid+'&performerid='+performer,'color123','width=350,height=250');
	setTimeout('newwin2.focus();',250);
};

function addCredit()
{
	newwin3 = window.open('account.php?'+session_name+'='+sid,'_blank','width=800,height=600,scrollbars=1'); 
	setTimeout('newwin3.focus();',250);
};

function chatEnd(perfId, perfCat, sessId)
{
	location.href='privatechatend.php?'+session_name+'='+sid+'&performerid='+performer+'&categoryid='+categoryid;		
};

function personalPage()
{
	launchwin("perfinfo.php?performerid="+performer+"&'+session_name+'="+sid, 'newwindow' , 'height=780,width=700, resizable=yes, scrollbars=yes');
};
function setFavorite(action)
{
	launchwin('favouritechange.php?performerid='+performer+'&action='+action+'&'+session_name+'='+sid , 'newwindow' , 'height=256,width=329');
};

function addCredit()
{
	newwin3 = window.open('buycredit.php?'+session_name+'='+sid, '_blank','width=800,height=600,scrollbars=1'); 

	setTimeout('newwin3.focus();',250);
};

/************* Performer rate **********************/

var sMax = 5;
var preSet; 
var rated;


function rating(id, pname)
{
	for (i = 1; i <= sMax; i++)
	{		
		if (i<=id)
		{
			document.getElementById("x"+i+pname).className = "star_full";	
		}
		else
		{
			document.getElementById("x"+i+pname).className = "star_empty";
		}
	}
};


function off(id, sum, pname)
{	
	for (i = 1; i <= sMax; i++){
		if (i > sum)
		{
			document.getElementById("x"+i + pname).className = "star_empty";
		}
		else
		{
			document.getElementById("x"+i + pname).className = "star_full";
		}
	}
};

function updatePerformerRate(rate, performerId)
{
  $.ajax({
   type: "GET",
   url: "ajax/response.php?module=rates&action=setPerformerRate&params[performerid]="+performerId+"&params[rate]="+rate,
   success: function(msg)
   {
	  actualRate = rate;
	  var starElement = $("a.star_full, a.star_empty");
	   
		  for (i=0; i<starElement.length; i++)
		  {
			  starElement[i].className = "star_empty";
	  }
   
	  for (i=0; i<rate; i++)
	  {
	    starElement[i].className = "star_full";
	  }
   },
   error: function()
   {
      alert("Error while saving rate!");
   }
 });
};

$(document).ready(function()
{
  $("a.star_full, a.star_empty").click(function() 
  {
    if (loggedin == true)
    {
		updatePerformerRate(this.id.substr(1,1), this.id.substr(2, this.id.length));  
	}
    return false;
  });
  
  $("a.star_full, a.star_empty").mouseout(function() 
  {
    var pname = this.id.substr(2,this.id.length);
    off(this.id, actualRate, pname);
    return false;
  });
  
  $("a.star_full, a.star_empty").mouseover(function() 
  {
    var id = this.id.substr(1,1);
	var pname = this.id.substr(2,this.id.length);
	rating(id, pname);  
    return false;
  });
});