// JavaScript Document

function retDateMonth(value) {
	switch (value)	{
	case 1:
		return "JAN"; 		
		break;
	case 2:
		return "FEB";
		break;
	case 3:
		return "MAR";
		break;
	case 4:
		return "APR";
		break;
	case 5:
		return "MAY";
		break;
	case 6:
		return "JUNE";
		break;
	case 7:
		return "JULY";
		break;
	case 8:
		return "AUG";
		break;
	case 9:
		return "SEP";
		break;
	case 10:
		return "OCT";
		break;
	case 11:
		return "NOV";
		break;
	case 12:
		return "DEC";
		break;
	}
}
	
function GoHome(){
	//window.Navigate("SessionCheck1.asp?logout=yes",'_SELF');
}

function ViewJobs(GroupID){
	document.CatJobs.action = "SchTypeCatJobResults30b7.html?SchType="+GroupID;
	document.CatJobs.submit();

}

function ViewVacancy(){
	document.searchbyid.action = "ViewVacancy2a01.html?JobRefno=" + document.searchbyid.JobID.value;
	document.searchbyid.submit();
}

function QuickSearch(){
	document.quicksearch.action = "SearchResultJob40aa.html?m=1";
	document.quicksearch.submit();
}


function Subscribe(){
	m2len = m2.length;
	if (m2len < 1 ) {
		myOption=new Option();
		myOption.text="Any";
		myOption.value="0";
		m2.options[m2len]= myOption;
	}
	
	m2len = m2.length;
	for ( i=0; i<m2len ; i++){
		m2.options[i].selected = true;
	}
	
	document.JobsByEmail.action = "email-jobs-confirmation.html";
	if (Verify_Form(document.JobsByEmail))
		document.JobsByEmail.submit();
}

function one2two() {
    m1len = m1.length ;
    for ( i=0; i<m1len ; i++){
        if (m1.options[i].selected == true ) {
            m2len = m2.length;
			//myoption = new Option

			myOption=new Option();
		    myOption.text=m1.options[i].text;
		    myOption.value=m1.options[i].value;

            m2.options[m2len]= myOption;
			//alert(m1.options[i].text);
			//alert(m1.options[i].value);
        }
    }
	
    for ( i = (m1len -1); i>=0; i--){
        if (m1.options[i].selected == true ) {
            m1.options[i] = null;
        }
    }
}

function two2one() {
    m2len = m2.length ;
        for ( i=0; i<m2len ; i++){
            if (m2.options[i].selected == true ) {
                m1len = m1.length;
				myOption=new Option();
		   		myOption.text=m2.options[i].text;
		    	myOption.value=m2.options[i].value;
                m1.options[m1len]= myOption;
            }
        }
        for ( i=(m2len-1); i>=0; i--) {
            if (m2.options[i].selected == true ) {
                m2.options[i] = null;
            }
        }
}

function selectall(){
	m1len = m1.length ;
	m2len = m2.length;
	if (m2len < 1 ) {
		for ( i=0; i<m1len ; i++){
				m2len = m2.length;
				myOption=new Option();
				myOption.text=m1.options[i].text;
				//alert(myOption.text);
				myOption.value=m1.options[i].value;
				//alert(myOption.value);
				m2.options[m2len]= myOption;
		}
	}
	
	m2len = m2.length;
	for ( i=0; i<m2len ; i++){
		m2.options[i].selected = true;
	}
	//document.JobSearch.submit();
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function Validateemail(txtEmail){
	var emailID=txtEmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }


function isAlphabatic(str){

	if (str.value.match(/^[a-zA-Z. ]+$/)){
		return true;
	}
	else
	{
		alert("Value should be Alphabatic");
		str.value="";
		return false;
	}	
}

function isNumeric(str){

	if (isNaN(str.value))
	{
		alert("Value should be Numeric");
		str.value="";
		return false;
	}
	else
	{
		return true;
	}	
}

function isAlphaNumeric(str)
{
	if (str.value.match(/^[a-zA-Z0-9. ,': ]+$/))
	{
		return true;
	}
	else
	{
		alert("Value should be AlphaNumeric");
		str.value="";
		return false;

	}	
}

function Convertcrtobr(str)
{
	str.value = str.value.replace(/\r/g,"<br>")
}

function isRefinedTelNumber(str)
{
	str.value = str.value.replace(/[a-zA-Z\W]+/g,"")
}

function isTelNumber(str)
{
	if (str.value.match(/^[0-9]+$/))
	{
		return true;
	}
	else
	{
		alert("Value should be Numbers ");
		str.value="";
		return false;

	}	
}

function isEmail(str){
	var filter= /(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{2})|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{4}))*$)/i;
	//alert(str.value);
	//alert(filter.test(str.value));
	if (filter.test(str.value)){
		//alert ("oK");
		return true;
	}
	else{
		alert("Email address should be in proper format");
		str.value="";
		return false;
	}
}



function isDate(str){
	var filter=str.value.split("index.html"); 
	
	if (filter[0]>0 && filter[0]<32){
		if (filter[1]>0 && filter[1]<13){
			if (filter[2]>2000 && filter[2]<2010){
				return true;
			}
			else{
			alert("Date should be in proper format");
			str.value="";
			return false;
			}
		}
		else{
		alert("Date should be in proper format");
		str.value="";
		return false;
		}
	}
	else{
		alert("Date should be in proper format");
		str.value="";
		return false;
	}
}

function dateformat(str,format){
	var filter=str.value.split("index.html"); 
	if (format=="USA"){
		return filter[1]+"/"+filter[0]+"/"+filter[2];
	}
	else{
		return filter[0]+"/"+filter[1]+"/"+filter[2];
	}
	
}