// JavaScript Document
var xmlhttp = false;
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 showCDirectory()
{
	var countryId = document.getElementById('cmbcountries').value;
	window.location = "cdirectory/listDirectory/"+countryId;
}	
function onKeyUp(evt)
{
	var charCode = (evt.charCode) ? evt.charCode :
	((evt.which) ? evt.which : evt.keyCode);
	if(charCode==13)
		signup();
}


function trySubmit(evt)
{
	var charCode = (evt.charCode) ? evt.charCode :
	((evt.which) ? evt.which : evt.keyCode);
	if(charCode==13)
		signupPublisher();
}
function subscribeJobsFooter()
{
	var subscriberEmail = document.getElementById('subscriberEmail1');
	if (subscriberEmail.value ==""){
		alert("Enter email");
		subscriberEmail.focus();
		return false;
	}
	
	if (subscriberEmail.value !=""){
		var re = new RegExp(/^[\w\.\-]+\@[\w\.\-]+\.[a-z\.]{2,6}$/);
		var str=subscriberEmail.value;
		if(str.search(re)==-1)
		{
			alert("Please valid email address");
			subscriberEmail.focus();
			return false;
		}
	}
}
function signup()
{
	
	var username = document.getElementById('username');
	var password = document.getElementById('userpassword');
	
	if(username.value != "" && password.value != "")
	{
	
		authenticate(username.value,password.value);
	}
	else
	{
			alert("Enter User name and Password");
	}
}
function signupPublisher()
{
	
	var username = document.getElementById('username');
	var password = document.getElementById('password');
	//alert(password.value);
	if(username.value != "" && password.value != "")
	{
		
		authenticatePublisher(username.value,password.value);
	}
	else
	{
			alert("Enter User name and Password");
			return false;
	}
}
function logoff()
{
	ajaxInit();
	var serverPage = "signup/logoff";
	xmlhttp.open("GET", serverPage);
	xmlhttp.onreadystatechange = function() 
	{
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
		{
			var message = xmlhttp.responseText;
			if(message == "TRUE")
				//window.location = "http://demo.cabotsolutions.com/gulfbazaar/welcome";
				window.location = "http://sheeja/gulfbazaar/welcome";
			else
				alert("Error on logoff");			
		}
	}
	xmlhttp.send(null);
}
/*function authenticate(username,password)
{
	ajaxInit();
	var serverPage = "signup/authenticate/"+username+"/"+password;
	xmlhttp.open("GET", serverPage);
	xmlhttp.onreadystatechange = function() 
	{
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
		{
			var message = xmlhttp.responseText;
			
			var obj = document.getElementById('masksignup');
			obj.style.display="none";
			if(message == "TRUE")
				//window.location = "http://demo.cabotsolutions.com/gulfbazaar/welcome";
				window.location = "http://sheeja/gulfbazaar/welcome";
			else
			{
				obj = document.getElementById('authen_result');
				obj.innerHTML="Invalid username and password";
			}
				
		}
	}
	xmlhttp.send(null);
}
*/
function authenticatePublisher(username,password)
{
	ajaxInit();
	var serverPage = "publishers/login/authenticate/"+username+"/"+password;
	//alert(serverPage);
	xmlhttp.open("GET", serverPage);
	xmlhttp.onreadystatechange = function() 
	{   
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
		{   
			var message = xmlhttp.responseText;
			if(message == "TRUE")
				window.location = "publishers/home";
			else
			{	
				obj = document.getElementById('authen_result');
				obj.innerHTML="Invalid username and password";
			}
				
		}
	}
	xmlhttp.send(null);
}

function headerSearch()
{
	if(document.headerform.txthsearch.value != "")
		document.headerform.submit();
}
///////////////////////////////////////////library functions//////////////////////////////////////
function ajaxInit()
{
	try {
	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} 
	catch (e) {
	try {
	//xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (E) {
	xmlhttp = false;
	}
	}
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
	xmlhttp = new XMLHttpRequest();
	}
}

function getElementPositionX(elemID) {
    var offsetTrail = elemID;
    var offsetLeft = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
    }
    return offsetLeft;
	}
	function getElementPositionY(elemID) {
		var offsetTrail = elemID;
		var offsetTop = 0;
		while (offsetTrail) {
			offsetTop += offsetTrail.offsetTop;
			offsetTrail = offsetTrail.offsetParent;
		}
		if (navigator.userAgent.indexOf("Mac") != -1 && 
			typeof document.body.leftMargin != "undefined") {
			offsetTop += document.body.topMargin;
		}
		return offsetTop;
	}
function checkJobs1()
{  
	var val=document.getElementById("searchJobs").value;	
	//alert(val);
	if(val=="")
	{
		var value=document.getElementById("searchJobsFooter").value;
		if(value=="")
		{
			alert("Enter Keyword To Search");
			document.getElementById("searchJobs").focus();	
			return false;
		}
		else
		{
			document.searchform.submit();	
			return true;
		}
	}
	else
	{
		//alert(document.getElementById("searchLocations").value);
		document.searchform.submit();	
		return true;
	}
}
function trim(str) {
    return str.replace(/^\s+|\s+$/g,"");
}
function checkJobs(){ 
	var firstChar;
	
	var footerSearch, mainSearch, mainLocation, footerLocation;
	
	if(document.getElementById("searchJobs"))
		mainSearch = document.getElementById("searchJobs").value;
	else
		mainSearch = '';
	if(document.getElementById("searchJobsFooter"))
		footerSearch=document.getElementById("searchJobsFooter").value;
	else
		footerSearch = '';
	if(document.getElementById("searchLocations"))
		mainLocation = document.getElementById('searchLocations').value;
	else
		mainLocation = '';
	if(document.getElementById("searchLocationsFooter"))
		footerLocation = document.getElementById('searchLocationsFooter').value;
	else
		footerLocation = '';
	
	mainSearch = trim(mainSearch);
	mainLocation = trim(mainLocation);
	footerSearch = trim(footerSearch);
	footerLocation = trim(footerLocation);
	firstChar = mainSearch.substr(0,1) 
	if(firstChar == '.' || firstChar == '/' || firstChar == '#'){
		mainSearch = mainSearch.substr(1);
		document.getElementById("searchJobs").value = trim(mainSearch);
	}
	firstChar = mainLocation.substr(0,1) 
	if(firstChar == '.' || firstChar == '/' || firstChar == '#'){
		mainLocation = mainLocation.substr(1);
		document.getElementById("searchLocations").value = trim(mainLocation);
	}
	firstChar = footerSearch.substr(0,1) 
	if(firstChar == '.' || firstChar == '/' || firstChar == '#'){
		footerSearch = footerSearch.substr(1);
		document.getElementById("searchJobsFooter").value = trim(footerSearch);
	}
	firstChar = footerLocation.substr(0,1) 
	if(firstChar == '.' || firstChar == '/' || firstChar == '#'){
		footerLocation = footerLocation.substr(1);
		document.getElementById("searchLocationsFooter").value = trim(footerLocation);
	}
	
	if(mainSearch == '' && mainLocation == ''){
		if(footerSearch == '' && footerLocation == ''){
			alert("Enter valid Keyword or location to Search");
			document.getElementById("searchJobs").focus();
			return false
		}
		else 
			return true; 
	}
	
	document.searchform.submit();
	//return true;
	
}
function checkJobsMain(){
	var footerSearch, mainSearch, mainLocation, footerLocation;

	if(document.getElementById("searchJobs"))
		mainSearch = document.getElementById("searchJobs").value;
	else
		mainSearch = '';
	
	if(document.getElementById("searchLocations"))
		mainLocation = document.getElementById('searchLocations').value;
	else
		mainLocation = '';
	
	
	//alert(mainSearch + mainLocation);
	var firstChar
	if(mainSearch != ''){
		firstChar = mainSearch.substr(0,1) 
		if(firstChar == '.' || firstChar == '/' || firstChar == '#'){
			mainSearch = mainSearch.substr(1);
			document.getElementById("searchJobs").value = trim(mainSearch);
		}
	}
	if(mainLocation != ''){
		firstChar = mainLocation.substr(0,1) 
		if(firstChar == '.' || firstChar == '/' || firstChar == '#'){
			mainLocation = mainLocation.substr(1);
			document.getElementById("searchLocations").value = trim(mainLocation);
		}
	}
	
	
	var name;
	var nameValue = '';
	var i;
	if(mainSearch != ''){
		name=mainSearch.split(" ");
		if(name.length>1)
		{
			for(i=0;i<name.length;i++)
			{
				if(i!=0)
					nameValue=nameValue+"-"+name[i];
				else
					nameValue=name[i];
			}
		}
		else
		{
			nameValue=name[0];
		}
	}
	//alert(nameValue);
	var searchLocation;
	if(mainLocation != ''){
		searchLocation = mainLocation.replace(/\s/g,'-');
		//alert(nameValue);
		if(nameValue != '')
			nameValue = nameValue + '-l-' + searchLocation;
		else
			nameValue =  searchLocation;
	}
	//alert(nameValue);
	document.document.getElementById('searchform').action="search/"+nameValue;
	document.searchform.submit();
	//alert("dddd");
	
	//window.location = "search/"+nameValue;
}
function subscribeJobs()
{
	var subscriberEmail = document.getElementById('subscriberEmail');
	if (subscriberEmail.value ==""){
		alert("Enter email");
		subscriberEmail.focus();
		return false;
	}
	
	if (subscriberEmail.value !=""){
		var re = new RegExp(/^[\w\.\-]+\@[\w\.\-]+\.[a-z\.]{2,6}$/);
		var str=subscriberEmail.value;
		if(str.search(re)==-1)
		{
			alert("Please valid email address");
			subscriberEmail.focus();
			return false;
		}
	}
}	
function emailCheck (emailStr) {

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

alert("Email address seems incorrect ");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Ths username contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Ths domain name contains invalid characters.");
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

alert("The username doesn't seem to be valid.");
return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!");
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The domain name does not seem to be valid.");
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The address must end in a well-known domain or two letter " + "country.");
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
alert("This address is missing a hostname!");
return false;
}

// If we've gotten this far, everything's valid!
return true;
}

function isValidURL(url){
    var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
    if(RegExp.test(url)){
        return true;
    }else{
        return false;
    }
}

function jobSeekerSignup(){
	
	

	var first = document.getElementById('jobSeekerFirstName').value;
	var last = document.getElementById('jobSeekerLastName').value;
	
	var email = document.getElementById('jobSeekerEmail').value;
	var retypeEmail = document.getElementById('jobSeekerRetypeEmail').value;
	var password = document.getElementById('jobSeekerPassword').value;
	var retypePassword = document.getElementById('jobSeekerRetypePassword').value;
	var zip = document.getElementById('jobSeekerZip').value;
	var uscanada = document.getElementById('jobSeekerUsCanada').value;
	
	if(trim(first) == ''){
		alert("Please enter your first name");
		document.getElementById('jobSeekerFirstName').focus();
		return false;
	}
	if(trim(last) == ''){
		alert("Please enter your last name");
		document.getElementById('jobSeekerLastName').focus();
		return false;
	}
	if(trim(email) == ''){
		alert("Please enter your Email");
		document.getElementById('jobSeekerEmail').focus();
		return false;
	}
	if(trim(retypeEmail) == ''){
		alert("Please retype your Email");
		document.getElementById('jobSeekerRetypeEmail').focus();
		return false;
	}
	if(trim(password) == ''){
		alert("Please enter password");
		document.getElementById('jobSeekerPassword').focus();
		return false;
	}
	if(trim(retypePassword) == ''){
		alert("Please retype password");
		document.getElementById('jobSeekerRetypePassword').focus();
		return false;
	}
	
	var re = new RegExp(/^[\w\.\-]+\@[\w\.\-]+\.[a-z\.]{2,6}$/);
	if (email != ''){		
		//var str=subscriberEmail.value;
		if(email.search(re)==-1)
		{
			alert("Please enter valid email address");
			document.getElementById('jobSeekerEmail').focus();
			return false;
		}
	}
	if(retypeEmail != email){
		alert("The email addresses entered are not matching. please check.");
		document.getElementById('jobSeekerEmail').focus();
		return false;
	}
	if(!document.getElementById('jobSeekerUsCanada').checked){
		if(!validateZIP(zip))
			return false;
	}
	if(password != retypePassword){
		alert("The passwords entered are not matching. please check.");
		document.getElementById('jobSeekerRetypePassword').focus();
		return false;
	}
	if(document.getElementById('jobSeekerUsCanada').checked){
		document.getElementById('jobSeekerUsCanada').value = 1;
		document.getElementById('jobSeekerZip').value = '';
	}else{
		document.getElementById('jobSeekerUsCanada').value = 0;
	}	
	

	//alert(document.getElementById('jobSeekerUsCanada').value);
	//alert(document.form1.jobSeekerSelectedField.value);
	document.form1.submit();
}
		

function validateZIP(field) {
	var valid = "0123456789-";
	var hyphencount = 0;

	if (field.length!=5 && field.length!=10) {
	alert("Please enter valid zip code.");
	return false;
	}
	for (var i=0; i < field.length; i++) {
	temp = "" + field.substring(i, i+1);
	if (temp == "-") hyphencount++;
	if (valid.indexOf(temp) == "-1") {
	alert("Invalid characters in your zip code.  Please try again.");
	return false;
	}
	if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
	alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
	return false;
	   }
	}
	return true;
}	
function checkEmailForm(){
	var oldEmail = document.getElementById('oldEmail').value;
	var newEmail = document.getElementById('newEmail').value;
	var confEmail = document.getElementById('confNewEmail').value;
	var re = new RegExp(/^[\w\.\-]+\@[\w\.\-]+\.[a-z\.]{2,6}$/);
	
	if(oldEmail == '' || newEmail == '' || confEmail == ''){
		alert("Please enter Current, New and confirm email id fields");
		return false;
	}
	
	if (oldEmail != ''){		
		//var str=subscriberEmail.value;
		if(oldEmail.search(re)==-1)
		{
			alert("Please enter valid email address");
			document.getElementById('oldEmail').focus();
			return false;
		}
	}

	if (newEmail != ''){		
		//var str=subscriberEmail.value;
		if(newEmail.search(re)==-1)
		{
			alert("Please enter valid email address");
			document.getElementById('newEmail').focus();
			return false;
		}
	}
	if (confEmail != ''){		
		//var str=subscriberEmail.value;
		if(confEmail.search(re)==-1)
		{
			alert("Please enter valid email address");
			document.getElementById('confEmail').focus();
			return false;
		}
	}
	if(newEmail != confEmail){
		alert("New email id and confirm email id fields must be identical");
		document.getElementById('confEmail').focus();
		return false;
	}
	return true;
}
function checkPasswordForm(){
	var curPass = document.getElementById('curPassword').value;
	var newPass = document.getElementById('newPassword').value;
	var confPass = document.getElementById('confNewPassword').value;
	
	if(curPass == '' || newPass == '' || confPass == ''){
		alert("Please enter values for the three fields");
		return false;
	}
	
	if(newPass != confPass){
		alert("New password and confirm password fields must be identical");
		document.getElementById('confNewPassword').focus();
		return false;
	}
	return true;
}
function checkZipForm(){
	var zip = document.getElementById('zipCode').value;
/*	var newPass = document.getElementById('newPassword').value;
	var confPass = document.getElementById('confNewPassword').value;*/
	
	if(zip == ''){
		alert("Please enter zip code to change");
		document.getElementById('zipCode').focus();
		return false;
	}
	
	if(!validateZIP(zip))
		return false;
	return true;
	
}

function checkPersonalForm(){
	var first = document.getElementById('firstName').value;
	var last = document.getElementById('lastName').value;
	
	if(first == '' || last == ''){
		alert("First name or Last name should not be blank!");
		return false;
	}
	return true;
}
function checkforgotpasswordForm(){
	var email = document.getElementById('useremail').value;
	if(email == ''){
		alert("Please enter your email address.");
		document.getElementById('useremail').focus();
		return false;
	}
	var re = new RegExp(/^[\w\.\-]+\@[\w\.\-]+\.[a-z\.]{2,6}$/);
	if (email != ''){		
		//var str=subscriberEmail.value;
		if(email.search(re)==-1)
		{
			alert("Please enter valid email address");
			document.getElementById('useremail').focus();
			return false;
		}
	}
	return true;
}
function confirmCancel(){
	var conf = confirm("Do you really want to cancel you member from this site?");
	if(conf == true){
		parent.location = "useraccount/cancelmembership";
	}else{
		return false;
	}
}
function publisherSignup(){

	var first = document.getElementById('publisherFirstName').value;
	var last = document.getElementById('publisherLastName').value;
	var email = document.getElementById('publisherEmail').value;
	var retypeEmail = document.getElementById('publisherConfirmEmail').value;
	var password = document.getElementById('publisherPassword').value;
	var retypePassword = document.getElementById('publisherConfirmPassword').value;
	var jobSite = document.getElementById('publisherJobsiteName').value;
	var jobtreckAddress = document.getElementById('publisherJobtreksAddress').value;
	var priceperJob = document.getElementById('publisherPricePerJob').value;
	var joblistPeriod = document.getElementById('publisherListPeriod').value;
	var subscription = document.getElementById('publisherSubscription').value;
		
	var verificationCode = document.getElementById('publisherVerificationCode').value;
	
	
	if(trim(first) == ''){
		alert("Please enter your first name");
		document.getElementById('publisherFirstName').focus();
		return false;
	}
	if(trim(last) == ''){
		alert("Please enter your last name");
		document.getElementById('publisherLastName').focus();
		return false;
	}
	if(email == ''){
		alert("Please enter your Email");
		document.getElementById('publisherEmail').focus();
		return false;
	}
	var re = new RegExp(/^[\w\.\-]+\@[\w\.\-]+\.[a-z\.]{2,6}$/);
	if (email != ''){		
		//var str=subscriberEmail.value;
		if(email.search(re)==-1)
		{
			alert("Please enter valid email address");
			document.getElementById('publisherEmail').focus();
			return false;
		}
	}
	if(trim(retypeEmail) == ''){
		alert("Please retype your Email");
		document.getElementById('publisherConfirmEmail').focus();
		return false;
	}
	if(retypeEmail != email){
		alert("The email addresses entered are not matching. please check.");
		document.getElementById('publisherEmail').focus();
		return false;
	}
	if(trim(password) == ''){
		alert("Please enter password");
		document.getElementById('publisherPassword').focus();
		return false;
	}
	if(trim(retypePassword) == ''){
		alert("Please retype password");
		document.getElementById('publisherConfirmPassword').focus();
		return false;
	}
		
	if(password != retypePassword){
		alert("The passwords entered are not matching. please check.");
		document.getElementById('publisherConfirmPassword').focus();
		return false;
	}
	if(trim(jobSite) == ''){
		alert("Please enter name of your jobsite");
		document.getElementById('publisherJobsiteName').focus();
		return false;
	}
	if(trim(jobtreckAddress) == ''){
		alert("Please choose a jobtreks address  ");
		document.getElementById('publisherJobtreksAddress').focus();
		return false;
	}
	var len = document.form1.publisherSubscription.length;
	var chosen;
	for (var i = 0; i <len; i++) {
		if (document.form1.publisherSubscription[i].checked) {
		    // alert(document.form1.publisherSubscription[i].value);
		     if(document.form1.subscription_val[i].value != 0.00) {
		     	if(trim(priceperJob) == ''){
					alert("Please enter the price per job listing  ");
					document.getElementById('publisherPricePerJob').focus();
					return false;
				}
				if(trim(joblistPeriod) == ''){
					alert("Please enter the job listing period  ");
					document.getElementById('publisherListPeriod').focus();
					return false;
				}
		     	
		     }
		     
		 }    
	}	 
	
		
	if(trim(verificationCode) == ''){
		alert("Please enter the verification code  ");
		document.getElementById('publisherVerificationCode').focus();
		return false;
	}
	if(document.getElementById('publisherAgreePolicy').checked == ''){
		alert("Please select the check box for agreeing the terms and conditions  ");
		document.getElementById('publisherAgreePolicy').focus();
		return false;
	}
	
	document.form1.submit();
}

/**
 * To check email is unique for publisher signup.
 * @return
 */
function uniqueEmail(){ 
	ajaxInit();
	var serverPage = "publisher/email/"+document.getElementById('publisherEmail').value;
	//alert(serverPage);
	
	xmlhttp.open("GET", serverPage);
	xmlhttp.onreadystatechange = function() 
	{   
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
		{  
			var message = xmlhttp.responseText;
			if(message == "TRUE"){
				obj = document.getElementById('email_result');
				document.getElementById('publisherEmail').focus();
				obj.innerHTML = "<font color='red'>Username(Email) already exists!</font>";
			}	
			else
			{	
				obj = document.getElementById('email_result');
				
				obj.innerHTML = "";
			}
				
		}
	}
	xmlhttp.send(null);
}

/**
 * To check email is unique for publisher signup.
 * @return
 */
function uniqueJobseekerEmail(){ 
	ajaxInit();
	var serverPage = "jobseeker/email/"+document.getElementById('jobSeekerEmail').value;
	//alert(serverPage);
	
	xmlhttp.open("GET", serverPage);
	xmlhttp.onreadystatechange = function() 
	{   
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
		{  
			var message = xmlhttp.responseText;
			if(message == "TRUE"){
				obj = document.getElementById('email_result');
				document.getElementById('jobSeekerEmail').focus();
				obj.innerHTML = "<font color='red'>Username(Email) already exists!</font>";
			}	
			else
			{	
				obj = document.getElementById('email_result');
				
				obj.innerHTML = "";
			}
				
		}
	}
	xmlhttp.send(null);
}

/*function search_val()
{
	var val=document.getElementById("search_val").value;	
	if(val=="")
	{
			alert("Enter Keyword To Search");
			document.getElementById("search_val").focus();	
			return false;
	}
	else
	{
		document.searchform.submit();	
	}
	
}*/
///////////////////////////////////////////library functions//////////////////////////////////////	
	
