// Background Flicker Function
(function(){

	/*Use Object Detection to detect IE6*/
	var  m = document.uniqueID /*IE*/
	&& document.compatMode  /*>=IE6*/
	&& !window.XMLHttpRequest /*<=IE6*/
	&& document.execCommand ;
	
	try{
		if(!!m){
			m("BackgroundImageCache", false, true) /* = IE6 only */ 
		}
		
	}catch(oh){};
})();

function Paging(CurPage){
	document.f.CurPage.value=CurPage		
	document.f.submit()
}
function GetObj(id){
return document.getElementById(id)
}

// Popup Player Luncher
var popUpWin=0;
	function popUpWindow(URLStr, left, top, width, height){
		if(popUpWin){
			if(!popUpWin.closed) popUpWin.close();
		}
		popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
	}

// Marquee Function
var Scroller = function(frameId,contentId,direction,tempo,w,h)
{
	// default parameters
	var thisObj 		= this;
	this.nXlocation 	= 0;
	this.nYlocation 	= 0;
	this.nFrameHeight 	= h;
	this.nFrameWidth	= w;
	this.nTempo			= tempo;
	this.strDirection	= direction;
	this.scrollerStat	= true;
	this.objFrame		= document.getElementById(contentId);
	this.ScrollCycle;
	
	// frame parameter
	frm = document.getElementById(frameId);
	frm.style.height 	= h+'px';
	frm.style.width 	= w+'px';

	this.MoveScroller = function()
	{
		switch(this.strDirection)
		{
			case 'u':	// moving up
				this.nXlocation--;
				this.objFrame.style.top=this.nXlocation+"px";
				break;
			case 'd':	// moving sown
				this.nXlocation++;
				this.objFrame.style.top=this.nXlocation+"px";
				break;
			case 'r':	// moving right
				this.nYlocation++;
				this.objFrame.style.left=this.nYlocation+"px";
				break;
			case 'l':	// moving left
				this.nYlocation--;
				this.objFrame.style.left=this.nYlocation+"px";
				break;
		}
	}

	this.CheckScroller = function()
	{
		switch(this.strDirection)
		{
			case 'u':
				if ((0-this.nXlocation) > this.objFrame.offsetHeight)
				this.nXlocation = this.nFrameHeight;
				break;
			case 'd':
				if (this.nXlocation > this.nFrameHeight)
				this.nXlocation = -this.objFrame.offsetHeight;
				break;
			case 'r':
				if (this.nYlocation > this.nFrameWidth)
				this.nYlocation = -this.objFrame.offsetWidth;
				break;
			case 'l':
				if ((0-this.nYlocation) > this.objFrame.offsetWidth)
				this.nYlocation = this.nFrameWidth;
				break;
		}	
	}
	
	this.RunScroll = function()
	{
		if (this.scrollerStat)
		{
			this.MoveScroller();
			this.CheckScroller();
		}
	}
	
	this.StartScroll = function()
	{
		this.ScrollCycle=setInterval(function() { thisObj.RunScroll(); },thisObj.nTempo);
	}
	this.StopScroll = function()
	{
	  clearInterval(this.ScrollCycle);
	}	
}

function Paging(CurPage){
	document.f.CurPage.value=CurPage		
	document.f.submit()
}


//Contact Form Function
function ColorInput(Obj,CellColor)
{
	Obj.style.backgroundColor=CellColor
}

function replaceChar(str,from,to)
{
	var tmp=str.split(from);
	str="";
	for (var i=0;i<tmp.length;i++)
	{
		str+=tmp[i]+to;
	}
	str = str.substring(0,str.length-to.length);
	return  str
}

	function ChkFrm(FrmObj)
	{
	var first=true;  //  a boolean to indicate if were in the first field that was found incorrect
	var Flag=false,Flag2=false,Flag3=false,Flag4=false;
	var already_mandetored = false
		j=FrmObj.elements.length
		for (i=0; i<j; i++) 
		{
			if((FrmObj.elements[i].type=="text")||(FrmObj.elements[i].type=="password")||(FrmObj.elements[i].type=="textarea")||(FrmObj.elements[i].type=="select-one")) 
				ColorInput(FrmObj.elements[i],"#ffffff")
			
			var CondArr=FrmObj.elements[i].id.split("_")
			for(x=0;x<CondArr.length;x++)
				{
					//alert(CondArr[x])
					switch (CondArr[x])
					{
				 	case "mandatory" :  // if we have to check for mandatory
						{
							if(((FrmObj.elements[i].type=="text")||(FrmObj.elements[i].type=="password")||(FrmObj.elements[i].type=="textarea")||(FrmObj.elements[i].type=="select-one")) && (replaceChar(FrmObj.elements[i].value," ","")==""))
							{
								ColorInput(FrmObj.elements[i],"#ffffa0")
								Flag=true
								already_mandetored = true

								if(first==true)
								{
									FrmObj.elements[i].focus();
									first=false;
								}
							}
							break;
						}
				 	case "EmailCheck":   // if we have to check the e-mail is correct then :
						{
							if ((already_mandetored==false)&& (replaceChar(FrmObj.elements[i].value," ","")!="") &&(FrmObj.elements[i].type=="text") && (/^\w+([\.]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})$/.test(FrmObj.elements[i].value)==false))
							{
								ColorInput(FrmObj.elements[i],"#ffffa0")
								alert("חובה להזין כתובת דואר תיקנית")
								FrmObj.elements[i].focus();
								return false
							}
							break;
						}
					case "FloatNumber":  // checks if the nukmber is a float number (including '.')
						{
							
							var reFloatF1 = /^((\d+(\.\d*)?)|((\d*\.)?\d+))$/; // format 1
							//var reFloatF2 = /^((\d+(\,\d*)?)|((\d*\,)?\d+))$/; // format 2

							if (!(reFloatF1.test (FrmObj.elements[i].value)) && (FrmObj.elements[i].type=="text") && (replaceChar(FrmObj.elements[i].value," ","")!=""))
							{
								ColorInput(FrmObj.elements[i],"#ffffa0");			
								Flag2=true
								if(first==true)
								{
									FrmObj.elements[i].focus();
									first=false;
								}
							}							
							break;
						}
					case "tz":  // checks if the id number is correct
						{
							
							if((already_mandetored==false)&&(checkidnum(FrmObj.elements[i])==false) && (FrmObj.elements[i].type=="text") && (replaceChar(FrmObj.elements[i].value," ","")!=""))
							{
								ColorInput(FrmObj.elements[i],"#ffffa0");
								Flag3=true;
								if(first==true)
								{
									FrmObj.elements[i].focus();
									first=false;
								}
							}

							break;

						}					
					}
				}

		}

		if(Flag)
		{
			alert("!חובה למלא את השדות המסומנים כראוי")
			return false;
		}
		
		if(Flag2)
		{
			alert("!ניתן להזין מספרים בלבד")
			return false;
		}
		
		if(Flag3)
		{
			alert("חובה להזין תעודת זהות תקינה");
			return false;
		}
		
		if(Flag4)
		{
			alert("!חובה להזין תאריך תקני בפורמט שששש/חח/יי");
			return false;
		}
		
		return true;
	}
/*******************************************************************************/
