//-- Forms scripts

function gotosite(){
    if (document.units.tafrit.options[1].selected){
           location.href = "/hashkal/hashkalframe.htm";}
    if (document.units.tafrit.options[2].selected){
           location.href = "/micun/micunframe.htm";}
    if (document.units.tafrit.options[3].selected){
           location.href = "/itc";}
    if (document.units.tafrit.options[4].selected){
           location.href = "/customs";}
	if (document.units.tafrit.options[5].selected){
           location.href = "/hon";}
    if (document.units.tafrit.options[6].selected){
           location.href = "/chov/general/mainpage.asp";}
    if (document.units.tafrit.options[7].selected){
           location.href = "/hachnasot";}
    if (document.units.tafrit.options[8].selected){
           location.href = "/research";}
    if (document.units.tafrit.options[9].selected){
           location.href = "http://www.mof.gov.il/pictures";}
    if (document.units.tafrit.options[10].selected){
           location.href = "/sachar";}
    if (document.units.tafrit.options[11].selected){
           location.href = "/bud_frame_h.htm";}
    if (document.units.tafrit.options[12].selected){
           location.href = "/beinle/beinfr_eng.htm";}
    if (document.units.tafrit.options[13].selected){
           location.href = "/rechev";}
    if (document.units.tafrit.options[14].selected){
           location.href = "/resh/index.htm";}
    if (document.units.tafrit.options[15].selected){
           location.href = "http://www.itpolicy.gov.il";}
    if (document.units.tafrit.options[16].selected){
           location.href = "/dover";}
    if (document.units.tafrit.options[17].selected){
           location.href = "/tehila/mainpage.htm";}
    if (document.units.tafrit.options[18].selected){
           location.href = "http://www.ifts.gov.il";}
	if (document.units.tafrit.options[19].selected){
           location.href = "/pension/mainpage.htm";}
	if (document.units.tafrit.options[20].selected){
           location.href = "http://www.mof.gov.il/training/";}
    if (document.units.tafrit.options[21].selected){
           location.href = "/lishka/mainpage.htm";}
    if (document.units.tafrit.options[22].selected){
           location.href = "/minhal";}
	if (document.units.tafrit.options[23].selected){
           location.href = "http://www.gp.gov.il";}
	if (document.units.tafrit.options[24].selected){
           location.href = "/2000";}
 }

function gototool(){
    if (document.tool.category.options[1].selected){
           location.href = "../../whatisnew.htm";}
    if (document.tool.category.options[2].selected){
           location.href = "http://press.info.gov.il/dover_first.asp?mofid=12";}
    if (document.tool.category.options[3].selected){
           location.href = "../../tender.htm";}
    if (document.tool.category.options[4].selected){
           location.href = "../../forums.htm";}
    if (document.tool.category.options[6].selected){
           location.href = "../../applications.htm";}
    if (document.tool.category.options[7].selected){
           location.href = "../../civil_info.htm";}
    if (document.tool.category.options[8].selected){
           location.href = "../../ecinfo.htm";}
    if (document.tool.category.options[9].selected){
           location.href = "../../budget2000/mainpage.htm";}
    if (document.tool.category.options[10].selected){
           location.href = "../../publications.htm";}
    if (document.tool.category.options[11].selected){
           location.href = "../../law.htm";}
    if (document.tool.category.options[13].selected){
           location.href = "../../navat.htm";}
    if (document.tool.category.options[14].selected){
           location.href = "../../learn.htm";}
    if (document.tool.category.options[15].selected){
           location.href = "../../address.htm";}
    if (document.tool.category.options[16].selected){
           location.href = "../../structure.htm";}
 }

/* Preload Images */ 
	if (document.images) {
		but1 = new Image;
		but1.src="../images/mainpage/but1_on.jpg";
	
		but2 = new Image;
		but2.src="../images/mainpage/but2_on.jpg";
		
		but2a = new Image;
		but2a.src="../images/mainpage/but2a_on.jpg";		
	
		but3 = new Image;
		but3.src="../images/mainpage/but3_on.jpg";
	
		but4 = new Image;
		but4.src="../images/mainpage/but4_on.jpg";
	
		but4 = new Image;
		but1.src="../images/mainpage/but4_on.jpg";
	
		but5 = new Image;
		but5.src="../images/mainpage/but5_on.jpg";
	
		but6 = new Image;
		but6.src="../images/mainpage/but6_on.jpg";
	
		but7 = new Image;
		but7.src="../images/mainpage/but7_on.jpg";
	
		but8 = new Image;
		but8.src="../images/mainpage/but8_on.jpg";
	}

//-- New window
function bigten(sd){
if (document.images)
  {
   nwin=window.open(sd,"an","toolbar=no,member=no,location=no,directories=no,scrollbars=yes,status=no,copyhistory=no,resizable=yes,height=359,width=261");
   nwin.focus();
  }
}

function open_win(xv){  // open window with no toollbar & other things...
if (document.images)
  {
   nwin1=window.open(xv,"an","toolbar=no,member=no,location=no,directories=no,scrollbars=yes,status=no,copyhistory=no,resizable=yes,height=510,width=630,top=10,left=10");
   nwin1.focus();
  }
}

function open_file(xv){  // same, but no focus, for 'read only' files
   nwin1=window.open(xv,"an","menubar=yes,toolbar=no,member=no,location=no,directories=no,scrollbars=yes,status=no,copyhistory=no,resizable=yes,height=510,width=630,top=10,left=10");
}

function open_bond(xv){  // open new full ellements window
if (document.images)
  {
   nwin1=window.open(xv,"an","toolbar=no,member=no,location=no,directories=no,scrollbars=yes,status=no,copyhistory=no,resizable=yes,height=535,width=600,top=10,left=10");
   nwin1.focus();
  }
}

function links(xv){
if (document.images)
  {
   nwin1=window.open(xv,"an","toolbar=no,member=no,location=no,directories=no,scrollbars=yes,status=no,copyhistory=no,resizable=yes,height=340,width=550");
   nwin1.focus();
  }
}

//function position: position layer according to screen size and resolution
function position(scrWidth){		
var sum;
sum=scrWidth-645;   //sum = screen width - content
sum=sum/2;			//sum / 2  to get left column width

document.all.blockDiv0.style.left=sum+12;
document.all.blockDiv0.style.top=310; 

document.all.blockDiv1.style.left=sum+12;
document.all.blockDiv1.style.top=310; 
					
document.all.blockDiv2.style.left=sum+12;
document.all.blockDiv2.style.top=310; 

document.all.blockDiv2a.style.left=sum+12;
document.all.blockDiv2a.style.top=310; 
					
document.all.blockDiv3.style.left=sum+12;
document.all.blockDiv3.style.top=310; 
					
document.all.blockDiv4.style.left=sum+12;
document.all.blockDiv4.style.top=310; 
					
document.all.blockDiv5.style.left=sum+12;
document.all.blockDiv5.style.top=310; 
					
document.all.blockDiv6.style.left=sum+12;
document.all.blockDiv6.style.top=310; 
					
document.all.blockDiv7.style.left=sum+12;
document.all.blockDiv7.style.top=310; 
																			
			//51 is the width of the starting point of the content 
			//to the starting point of the layer , 
			//added to that is the left column width.

} 

/* group list form script */
var flag
 function checkFields(){
	var n=document.listform.elements.length;
	
	for ( i=0; i<n; i++ ){
		//alert(document.listform.elements[i].value)
		if (document.listform.elements[i].value==""){
			//alert(document.listform.elements[i].value);
			flag= false;
			return;
		}
	}
		if (flag = false){
			return false;
		}
		else { return true }
 }

 function checkEmail(email) //  Check "strange" formats of E-mail address.
{
	var email=document.listform.email.value
	var len=email.length
	var first=email.indexOf('@')
	var last =email.lastIndexOf('@')
	var firstD=email.indexOf('.') 
	var lastD =email.lastIndexOf('.') 
	var eChar = "!$%^&*()?><|"
	// Standard check	  
	if ((first==-1) ||
		(first==0)||
		(first==len-1)||
		(first != last) ||
		(firstD==-1) ||
		(firstD==0)||
		(firstD==len-1)||
		(lastD == firstD+1)||
		(firstD == first+1)|| 
		(lastD==len-1)   ||
		(email.indexOf("..")!=-1)){
	 	alert("!בבקשה תקן את כתובת הדואר האלקטרוני"); 
	 	return false;
	}
	// Check for elegal chars. more chars can be added to the variable eChar
	else {
		flag = true
		for (i=0; i<email.length; i++){
   			tst=email.substring(i,i+1)
			//alert(tst)
    		if (eChar.indexOf(tst)>-1){
	 			alert("!בבקשה תקן את כתובת הדואר האלקטרוני"); 
	 			flag = false;
				return;
   			}
		}
		if (flag = false){
			return false;
		}
		else { return true }
	}
}	


 function lastCheck(){
 	if(checkFields() && checkEmail()){
		//alert("ok");
		document.listform.submit();
 	}
	else { alert("Please correct your e-mail address") }
 }
