var Browser={};
Browser.Agent=navigator.userAgent.toLowerCase();
Browser.IE=Browser.Agent.indexOf("msie")!=-1;
Browser.Moz=Browser.Agent.indexOf("gecko")!=-1;

if (Browser.Moz)
{
	var View = {
		OffsetLeft:function (oEl) {
			for (var iX=0;oEl;iX+=oEl.offsetLeft,oEl=oEl.offsetParent);
			return iX;
		}
	}

	HTMLElement.prototype.getClientRects=function () {
		return [
			{
				left:View.OffsetLeft(this)+2
			}
		]; 
	}
}

function Movie_Thumb_Description(sDes) {
	document.getElementById("Movie_Thumb_Description").innerHTML = sDes.replace(/\&lt;/gi,"<").replace(/\&gt;/gi,">");
}

function Movie_Thumb_Description_Clear() {
	document.getElementById("Movie_Thumb_Description").innerHTML = "<span class=\"color1\">move your cursor over a movie poster to view its details</span>";
}

function DeleteLink(linkId,callback) { // added in 05.02.09
	if (!protectMembers()) return false;
	$.ajax({
		type: "POST",
		url: ROOT_URL+"pro-video-links.asp",
		data: {act:"delete",id:linkId},
		dataType:"json",
		success: function(json){
			if (!json.isModeratorOrUser) {
				MessageBox(396,119,"Got it! close this message","<span>You must be the publisher or a moderator in order to remove<br/> a link. If the link isn't working you can send a 'broken link' alert<br/> using the <img src=\""+ROOT_URL+"images\/icons\/actions\/ico-report.gif\" alt=\"\" \/> report button.</span>",true,null,true,null,null,null,"MessageBox_Delete");
			} else {
				if (callback) callback();
			}
		}
	});
}

function Report(iLinkID) {
	MessageBox(396,116,"Report problem!","<div id=\"Report_Fields[iDepth]\"><span><form><div class=\"fleft\"><div id=\"Report_Validation_[iDepth]\" class=\"Report_Validation\"></div></div><input type=\"hidden\" value=\"\" name=\"reportType\" id=\"reportType[iDepth]\"/><div class=\"fleft\">report type:</div><div class=\"fleft radios\"><img src=\""+ROOT_URL+"images/controllers/radio/radio-unselected.gif\" onedit=\"SetRadValue('reportType[iDepth]','0')\" alt=\"\" class=\"ProfileRadio\" id=\"rep[iDepth]_1\" onclick=\"RadioButtons(this,'rep[iDepth]');SwitchReport(1,[iDepth])\" />&nbsp;broken link<img src=\""+ROOT_URL+"images/controllers/radio/radio-unselected.gif\" onedit=\"SetRadValue('reportType[iDepth]','1')\" alt=\"\" class=\"ProfileRadio\" id=\"rep[iDepth]_2\" onclick=\"RadioButtons(this,'rep[iDepth]');SwitchReport(2,[iDepth])\" />&nbsp;wrong page<img src=\""+ROOT_URL+"images/controllers/radio/radio-unselected.gif\" onedit=\"SetRadValue('reportType[iDepth]','2')\" alt=\"\" class=\"ProfileRadio\" id=\"rep[iDepth]_3\" onclick=\"RadioButtons(this,'rep[iDepth]');SwitchReport(3,[iDepth])\" />&nbsp;copyright infringement</div><div style=\"clear:both;float:left;display:inline;width:100%;margin-top:6px;\"><div id=\"reportOpt1[iDepth]\"><div>if you have an alternative link to suggest, please type it here:</div><div style=\"float:left;display:inline;width:100%;margin-top:2px;\"><div class=\"inputgreyl\"></div><input type=\"text\" id=\"alternativeLink[iDepth]\" class=\"inputgreysize165\" style=\"width:357px;\"/><div class=\"inputgreyr\"></div></div></div><div style=\"display:none;\" id=\"reportOpt2[iDepth]\"><div>is the link listed under the wrong page? where should it be listed?</div><div style=\"float:left;display:inline;width:100%;margin-top:2px;\"><div class=\"inputgreyl\"></div><input type=\"text\" class=\"inputgreysize165\" id=\"shouldBeListed[iDepth]\" style=\"width:357px;\"/><div class=\"inputgreyr\"></div></div></div><div style=\"display:none;\" id=\"reportOpt3[iDepth]\"><div>if you\'ve found a link that is violating any copyrights, please refer to</div><div style=\"float:left;display:inline;width:100%;margin-top:2px;height:17px\">our copyrights section under the <a href=\"\" class=\"underline\" style=\"color:#323232;font-size:11px;\">terms of use</a> page for more details.</div></div></div></form></span></div><div id=\"Report_SuccessMessage[iDepth]\" class=\"Report_SuccessMessage\"><div class=\"color8\">Thank you! report sent.</div><div><span class=\"color1\">(</span><span class=\"color2\">this message will close in 2 seconds</span><span class=\"color1\">)</span></div></div>",true,function(iDepth) {
		if ($("#reportType"+iDepth).val() == "")
		{
			document.getElementById("Report_Validation_"+iDepth).innerHTML = "[<span class=\"color3\">cannot send! - you must select the report type</span>]";
			return false;
		} else {
			var sValue = $("#reportType"+iDepth).val() == "0" ? $("#alternativeLink"+iDepth).val() : $("#shouldBeListed"+iDepth).val();
			
			if ($("#reportType"+iDepth).val() == "1" && sValue.replace(/\s/gi,"") == "")
			{
				document.getElementById("Report_Validation_"+iDepth).innerHTML = "[<span class=\"color3\">cannot send! - the message field is empty</span>]";
				return false;		
			} else {
				$.ajax({
					type: "POST",
					url: ROOT_URL+"pro-video-links.asp?rnd="+new Date().getTime(),
					data: {act:"report",id:iLinkID,reportType:$("#reportType"+iDepth).val(),value:sValue},
					success: function(msg){}
				});
				$("#Report_Fields"+iDepth).css("display","none");
				$("#Report_SuccessMessage"+iDepth).css("display","block");
				$("#MessageBox_Button_"+iDepth).css("display","none");
				
				setTimeout(function() {
					try
					{
						document.getElementById("MessageBox_"+iDepth).style.display='none';
						document.getElementById("MessageBoxCont_"+iDepth).parentNode.removeChild(document.getElementById("MessageBoxCont_"+iDepth));
					}
					catch (e) {}
				},2000);
			}
		}
		return false;
	},true,"Report a Problem",true,null,"MessageBox_AddReport");
}

function getIndex(obj) {
	var iCnt = 0;
	while (!$(obj).is(":first-child"))
	{
		iCnt++;
		obj = $(obj).prev().get(0);
	}
	return iCnt;
}

function OnlyNum(obj){
	obj.value = obj.value.replace(/\D/gi,"");
}

function ForgotPassword(iDepth) {
	document.getElementById("Login"+iDepth).style.display = "none";
	document.getElementById("ForgotPassword"+iDepth).style.display = "block";
	$("#ForgotPassword"+iDepth).find("input:first").each(function() {this.focus();});
}

function SendPassword(iDepth) {
	var sUsername = $("#ForgotPassword"+iDepth).find("INPUT[name='username']").val(),
		sEmail = $("#ForgotPassword"+iDepth).find("INPUT[name='email']").val();
	if (sUsername.replace(/\s/g,"") == "" || sEmail.replace(/\s/g,"") == "")
	{
		document.getElementById("ForgotPassError"+iDepth).innerHTML = "[<span style=\"font-size:10px;\" class=\"color3\">you must fill both text fields</span>]";
	} else if (!/^([\w\.\-])+@([\w\-\.]+\.)+\w{2,3}$/.test(sEmail))
	{
		document.getElementById("ForgotPassError"+iDepth).innerHTML = "[<span style=\"font-size:10px;\" class=\"color3\">you must enter a valid email address</span>]";
	} else {
		$.ajax({
		   type: "POST",
		   url: ROOT_URL+"pro-users.asp?rnd="+new Date().getTime(),
		   data: {act:"password-reminder",username:sUsername,email:sEmail},
		   success: function(msg){

				document.getElementById("ForgotPassword"+iDepth).style.display = "none";

				if (msg=="true")
				{
					document.getElementById("PasswordSentSMessage"+iDepth).innerHTML = document.getElementById("PasswordSentSMessage"+iDepth).innerHTML.replace(/\[EmailAddress\]/gi,sEmail);
					document.getElementById("PasswordSent"+iDepth).style.display = "block";
				} else {
						document.getElementById("PasswordSentFaild"+iDepth).style.display = "block";
				}
		   }
		});	
	}
}

function DoLogin(iDepth,sUrl) {
	var sUsername = $("#Login"+iDepth).find("INPUT[name='username']").val(),
		sPass = $("#Login"+iDepth).find("INPUT[name='pass']").val();
	if (sUsername.replace(/\s/g,"") == "" || sPass.replace(/\s/g,"") == "")
	{
		document.getElementById("LoginError"+iDepth).style.display = "inline";
	} else {
		$.ajax({
		   type: "POST",
		   url: ROOT_URL+"pro-users.asp?rnd="+new Date().getTime(),
		   data: {act:"login",username:sUsername,password:sPass,isAjax:true},
		   success: function(msg){
				if (msg=="true")
				{
					if (sUrl == "")
						location.reload();
					else {
						location.href = sUrl;
					}
				} else {
					document.getElementById("LoginError"+iDepth).style.display = "inline";
				}
		   }
		});
	}
}

function SignUp() {
	location.href = USER_REGISTER_URL;
}

function Login(sUrl,ActionDetails,bPasswordReminder) {
	if (!sUrl) sUrl = USER_PROFILE_SELFVIEW_URL;
	if (!ActionDetails) ActionDetails="Please enter a username / password to log in:";
	var iDepth = MessageBox(396,119,"Got it! close this message","<span><div style=\"display:block;\" id=\"Login[iDepth]\"><span class=\"rtitle\">Member Login</span><form><div class=\"color13\">"+ActionDetails+"</div><div style=\"margin-top:3px;\"><div class=\"fleft\" style=\"margin-right:5px;\">username:</div><div class=\"fleft\"><div class=\"inputgreyl\"></div><input type=\"text\" class=\"inputgreysize165\" name=\"username\" style=\"width:300px;\"/><div class=\"inputgreyr\"></div></div><div class=\"fleft\" style=\"margin-right:3px;\">password:</div><div class=\"fleft\" style=\"margin-top:2px;\"><div class=\"inputgreyl\"></div><input type=\"password\" class=\"inputgreysize165\" name=\"pass\" style=\"width:300px;\"/><div class=\"inputgreyr\"></div></div><div class=\"fleft\" style=\"width:250px;clear:both;margin-top:7px;\"><span class=\"color2\">[</span><span id=\"LoginError[iDepth]\" style=\"display:none;\"><span class=\"bold color3\" style=\"font-size:10px;\">cannot log in!</span> - </span><span onclick=\"ForgotPassword([iDepth])\" class=\"color3 underline hand\" style=\"font-size:10px;\">forgot your password?</span><span class=\"color2\">]</span></div><div style=\"margin-top:-16px;width:165px;margin-right:7px;\" class=\"fright\"><div class=\"ovalred2 hand fright\" id=\"BtnSignUp[iDepth]\" onclick=\"SignUp()\"><div class=\"L\"></div><div class=\"C\"><div class=\"whitearrows cbtnimg\"></div>Sign up</div><div class=\"R\"></div></div><div class=\"ovalgreen2 hand fright\" id=\"BtnLogin[iDepth]\" onclick=\"DoLogin([iDepth],'"+sUrl+"')\"><div class=\"L\"></div><div class=\"C\"><div class=\"whitearrows cbtnimg\"></div>Log in</div><div class=\"R\"></div></div></div></div></form></div>                <div id=\"ForgotPassword[iDepth]\" style=\"display:none\"><span class=\"rtitle\">Password Reminder</span><form action=\"Forgotpassword.asp\"><div class=\"color13\">To retrieve your password, please submit the following fields:</div><div style=\"margin-top:3px;\"><div class=\"fleft\" style=\"margin-right:5px;\">username:</div><div class=\"fleft\"><div class=\"inputgreyl\"></div><input type=\"text\" class=\"inputgreysize165\" name=\"username\" style=\"width:300px;\"/><div class=\"inputgreyr\"></div></div><div class=\"fleft\" style=\"margin-right:29px;\">email:</div><div class=\"fleft\" style=\"margin-top:2px;\"><div class=\"inputgreyl\"></div><input type=\"text\" class=\"inputgreysize165\" name=\"email\" style=\"width:300px;\"/><div class=\"inputgreyr\"></div></div><div class=\"fleft\" style=\"width:250px;clear:both;margin-top:7px;\">    <div class=\"ovalgreen2 hand fleft\" style=\"width:170px;\" id=\"SendPassword[iDepth]\" onclick=\"SendPassword([iDepth])\"><div class=\"L\"></div><div class=\"C\" style=\"width:160px;\"><div class=\"whitearrows cbtnimg\"></div>Send me my password!</div><div class=\"R\"></div></div>     </div><div style=\"margin-top:-16px;width:185px;margin-right:10px;text-align:center;font-size:10px\" class=\"fright color1\" id=\"ForgotPassError[iDepth]\"></div></div></form></div>                               <div id=\"PasswordSent[iDepth]\" style=\"display:none\"><span class=\"rtitle\">Password Sent!</span><div class=\"color8\" id=\"PasswordSentSMessage[iDepth]\" style=\"margin-top:8px;margin-bottom:8px;\">Your password has been successfully sent to your email and should<br/>be delivered to your account ([EmailAddress]) within a<br/>few minutes</div><div class=\"fleft\" style=\"width:250px;clear:both;margin-top:7px;\"><div class=\"ovalgreen2 hand fleft\" style=\"width:180px;\" id=\"BtnPasswordSent[iDepth]\" onclick=\"CloseMessageBox([iDepth])\"><div class=\"L\"></div><div class=\"C\" style=\"width:170px;\"><div class=\"whitearrows cbtnimg\"></div>Got it! close this message</div><div class=\"R\"></div></div>     </div></div>                                                                       <div id=\"PasswordSentFaild[iDepth]\" style=\"display:none\"><span class=\"rtitle\">Wrong details!</span><div class=\"color8\" style=\"margin-top:8px;margin-bottom:8px;\">We could not find your email or username in our system.<br/>Please make sure that your CAPS-LOCK button is off and try again.<br/>(press the top-right X button to close this message)</div><div class=\"fleft\" style=\"width:250px;clear:both;margin-top:7px;\"><div class=\"ovalgreen2 hand fleft\" style=\"width:180px;\" id=\"BtnPasswordSent[iDepth]\" onclick=\"LoginGoBack([iDepth])\"><div class=\"L\"></div><div class=\"C\" style=\"width:170px;\"><div class=\"whitearrows cbtnimg\"></div>Go back and try again</div><div class=\"R\"></div></div>     </div></div>     </span>",false,null,true,null,null,null,"",true);
	if (bPasswordReminder)
		ForgotPassword(iDepth);
}

function LoginGoBack(iDepth) {
	document.getElementById("PasswordSentFaild"+iDepth).style.display = "none";
	document.getElementById("ForgotPassword"+iDepth).style.display = "block";
	$("#ForgotPassword"+iDepth).find("INPUT[name='username']").val("");
	$("#ForgotPassword"+iDepth).find("INPUT[name='email']").val("");
}

function ShowHide(sId,oEl) {
	document.getElementById(sId).style.display = document.getElementById(sId).style.display == "none" ? "block" : "none";
}

var MessageBoxesGlobal = {
	"iDepth":1,
	"getNextHighestDepth":function() {
		return MessageBoxesGlobal["iDepth"]++;
	}
}

function CloseMessageBox(iDepth) {
	document.getElementById("MessageBox_"+iDepth).style.display='none';
	document.getElementById("MessageBoxCont_"+iDepth).parentNode.removeChild(document.getElementById("MessageBoxCont_"+iDepth));
}

function ClickMessageBoxButton(bDoNotCloseAfterClicking,fButton,obj) {
	if (!bDoNotCloseAfterClicking || (bDoNotCloseAfterClicking && !fButton))
	{
		document.getElementById("MessageBox_"+obj.id.replace(/\D/gi,"")).style.display='none';
		document.getElementById("MessageBoxCont_"+obj.id.replace(/\D/gi,"")).parentNode.removeChild(document.getElementById("MessageBoxCont_"+obj.id.replace(/\D/gi,"")));
	}

	if (fButton && !bDoNotCloseAfterClicking) {
		fButton();
	} else if (fButton) {
		var bClose = fButton(obj.id.replace(/\D/gi,""));
		if (bClose) {
			document.getElementById("MessageBox_"+obj.id.replace(/\D/gi,"")).style.display='none';
			document.getElementById("MessageBoxCont_"+obj.id.replace(/\D/gi,"")).parentNode.removeChild(document.getElementById("MessageBoxCont_"+obj.id.replace(/\D/gi,"")));
		}
	}
	document.onkeyup = null;
}

function MessageBox(iWidth,iHeight,sButtonText,sHtmlContent,bTitle,fButton,bSingle,MessageBoxTitle,bDoNotCloseAfterClicking,fOnDispose,sClass,bDontShowButton) {

	if ((document.getElementById("MessageBox_"+(MessageBoxesGlobal["iDepth"]-1)) == null || document.getElementById("MessageBox_"+(MessageBoxesGlobal["iDepth"]-1)).style.display == 'none' && bSingle) || !bSingle) {

		if (!MessageBoxTitle) {	var MessageBoxTitle = "MoviesPlanet Notification"; }
		sClass = sClass ? " " + sClass : "";
		var sBtn = bDontShowButton ? "display:none;" : "display:block;";
		var iDepth = MessageBoxesGlobal["getNextHighestDepth"]();
		var sHtmlStr = "<div class=\"MessageBox"+sClass+"\" style=\"width:"+iWidth+"px;\" id=\"MessageBox_"+iDepth+"\"><div class=\"Top\"><div class=\"TL\"></div><div class=\"TC\" style=\"width:"+(iWidth-14)+"px;\"></div><div class=\"TR\"></div></div><div class=\"Center\" style=\"height:"+(iHeight-14)+"px;\"><div class=\"CL\"></div><div class=\"CC\" style=\"width:"+(iWidth - 14)+"px;\"><div class=\"MessageCont\"><div class=\"CloseMessage\"><span>&nbsp;</span><span class=\"color2\" id=\"MessageBox_CloseMessage_"+iDepth+"\">close message</span><img id=\"MessageBox_CloseButton_"+iDepth+"\" class=\"hand\" onmouseout=\"this.src='"+ROOT_URL+"images/structure/buttons/btn-x.gif';document.getElementById('MessageBox_CloseMessage_"+iDepth+"').style.display='none';\" onmouseover=\"this.src='"+ROOT_URL+"images/structure/buttons/btn-x-hover.gif';document.getElementById('MessageBox_CloseMessage_"+iDepth+"').style.display='inline';\" src=\""+ROOT_URL+"images/structure/buttons/btn-x.gif\" alt=\"\" /></div><div class=\"MessageContent\"><div id=\"MessageBox_ContentArea_"+iDepth+"\">"+(bTitle?"<span class=\"rtitle\">"+MessageBoxTitle+"</span>":"")+sHtmlContent.replace(/\[iDepth\]/g,iDepth.toString())+"</div><div style=\""+sBtn+"\" class=\"ovalgreen hand MessageBox_Button\" id=\"MessageBox_Button_"+iDepth+"\" onmousedown=\"document.getElementById('MessageBox_"+iDepth+"').style.display='none'\" style=\"width:auto;\"><div class=\"L\"></div><div class=\"C\" style=\"width:auto;\"><img class=\"couple-arrows\" src=\""+ROOT_URL+"images/icons/arrows/couple-arrows.gif\" alt=\"\"/>"+sButtonText+"</div><div class=\"R\"></div></div></div></div></div><div class=\"CR\"></div></div><div class=\"Bottom\"><div class=\"BL\"></div><div class=\"BC\" style=\"width:"+(iWidth - 14)+"px;\"></div><div class=\"BR\"></div></div></div>";
		var oDiv2 = document.createElement("DIV");
		oDiv2.className = "MessageBoxCont";
		oDiv2.id = "MessageBoxCont_"+iDepth;
		document.body.appendChild(oDiv2);
		
		ofHeight = oDiv2.offsetHeight;
		var ofTop = 0;

		if (document.body.offsetHeight > oDiv2.offsetHeight)
			oDiv2.style.height = (Browser.Moz ? document.documentElement.offsetHeight : document.body.offsetHeight) + "px";
	
		if (Browser.IE && jQuery.browser.version == "6.0")
		{
			oDiv2.style.height = ((document.documentElement.offsetHeight - 4) > document.body.offsetHeight ? (document.documentElement.offsetHeight - 4) : document.body.offsetHeight) + "px";
			ofHeight = (document.documentElement.offsetHeight - 4);
			ofTop = document.documentElement.scrollTop;
		}

		if (Browser.Moz)
			ofTop = -5;
		else
			ofTop -= 23;

		oDiv = document.createElement("DIV");
		oDiv.id = "macao_"+iDepth;
		oDiv.innerHTML = sHtmlStr;
		oDiv.className="MaCo";
		oDiv.style.display = 'none';
		document.body.appendChild(oDiv);

		oDiv.style.top = (ofTop + (ofHeight/2) - (iHeight/2)) + "px";
		oDiv.style.display = 'block';

		$(oDiv).find("INPUT[type='text']:first").each(function() {
			this.focus();
		});

		document.getElementById("MessageBox_CloseButton_"+iDepth).onmousedown = function() {
			document.getElementById("MessageBox_"+this.id.replace(/\D/gi,"")).style.display='none';
			document.getElementById("MessageBoxCont_"+this.id.replace(/\D/gi,"")).parentNode.removeChild(document.getElementById("MessageBoxCont_"+this.id.replace(/\D/gi,"")));
		}

		document.getElementById("MessageBox_Button_"+iDepth).onmousedown = function() {
			ClickMessageBoxButton(bDoNotCloseAfterClicking,fButton,this);
		}

		document.body.setAttribute("MessageBox_Depth",iDepth);
		document.onkeydown = function() {
			var oEv = window.addEventListener ? arguments[0] : event;
			if (oEv.keyCode == 13) {
				return false;
			}
		}

		document.onkeyup = function() {
			var oEv = window.addEventListener ? arguments[0] : event;
			if (oEv.keyCode == 13) {

				if (document.getElementById("ForgotPassword"+iDepth) && document.getElementById("ForgotPassword"+iDepth).style.display != "none")
				{
					$("#SendPassword"+iDepth).trigger("click");
				} else if (document.getElementById("BtnLogin"+iDepth))
				{
					
					$("#BtnLogin"+iDepth).trigger("click");
				} else {
					
					ClickMessageBoxButton(bDoNotCloseAfterClicking,fButton,$("#MessageBox_Button_"+document.body.getAttribute("MessageBox_Depth")).get(0));
				}
			}
		}

		if (fOnDispose)
			fOnDispose(iDepth);

		return iDepth;
	}
}

function getTop(theObj) {
	var iCount=0;
	while(theObj) {
		iCount+=(theObj.offsetTop?theObj.offsetTop-theObj.scrollTop:0);
		theObj=theObj.offsetParent;
	}
	return iCount;
}

function getLeft(theObj,isIE) {
	return (theObj.getClientRects()[0].left-2) + 2;
}

function OpenCloseTableInfo(obj,sId) {
	sStatus = document.getElementById(sId).style.display == "none" ? "" : "none";
	document.getElementById(sId).style.display = sStatus;

	if (obj.tagName != "IMG")
		obj = document.getElementById("magnifyingGlass_"+ sId.replace(/\D/gi,""));
	
	if (sStatus == "none")
		obj.src = ROOT_URL+"images/icons/actions/magnifying-glass-closed.gif";
	else
		obj.src = ROOT_URL+"images/icons/actions/magnifying-glass-opened.gif";
}

function PollHover(obj) {
	if (obj.firstChild.src.indexOf("pollvote-checked.gif") == -1)
		obj.firstChild.src = obj.firstChild.src.replace(/poll\-vote\.gif/gi,"poll-vote-hover.gif");
}

function PollOut(obj) {
	if (obj.firstChild.src.indexOf("pollvote-checked.gif") == -1)
		obj.firstChild.src = obj.firstChild.src.replace(/poll\-vote\-hover\.gif/gi,"poll-vote.gif");
}

var ScrollRight_Interval,ScrollLeft_Interval;
function ScrollLeft(obj,iArrowSeries,iImgType) {
	var sArrowSeries = iArrowSeries ? "-"+iArrowSeries : "";
	var sImgType = iImgType ? "-"+iImgType : "";
	var bgsc = document.getElementById("bgsc"+sArrowSeries);

	
	if (obj.src == null || obj.src.indexOf("zones-arrow-l-on"+sImgType+".gif") > -1)
	{
		if (sImgType=="-SpriteMini")
		{
			obj.style.backgroundPosition = "-1704px -34px";
			//document.getElementById("arrow_scroll_right"+sArrowSeries).style.backgroundPosition = "-1774px 0px";
		} else if (sImgType == "") {
			obj.style.background = "url(/images/sprites/sprite-index.gif) 0px -932px no-repeat";
			document.getElementById("arrow_scroll_right").style.background = "url(/images/sprites/sprite-index.gif) 0px -898px no-repeat";
		} else {
			obj.src = ROOT_URL+"images/icons/arrows/zones-arrow-l-run"+sImgType+".gif";
			document.getElementById("arrow_scroll_right"+sArrowSeries).src = ROOT_URL+"images/icons/arrows/zones-arrow-r-on"+sImgType+".gif"; 
		}
		
		ScrollLeft_Interval = setInterval(function() {
			bgsc.scrollLeft--;
			if (bgsc.scrollLeft == 0)
			{
				StopScroll(obj,'left',iArrowSeries,iImgType);
			}
		},15);
	}
}

function ScrollRight(obj,iArrowSeries,iImgType) {
	var sArrowSeries = iArrowSeries ? "-"+iArrowSeries : "";
	var sImgType = iImgType ? "-"+iImgType : "";
	var bgsc = document.getElementById("bgsc"+sArrowSeries);

	if ((obj.src == null || obj.src.indexOf("zones-arrow-r-on"+sImgType+".gif") > -1) && bgsc.offsetWidth < bgsc.scrollWidth)
	{	

		if (sImgType=="-SpriteMini")
		{
			obj.style.backgroundPosition = "-1750px -34px";
			//document.getElementById("arrow_scroll_left"+sArrowSeries).style.backgroundPosition = "-1726px 0px";
		} else if (sImgType == "") {
			obj.style.background = "url(/images/sprites/sprite-index.gif) 0px -1074px no-repeat";
			document.getElementById("arrow_scroll_left").style.background = "url(/images/sprites/sprite-index.gif) 0px -676px no-repeat";
		} else {
			obj.src = ROOT_URL+"images/icons/arrows/zones-arrow-r-run"+sImgType+".gif";
			document.getElementById("arrow_scroll_left"+sArrowSeries).src = ROOT_URL+"images/icons/arrows/zones-arrow-l-on"+sImgType+".gif"; 
		}
		
		ScrollRight_Interval = setInterval(function() {
			bgsc.scrollLeft++;
			
			if (bgsc.scrollLeft == (bgsc.scrollWidth - bgsc.offsetWidth))
			{
				StopScroll(obj,'right',iArrowSeries,iImgType);
			}
		},15);
	}
}

function StopScroll(oEl,sDirection,iArrowSeries,iImgType) {
	var sArrowSeries = iArrowSeries ? "-"+iArrowSeries : "";
	var sImgType = iImgType ? "-"+iImgType : "";
	var bgsc = document.getElementById("bgsc"+sArrowSeries);
	try {clearInterval(ScrollLeft_Interval)}
	catch (e){}
	try {clearInterval(ScrollRight_Interval)}
	catch (e){}

	if (sDirection == "left")
	{

		if (sImgType=="-SpriteMini")
		{
			oEl.style.backgroundPosition = "-1704px 0px";
		} else if (sImgType == "")
		{
			if (bgsc.scrollLeft == 0)
				oEl.style.background = "url(/images/sprites/sprite-index.gif) 0px -547px no-repeat";
			else
				oEl.style.background = "url(/images/sprites/sprite-index.gif) 0px -676px no-repeat";
		} else {
			if (bgsc.scrollLeft == 0)
				oEl.src = ROOT_URL+"images/icons/arrows/zones-arrow-l-off"+sImgType+".gif";
			else
				oEl.src = ROOT_URL+"images/icons/arrows/zones-arrow-l-on"+sImgType+".gif";
		}
	} else {


		if (sImgType=="-SpriteMini")
		{
			oEl.style.backgroundPosition = "-1750px 0px";
		} else if (sImgType == "")
		{
			if (bgsc.scrollLeft == (bgsc.scrollWidth - bgsc.offsetWidth)) {
				
				oEl.style.background = "url(/images/sprites/sprite-index.gif) 0px -1197px no-repeat";
			} else
				oEl.style.background = "url(/images/sprites/sprite-index.gif) 0px -898px no-repeat";
		} else {
			if (bgsc.scrollLeft == (bgsc.scrollWidth - bgsc.offsetWidth))
				oEl.src = ROOT_URL+"images/icons/arrows/zones-arrow-r-off"+sImgType+".gif";
			else
				oEl.src = ROOT_URL+"images/icons/arrows/zones-arrow-r-on"+sImgType+".gif";
		}
	}
}

function SelectStatus(id) {
	$.ajax({
	  type: "POST",
	  url: ROOT_URL+"pro-users.asp",
	  data: { act:"set-onlinestatus",id:id },
	  success: function(msg){}
	});
}

function BtnSaveOver(oBtn) {
	oBtn.className="btngrn1-Over hand";
}

function BtnSaveOut(oBtn) {
	oBtn.className="btngrn1";
}

function RolloverActorMovie(sId) {
	document.getElementById(sId).style.visibility='visible';
}

function RolloutActorMovie(sId) {
	document.getElementById(sId).style.visibility='hidden';
}

function UserDetailsOver(sText, sId) {
	document.getElementById(sId).innerHTML = sText;
}

function UserDetailsOut(sId) {
	var sMessage = "move the cursor across a user pic to see his details";
	document.getElementById(sId).innerHTML = sMessage;
}

function NavHover(ev) {
	oEl = ev.srcElement ? ev.srcElement : ev.target;
	if (oEl.tagName == "A")
	{
		try {clearInterval(SubMenu_Interval)}
		catch (e){}	
	}
}

var arrIntervals = [];

function HeaderHover(ev,obj) {
	clearInterval(MenuInterval);
	//if (obj.id != Settings_MainSection)
	//{	
		if (Settings_MainSection != "")
			document.getElementById(Settings_MainSection).className = "";
		$(obj.parentNode).children().children(".MenuPopup").each(function() { 
			if (obj != this && PopUp_Obj != obj) {
				this.parentNode.className = "";
				this.style.display = "none";
			}
		});
		if (obj == PopUp_Obj)
			clearInterval(PopUp_Interval);
		obj.className = "selected";
		var oPopped = $(obj).children().get(1);
		oPopped.style.display = "block";
		oPopped.focus();
	//} else {
	//	if (Settings_MainSection != "")
	//		document.getElementById(Settings_MainSection).className = "selected";
	//}
}

var PopUp_Obj;
var PopUp_Interval;
var MenuInterval;

function HeaderOut(ev,obj) {
	//if (obj.id != Settings_MainSection)
	//{
		var oEl = window.addEventListener ? ev.relatedTarget : ev.toElement;
		var isCurrent = false;
		var isPopup = false;
		try
		{
			var tName = oEl.tagName; // Causes a permission bug in ff, so this is not the current!
			while (oEl.tagName != "BODY")
			{
				if (oEl == obj) {
					isCurrent = true;
					break;
				}
				oEl = oEl.parentNode;
			}
		}
		catch (e)
		{
			isCurrent = false;
		}

		if (!isCurrent)
		{
			var oElOuted = window.addEventListener ? ev.target : ev.srcElement;
			while (oElOuted.tagName != "BODY")
			{
				if (oElOuted.className.indexOf("MenuPopup") > -1) {
					isPopup = true;
					break;
				}
				oElOuted = oElOuted.parentNode;
			}

			if (isPopup)
			{
				PopUp_Obj = obj;
				PopUp_Interval = setInterval(function() {
					clearInterval(PopUp_Interval);
					obj.className = "";
					$(obj).children().get(1).style.display = "none";
				},350);

				MenuInterval = setInterval(function() {
					clearInterval(MenuInterval);
					if (Settings_MainSection != "")
						document.getElementById(Settings_MainSection).className = "selected";
				},350);

			} else {
				obj.className = "";
				$(obj).children().get(1).style.display = "none";
				MenuInterval = setInterval(function() {
					clearInterval(MenuInterval);
					if (Settings_MainSection != "")
						document.getElementById(Settings_MainSection).className = "selected";
				},250);
			}
		}
	//}
}

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 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 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";
  }
  document.cookie = null;
}

function LoadBlocksSettings(sId) {
	if (getCookie(sId) == "minimize")
	{
		var oEl = document.getElementById(sId);
		oEl.style.width = oEl.offsetWidth;
		oEl.style.overflow="hidden";
		oElImg = document.getElementById(sId+"_Img");
		oElImg.src = oElImg.src.replace(/minimize/i,"maximize");
		oElImg.style.marginTop = "3px";
		oElImg.parentNode.parentNode.className = "Ovald";
		oElImg.id = "h"+oEl.offsetHeight;
		oEl.scrollTop = oEl.offsetHeight;
		oEl.style.height = "0px";
		oElImg.setAttribute("InAction","false");
	}
}

function ExpandUnExpand(oElImg,sIdToExpand) {

	var isImg = oElImg.tagName == "IMG";

	if (oElImg.getAttribute("InAction") != "true")
	{
	
		var oEl = document.getElementById(sIdToExpand);

		if ((isImg && oElImg.src.indexOf("minimize") > -1) || (!isImg && oEl.offsetHeight > 0))
		{
			var now = new Date();
			now.setTime(now.getTime() + 1000 * 60 * 60 * 60 * 24 * 7); // setting a cookie for 1 week...
			setCookie(sIdToExpand,"minimize",now);

			var oElHeight = oEl.offsetHeight;
			var oElWidth = oEl.offsetWidth;
			oElImg.id = "h"+oElHeight;

			oElImg.setAttribute("InAction","true");
			oEl.style.height = oElHeight + "px";
			oEl.style.width = oElWidth + "px";
			oEl.style.overflow="hidden";
			iScrollTop = 0;

			var oExpandInterval = setInterval(function() {
				oElHeight -= 5;
				iScrollTop += 5;

				if (oElHeight >= 0)
					oEl.style.height = oElHeight + "px";
				else
					oEl.style.height = "0px";

				oEl.scrollTop = iScrollTop;
				if (oElHeight <= 1)
				{
					oElHeight = 0;
					oEl.style.height = "0px";
					clearInterval(oExpandInterval);
					oElImg.setAttribute("InAction","false");
					if (isImg)
					{
						oElImg.src = oElImg.src.replace(/minimize/i,"maximize");
						oElImg.style.marginTop = "3px";
						oElImg.parentNode.parentNode.className = "Ovald";
					} else {
						oElImg.parentNode.className = "box3 Ovald";
					}
				}

			},10);
		} else {

			var now = new Date();
			now.setTime(now.getTime() + 1000 * 60 * 60 * 60 * 24 * 7); // setting a cookie for 1 week...
			setCookie(sIdToExpand,"maximize",now);

			var oElHeight = oElImg.id.replace(/\D/gi,"")*1;
			var iC = 0;
			oElImg.setAttribute("InAction","true");

			if (isImg)
				oElImg.parentNode.parentNode.className = "";
			else
				oElImg.parentNode.className = oElImg.parentNode.className.replace(/Ovald/gi,"");

			var oExpandInterval = setInterval(function() {
				iC += 5;
				oEl.style.height = iC + "px";
				oEl.scrollTop = 0;
				if (iC >= oElHeight)
				{
					iC = oElHeight;
					oEl.style.height = oElHeight + "px";
					
					clearInterval(oExpandInterval);
					
					oElImg.setAttribute("InAction","false");
					
					if (isImg)
					{
						oElImg.src = oElImg.src.replace(/maximize/i,"minimize");
						oElImg.style.marginTop = "5px";
					}
				}
			},10);
		}
	}
}

function forVIPS() {
	MessageBox(396,119,"Learn more!","<span>This feature is for premium members only! to learn more about becoming a premium subscriber, press the \"Learn more!\" button.</span>",true,function() {
		open(USER_VIP_URL);
	},true);
}

function protectMembers() {
	if (!UserIsOnline) {
		location.href=LOGIN_URL;
		return false;
	}
	return true;
}

function OpenMessanger() {
	open(MESSENGER_URL,"","width=460,height=300,status=yes,toolbar=no,menubar=no,location=no");
}
function OpenViewLink(iLinkID) {
	open(VIEW_LINK_URL.replace("{0}",iLinkID));
}


var OpenCloseHeaderItem_Interval;
var OpenCloseHeaderItem_InAction = false;
function OpenCloseHeaderItem(oEl) {

	if (!OpenCloseHeaderItem_InAction)
	{
	
		var oEl2 = $(oEl).next().get(0);
		
		if (oEl2.offsetHeight == "0")
		{
			oEl2.style.display = "block";
			oEl.className = "p expandable docked";
			if (oEl2.getAttribute("scrollerLoaded") != "true")
			{
				oEl2.style.height = "65px";
				var Header_SubMenuScroller = new Scroller();
				var oContentId = $(oEl2).children(":first").get(0).id;
				Header_SubMenuScroller.Apply(oContentId,oContentId+'-Scroller');
				Header_SubMenuScroller.Update();
				oEl2.style.height = "0px";
			}

			OpenCloseHeaderItem_InAction = true;
			OpenCloseHeaderItem_Interval = setInterval(function() {
				if (oEl2.offsetHeight >= "65")
				{
					oEl2.style.height = "65px";
					clearInterval(OpenCloseHeaderItem_Interval);
					OpenCloseHeaderItem_InAction = false;
				} else
					oEl2.style.height = (oEl2.offsetHeight+5) + "px";
			},10);

		} else {

			OpenCloseHeaderItem_InAction = true;
			OpenCloseHeaderItem_Interval = setInterval(function() {
				if (oEl2.offsetHeight <= "0")
				{
					oEl2.style.height = "0px";
					clearInterval(OpenCloseHeaderItem_Interval);
					OpenCloseHeaderItem_InAction = false;
				} else
					oEl2.style.height = (oEl2.offsetHeight-5) + "px";
			},10);
			
			oEl.className = "p expandable";

		}

	}
}

function getPreviousSibling(obj) {
	while (obj.previousSibling)
	{
		obj = obj.previousSibling;
		if (obj.nodeType == 1)
			return obj;
	}

	return null;
}

function getNextSibling(obj) {
	while (obj.nextSibling)
	{
		obj = obj.nextSibling;
		if (obj.nodeType == 1)
			return obj;
	}
	return null;
}

function deleteComment(iCommentID,type,obj) {
	MessageBox(396,119,"Yes! delete this message","<span>Are you sure you want to delete this message? (press the X button to cancel)</span>",true,function() {
		$.ajax({
		   type: "POST",
		   url: ROOT_URL+"pro-comments.asp",
		   data: {act:"deleteComment",type:type,id:iCommentID},
		   success: function(msg){
				var oBoxesContainer = obj.parentNode.parentNode.parentNode.parentNode;
				var oBoxToDelete = obj.parentNode.parentNode.parentNode;
				var oBoxSibling = oBoxToDelete;

				if (getPreviousSibling(oBoxSibling))
					oBoxSibling = getPreviousSibling(oBoxSibling);

				oBoxesContainer.removeChild(oBoxToDelete);

				if (!getNextSibling(oBoxSibling) && getPreviousSibling(oBoxSibling))
					oBoxSibling.className = "boxes last";
		   }
	   });
	},true);
}

var MAX_DUMP_DEPTH=2;
function h(obj,name,indent,depth) {
	indent=indent || "";
	if (depth>MAX_DUMP_DEPTH) return indent+name+": <Maximum Depth Reached>\n";
	if (typeof obj=="object") {
		var child=null;
		var output=indent+name+"\n";
		indent+="\t";
		for (var item in obj) {
			try {
				child=obj[item];
			} catch (e) {
				child="<Unable to Evaluate>";
			}
			if (typeof child=="function") continue;

			if (typeof child=="object") output+=h(child,item,indent,depth+1);
			else output+=indent+item+": "+child+"\n";
		}
		return output;
	}
	else return obj;
}

function ShowHideResultsFilter(oButton) {

	if (oButton.className.indexOf("btn-resultson") > -1) {
		$("#results-filter").css("display","none");
		$("#results-info").css("display","block");
		$(oButton).removeClass("btn-resultson").children(".C").html("results filter");

	} else {
		$("#results-info").css("display","none");
		$("#results-filter").css("display","block");
		$(oButton).addClass("btn-resultson").children(".C").html("hide filters");
	}
}


var search_radio_select_aValues = ["enter a movie/show title","enter a movie title","enter a tv show title","enter a celebrity name"];
function search_radio_select(oContainer,sInputID,sSearchInputID,oEvent) {

	
	var oEl = window.addEventListener ? oEvent.target : oEvent.srcElement;

	if (oEl.tagName == "SPAN")
	{
		var iIndex = -1;
		var oElIndex = -1;

		$(oContainer).children("SPAN").each(function(Index) {
			if (this.className == "selected")
				iIndex = Index;
			if (this == oEl)
				oElIndex = Index;
		});

		var oSearchInput = $("#"+sSearchInputID);
		if (oSearchInput.val() == search_radio_select_aValues[iIndex+1])
			oSearchInput.val(search_radio_select_aValues[oElIndex+1]);

		$(oContainer).children("SPAN").removeClass("selected");
		oEl.className = "selected";
		$("#"+sInputID).val(oEl.innerHTML);
	}
}

function search_radio_val(oContainer) {
	var sVal = search_radio_select_aValues[0];
	$(oContainer).children("SPAN").each(function(Index) {
		if (this.className == "selected")
			sVal = search_radio_select_aValues[Index+1];
	});
	return sVal;
}

var PopularTags = {
	Height:0,
	El: null,
	Closed: true,
	InAction: false,
	OpenClose: function() {

		if (PopularTags.InAction)
			return;
		
		PopularTags.InAction = true;

		if (PopularTags.El == null)
			PopularTags.El = $("#SearchPopularTags").get(0);

		if (PopularTags.El.style.display == "none")
		{
			$("#SearchBottomShad").css("height","1px");
			$("#OpenerButton").css("top","3px");
			$("#SearchApr_pxofl").css("display","none");
		} else {
			$("#SearchBottomShad").css("height","0px");
			$("#OpenerButton").css("top","3px");
			$("#SearchApr_pxofl").css("display","block");
		}
		
		$(PopularTags.El).animate(
			{
				height: "toggle"
			},
			{
				duration: 200, 
				specialEasing: {
				  width: 'linear',
				  height: 'easeOutBounce'
				},
				complete: function() {
					PopularTags.InAction = false;
					if (PopularTags.El.style.display == "block")
					{
						$("#SearchOpenerArrowBottom").addClass("viewup");
					} else {
						$("#SearchOpenerArrowBottom").removeClass("viewup");
					}
				}
			}
		);


	}
}

var MovieChartBox = {
	Hover: function(event) {
		var oEl = window.addEventListener ? event.target : event.srcElement;
		$(oEl).parents(".MovieItem").addClass("MovieItemSelected");
	},
	Out: function(event) {
		var oEl = window.addEventListener ? event.target : event.srcElement;
		$(oEl).parents(".MovieItem").removeClass("MovieItemSelected");
	},
	ExpandUnExpand: function() {

		if ($("#MiniBoxOfficeChart").css("height") != "255px")
		{
			$("#MiniBoxOfficeChart").animate({height:"255px"},
			{
				duration: 150, 
				specialEasing: {
				  height: 'easeOutBounce'
				}
			});

			$("#MovieChartBox .Side").animate({height:"187px"},
			{
				duration: 150, 
				specialEasing: {
				  height: 'easeOutBounce'
				},
				complete: function() {
					$("#OfficeChartExpandDirection").addClass("arrow-direction-bottom");
				}
			});

			$("#OfficeChartExpandDirection").animate({marginTop:"27px"},
			{
				duration: 150, 
				specialEasing: {
				  height: 'easeOutBounce'
				},
				complete: function() {
					$("#OfficeChartExpandDirection").removeClass("arrow-direction-bottom");
				}
			});
		} else {

			$("#MiniBoxOfficeChart").animate({height:"235px"},
			{
				duration: 150, 
				specialEasing: {
				  height: 'easeOutBounce'
				}
			});

			$("#MovieChartBox .Side").animate({height:"136px"},
			{
				duration: 150, 
				specialEasing: {
				  height: 'easeOutBounce'
				}
			});

			$("#OfficeChartExpandDirection").animate({marginTop:"7px"},
			{
				duration: 150, 
				specialEasing: {
				  height: 'easeOutBounce'
				},
				complete: function() {
					$("#OfficeChartExpandDirection").addClass("arrow-direction-bottom");
				}
			});
		}
	}
}

var bCloseSearchOptions = false;
function OpenSearchOptions() {
	document.getElementById("SearchPopupOptions").style.display = "block";
	bCloseSearchOptions = false;
}

function CloseSearchOptions() {
	bCloseSearchOptions = true;
	setTimeout(function() {
		if (bCloseSearchOptions)
			document.getElementById("SearchPopupOptions").style.display = "none";
	},200);
}

function SelectSearchPopup(sOptionValue) {
	$("#SearchOptionSelected").html(sOptionValue);
}


function r() {
	var a=Array.prototype.slice.apply(arguments);
	alert(a.join("\n"));
}
var h2=function (o) {
	r(h(o));
};

function $log() {
	window.console && typeof(console.log)=="function" && console.log.apply(console,arguments);
}