function checkmail(emailField,infoFld,text1,text2) {
	var str = document.getElementById(emailField).value;
	var at="@"
	var dot="."
	var off=""
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1) {off=1;}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)  {off=1;}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)  {off=1;}
	if (str.indexOf(at,(lat+1))!=-1)  {off=1;}
	if (str.indexOf(" ")!=-1) {off=1;}
	if (off==1) {
		
		changeClass('email','contactInput_red');
		return false;
	}  else {
		
		return true;
	}
}

function submitform(){
if( order()){
        	document.orderf.submit();
            document.orderf.name.value="";
           document.orderf.phone.value="";
            document.orderf.email.value="";
             
}
}


function formCheck(formobj){
	var fNameOk = 0;
	var emailOk = 0;
	var phoneOK=0;
	if (!getFieldValue('turnName')) {
		changeClass('turnName','contactInput_red');	
	} else {
		
		fNameOk=1;
	}
	if (!getFieldValue('phone')) {
		changeClass('phone','contactInput_red');	
	} else {
		
		phoneOK=1;
	}
	if (checkmail('emailAddress','','','')===true) emailOk=1; else emailOk=0;
	
	if (fNameOk==1 && lNameOk==1 && emailOk==1) {
		return true; 
	} else {
		alert ('חלק משדות החובה נשארו ריקים. אנא מלא את השדות בהתאם לסימונים האדומים');
	 	return false;
	}
}

function fcusInput (who)
{
	who.className="contactInput";
}



/**drop doun**/
function showHideByIDSmartSelect(elementName) {
	closeDropBox();
	var dateA = new Date();
	startTimeDropBox = dateA.getTime();
	if (elementName) {
		if (document.getElementById(elementName).style.display=='block') {
			hideByID(elementName);
			windowOpen=0;
			curOpenInput='';
		} else {
			showBlockByID(elementName);
			windowOpen=1;
			curOpenInput=elementName;
		}
	}
}

function closeDropBox() {

	var dateB = new Date();
	endTimeDropBox = dateB.getTime();
	if (curOpenInput && ((endTimeDropBox-startTimeDropBox)>2)) {
		hideByID(curOpenInput);
		curOpenInput='';
	}
}


function handleMailListSmartBox(id,drid, tedtID,app) 
{
	var Val = document.getElementById(id).innerHTML;
	changeFieldValue(app,Val);
	changeText(tedtID,Val);
	showHideByIDSmartSelect(drid );
}
function handleMailListSmartBoxCallBack(id,drid, tedtID,app) 
{
	
	if(id=='back4')
	{
		if(getText('sup')!='פלטיניום')
		{
		showPopup(  );
		
		}else{
			var Val = document.getElementById(id).innerHTML;
			changeFieldValue(app,Val);
			changeText(tedtID,Val);
			showHideByIDSmartSelect(drid );
			
		}
	}else{
		closepopup();
		var Val = document.getElementById(id).innerHTML;
		changeFieldValue(app,Val);
		changeText(tedtID,Val);
		showHideByIDSmartSelect(drid );
	}
}

/**popup**/
function showPopup(  )
	{
	var popUp=document.getElementById('popup1');
	//var theShade=document.getElementById('shade');
	//theShade.style.width=document.body.scrollWidth;
	//theShade.style.height=document.body.scrollHeight;
	//theShade.style.width = "100%";
	//theShade.style.height = "100%";
	//theShade.style.left='0px';
	//theShade.style.top='0px';
	
	var theHeight=document.body.scrollTop;
	var middleWidth= Math.round((document.body.clientWidth-popUp.offsetWidth)/2);
	var middleHeight=theHeight+Math.round((document.body.clientHeight-popUp.offsetHeight) / 2);
	
	document.getElementById('popup1').style.left=middleWidth+'px';
	document.getElementById('popup1').style.top=middleHeight+'px';
	var maybeW = document.body.scrollWidth;
	var maybeH = document.body.scrollHeight;
	//if (theShade.offsetWidth < maybeW) theShade.style.width = maybeW + "px";
	//if (theShade.offsetHeight < maybeH) theShade.style.height = maybeH + "px";
	corrector = setTimeout("showPopup();",250);
	
}
var corrector = null;
function closepopup(){
	clearInterval(corrector);
	corrector = null;
	correctorPic = -1;
	document.getElementById('popup1').style.left='0px';
	document.getElementById('popup1').style.top='-1000px';
	//var theShade=document.getElementById('shade');
	//theShade.style.width='1px';
	//theShade.style.height='1px';
	//theShade.style.left='100px';
	//theShade.style.top='-100px';
}

/****/
function chckeprio(id)
{
	var prioid = new Array;
	prioid[5]='נמוך';
	prioid[6]=' רגיל';
	prioid[7]='גבוה';
	prioid[8]='קריטי';
	for(var i =5; i<=8; i++)
	{	
		if(i==id)
		{
			changePic('checkbox'+i, 'templates/t1231/img/checkOn.png');
			changeFieldValue('priorityCase', prioid[i]);
		}else{
			
			changePic('checkbox'+i, 'templates/t1231/img/checkOff.png');	
		}	
	}
}

function openCloseCall( calID, who)
		{
			if(who.className=="openBTN")
			{
				showBlockByID('call'+calID);
				who.className="closeBTN";
				changeText ("callBTN"+calID, "סגור");
			}else{
				hideByID('call'+calID);
				who.className="openBTN";
				changeText ("callBTN"+calID, "פתח");
			}
		}
		
		
	function formCheckLanding(formobj){
	var fNameOk = 0;
	var emailOk = 0;
	var phoneOK=0;
	if (!getFieldValue('fName')) {
		changeClass('turnName','contactInput_red');	
	} else {
		
		fNameOk=1;
	}
	if (!getFieldValue('phone')) {
		changeClass('phone','contactInput_red');	
	} else {
		
		phoneOK=1;
	}
	if (checkmail('email','','','')===true) {
		emailOk=1;
	} else {
		emailOk=0;
		changeClass('emailFeild','contactInput_red');
		
	}
	
	
	if (fNameOk==1 && lNameOk==1 && emailOk==1) {
		return true; 
	} else {
		alert ('חלק משדות החובה נשארו ריקים. אנא מלא את השדות בהתאם לסימונים האדומים');
	 	return false;
	}
}