﻿
    function siteSearch(act)
    {
        if(lang=="1")
        {
            if(act=='blur' && document.getElementById(siteSearchInpt).value=='')
            {
                document.getElementById(siteSearchInpt).value = "חיפוש סרט" ;
                return false;
            }   
            
            if(act=='focus' && document.getElementById(siteSearchInpt).value=='חיפוש סרט')
            {
                document.getElementById(siteSearchInpt).value = "" ;
                return false;
            }
            
            if(act=='submit' && document.getElementById(siteSearchInpt).value=='חיפוש סרט')
            {
                document.getElementById(siteSearchInpt).value = "" ;
                alert('יש להזין ערך לחיפוש')
                document.getElementById(siteSearchInpt).focus();
                return false;
            }
            
            if(act=='submit' && document.getElementById(siteSearchInpt).value!='חיפוש סרט' && document.getElementById(siteSearchInpt).value!='')
            {
                return true;
            }
           
        }
        else
        {
            if(act=='blur' && document.getElementById(siteSearchInpt_EN).value=='')
            {
                document.getElementById(siteSearchInpt_EN).value = "Film Search" ;
                return false;
            }   
            
            if(act=='focus' && document.getElementById(siteSearchInpt_EN).value=='Film Search')
            {
                document.getElementById(siteSearchInpt_EN).value = "" ;
                return false;
            }
            
            if(act=='submit' && document.getElementById(siteSearchInpt_EN).value=='Film Search')
            {
                document.getElementById(siteSearchInpt_EN).value = "" ;
                alert('Please insert a value to search')
                document.getElementById(siteSearchInpt_EN).focus();
                return false;
            }
            
            if(act=='submit' && document.getElementById(siteSearchInpt_EN).value!='Film Search' && document.getElementById(siteSearchInpt_EN).value!='')
            {
                return true;
            }
        }
    }

    function siteSearchAdvanced()
    {
        if(document.getElementById(AdvSearch).value=='' && document.getElementById(AdvDirector).value=='' && document.getElementById(AdvActor).value=='' && document.getElementById(AdvCountry).value=='')
        {
            if(lang=="1")
                alert("יש להזין ערך לחיפוש");
            else    
                alert("Please insert some text to search for");
                
            document.getElementById(AdvSearch).focus();
            return false;
        }   
        return true;
    }

    function valSearchForm()
    {
        if(document.getElementById(AdvSearchTxt).value=='')
        {
            if(lang=="1")
                alert("יש להזין ערך לחיפוש");
            else
                alert("Please insert some text to search for");
                
            document.getElementById(AdvSearchTxt).focus();
            return false;
        }  
        
        return true;
    }

        
    function printNow(){
        window.print();
    }
    
    function noError(){return true;}
    //This script will stop all the errors alerts of javascript
    //window.onerror = noError;

    function openPrint(pageToView){
        //alert(pageToView);
        
        OpenWin = this.open(pageToView, "printWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=600,height=600,left=50,top=50");
        OpenWin.document.print();
    }

    
    function stripHTML(strToStrip){
        
        var re= /<\S[^><]*>/g;
        var thestrToStrip = new String(strToStrip);
        thestrToStrip=thestrToStrip.replace(re, "");
        return thestrToStrip;
        
    }
    

	function NewWindow(page,width,height,top,left)
	{
		OpenWin = this.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width="+width+",height="+height+",left="+left+",top="+top+"");
	}

	function NavTo(url){window.location = url }

	function ChangeIframeHeight(theFrameName)
	{
		if (parent == window) return;
		else parent.setIframeHeight(theFrameName);
    }
	
	function getDocHeight(doc) 
	{
	  var docHt = 0, sh, oh;
	  if (doc.height) docHt = doc.height;
	  else if (doc.body) {
		if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
		if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
		if (sh && oh) docHt = Math.max(sh, oh);
	  }
	  if(docHt<=250)
	  	docHt=500;
	  return docHt;
	}
	
	function setIframeHeight(iframeName) {
	
	  var iframeWin = window.frames[iframeName];
	  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
	  if ( iframeEl && iframeWin ) {
		  
		iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
		var docHt = getDocHeight(iframeWin.document);
		//alert(docHt)
		// need to add to height to be sure it will all show
		if (docHt) iframeEl.style.height = docHt + 30 + "px";
	  }
	}
	
	
	function addToFavorites()
	{
	    var chr = 'CTRL-D';
        var agt=navigator.userAgent.toLowerCase();
        if(agt.substr(agt.indexOf('opera')+6,1) < 9) 
            chr = 'CTRL-T';
        if(window.external) 
            document.write('<a href="javascript:window.external.AddFavorite(self.location,document.title)">Add to Favorites<\/a>');
        else 
            document.write('Press '+chr+' to bookmark this page.');
    }
    
    function createCookie(name,value,days) {
	        if (days) {
		        var date = new Date();
		        date.setTime(date.getTime()+(days*24*60*60*1000));
		        var expires = "; expires="+date.toGMTString();
	        }
	        else var expires = "";
	        document.cookie = name+"="+value+expires+"; path=/";
        }

        function readCookie(name) {
	        var nameEQ = name + "=";
	        var ca = document.cookie.split(';');
	        for(var i=0;i < ca.length;i++) {
		        var c = ca[i];
		        while (c.charAt(0)==' ') c = c.substring(1,c.length);
		        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	        }
	        return null;
        }

        function eraseCookie(name) {
	        createCookie(name,"",-1);
        }
