
if (document.images) {
	SpiderLoginImage = new Image(100, 100);
	SpiderLoginImage.src = "/images/razorprocessinglogina.gif";
	SpiderRegImage = new Image(100, 100);
	SpiderRegImage.src = "/images/razorprocessinga.gif";
}

function jsStatusMessage(messg) {
	window.status = messg;
}

function jsSwapImgRestore() { //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 jsFindObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("^/default.htm.htm"))>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=jsFindObj(n,d.layers[i].document); return x;
}

function jsSwapImage() { //v3.0
  var i,j=0,x,a=jsSwapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=jsFindObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function jsGetCharacterCount(fname, flname, maxlen) {
	aForm = eval("document." + fname + "." + flname);
	aLength = aForm.value.length;
	if (aLength > maxlen) {
		aForm.value = aForm.value.substring(0, maxlen);
	}
	else {
		aRem = maxlen - aLength;
		aSp = flname + "Sp";
		document.getElementById(aSp).innerHTML = aRem;	
	}
}

function jsCheckPhoneFormat(phonenum) {
	if (phonenum.search(/\d{3}\-\d{3}\-\d{4}/)==-1) {
		return false;
	}
	else {
		return true;
	}
}
function jsMoveBetweenSelects(from,ato,saveto,type) {
   var continuemove = "yes";
   //for(i=0; i<from.length; i++) {
   //	  if (from.options[i].selected && from.options[i].value == "") {
	//  	continuemove = "no";
	//  }
  // }
   if (continuemove == "yes") {
	   for(i=0; i<from.length; i++) {
	      if (from.options[i].selected && from.options[i].value != "") {
	         j = 0;
	         alreadyInList = false;
			 ftext = from.options[i].text;
			 fvalue = from.options[i].value;
			 //name = fvalue.substr(0, fvalue.indexOf("~"));
			//value = fvalue.substr(fvalue.indexOf("~")+1, fvalue.length);
			// allname = name + " " + "- All";			 
			 //if (name != "") {
				// dispname = name + " " + ftext;
			 //}
			// else {
			 	//dispname = ftext;
			 //}			
			// if (dispname == allname) {
			 //	for(k=0; k<ato.length; k++) {
				//	if (ato.options[k].text.indexOf(name) != "-1") {
				//		ato.options[k] = null;	
        		// 		k--;
				//	}
				//}
			// }
			dispname = ftext;
			value = fvalue
	         while((j < ato.length) && (ato.options[j].text)) {
	            if(ato.options[j].text == dispname) {
	               alreadyInList=true;
	            }
				//else if (ato.options[j].text == allname) {
				//	alert("You have already selected the \"All\" option. \nIf you want to add an individual "+type+", please remove the corresponding \"All\" option.");
					//alreadyInList=true;
				//}
	            j++;
	           }
	         if(!alreadyInList) {
			 	var optName = new Option("", "");
				ato.options[j] = optName;
				ato.options[j].text =  dispname;
	            ato.options[j].value = value;
				var aTheID = ato.options[j].value;
				if (saveto.value == "") {
					saveto.value = aTheID;
				}
				else {
					saveto.value = saveto.value + "," + aTheID;				
				}
	         }
		  }   
	    }
	}
	else {
		if (type == "location") {		
			alert("Please ignore this option");
		}
		else {
			alert("Please select only the sub-categories for this " +type);
		}
	}
}

function jsRemoveFromSelect(slect, saveto)
{
   saveto.value = "";
   for(i=0; i<slect.length; i++) {     
	  if(slect.options[0].selected) {
	    alert("You cannot remove this item. This item will not be added to the list. So please ignore it.")
	    break;
	  }
      if(slect.options[i].selected) {	  	
         slect.options[i] = null;	
         i--;
      }	 
	  else
	  {	    
		var aTheID = slect.options[i].value;
		if (aTheID != "") {
			if (saveto.value == "") {
				saveto.value = aTheID;
			}
			else {
		  		saveto.value = saveto.value + "," + aTheID;
			}
		 }	
	  }  
   }
}

function jsCustomPopupWindow(url, wd, ht, lt, tp, name)
{
	var crip = null;
	if (name == "") {	
		name = "popupwindow";
	}
	if((crip == null) || (crip.closed)) 
	{
		crip = window.open(url, name, 'toolbar=no,directories=no,status=no,location=no,menubar=no,scrollbars=yes,width='+wd+',height='+ht+',left='+lt+',top='+tp+',resizable=no');
		crip.focus();
	}
	else
	{
		crip.location = url;
		crip.focus();
	}
}

function jsPopupWindowAll(url, wd, ht, lt, tp)
{
	var crip = null;
	if((crip == null) || (crip.closed)) 
	{
		crip = window.open(url, name, 'toolbar=no,directories=no,status=yes,location=no,menubar=yes,scrollbars=yes,width='+wd+',height='+ht+',left='+lt+',top='+tp+',resizable=yes');
		crip.focus();
	}
	else
	{
		crip.location = url;
		crip.focus();
	}
}

function jsWriteLink(abox) {
	aembox = abox + "@razorhire.com";
	document.write("<a href=\"mailto: "+aembox+"\" class=\"medium\">"+aembox+"</a>");
}

function jsTrim(str) {
   return str.replace(/^\s*|\s*$/g,"");
}

function jsIsDate(dateStr) {
    var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
    var matchArray = dateStr.match(datePat);
    if (matchArray == null) {
        alert("Please enter the date as mm/dd/yyyy");
        return false;
    }
    month = matchArray[1];
    day = matchArray[3];
    year = matchArray[5];
    if (month < 1 || month > 12) {
        alert("Month must be between 1 and 12");
        return false;
    }
    if (day < 1 || day > 31) {
        alert("Day must be between 1 and 31");
        return false;
    }
    if ((month==4 || month==6 || month==9 || month==11) && day==31) {
        alert("Month "+month+" doesn not have 31 days")
        return false;
    }
    if (month == 2) {
        var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
        if (day > 29 || (day==29 && !isleap)) {
            alert("February " + year + " doesn not have " + day + " days");
            return false;
        }
    }
    return true;
}

function jsECheck(str) {
	var aResult = true;
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (str != "") {
		if (filter.test(str)) {
			aResult = true;
		}
		else {
			aResult = false;
		}
	}
	else {
		aResult = false;
	}
	return (aResult)
}	

function jsArrayFind(arr, value) {
    for (var i = 0; i < arr.length ; i++) {
        if (arr[i] == value) {
            return "yes";
        }
	 }
    return "no";
}

function jsValidateEmpRecSignUp() {
	if (!jsECheck(document.AEmployerRecruiterSignUp.AUsername.value)) {
		alert("Please enter a valid E-mail Address for your Username.");
		return false;
	}
	else if (document.AEmployerRecruiterSignUp.AUsername.value != document.AEmployerRecruiterSignUp.AConfirmUsername.value) {
			alert("Your Usernames do not match. Please check and try again.");
			return false;
	}
	else if (jsTrim(document.AEmployerRecruiterSignUp.ACompanyName.value) == "") {
		alert("Please enter your Company Name.");
		return false;
	}
	else if (jsTrim(document.AEmployerRecruiterSignUp.AFirstName.value) == "") {
		alert("Please enter your First Name.");
		return false;
	}
	else if (jsTrim(document.AEmployerRecruiterSignUp.ALastName.value) == "") {
		alert("Please enter your Last Name.");
		return false;
	}
	else if (jsTrim(document.AEmployerRecruiterSignUp.ATitle.value) == "") {
		alert("Please enter your Title.");
		return false;
	}
	else if (jsTrim(document.AEmployerRecruiterSignUp.AAddress.value) == "") {
		alert("Please enter your Address.");
		return false;
	}
	else if (jsTrim(document.AEmployerRecruiterSignUp.ACity.value) == "") {
		alert("Please enter your City.");
		return false;
	}
	else if (jsTrim(document.AEmployerRecruiterSignUp.AStateID.value) == "") {
		alert("Please select your state.");
		return false;
	}
	else if (jsTrim(document.AEmployerRecruiterSignUp.AZipCode.value) == "") {
		alert("Please enter your Zip Code.");
		return false;
	}
	else if (document.AEmployerRecruiterSignUp.APhone.value == "") {
			alert("Please enter your Phone Number.");
			return false;
		}
	else if (document.AEmployerRecruiterSignUp.ACompanyTypeID[0].selected) {
		alert("Please select your Company Type.");
		return false;
	}
	else if (jsTrim(document.AEmployerRecruiterSignUp.ACompanyDescription.value) == "") {
		alert("Please enter your Company Description.");
		return false;
	}	
	else if (document.AEmployerRecruiterSignUp.ASelectedCities.length == "1") {
		alert("Please select at least one Location.");
		return false;
	}
	else if (document.AEmployerRecruiterSignUp.ASelectedJobFunctionTypes.length == "1") {
		alert("Please select at least one Job Function.");
		return false;
	}
	else if (document.AEmployerRecruiterSignUp.ASelectedIndustryTypes.length == "1") {
		alert("Please select at least one Industry.");
		return false;
	}
	else {
		return true;
	}
}

function jsValidatSpiAffSignUp(aIgnorePassword) {
	if (!jsECheck(document.ASpiderAffiliateSignUp.AUsername.value)) {
		alert("Please enter a valid E-mail Address for your Username.");
		return false;
	}
	if (aIgnorePassword == "") {
		if (jsTrim(document.ASpiderAffiliateSignUp.APassword.value).length < 5) {
			alert("Your password should be at least 5 characters");
			return false;
		}
		else if (jsTrim(document.ASpiderAffiliateSignUp.AConfirmPassword.value) < 5) {
			alert("Please confirm your Password.");
			return false;
		}
		else if (document.ASpiderAffiliateSignUp.APassword.value != document.ASpiderAffiliateSignUp.AConfirmPassword.value) {
			alert("Your Passwords do not match. Please check and try again.");
			return false;
		}
	}	
	if (jsTrim(document.ASpiderAffiliateSignUp.AFirstName.value) == "") {
		alert("Please enter your First Name.");
		return false;
	}
	else if (jsTrim(document.ASpiderAffiliateSignUp.ALastName.value) == "") {
		alert("Please enter your Last Name.");
		return false;
	}
	else if (jsTrim(document.ASpiderAffiliateSignUp.AAddress.value) == "") {
		alert("Please enter your Address.");
		return false;
	}
	else if (jsTrim(document.ASpiderAffiliateSignUp.ACity.value) == "") {
		alert("Please enter your City.");
		return false;
	}
	else if (jsTrim(document.ASpiderAffiliateSignUp.AZipCode.value) == "") {
		alert("Please enter your Zip Code.");
		return false;
	}
	else if (jsTrim(document.ASpiderAffiliateSignUp.APhone.value) == "") {
		alert("Please enter your Phone Number.");
		return false;
	}
	else {
		return true;
	}
}

function jsCheckLoginForm() {
	if (document.ALogin.AUsername.value == "") {
		alert("Please enter the Username");
		return false;
	}
	else if (document.ALogin.APassword.value == "") {
		alert("Please enter the Password");
		return false;
	}
	else {
		return true;	
	}
}

function jsCheckChangePasswordForm() {
	if (document.AChangePassword.ACurrentUsername.value == "") {
		alert("Please enter your current Username");
		return false;
	}
	else if (document.AChangePassword.ACurrentPassword.value == "") {
		alert("Please enter your current Password");
		return false;
	}
	else if (jsTrim(document.AChangePassword.ANewPassword.value).length < 5) {
		alert("Your password should be at least 5 characters");
		return false;
	}
	else if (jsTrim(document.AChangePassword.AConfirmPassword.value) < 5) {
		alert("Please confirm your Password.");
		return false;
	}
	else if (document.AChangePassword.ANewPassword.value != document.AChangePassword.AConfirmPassword.value) {
		alert("Please Passwords do not match");
		return false;
	}
	else {
		return true;	
	}
}

function jsCheckContactUsForm() {
	if (document.AContactForm.AFull_Name.value == "") {
		alert("Please enter your Full Name");
		return false;
	}
	else if (!jsECheck(document.AContactForm.AEmail.value)) {
		alert("Please enter a valid E-mail address");
		return false;
	}
	else if (document.AContactForm.ASubject.value == "") {
		alert("Please enter the Subject");
		return false;
	}
	else {
		return true;	
	}
}

function jsCheckBetterResumeForm() {
	if (document.ABetterResumeForm.ACheckBox.checked == false ) {
		alert("You must check the box to continue");
		return false;
	}
	else {
		return true;	
	}
}

function jsCheckEmailUsForm() {
	if (document.AEmailUsForm.AFull_Name.value == "") {
		alert("Please enter your Full Name");
		return false;
	}
	else if (!jsECheck(document.AEmailUsForm.AEmail.value)) {
		alert("Please enter a valid E-mail address");
		return false;
	}
	else if (document.AEmailUsForm.ASubject.value == "") {
		alert("Please enter the Subject");
		return false;
	}
	else if (document.AEmailUsForm.AQuestion.value == "") {
		alert("Please enter your Question");
		return false;
	}
	else {
		return true;	
	}
}

function jsCheckNewsletterForm() {
	if (!jsECheck(document.ANewletterForm.ASubscribeEmail.value)) {
		alert("Please enter a valid E-mail Address");
		return false;
	}
	else {
		return true;	
	}
}