function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}


function validateForm(form) { //This is the name of the function

if (form.email.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the Email field"); //Informs user of empty field
   form.email.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }
// you may copy the above 5 lines for each form field you wish to validate
// Replace the text "FIELD1" with the name you wish to call the field
}

function validateForm2(form) { //This is the name of the function

if (form.counts.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the Counts field"); //Informs user of empty field
   form.counts.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }
if (form.counts.value == "0") { //This checks to make sure the field is not empty
   alert("Please fill in a value greater than zero in the Counts field"); //Informs user of empty field
   form.counts.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }   
if (form.hourly.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the Hourly Rate field"); //Informs user of empty field
   form.hourly.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }   

var hourlyInt;
	hourlyInt = parseInt(form.hourly.value);

if (hourlyInt < "9") { //This checks to make sure the field is not zero or below zero
   alert("Our saving tool is not set up to provide estimates for hourly rates below $9/hour.\n\nPlease contact us directly for a personalized business case, based on your quantifiable cost savings, the improved accuracy of your data, and increased safety for your field staff. "); //Informs user of empty field
   form.hourly.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }      
// you may copy the above 5 lines for each form field you wish to validate
// Replace the text "FIELD1" with the name you wish to call the field
}

function validateForm3(form) { //This is the name of the function

if (form.staff.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in how many staff members regularily make document and data retrieval from your existing systems"); //Informs user of empty field
   form.staff.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }
if (form.staff.value == "0") { //This checks to make sure the field is not empty
   alert("Please fill in how many staff members regularily make document and data retrieval from your existing systems"); //Informs user of empty field
   form.staff.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }

if (form.retrievals.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the number of document and data retrievals staff members make per week per staff member."); //Informs user of empty field
   form.retrievals.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }   
if (form.retrievals.value == "0") { //This checks to make sure the field is not empty
   alert("Please fill in the number of document and data retrievals staff members make per week per staff member."); //Informs user of empty field
   form.retrievals.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }   
   
// you may copy the above 5 lines for each form field you wish to validate
// Replace the text "FIELD1" with the name you wish to call the field
}

function validateForm4(form) { //This is the name of the function

if (form.namet.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the Name field"); //Informs user of empty field
   form.namet.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }
if (form.companyt.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the Company field"); //Informs user of empty field
   form.companyt.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }

if (form.emailt.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the Email field"); //Informs user of empty field
   form.emailt.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }   
if (form.phonet.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the Phone field"); //Informs user of empty field
   form.phonet.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }   
if (form.commentt.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the Available Times field"); //Informs user of empty field
   form.commentt.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }    
// you may copy the above 5 lines for each form field you wish to validate
// Replace the text "FIELD1" with the name you wish to call the field
}

function validateForm5(form) { //This is the name of the function

if (form.w_name.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the Name field"); //Informs user of empty field
   form.w_name.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }
if (form.w_company.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the Company field"); //Informs user of empty field
   form.w_company.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }

if (form.w_email.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the Email field"); //Informs user of empty field
   form.w_email.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }   
if (form.w_phone.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the Phone field"); //Informs user of empty field
   form.w_phone.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }   
// you may copy the above 5 lines for each form field you wish to validate
// Replace the text "FIELD1" with the name you wish to call the field
}


function validateForm6(form) { //This is the name of the function

if (form.namet.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the Name field"); //Informs user of empty field
   form.namet.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }
if (form.companyt.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the Company field"); //Informs user of empty field
   form.companyt.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }

if (form.emailt.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the Email field"); //Informs user of empty field
   form.emailt.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }   
if (form.phonet.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the Phone field"); //Informs user of empty field
   form.phonet.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }   
// you may copy the above 5 lines for each form field you wish to validate
// Replace the text "FIELD1" with the name you wish to call the field
}


function validateForm7(form) { //This is the name of the function

if (form.namet.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the Name field"); //Informs user of empty field
   form.namet.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }
if (form.companyt.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the Company field"); //Informs user of empty field
   form.companyt.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }

if (form.emailt.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the Email field"); //Informs user of empty field
   form.emailt.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }   
if (form.phonet.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the Phone field"); //Informs user of empty field
   form.phonet.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }   
if (form.cityt.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the City field"); //Informs user of empty field
   form.phonet.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }   
if (form.statet.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the State field"); //Informs user of empty field
   form.phonet.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }   
if (form.countryt.value == "") { //This checks to make sure the field is not empty
   alert("Please fill in the Country field"); //Informs user of empty field
   form.phonet.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }   
// you may copy the above 5 lines for each form field you wish to validate
// Replace the text "FIELD1" with the name you wish to call the field
}






/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}


/***********************************************
* VALIDATION CODE FOR THE NETSUITE FORMS
* BY HUZI --
***********************************************/


///////////////////////////////////////////// EMAIL VALIDATION /////////////////////////////////////////////////

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}


/////////////////////////////////////// PHONE VALIDATION /////////////////////////////////////////////////////////////////////////
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters =  "()- Eext.";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
function trim(s)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not a whitespace, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (c != " ") returnString += c;
    }
    return returnString;
}
function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
var bracket=3
strPhone=trim(strPhone)
if(strPhone.indexOf("+")>1) return false
if(strPhone.indexOf("-")!=-1)bracket=bracket+1
if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false
var brchr=strPhone.indexOf("(")
if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false
if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

//////////////////////////////////////////////////////////////////// VALIDATE FUNCTION CALLS ///////////////////////////////////////////////////
function ValidateNSForm(){
	///////////////// EMAIL ///////////////////////////
	var emailID=document.getElementById('txtEmail')
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}

	////////////////// PHONE //////////////////////
		var Phone=document.getElementById('txtPhone')
	
	if ((Phone.value==null)||(Phone.value=="")){
		alert("Please Enter your Phone Number")
		Phone.focus()
		return false
	}
	if (checkInternationalPhone(Phone.value)==false){
		alert("Please Enter a Valid Phone Number")
		Phone.value=""
		Phone.focus()
		return false
	}
	return true
 }
