
var CatOnCount;
var CatOffCount;
var CatOnCount2;
var CatOffCount2;
var IsLoaded = false;
CatOnCount=0;
CatOffCount=0;
CatOnCount2=0;
CatOffCount2=0;
var fly_place_text = "fly_place";

function FillRightPane()
{
	GetRefID("right_pane").innerHTML=ExecuteXML("right_pane.asp");
	//GetRefID("right_pane").innerHTML="aaa";		
	TruncRightPane();
	
	
}

function UpdateHeader(txt,obj)
{
    if (has_header)    
        document.all.basket_count.innerHTML = txt;
   StartFlyThumb(obj);
}
function TruncRightPane()
{
	
	var a;
	var i;
	a=document.getElementsByName("wishlist");
		
	for(i=0;i<a.length;i++)
	{
		
		while(a[i].parentNode.offsetHeight > 25)
		{
			a[i].innerHTML = a[i].innerHTML.substr(0,a[i].innerHTML.length-3)+"..";
		}
	}

}
function swap(obj)
{
	var tmp;

		
	tmp = obj.src;
	obj.src=obj.alt;
	obj.alt=tmp;
	
};
function SetImage(id,img)
{
	GetRefID(id).src=img;
};
function GetRefID(id)
{
//alert(id);
	if (navigator.appName == "Netscape")
	{refname = document.getElementById(id)}
	else
	{refname=eval("document.all."+id)}
		//alert(refname.id);
		
	return refname;
}
function GetRefIDEX(win,id)
{
//alert(id);
	if (navigator.appName == "Netscape")
	{refname = eval("window."+win+".document").getElementById(id)}
	else
	{refname=eval("window."+win+".document.all."+id)}
		//alert(refname.id);
		
	return refname;
}
function StarOver(tid,num)
{
	
	var i,j;
	for (i=1;i<=5;i++)
	{
		ref="star"+tid+"-"+i;
		for(j=0;j<document.getElementsByName(ref).length;j++)
		{
			if (i <= num)
				document.getElementsByName(ref)[j].src = starfull.src;
			else
				document.getElementsByName(ref)[j].src = starempty.src;
				
		}
	}

}
function StarOut(tid,rating)
{
	
	
	StarOver(tid,rating);
}
function SetRating(tid,rating)
{
	
	if(!CanRateMovies)
	{
		DoRatePopup("?msg=cantrate");
		return;
	}

	var u;
	document.ratetitle.title_id.value = tid;
	document.ratetitle.rating.value = rating;
	document.ratetitle.submit();
	
}
function DoRecommendPopup()
{


	var w,h,lft,top;
	w=550;
	h=380;
	lft=window.screen.width/2-w/2;
	top=window.screen.height/2-h/2;
	window.open("recommendpopup.htm","","toolbar=0,location=0,top="+top+",left="+lft+",titlebar=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width="+w+",height="+h);
}

function DoRatePopup(extra)
{


	var w,h,lft,top;
	w=400;
	if(extra.length>0)
		h=530;
	else
		h=380;
	lft=window.screen.width/2-w/2;
	top=window.screen.height/2-h/2;
	window.open("ratings.asp"+extra,"","toolbar=0,location=0,top="+top+",left="+lft+",titlebar=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width="+w+",height="+h);
}
function DidntSee(tid)
{
	document.ratetitle.title_id.value = tid;
	document.ratetitle.rating.value = -1;
	document.ratetitle.submit();
}
var SeenHelpers = new Array('חרא של סרט','לא אהבתי','סרט בסדר','אהבתי','סרט מעולה');
function InsertStars(tid,rating)
{
	if(!CanRateMovies)
	{
		DoRatePopup("?msg=cantrate");
		return;
	}
	
	var ins,i,img;
	ins=""
	
	for (i=5;i>=1;i--)
	{
		if (rating >=i)
			img="images/starfull.gif";
		else
			img="images/starempty.gif";
			
		ins = ins+"<a href='javascript:SetRating("+tid+","+i+")'  onmouseover='StarOver("+tid+","+i+")' onmouseout='StarOut("+tid+","+rating+")'><img id='star"+tid+"-"+i+"' name='star"+tid+"-"+i+"' src='"+img+"' border=0 alt='"+SeenHelpers[i-1]+"'></a>";
		
		
	}
	ins+="<div style='margin-top:5px'>";
	if (rating == 0)
		ins+="<a class=movieinfosmall href=\"javascript:DoRatePopup('')\">דירוג</a> &nbsp&nbsp&nbsp&nbsp";
	ins+="<a class=movieinfosmall href='javascript:DidntSee("+tid+")'>לא ראיתי</a>";
	ins+="</div>";
	
	ref = "stars"+tid;
	for (i=0;i<document.getElementsByName(ref).length;i++)
	{
		document.getElementsByName(ref)[i].innerHTML = ins;
		document.getElementsByName(ref)[i].style.display="block";
		document.getElementsByName("add"+tid)[i].style.display="none";
	}
}


function DoAgreement(foot)
{
	var w,h,lft,top;
	w=700;
	h=window.screen.availHeight-35;
	if (h>690)
		h=690;
	lft=window.screen.width/2-w/2;
	top=1;
	window.open("agreement"+foot+".htm","","toolbar=0,location=0,top="+top+",left="+lft+",titlebar=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width="+w+",height="+h);
}

function DoPreview(id)
{
	var tp;
	var lft;
	var l;
	tp = window.screen.height/2-250;
	lft = window.screen.width/2-200;
	if (CanRateMovies)
		l="yes";
	else
		l="no"
		
		a =	window.open("preview.asp?l="+l+"&id="+id,"","toolbar=0,location=0,top="+tp+",left="+lft+",titlebar=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=450,height=500");
	
}
function DoListThumb(id)
{
	
	if (navigator.appName =="Netscape")
	{
		sTop=window.pageYOffset;
		
	}
	else
	{
		sTop = document.body.scrollTop *0.983;
	}
	
	
	GetRefID("list_thumb").src= "TitlesNorm/"+parseInt(id)+".jpg";
	GetRefID("list_thumb_div").style.visibility="visible";
	GetRefID("list_thumb_div").style.left = GetAbsLeft(GetRefID("MainTable"))+180;
	GetRefID("list_thumb_div").style.top = parseInt(sTop) +parseInt(window.screen.height/2)-parseInt(120);
	
	
	
	
}
function HideListThumb()
{
	GetRefID("list_thumb_div").style.visibility="hidden";
	GetRefID("list_thumb").src="images/loading.gif"
}
function DoSignup()
{

	var lft;
	var top;
	lft=window.screen.width/2-250;
	top=50;
	window.open("about:blank","dvdy_signup","toolbar=0,location=0,top="+top+",left="+lft+",titlebar=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=0,width=500,height=600");
	document.signup3.submit();
}
function ValidateSearch()
{
	if(document.search_form.search.value.length < 2)
	{
		alert("טקסט החיפוש חייב להכיל לפחות 2 תווים");
		return false;
	}
	else
	{
		return true;
	}
}
var bRectX;
var bRectDIR;
var CurNewTitle=0;
var CurSoonTitle=0;
var CurB2Title=0;
var CurBTitle=0;
var DoUpdate=1;
function UpdateSlideTitles()
{
	
	if (DoUpdate)
	{
	document.getElementsByName("slide_div")[CurNewTitle].style.display="none";
	CurNewTitle++;
	if (CurNewTitle >= document.getElementsByName("slide_div").length)
		CurNewTitle=0;
	document.getElementsByName("slide_div")[CurNewTitle].style.display="block";
	
	document.getElementsByName("b2_div")[CurB2Title].style.display="none";
	CurB2Title++;
	if (CurB2Title >= document.getElementsByName("b2_div").length)
		CurB2Title=0;
	document.getElementsByName("b2_div")[CurB2Title].style.display="block";
	
	document.getElementsByName("b_div")[CurBTitle].style.display="none";
	CurBTitle++;
	if (CurBTitle >= document.getElementsByName("b_div").length)
		CurBTitle=0;
	document.getElementsByName("b_div")[CurBTitle].style.display="block";
	}
		
	window.setTimeout("UpdateSlideTitles()",2500);
}
var starfull;
var starempty;
starfull = new Image();
starempty = new Image();
starfull.src = "images/starfull.gif"
starempty.src = "images/starempty.gif"
function DoLoad()
{

	
	var i;
	IsLoaded=true;
	
	//if (navigator.appName == "Netscape")
	//{
		//document.getElementById("category").style.cursor = "pointer";
		//document.getElementById("category2").style.cursor = "pointer";
		
//	}
//	
//	UpdateCategory();
//	if(CatOnCount > CatOffCount)
//		ShowCategories();
	
	CurSoonTitle=0;
	CurNewTitle=0;
	
	
	UpdateSlideTitles();
	
//	if(CatOnCount>CatOffCount)
//	{
		
//		CatOnCount=CatOffCount=0;
//		ShowCategories();
//	}
	
}
var DF_OrgX;
var DF_OrgY;
var DF_CurX;
var DF_CurY;
var DF_TargetX;
var DF_TargetY;
var DF_OrgWidth;
var DF_OrgHeight;
var DF_CurY;
var DF_Pos;
var DF_Dir;
function StartDiscFly()
{
	var obj;
	
	obj= GetRefID("disc_fly");
	DF_OrgX = GetAbsLeft(obj);
	DF_OrgY =GetAbsTop(obj);
	DF_OrgWidth=obj.width;
	DF_OrgHeight=obj.height;
	DF_TargetX = DF_OrgX;
	DF_TargetY = -60;
	DF_Pos=0;
	DF_Dir=1;
	UpdateDiscFly
	
};
function UpdateDiscFly()
{
	var obj;
	DF_Pos+=4*DF_Dir;
	obj= GetRefID("disc_fly");
	obj.style.top = DF_Pos*DF_TargetY / 100;
	obj.width = DF_OrgWidth *(100-DF_Pos)/100;
	obj.height = DF_OrgHeight *(100-DF_Pos)/100;
	if(DF_Pos >= 100 || DF_Pos <=0)
		DF_Dir*=-1;
	window.setTimeout ("UpdateDiscFly()",20);
	
}
function UpdateBRect()
{
	bRectX+=bRectDIR*20;
	if (bRectX>= GetAbsLeft(GetRefID("banner"))+GetRefID("banner").width-20)
	{
		bRectDIR*=-1;
		bRectX=GetAbsLeft(GetRefID("banner"))+GetRefID("banner").width-20
	}
	if (bRectX< GetAbsLeft(GetRefID("banner")))
	{
		bRectX= GetAbsLeft(GetRefID("banner"))
		bRectDIR*=-1;
	}
	GetRefID("banner_rect").style.left =bRectX;
	window.setTimeout("UpdateBRect()",50);
	
}
function SizeRight()
{

if (navigator.appName == "Netscape")
{
	GetRefID("right_pane").style.height=GetRefIDEX("right_pane","test").offsetHeight;
}
else
{
	//GetRefID("new_head").style.top = GetRefIDEX("right_pane","test").scrollHeight-150;
	GetRefID("right_pane").style.height=GetRefIDEX("right_pane","test").scrollHeight;
}

}
function DoRoller(id)
{
}
function ShowCategories()
{

	CatOnCount++;
	if(CatOnCount>CatOffCount && IsLoaded)
	{
		id = document.getElementById("category");;
		id.style.visibility="visible";
	
	
	}
	
	
	
}

function ShowCategories2()
{

	
		id = document.getElementById("category2");;
		id.style.visibility="visible";
		id = document.getElementById("category");;
		id.style.visibility="visible";
	
	CatOnCount++;
	CatOnCount2++;
}
function HideCategories()
{
	
	CatOffCount++;
	if (CatOffCount>CatOnCount)
		CatOffCount=CatOnCount;
	if (CatOnCount==CatOffCount)
	{
		id = document.getElementById("category");;
		id.style.visibility="hidden";
	}
	
};
function HideCategories2()
{

	CatOffCount++;
	CatOffCount2++;
	if (CatOnCount2==CatOffCount2)
	{
		id = document.getElementById("category2");;
		id.style.visibility="hidden";
	}
	if (CatOnCount==CatOffCount)
	{
		id = document.getElementById("category");;
		id.style.visibility="hidden";
	}
};
var pages= new Array("step1.htm","step2.htm","step3.htm","step4.htm")
var pages_height= new Array(270,230,430,380)
function DoPopup(page)
{
	var lft;
	var top;
	height= pages_height[page-1];
	lft=window.screen.width/2-200;
	top=window.screen.height/2-height/2;
	window.open(pages[page-1],"","toolbar=0,location=0,top="+top+",left="+lft+",titlebar=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=400,height="+height);
}
function DoZoneSel(id,rent,r)
{
	
	var lft;
	var top;

	
	lft=window.screen.width/2-250;
	top=window.screen.height/2-110;
	window.open("zonepref.asp?id="+id+"&rent="+rent+"&r="+r,"","toolbar=0,location=0,top="+top+",left="+lft+",titlebar=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=500,height=220");

}
function DoHotSel(id,prc,rent,r)
{
	
	var lft;
	var top;

	
	lft=window.screen.width/2-250;
	top=window.screen.height/2-110;
	window.open("hotpref.asp?id="+id+"&rent="+rent+"&r="+r+"&prc="+prc,"","toolbar=0,location=0,top="+top+",left="+lft+",titlebar=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=500,height=220");

}
function DoAction(action,val)
{

	var h;
	h="action.asp?action="+action+"&val="+val;
	
	window.location.href=h;

}
function DoInfoWindow(page,width,height)
{

	var lft;
	var top;

	
	lft=window.screen.width/2-width/2;
	top=window.screen.height/2-height/2;
	window.open(page,"","toolbar=0,location=0,top="+top+",left="+lft+",titlebar=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width="+width+",height="+height);


}
var atWin = 0;
function DoRentalInfo(id,ref)
{
	
	DoInfoWindow("rentalinfo.asp?id="+id+"&ref="+ref,440,310);
}

function BuyTitleUsed(id,thumb)
{


    if (thumb)
		ActiveFlyObject=GetRefID(thumb);
	ret= ExecuteXML("buytitle.asp?id="+id+"&type=used");
	fly_place_text = "fly_place_buy";
	eval(ret);	
	fly_place_text = "fly_place";
}
function BuyTitleNew(id,thumb)
{


    if (thumb)
		    ActiveFlyObject=GetRefID(thumb);
	ret= ExecuteXML("buytitle.asp?id="+id+"&type=new");
	fly_place_text = "fly_place_buy";
	eval(ret);	
	fly_place_text = "fly_place";
}

function AddTitle(id,thumb,rent,force)
{
	var ret;
	if (thumb)
		ActiveFlyObject=GetRefID(thumb);
	//if (navigator.appName == "Netscape")
	//{
		//document.addtitle.title_id.value = id;
		//document.addtitle.force.value = force;
		//document.addtitle.action="addtitle.asp?rent="+rent+"&direct=no";
		//document.addtitle.submit();
		
	
	//}
	//else
	//{
		ret= ExecuteXML("addtitle.asp?id="+id+"&force="+force+"&rent="+rent);
		eval(ret);	
	//}
	
	
	
};

function AddTitleFromBasket(id,pid)
{
	var ret;
	
		ret= ExecuteXML("addtitle.asp?id="+id+"&pid="+pid);
		eval(ret);	
	
	
	
	
};
var ni_Count;
ni_Count=0;

function NotInterested(id)
{
	if (navigator.appName =="Netscape")
	{
		sTop=window.pageYOffset;
		
	}
	else
	{
		sTop = document.body.scrollTop *0.983;
	}
	ret=ExecuteXML("notinterested.asp?id="+id);
	eval(ret);
	ni_Count++;
	if(ni_Count>=4)
	{
		window.location="movies.asp?genre=recommend&stop="+parseInt(sTop);
			
	}
}
function CancelRental(id)
{
	
	
	
	var ret;
	
	if (navigator.appName == "Netscape")
	{
		document.addtitle.title_id.value = id;
		document.addtitle.action="addtitle.asp?cancel=yes&direct=no";
		document.addtitle.submit();
		
	
	}
	else
	{
		ret= ExecuteXML("addtitle.asp?id="+id+"&cancel=yes");
		eval(ret);	
	}
	
};



function UpdateCategory()
{
	var i;
	var m;
	var m2;
	i = document.getElementById("category");
	i2=document.getElementById("category2");
	m=GetRefID("movies");
	m2=GetRefID("mnu");
	
	i.style.left = m.offsetLeft+m2.offsetLeft-17;
	i.style.top = m.offsetTop+m2.offsetTop+m.height-3;
	i2.style.left =m.offsetLeft+m2.offsetLeft-17-i.offsetWidth+10;
	i2.style.top =m.offsetTop+m2.offsetTop+m.height-3+i.offsetHeight-215;
	
	
}
function showCover(id,block,show)
{
	var ht,lft;
	if(!CanRateMovies && block)
	{
		alert("הגדלת עטיפות של סרטי מבוגרים ניתנת רק למי שנרשם. אם הינכם כבר רשומים נא בצעו כניסה למערכת");
		
	}
	else
	{
		if(window.screen.height>=768)
		{
			ht=700;
			lft = window.screen.width/2-350;
		}
		else
		{
			ht=540;
			lft = window.screen.width/2-350;
		}
		a =	window.open("cover.asp?id="+id+"&show="+show,"","toolbar=0,location=0,top=0,left="+lft+",titlebar=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=700,height="+ht);
		ExecuteXML("action.asp?action=cover&id="+id);
	}
}
function CatClick(extra)
{
	HideCategories();
	HideCategories2();		
	window.location = "movies.asp?page=1&"+extra;
}
var FlyWidth;
var FlyHeight;
var FlyX;
var FlyY;
var FlyPos;
var FlyTargetX;
var FlyTargetY;
var FlyTimer=0;
var ActiveFlyObject;



function GetAbsLeft(obj)
{
	var ret;
	var cur;
	cur=obj;
	ret = cur.offsetLeft;
	while(cur.tagName != "BODY")
	{
		cur = cur.offsetParent;
		ret = ret+cur.offsetLeft;
	}
	return ret;
}

function GetAbsTop(obj)
{
	var ret;
	var cur;
	cur=obj;
	ret = cur.offsetTop;
	while(cur.tagName != "BODY")
	{
		cur = cur.offsetParent;
		ret = ret+cur.offsetTop;
	}
	return ret;
}


function UpdateFlyThumb(obj)
{
	var fly;
	fly=GetRefID("fly_thumb");
	FlyPos+=2;
	fly.style.left = (FlyX+(FlyTargetX-FlyX)*FlyPos/100);
	fly.style.top = (FlyY+(FlyTargetY-FlyY)*FlyPos/100);
	fly.style.width = FlyWidth *(100-FlyPos+50)/150;
	fly.style.height = FlyHeight *(100-FlyPos+50)/150;
	if( FlyPos == 100)
	{
		fly.style.visibility="hidden";
		window.clearTimeout(FlyTimer);
		FlyTimer=0;
		if (DoReload == 0)
			FillRightPane();
		else
			window.location=window.location	;
	}
	else
	{
	FlyTimer=window.setTimeout("UpdateFlyThumb()",10);
	}
}
function StartFlyThumb(obj)
{
	
	var fly;
	fly=GetRefID("fly_thumb");
	fly.src = obj.src;
	fly.style.width = obj.width;
	fly.style.height=obj.height;
	FlyWidth=obj.width;
	FlyHeight=obj.height;
	
	FlyX = GetAbsLeft(obj);
	FlyY = GetAbsTop(obj);
	
	fly.style.left = FlyX;
	fly.style.top = FlyY;
	fly.style.visibility="visible";
	FlyTargetX = GetAbsLeft(GetRefID("right_pane"))+120;
	
	//FlyTargetY = GetAbsTop(GetRefID("right_pane"))+GetRefIDEX("right_pane","fly_place").offsetTop;
	FlyTargetY = GetAbsTop(document.getElementsByName(fly_place_text)[document.getElementsByName(fly_place_text).length-1]);
	
	
	FlyPos = 0;
	if(FlyTimer!=0)
		window.clearInterval(FlyTimer);
	FlyTimer=window.setTimeout("UpdateFlyThumb()",10);
	
	return true;
}

function CloseTitle(obj)
{
	obj.parentNode.parentNode.parentNode.parentNode.parentNode.style.visibility="hidden";
	obj.parentNode.parentNode.parentNode.parentNode.parentNode.innerHTML="";
}
function DoInfoPos(rid)
{
	
	obj=GetRefID("titleinfo"+rid);
	obj.style.visibility="hidden";
	obj.style.visibility="visible";
	if (navigator.appName =="Netscape")
	{
		sTop=window.pageYOffset;
		
	}
	else
	{
		sTop = document.body.scrollTop *0.983;
	}
	//if(GetAbsTop(obj) - sTop < 0 || GetAbsTop(obj) - sTop+400 >  window.screen.height)
	{
	    //alert("a");
		if (navigator.appName =="Netscape")
		{
			//alert(window.screen.height);
			window.scrollTo(0,GetAbsTop(obj)-window.screen.height+obj.offsetHeight+200);
		}
		else
		{
		
			obj.scrollIntoView(false);
		}
	}
}
function DoAddMessage(r)
{
	DoInfoWindow("addmessage.asp?r="+r,500,270);
}
function ExecuteXML(page)
{
	var x,ret;
	if (navigator.appName=="Netscape")
		x = new XMLHttpRequest();
	else
		x = new ActiveXObject('Microsoft.XMLHTTP');
	x.open('POST',page,false);
	x.send(null);
		
	ret=x.responseText;
	delete x;
	return ParseHebrew(ret);
}
var chars = "אבגדהוזחטיכלנמסעפצקרשתץןףם";
function ParseHebrew(txt)
{
	var ret;
	var i;
	var splt;
	ret=txt;
	for(i=chars.length-1;i>=0;i--)
	{
		splt = ret.split("#"+i);
		ret=splt.join(chars.substr(i,1));
	}
	
	
	return ret;
}
function DoTitle(id,rid,sale)
{
	
	GetRefID("titleinfo"+rid).innerHTML=ExecuteXML("titleinfo.asp?id="+id+"&sale="+sale);
	
	DoInfoPos(rid);	
	
	return false;
}


var DoReload = 0;
var CanRateMovies;

