
/*
	SWITCH CONTENT
*/

var enablepersist="off" //Enable saving state of content structure? (on/off)

function getElementbyClass(classname){
ccollect=new Array()
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags[i].className==classname)
ccollect[inc++]=alltags[i]
}
contractcontent("")
}
//
function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}
function expandcontent(cid){
if (typeof ccollect!="undefined"){
//contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
selectedItem=cid+"|"+document.getElementById(cid).style.display
}
}
function revivecontent(){
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
contractcontent(selectedComponents[0])
document.getElementById(selectedComponents[0]).style.display=selectedComponents[1]
}
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}
function saveswitchstate(){
if (typeof selectedItem!="undefined")
document.cookie=window.location.pathname+"="+selectedItem
}
function do_onload(){
getElementbyClass("switchcontent")

}
if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload
if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function validateForm(theForm)
{
	//check gender
	if (theForm.login.value == "") {
		alert ("You must enter a 'User Login'. Please try again.");
		return false;
	}
	if (theForm.password.value == "") {
		alert ("You must enter a 'Password'. Please try again.");
		return false;
	}
	return true;
}
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// 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);
}

function validateForm(theForm)
{
	var Phone=document.form1.homephone
	
	if ((Phone.value==null)||(Phone.value=="")){
		alert("Please Enter your Home Phone Number")
		Phone.focus()
		return false
	}
	if (checkInternationalPhone(Phone.value)==false){
		alert("Please Enter a Valid Home Phone Number")
		Phone.value=""
		Phone.focus()
		return false
	}
		var Phone=document.form1.cellphone
	
	if (checkInternationalPhone(Phone.value)==false){
		alert("Please Enter a Valid Cell Phone Number")
		Phone.value=""
		Phone.focus()
		return false
	}
	//check gender
	if (theForm.homephone.value == "") {
		alert ("You must enter a 'home phone'. Please try again.");
		return false;
	}
	if (theForm.address.value == "") {
		alert ("You must enter a 'address'. Please try again.");
		return false;
	}
	if (theForm.city.value == "") {
		alert ("You must enter a 'city'. Please try again.");
		return false;
	}
	if (theForm.state.value == "") {
		alert ("You must enter a 'state'. Please try again.");
		return false;
	}
	if (theForm.country.value == "") {
		alert ("You must enter a 'country'. Please try again.");
		return false;
	}

	if (theForm.zipcode.value == "") {
		alert ("You must enter a 'zipcode'. Please try again.");
		return false;

	}
	if (theForm.formeducationlevel.value == "") {
		alert ("You must enter a 'education'. Please try again.");
		return false;
	}
	if (theForm.uscitizen.value == "") {
		alert ("You must answer to 'Are you authorized to work in the U.S.?:'. Please try again.");
		return false;
	}

	if (theForm.securityclearance.value == "") {
		alert ("You must enter a 'security clearance'. Please try again.");
		return false;
	}
	if (theForm.resume.value == "") {
		alert ("You must enter a 'resume'. Please try again.");
		return false;
	}

	
	// <--------- End
	
	return true;
}


function resetForm(){ 
	document.getElementById('state').value  = ""; 
	document.getElementById('city').value = "";
	document.getElementById('homephone').value = "";
	document.getElementById('cellphone').value = "";
	document.getElementById('address').value = "";
	document.getElementById('country').value = "";
	document.getElementById('zipcode').value = "";
	document.getElementById('formeducationlevel').value = "";
	document.getElementById('uscitizen').value = "";
	document.getElementById('securityclearance').value = "";
	document.getElementById('coverletter').value = "";
	document.getElementById('resume').value = "";
	
} 





