function PrintFlash(str){
  document.write(str);
}

 function PopWinInfo(id){
  var winW = 550
  var winH = 400
  var winl = (screen.width - winW) / 2;
  var wint = (screen.height - winH) / 2;
  WPOPUP = window.open("wininfo.asp?id="+id,"Terms","toolbar=0,top="+wint+",left="+winl+",location=0,resizable=0,directories=0,status=0,scrollbars=0,menubar=0,resizable=0,width="+winW+",height="+winH);
  WPOPUP.focus();
}



var LastRowBGColor;
var LastRowTxtColor;

function doColor(id,TheRow){
 if (document.all('Msg'+id).style.display == 'none'){
  LastRowBGColor  = TheRow.style.backgroundColor;
  LastRowTxtColor = TheRow.style.color;
  TheRow.style.backgroundColor = '#A8D6FF';
 // TheRow.style.color='#58595B';
 }
}

function undoColor(id,TheRow){
 if (document.all('Msg'+id).style.display == 'none'){
  TheRow.style.backgroundColor = LastRowBGColor;
  TheRow.style.color=LastRowTxtColor;
 } 
}



function CheckMsg(){
 var Autor=document.FMsg.AutorName
 var Msubj=document.FMsg.MsgSubject
 
  if (document.FMsg.AutorName.value == "") {
	 alert("נא ציין שם מלא");
	 Autor.focus();
	 return false;
  }
  if (Msubj.value == "") {
	 alert("נא ציין את נושא התגובה");
	 Msubj.focus();
	 return false;
  }
  return (true);
}	 



function addMsg(MsgID,PId)
{
 ActiveForm = document.forms[0]
 var winW = 350
 var winH = 300
 var winl = (screen.width - winW) / 2;
 var wint = (screen.height - winH) / 2;
 var MsgWin = window.open("newMsg.asp?Mid="+MsgID+"&Pid="+PId,"Msg"+MsgID,"toolbar=0,top="+ wint +",left="+ winl +",location=0,resizable=0,directories=0,status=0,scrollbars=0,menubar=0,resizable=0,width="+ winW +",height="+ winH);
 MsgWin.creator = self;
 MsgWin.focus();
}

function GetText(id,TheRow) {
  if (document.all('Msg'+id).style.display == 'none') {
   document.all('Msg'+id).style.display = 'inline';
   //document.images['Pic' + id].src="images/minus.gif"   

  }else {
   document.all('Msg'+id).style.display = 'none';
   //document.images['Pic' + id].src="images/plus_blue.gif"  
  } 
}

//
function printSwf(s,w,h,c){
  strFlashCode = "";
  strFlashCode += "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+ w +"' height='"+ h +"' id='ronlight_menu' align='middle'>"
  strFlashCode += "<param name='allowScriptAccess' value='sameDomain' />"
  strFlashCode += "<param name='movie' value='"+ s +"' />"
  strFlashCode += "<param name='quality' value='high' />"
  strFlashCode += "<param name='bgcolor' value='"+ c +"' />"
  strFlashCode += "<embed src='"+ s +"' quality='high' bgcolor='"+ c +"' width='"+ w +"' height='"+ h +"' name='ronlight_menu' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"
  strFlashCode += "</object>"
  document.write(strFlashCode);
}


 
function checkForm(){

 var objForm = document.forms[0];
 if (objForm.fname.value.length < 2){
   alert("!נא ציין את שמך הפרטי");
   objForm.fname.focus();
   return (false);
 }
 if (objForm.lname.value.length < 2){
   alert("!נא ציין את שם משפחתך");
   objForm.lname.focus();
   return (false);
 }
 if(objForm.pcode.selectedIndex==0){
   alert("!נא ציין קידומת");
   objForm.pcode.focus();
   return (false);
 } 
 if (!CheckPhone(objForm.pnum.value)){
      alert("!נא ציין מספר טלפון")
       objForm.pnum.focus();
       return false;
 }
 
  if(objForm.agency.selectedIndex==0){
   alert("!נא בחר את הסניף הקרוב לביתך");
   objForm.agency.focus();
   return (false);
  }
   
  return (true);
}	 



function checkForm2(){

 var objForm = document.forms[0];
 if (objForm.fname.value.length < 2){
   alert("!נא ציין את שמך הפרטי");
   objForm.fname.focus();
   return (false);
 }
 if (objForm.lname.value.length < 2){
   alert("!נא ציין את שם משפחתך");
   objForm.lname.focus();
   return (false);
 }
 if(objForm.pcode.selectedIndex==0){
   alert("!נא ציין קידומת");
   objForm.pcode.focus();
   return (false);
 } 
 if (!CheckPhone(objForm.pnum.value)){
      alert("!נא ציין מספר טלפון")
       objForm.pnum.focus();
       return false;
 }

 if (!validEmail(objForm.Mail.value)){
      alert("!נא ציין כתובת דואר אלקטרוני")
       objForm.Mail.focus();
       return false;
 }
 

 if (objForm.Sn.value.length < 10){
      alert("!מספר סיריאלי של מכשירך")
       objForm.Sn.focus();
       return false;
 }
  return (true);
}






function checkRegForm(){

 var objForm = document.forms[0];
 if (objForm.fname.value.length < 2){
   alert("!נא ציין את שמך הפרטי");
   objForm.fname.focus();
   return (false);
 }
 if (objForm.lname.value.length < 2){
   alert("!נא ציין את שם משפחתך");
   objForm.lname.focus();
   return (false);
 }
 if (!validEmail(objForm.Mail.value)){
      alert("!נא ציין כתובת דואר אלקטרוני")
       objForm.Mail.focus();
       return false;
 }
 if (objForm.Password.value.length < 6){
      alert("!נא ציין סיסמא לפחות 6 תווים")
       objForm.Password.focus();
       return false;
 }

 if(objForm.mcode.selectedIndex==0){
   alert("!נא ציין מספר טלפון ניייד");
   objForm.mcode.focus();
   return (false);
 } 
 if (!CheckPhone(objForm.mnum.value)){
      alert("!נא ציין מספר טלפון ניייד")
       objForm.pnum.focus();
       return false;
 }

 if (objForm.DiType.selectedIndex==0){
      alert("!נא ציין סוג המכשיר שרכשת")
       objForm.DiType.focus();
       return false;
 }
  return (true);
}



function CheckPhone(PhoneNum){
  var num="0123456789"
  if (PhoneNum.length < 7)
     return false;
  for (var i=0; i < PhoneNum.length ; i++){
   temp=PhoneNum.substring(i,i+1)
   if(num.indexOf(temp)==-1)
   return false
  }	
   return true
}



function validEmail(email) {
	invalidChars = " /:,;תשרקצפעסנמלכיטחזוהדגבא"
	if (email == "") {						
		return false
	}
	for (i=0; i<invalidChars.length; i++) {	
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false
		}
	}
	atPos = email.indexOf("@",1)			
	if (atPos == -1) {
		return false
	}
	if (email.indexOf("@",atPos+1) != -1) {	
		return false
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {					
		return false
	}
	if (periodPos+3 > email.length)	{
		return false
	}
	return true
}

