	minimumPasswordLength	= 6;
	minimumZipLength		= 4;
	maximumZipLength		= 8;
	userTypeFreelancer		= 1;
	userTypeEmployer		= 2;
	userTypeAdmin			= 3;
	
	notActivated					= 'Your account is not yet activated.';
	deletedByAdmin					= 'Your account is deleted by Administrator';
	mailSentSuccessfully			= 'Mail has been sent to you successfully';
	recordsSuccessfullyActivated	= 'Records are successfully activated';
	recordsSuccessfullyDeactivated	= 'Records are successfully deactivated';
	recordsSuccessfullyDeleted		= 'Records are successfully deleted';
	successfullyLogout				= 'You are successfully logged out';
	setDefaultSearchSuccessfully	= "'Default Search' is successfully set.";
	
	mandatoryFieldsMissing			= '* marked fields cannot be blank';
	missingUserId					= "'Email' cannot be left blank.";
	missingPassword					= "'Password' cannot be left blank.";
	missingFirstName				= "'First Name' cannot be left blank.";
	missingLastName					= "'Last Name' cannot be left blank.";
	missingFullName					= "'Full Name' cannot be left blank.";
	missingComments					= "'Comments' cannot be left blank.";
	missingTitle					= "'Title' cannot be left blank.";
	missingCompany					= "'Company' cannot be left blank.";
	missingAddress1					= "'Address1' cannot be left blank.";
	missingCity						= "'City' cannot be left blank.";
	missingState					= "'State' cannot be left blank.";
	missingCountry					= "'Country' cannot be left blank.";
	missingZip						= "'Zip' cannot be left blank.";
	missingTelephone				= "'Telephone' cannot be left blank.";
	missingBillEmail				= "'Email' cannot be left blank.";
	missingCreditCard				= "'Credit Card' cannot be left blank.";
	missingCreditNumber				= "'Card Number' cannot be left blank.";
	missingExpMonth					= "'Exp. Month' cannot be left blank.";
	missingExpYear					= "'Exp. Year' cannot be left blank.";
	missingSecurityCode				= "'Security Code' cannot be left blank.";
	missingTermsAndConditions		= "Please agree to the 'Terms of Service'";
	missingSummary					= "'Summary and Objectives' cannot be left blank."
	missingExpertiseDetails		= "No Additional Expertise Selected."
	missingCompanyAssignment		= "'Experience' cannot be left blank."
	missingStreet					= "'Street' cannot be left blank.";
	missingDefaultSearch			= "Only 'Saved Search' can be set as Default.";
	
	emailMismatch					= "The value of 'Email' does not match with the value of 'Confirm Email'.";
	passwordMismatch				= "The value of 'Password' does not match with the value of 'Confirm Password'.";
	
	invalidBillEmail				= "Please enter a valid 'Email'.";
	invalidEmailId					= "Please enter a valid 'Email'.";
	passwordLengthError				= "Please enter 'Password' with minimum "+minimumPasswordLength+" characters.";
	zipLengthError					= "Please enter 'Zip' with minimum of "+minimumZipLength+" characters and maximum of "+maximumZipLength+" characters.";
	inValidCardNumber				= "Please enter a valid 'Card Number'";
	inValidCCExpDate				= "Please enter a valid 'Expiration Date'";
	
	invalidZip						= "'Zip' should be alphanumeric.";
	invalidAddress					= "'Address' should be alphanumeric.";
	cardNumberNonNumeric			= "Please enter numeric value of 'Card Number'";
	
	userTypeNotSet					= 'The value of user type is not set.';
	emailIdInUse					= 'Email is Already in Use. Please use another Id';
	commentsAddedSuccessfully		= 'Comments are successfully added.';
	resumeSavedSuccessfully			= 'Resume has been saved successfully.';
	invalidFirstName				= "'First Name' should be alphabetic.";
	invalidLastName					= "'Last Name' should be alphabetic.";
	invalidCompany					= "'Company Name' should be alphabetic.";
	invalidCity						= "'City' should be alphabetic.";
	invalidExpertise				= "Please enter a valid 'Expertise'.";
	blankSubject					= "'Subject' cannot be left blank.";
	blankMessage					= "'Message' cannot be left blank.";
	selectEmailCriteria				= 'Please select a email preferences criteria.';

function $(id)
{
	return document.getElementById(id);
}
	
function addMessage(divId, msg){
		if(document.getElementById(divId).innerHTML == ''){
			document.getElementById(divId).innerHTML = '<li>'+msg+'</li>';
		}else{
			document.getElementById(divId).innerHTML += '<li>'+msg+'</li>';
		}
	}
	 	
function validate(object,type){
	var errorElement = document.getElementById(object.name + "_error");
	if(type == 'Required' && (object.value == '' || object.value.length == 0) ){
		errorElement.innerHTML = "Field is required, cannot be blank";
	}else{
	errorElement.innerHTML ="";
	}
}

function verifyEmail(email){
	var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
     if (email.search(emailRegEx) == -1) {
        return false;
     }else{
     	return true;
     }
	}
	
	function isAlphabetical(value){
		var regEx = /^[A-Z a-z]+$/i;
     if (value.search(regEx) == -1) {
       return true;
     }else{
     	return false;
     }
	} 
	
	function isAlphaNumeric(value){
		var regEx = /^[A-Za-z0-9 _]+$/i;
     if (value.search(regEx) == -1) {
        return true;
     }else{
     	return false;
     }
	}
	
	
	function checkMinimumLength(str, len){
     if (str.length < len) {
        return false;
     }else{
     	return true;
     }
	}
	
	function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
	
function checkCCExpDate(expMonth, expYear){
	var time = new Date();
	var currentMonth = time.getMonth() + 1;
	var currentYear = time.getFullYear();
	if( (expYear < currentYear) || ((expYear == currentYear) && (expMonth < currentMonth)) ){
		return false;
	}else{
		return true;
	}
}


/*	return the value of the radio button that is checked
	return an empty string if none are checked, or
	there are no radio buttons
*/
	
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

/*	set the radio button with the given value as being checked
 	do nothing if there are no radio buttons
	if the given value does not exist, all the radio buttons
	are reset to unchecked
*/
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

/*
	Unselects all the selected values of a select box
*/
function clearDropDown(selObj){
	var selObjOptions = selObj.options;
	for(var i = 0; i <selObjOptions.length;i++){
		selObjOptions[i].selected = false;
	}
}

/*
	This function is used to add a option to select box
*/
function addOption(selectbox,text,value )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	selectbox.options.add(optn);
}


function isAlphaNumericWithDot(value){
	var regEx = /^[A-Z a-z.0-9-']+$/i;
	if (value.search(regEx) == -1) {
		return false;
	}else{
		return true;
	}
} 

function wordLimitCounter(obj, maxLength){
	if(typeof(maxLength) == "undefined"){
		maxLength = 500;
	}
	var desc = new String(obj.value);
	if (maxLength-desc.length <1){
		obj.value = obj.value.slice(0,maxLength);
	}
}	

function getStatesList(countryOption,stateID,selectedValue,defaultSize,isBilling){
	var countries = countryOption;
	var countryId = countries[countries.selectedIndex].value;
	
	var statesresult = function(req){
		stateObj = document.getElementById(stateID);
		stateObj.innerHTML = req.responseText;
	}
	
	if(!isBilling){
	isBilling = '';
	}
	
	var parameters =  { 
							"countryId":countryId,
							"selectedValue":selectedValue,
							"defaultSize":defaultSize,
							"isBilling":isBilling
						   };
					
	AjaxRequest.post({
						'url':'/app/controllers/commonController.php',
						'parameters': parameters,
						'onSuccess':statesresult,
						'onError': function(req){ errorMessegeTd.innerHTML = "<li>Error while saving search.</li>";}
					});
}


/***********************************************
  Modal windows
 ***********************************************/

function getWindowDims()
{
	var w = h = 0;
	if( typeof( window.innerHeight ) == 'number' ) { //Non-IE
		w = window.innerWidth;
		h = window.innerHeight;
	}
	else if( document.documentElement && document.documentElement.clientHeight ) { //IE 6+ in 'standards compliant mode'
		w = document.documentElement.clientWidth;
		h = document.documentElement.clientHeight;
	}
	else if( document.body && document.body.clientHeight ) { //IE 4 compatible
		w = document.body.clientWidth;
		h = document.body.clientHeight;
	}
	return [w,h];
}

function showLoginForm(type)
{
	var dims = getWindowDims();
	var modal = document.getElementById("modal");
	var modal_content = modal.childNodes[0];
	
	var showLogin = function(req){
		modal_content.innerHTML = req.responseText;
		document.getElementById("userId").focus();
	}
	
	var parameters =  { };
	AjaxRequest.get({
						'url':'/app/views/login/'+type+'.php',
						'parameters': parameters,
						'onSuccess': showLogin,
						'onError': function(req){ modal_content.innerHTML = 'Error.';}
					});
					
	modal.style.display = 'block';
	modal_content.style.top = Math.floor(((dims[1]-modal_content.offsetHeight)/2)-60)+'px';
	modal_content.style.left = Math.floor((dims[0]-modal_content.offsetWidth)/2)+'px';
}

function hideLoginForm()
{
	var modal = document.getElementById("modal");
	modal.style.display = 'none';
	modal.childNodes[0].innerHTML = '';
}

function triggerGate(usertype)
{
	var dims = getWindowDims();
	var modal = document.getElementById("modal");
	var modal_content = modal.childNodes[0];

	var showGate = function(req){
		modal_content.innerHTML = req.responseText;
	}

	var parameters =  { "usertype":usertype };

	AjaxRequest.get({
						'url':'/app/views/search/searchGate.php',
						'parameters': parameters,
						'onSuccess': showGate,
						'onError': function(req){ modal_content.innerHTML = 'Error.';}
					});
					
	modal.style.display = 'block';
	modal_content.style.top = Math.floor(((dims[1]-modal_content.offsetHeight)/2)-60)+'px';
	modal_content.style.left = Math.floor((dims[0]-modal_content.offsetWidth)/2)+'px';
}

function checkLogin(key) {
	var formName	= key+'Form';
	var divID		= key+'MsgDiv';
	var thisForm	= document.getElementById(formName);
	var uId			= trim(thisForm.userId.value);
	var uPswd		= trim(thisForm.password.value);
	document.getElementById(divID).innerHTML = '';
	if(uId == ""){
		addMessage(divID, missingUserId);
	}else if(verifyEmail(uId) == false){
		addMessage(divID, invalidEmailId);
	}
	if(uPswd == ""){
		addMessage(divID, missingPassword);
	}else if(checkMinimumLength(uPswd, minimumPasswordLength) == false){
		addMessage(divID, passwordLengthError);
	}
	if(document.getElementById(divID).innerHTML == ''){
		thisForm.submit();
	}
}

function getQueryString(obj)
{
	qstr = '';
	for (var i in obj) {
		if (qstr.length>0) { qstr += "&"; };
		qstr += encodeURIComponent(i) + "=" + encodeURIComponent(obj[i]);
	}
	return qstr;
}

// consolidated from separate locations

function updateHiddenVariables(fler){
	if(document.getElementById("tempYearsArrayParent")!=null){
		document.getElementById("yearsArrayParent").value = document.getElementById("tempYearsArrayParent").value;
		document.getElementById("specialityArrayParent").value = document.getElementById("tempSpecialityArrayParent").value;
		document.getElementById("subExpertiseArrayParent").value = document.getElementById("tempSubExpertiseArrayParent").value;
		///if (fler)
		callSubExpertise();
	}
}

function tab_view(key)
{
	tab = document.getElementById('tab-'+key);
	tab.className = 'tabOn';
}

function toggleSub(div)
{
	el = document.getElementById('blk'+div);
	img = document.getElementById('img'+div);
	if (el && img) {
		elstate = el.style.display == 'none' ? 'block' : 'none';
		imgsrc = el.style.display == 'none' ? '/images/triangle-d.gif' : '/images/triangle-l.gif';
		el.style.display = elstate;
		img.src = imgsrc;
	}
}

