//
//<meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
//<meta http-equiv="Content-Language" content="he">
//**************************************************************************************************************
//                                      Generic Fuctions
//**************************************************************************************************************

/////////////////////////////////////////////////////////////////////////////
function frm_validation(formName, formField, thanksDetails)
/////////////////////////////////////////////////////////////////////////////
{	
	var msg, i;	
	i =0;
	msg = "";
	//////mandatory field check//////////
	for (var mandatoryCount in formField)
	{
	   if (formField[mandatoryCount].mand=='yes'){		  
			if (this[formName][formField[mandatoryCount].name].value==""){
				msg = msg  + formField[mandatoryCount].alertIt + "is a mandatory field!";
				i++;
				alert (msg);
				this[formName][formField[mandatoryCount].name].focus();
				window.event.cancelBubble=true;
				window.event.returnValue=0;
				return false;
			}
		}
		
	}	
	//////field type check/////////////
	for (var typeCount in formField) {
		if(this[formName][formField[typeCount].name].value!=""){
			    if(formField[typeCount].type=='number'){				
						if (!(isANumber(this[formName][formField[typeCount].name].value, formField[typeCount].alertIt))) {
						i++;
						this[formName][formField[typeCount].name].focus();
						this[formName][formField[typeCount].name].select();
						window.event.cancelBubble=true;
						window.event.returnValue=0;
						return false;
						}				
				}else if(formField[typeCount].type=='email'){					
					if (!(emailCheck(this[formName][formField[typeCount].name].value))) {
					i++;
					this[formName][formField[typeCount].name].focus();
					this[formName][formField[typeCount].name].select();
					window.event.cancelBubble=true;
					window.event.returnValue=0;
					return false;
					}
				}else if(formField[typeCount].type=='url'){
					if (!(urlCheck(this[formName][formField[typeCount].name].value))) {
					i++;
					this[formName][formField[typeCount].name].focus();
					this[formName][formField[typeCount].name].select();
					window.event.cancelBubble=true;
					window.event.returnValue=0;
					return false;
					}
				}else if(formField[typeCount].type=='pass'){					
					if (!(passCheck(this[formName][formField[typeCount].name].value, formField[typeCount].passVal))) {
					i++;
					this[formName][formField[typeCount].name].focus();
					this[formName][formField[typeCount].name].select();
					window.event.cancelBubble=true;
					window.event.returnValue=0;
					return false;					
					}	
				}else if(formField[typeCount].type=='select'){					
					if (!(selectCheck(this[formName][formField[typeCount].name].value, formField[typeCount].selectValueCheck))) {
					i++;
					this[formName][formField[typeCount].name].focus();					
					window.event.cancelBubble=true;
					window.event.returnValue=0;
					return false;
					}
				}else if(formField[typeCount].type=='radio'){					
					if (!(radioCheck(this[formName][formField[typeCount].name], formField[typeCount].alertIt))) {
					i++;					
					window.event.cancelBubble=true;
					window.event.returnValue=0;
					return false;
					}
				}
			}
		}		

	//////field length field check//////////
	for (var maxLengthCount in formField)
	{

		/*if(!(formField[maxLengthCount].maxLength==null)){
			alert(formField[maxLengthCount].maxLength)
			var theFuck = (this[formName][formField[maxLengthCount].name].value)
			alert(theFuck.length)			
			}*/
		
		if(!(formField[maxLengthCount].maxLength==null)){  
			var theCheckedValue = (this[formName][formField[maxLengthCount].name].value)
			if ((theCheckedValue.length)>(formField[maxLengthCount].maxLength)){
				msg = msg  + formField[maxLengthCount].maxLength + " maximum characters allowed!";
				i++;
				alert (msg);
				this[formName][formField[maxLengthCount].name].focus();
				this[formName][formField[maxLengthCount].name].select();
				window.event.cancelBubble=true;
				window.event.returnValue=0;
				return false;
			}
		}
		
	}
	//////////// end  length field check
	
	if (i==0 && !(thanksDetails.name == 'noThanks') && (thanksDetails.suffixWhole == null)){
			alert(" Thank You " + this[formName][thanksDetails.name].value + ', ' + thanksDetails.suffix)
			}else if (i==0 && !(thanksDetails.suffixWhole == null)) {		
			alert(thanksDetails.suffixWhole + ' ' + this[formName][thanksDetails.name].value)			
	}

	
}
//////////////end frm_validation main function///////////////
/////////////////////////////
function radioCheck(radioID, radioAlert)
/////////////////////////////
{
	var radio_choice = false;
	for (counter = 0; counter < radioID.length; counter++){
		if (radioID[counter].checked)
		radio_choice = 1; 
	}	
	if (!radio_choice){
		alert(radioAlert)
		radio_choice = 0
		window.event.cancelBubble=true;
		window.event.returnValue=0;
	}
	return radio_choice;
}


///////////////////////////////////
function selectCheck(selectField, selectValueCheckIt)
///////////////////////////////////
{
	selectAnswer = 1;	
	if (selectField == selectValueCheckIt)
	{
		selectAnswer = 0;
		alert('Please select an option from the list');		
		window.event.cancelBubble=true;
		window.event.returnValue=0;
	}
	return selectAnswer;	
}


///////////////////////////////////
function emailCheck(emailField)
///////////////////////////////////
{
	emailAnswer = 1;
	var emailCheck1=emailField.indexOf('@');
	var emailCheck2=emailField.indexOf('.');
	var emailCheck3=emailField.indexOf(' ');
	var emailCheck4=emailField.indexOf('\'')
	var emailCheck5=emailField.indexOf('\"')
	var emailCheck6=emailField.indexOf('\&')
	var emailCheck7=emailField.indexOf('\\')
	if (!(emailCheck1>0 && emailCheck2>0 && emailCheck3==-1 && emailCheck4==-1 && emailCheck5==-1 && emailCheck6==-1 && emailCheck7==-1))
	{
		emailAnswer = 0;
		alert('Please Enter a Valid Email');		
	}
	return emailAnswer;
}

///////////////////////////////////
function urlCheck(urlField)
///////////////////////////////////
{
	urlAnswer = 1;
	var urlCheck1=urlField.substr(0,7); 	
	var urlCheck2=urlField.indexOf('.');
	var urlCheck3=urlField.indexOf(' ');	
	if (!(urlCheck1="http://" && urlCheck2>0 && urlCheck3==-1))
	{
		urlAnswer = 0;
		alert('Please Enter a Valid URL');		
	}
	return urlAnswer;
}

///////////////////////////////////
function passCheck(passField, passFieldCompare)
///////////////////////////////////
{
	passAnswer = 1;
	var myPassField = passField.toUpperCase()
	if (!(myPassField == passFieldCompare))
	{
		passAnswer = 0;
		alert('Please Enter a Valid Security Code');		
	}
	return passAnswer;
}

////////////////////////////////////
function isANumber(number, message)
////////////////////////////////////
{
	answer = 1;
	for (var i=0; i<number.length; i++) {
		if ((number.charAt(i) != "0") && (!parseFloat(number.charAt(i)) && (number.charAt(i) != "+") && (number.charAt(i) != "-") && (number.charAt(i) != "/") && (number.charAt(i) != " "))) {
			answer = 0;
			alert("Please Enter a Valid" + message);
			break;
			}
		}	
		return answer;
	}
	
/////////////////////////////////////////////////////////////////////////////
function translateThisPage(url,lang)
/////////////////////////////////////////////////////////////////////////////
{
	//german = 'de'
	//spanish = 'es'
	//french = 'fr'
	//italian = 'it'
	//portuguese = 'pt'

	var curUrlLen = url.length-7
	url = url.substr(7,curUrlLen);//cut the 'http://' part
	var fullUrl = "http://translate.google.com/translate?u=http%3A%2F%2F" + url + "&langpair=en%7C" + lang + "&hl=en&ie=ISO-8859-1&prev=%2Flanguage_tools";
	openInnewWindow(fullUrl,800,600,1);
}

/////////////////////////////////////////////////////////////////////////////
function openWin(url,title,attrib) 
/////////////////////////////////////////////////////////////////////////////
{
	wref=window.open(url,title,attrib);
	wref.focus()
}

/////////////////////////////////////////////////////////////////////////////
function openInnewWindow(url,width,height,toolbar,top,left,title)
/////////////////////////////////////////////////////////////////////////////
{
	if(toolbar==1) {openWin(url,title,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+width+',height='+height +' top=' + top + ' left=' + left)}
	else {openWin(url,title,'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,movable=yes,resizable=no,width='+width+',height='+height  +' top=' + top + ' left=' + left)}
}

/////////////////////////////////////////////////////////////////////////////
function writeEMail(user, host)
/////////////////////////////////////////////////////////////////////////////
{
	var username = user
	var hostname = host
	document.write(username + "@" + hostname)
}

/////////////////////////////////////////////////////////////////////////////
function addbookmark(url, title)
/////////////////////////////////////////////////////////////////////////////
{
var bookmarkurl=url
var bookmarktitle=title
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

/////////////////////////////////////////////////////////////////////////////
function BlinkTxt()
/////////////////////////////////////////////////////////////////////////////
{
	if(document.getElementById && document.all){
        	obj = document.getElementsByTagName('blink');
        	for (var i=0; i<obj.length; i++){
        		if (obj[i].style.color=="black") {
        			obj[i].style.color="#9C0113";
    			}
    			else {
        			obj[i].style.color="black";
    			}
		}
    		setTimeout('BlinkTxt()',400);
    	}		
}

/////////////////////////////////////////////////////////////////////////////
function showhide(what,what2)
/////////////////////////////////////////////////////////////////////////////
{
	if (what.style.display=='none'){
	what.style.display='';
	what2.src=Open.src
	}
else{
	what.style.display='none'
	what2.src=Closed.src
	}
}
/////////////////////////////////////////////////////////////////////////////
function printVersion()
/////////////////////////////////////////////////////////////////////////////
{		
	for (var printCount=1; printCount<=8; printCount++){
		var printID="printVersion"+printCount	
   		printVar=document.getElementById(printID);
		printVar.style.display='none'		   
   }
   //printVar=document.getElementById("printVersion9");
   //printVar.style.visibility='visible'
   
   mainWidth=document.getElementById("mainTable");
   mainWidth1=document.getElementById("mainTable1");
   mainWidth2=document.getElementById("printVersion5");
   mainWidth3=document.getElementById("printVersion7");
   myFooter=document.getElementById("footer");
   mainPrint=document.getElementById("printButton");
   mainWidth.width='580';
   mainWidth.align='center';
   mainWidth.style.paddingLeft='35px';
   mainWidth1.width='580';
   mainWidth1.align='center'
   mainWidth2.width='1'
   mainPrint.style.display='';   
   mainWidth3.style.display='';   
   myFooter.width='530';
}
/////////////////////////////////////////////////////////////////////////////
function printVersion2()
/////////////////////////////////////////////////////////////////////////////
{
	for (var printCount=1; printCount<=10; printCount++){
		var printID="printVersion"+printCount	
   		printVar=document.getElementById(printID);
		printVar.style.display='none'		   
   }
   //printVar=document.getElementById("printVersion9");
   //printVar.style.visibility='visible'
   
   mainWidth=document.getElementById("mainTable");
   mainWidth1=document.getElementById("mainTable1");
   mainWidth2=document.getElementById("mainTable2");
   mainPrint=document.getElementById("printButton");
   mainWidth.width='550';
   mainWidth1.width='550';
   mainWidth2.width='570'
   mainPrint.style.display='';   
}


function printSuffixPrefixSwitch()
{
	var checkIDString=window.location.href;
	IDPassCheck=checkIDString.indexOf('?')						
	if(IDPassCheck>0){printItID='&printIt=yes'}
	else {printItID='?printIt=yes'}
	openInnewWindow(window.location.href+printItID,600,450,1)
}

/////////////////////////////////////////escape yellow fields/////////////////////////////////
  if(window.attachEvent)
  window.attachEvent("onload",restoreStyles);	  
 
  function restoreStyles(){
    inputList = document.getElementsByTagName("INPUT");
    for(i=0;i<inputList.length;i++)	
      inputList[i].style.backgroundColor = "";
    selectList = document.getElementsByTagName("SELECT");
    for(i=0;i<selectList.length;i++)
      selectList[i].style.backgroundColor = "";	  
  }
/////////////////////////////////////////end escape yellow fields/////////////////////////////////

/////////self close/////////////
function selfClose(howFast)
{
setTimeout('selfCloseMe()',howFast);
}
function selfCloseMe()
{
	window.close()
}
///////page name//////
var sPath = window.location.pathname;
var myPage = sPath.substring(sPath.lastIndexOf('/') + 1);

///////fix page title/////
function fixPageTitle(myPageTitle)
{
	var myOnlyPageTitle = myPageTitle;	
	document.title = myOnlyPageTitle;	
}

//////////Combo Box (Select) Switch Generic functions////////////////
function childCombo(iID, sName, iTypeID) {
	this.ID = iID;
	this.Name = sName;
	this.TypeID = iTypeID;
}
function childComboSwitch(frmName,cmbMainName,cmbChildName,spanIdName,childArrayName,cmbChilClassName) {
     var sSelect = '<SELECT class="'+ [cmbChilClassName] +'" NAME=' + [cmbChildName] +'></OPTION>';
     var iTypeID = document[frmName][cmbMainName].value;
for (var x=1; x<this[childArrayName].length; x++) {	
if(this[childArrayName][x]!=null){
          if (this[childArrayName][x].TypeID == iTypeID) {
               sSelect = sSelect + '<OPTION VALUE=' + this[childArrayName][x].ID + '>' + this[childArrayName][x].Name + '</OPTION>'
          }
		}
     }
     sSelect = sSelect + '</SELECT>';
     document.all[spanIdName].innerHTML = "";
     document.all[spanIdName].innerHTML = sSelect; 	 
}

//this function is problematic and most probably won't be in use
function setOptionSelected(myFormName, mySelectName, myOptionID){
	//alert(window[myFormName][mySelectName].options[2].value)
	window[myFormName][mySelectName].options[myOptionID].selected = true;	
}
//end problematic function (not used)

function checkOptionValue(formName, selectName, optionValue){
	var myOptionCount=window[formName][selectName].options.length;		
		for (var i=0; i<myOptionCount; i++){
		var myOptionValue=window[formName][selectName].options[i].value;				
		if(myOptionValue==([optionValue])){		
			setOptionSelected([formName], [selectName], i)
			}
		}
	}

///21 oct 2004 - cleans form field
function myPassClean(clFormName, clFieldName, clHowLong){
	setTimeout('myPassCleanTimed("'+[clFormName]+'", "'+[clFieldName]+'")',[clHowLong]);
	
}
function myPassCleanTimed(clFormName, clFieldName){
	document[clFormName][clFieldName].value="";
	document[clFormName][clFieldName].focus();	
}

function alertSecNumber(){			
	alert("Please enter a valid security code");	
	myPassClean("premiumForm", "myPassInput", 500);
}
//////////////by Albert////////////////////2004////////////

///////blink//////////
BlinkTxt();