var agt,MSIE

agt=navigator.userAgent.toLowerCase();
MSIE =agt.indexOf('msie')!=-1&&agt.indexOf('opera')<3
var CIO
function openCal(p){
	CIO= document.getElementById(p)
	MSIE?openDialog2("/admin/html/culc.html",205,290):WOpener("/admin/html/culc.html",205,290);
}
function setCal(day1, month1, year1){
	CIO.innerHTML=day1 + "/" + month1 + "/" + year1
	eval("fo01.p_day.value='"+day1+"'")
	eval("fo01.p_month.value='"+month1+"'")
	eval("fo01.p_year.value='"+year1+"'")

}
function deleteNode( nodeObj){
	inOb = nodeObj.parentNode
	try{
		inOb.removeChild(nodeObj)
	}catch(e){
		try{
			nodeObj.removeMe(true)	
		}catch(e){
			try{
				nodeObj.removeNode(true)
			}catch(e){
				return false
			}
		}		
	}
	return true
}
var popstageS
function WOpener(lnk,winwid ,winhigh,scrol,resize ){
	if(resize==null)resize=0
	if(scrol==null)scrol=0
	if(popstageS!=null){popstageS.close();}
	if(winwid==null){winwid = 100}
	if(winhigh==null){winhigh=100}
	popstageS =  window.open(lnk,'tour', 'width='+winwid+',height='+winhigh+',scrollbars='+scrol+',left=50,top=20,menubar=0,location=0,toolbar=0,status=0,resizable='+resize)
	sti=setTimeout("window.popstageS.focus()",3000)

	}
flashShow=function(w,h,s,name){
	if(name==null)name="fl999"
	document.write( '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="'+w+'" height="'+h+'" id="'+name+'" align="middle">'+
		'<param name="allowScriptAccess" value="sameDomain" >'+
	'<param name="movie" value="'+s+'" >'+
	'<param name="menu" value="false" >'+
	'<param name="quality" value="high" >'+
	'<param name="wmode" value="transparent" >'+
	'<param name="bgcolor" value="#ffffff" >'+
	'<embed src="'+s+'" menu="false" quality="high" wmode="transparent" bgcolor="#ffffff" width="'+w+' height="'+h+'" name="'+name+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" >'+
	'</object>')
}

function emailVal(string){
valid = false
for (n=3;n<string.length;n++){
 	if(string.charAt(n)=="@" && n < (string.length - 5) ){
		for(nn=string.length-5;nn<string.length-2;nn++){
		if(string.charAt(nn)=="."){
		valid = true
		}		
		}	
	}		
}
return valid
}
function mapPointer(L,T){

}
function phoneVal(string){
	string = string.split(" ");
	string = string.join("");
	string = string.split("-");
	string = string.join("");
	p_phone_digits = 0
	re  = false
	for (n=0;n< string.length;n++){
			if (!isNaN(string.charAt(n))){
			p_phone_digits++
					if(p_phone_digits>7){
						re = true
						break;
					}
			} else {
			 p_phone_digits = 0	
			}
	}
	return re;
}
function validateForm(PO){
	if (document.form01.p_name.value.length < 2){
	alert("יש למלא את השדה: שם")
	window.form01.p_name.focus()
	}else{
	
		if (form01.p_email.value.length > 3 || form01.p_phone.value.length > 2 ){
		//chacking email validation
			if (form01.p_email.value == ""  || form01.p_email.value.length > 3 && emailVal(form01.p_email.value) ){
				valid01 = true
				
			}else{
			valid01 = false
			
			}
		/*phone validation*/
			if(phoneVal(form01.p_phone.value) || form01.p_phone.value == "" ){
			valid02 = true;
			}else{
			valid02 = false;
			}
			
				
						
			MSG01= "* כתובת הדואר האלקטרוני אינה תקינה .\r\n";
			MSG02 = "* מספר הטלפון שהוכנס אינו תקין .\r\n";
			
			if (!valid01 || !valid02  ){
			
				tex = " שדות לא תקינים : \r\n";
				if(!valid01){tex=tex+ MSG01;}
				if(!valid02){tex=tex+ MSG02;}
				alert(tex)
			}else
				if(PO==null){
					document.form01.submit()
				}else{
					p_cat = brkAnd(form01.p_card.value)
					nm=brkAnd(form01.p_name.value)
					pn=brkAnd(form01.p_phone.value)
					em=brkAnd(form01.p_email.value)
					comn=brkAnd(form01.p_comments.value)
					document.getElementById("formDiv").innerHTML=''
					document.getElementById("msg").innerHTML='<table><tr><td height="170"  style="vertical-align:middle;text-align:center;" id="msgg">--- שולח --- <br> אנא המתן... </td><td>&nbsp;</td></tr></table><hr>'
					str = '?p_cat='+p_cat+'&p_name='+nm+'&p_phone='+pn+'&p_email='+em+'&p_comment='+comn
					dhtmlLoadScript("/cds/1/takemail.asp"+str)
					//document.getElementById("msgg").innerText= str
				}		
			
		}else{
		alert("* יש למלא כתובת דואר אלקטרוני או טלפון ")
		
		}
	}
	
}

function reseter(){
document.form01.reset();
document.form01.p_name.value = "";
document.form01.p_email.value = "";
document.form01.p_phone.value = "";
document.form1.p_message.value = "";
};

function brkAnd(t){
	t = t.split("&")
	t=t.join("OOTWOO")
	t = t.split(String.fromCharCode(13))
	t=t.join("<br>")
	t = t.split(String.fromCharCode(8))
	t=t.join()
	t = t.split(String.fromCharCode(9))
	t=t.join()
	t = t.split(String.fromCharCode(10))
	t=t.join()
	t = t.split(String.fromCharCode(11))
	t=t.join()
	t = t.split(String.fromCharCode(12))
	t=t.join()
	return t
}
function dhtmlLoadScript(url)
{
   var e = document.createElement("script");
   e.src = url;
   e.type="text/javascript";
   document.getElementsByTagName("head")[0].appendChild(e); 
   
}
function toMany(p){
	if(p.value.length>400){
		tmp=p.value.substring(1,400)
		p.value=tmp
	}

}
overDiv=function(ob){
	ob.style.backgroundColor="#000066"
	ob.style.color="#ffffff"
}
outDiv=function(ob){
	ob.style.backgroundColor=""
	ob.style.color=""
}
function clrPx(p){
return eval(p.substring(0,p.indexOf("px")))
}
function openDialog(lnk,wi,hi){
	dial = window.showModalDialog("dlFrame.asp?lnk="+lnk,window,'dialogHeight:'+hi+'px;dialogWidth:'+wi+'px;status:0;help:0;center:1;help:1;unadorned:1;scroll:no;status:yes;')
	return dial
	}
function openDialog2(lnk,wi,hi){
	dial = window.showModalDialog("/admin/html/dlFrame.asp?"+lnk,window,'dialogHeight:'+hi+'px;dialogWidth:'+wi+'px;status:0;help:0;center:1;help:1;unadorned:1;scroll:no;status:yes;')
	return dial
	}
function compr(str,comp){
	tmpA=" "+str+" "
	tmpB=" "+comp+" "
	if(tmpB.indexOf(tmpA)>-1)
		return str
	else
		return ""
	}
function LTrim( value ) {
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

// Removes ending whitespaces
function RTrim( value ) {
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}

// Removes leading and ending whitespaces
function trim( value ) {
	return LTrim(RTrim(value));
}
