// JavaScript Document
function show_div()

{

  if(document.jobApplyForm.cover_note[0].checked)

   {

   	document.getElementById("write_now").style.display="none";

	document.getElementById("attach_now").style.display="block";

   }

  if(document.jobApplyForm.cover_note[1].checked)

   {

   	document.getElementById("attach_now").style.display="none";

	document.getElementById("write_now").style.display="block";

   }   

}
function ReplaceAll(Source,stringToFind,stringToReplace){

  var temp = Source;

    var index = temp.indexOf(stringToFind);

        while(index != -1){

            temp = temp.replace(stringToFind,stringToReplace);

            index = temp.indexOf(stringToFind);

        }

        return temp;

}
function trim(sStr)
{
   var s;
   sStr = sStr.toString();
   sStr = sStr.replace(/(^\s*)|(\s*$)/g,"");
   //sStr = sStr.replace(/\s{2,}/g," "); /*----- Removes the unwanted spaces(more than one)-----*/
   return(sStr);
}
function submitVal(frontUrl)
{
	var jobcategory		= 	document.jobsearchForm.jobcategory.value;

	var joblocation		= 	document.jobsearchForm.joblocation.value;

	var jobkeywords		= 	document.jobsearchForm.jobkeywords.value;
	
	jobcategory			=	ReplaceAll(trim(jobcategory),' ','_');
	
	joblocation			=	ReplaceAll(trim(joblocation),' ','_');
	
	jobkeywords			=	ReplaceAll(trim(jobkeywords),' ','_');

	if(jobkeywords == "Keywords" && jobcategory == "" && joblocation == "") {
		document.jobsearchForm.action 	= 	frontUrl;
	} else {	
		if(jobkeywords != "Keywords" && jobkeywords != "") {
			if(joblocation == "") {
				jobloc =	"anylocation";
			} else {
				jobloc =	joblocation;
			}
			
			if(jobcategory == "") {
				jobcat =	"anycategory";
			} else {
				jobcat =	jobcategory;
			}

			document.jobsearchForm.action 	= 	frontUrl+"/"+jobloc+"/"+jobcat+"/"+jobkeywords;
			
		} else {
			
			document.jobsearchForm.action 	= 	frontUrl+"/"+joblocation+"/"+jobcategory;
		}

	}
	document.jobsearchForm.submit();

	return true;
}
function goPagination(frontUrl, pageId, keyword_search)
{
	document.getElementById('pgId').value	=	pageId;	
	
	document.getElementById('jobkeywords').value	=	keyword_search;	

	document.jobPaginationForm.action 		= 	frontUrl;	

	document.jobPaginationForm.submit();
	
	return true;

}
