function toggle(object) {
  if (document.getElementById) {
    if (document.getElementById(object).style.visibility == 'visible')
      document.getElementById(object).style.visibility = 'hidden';
    else
      document.getElementById(object).style.visibility = 'visible';
  }

  else if (document.layers && document.layers[object] != null) {
    if (document.layers[object].visibility == 'visible' ||
        document.layers[object].visibility == 'show' )
      document.layers[object].visibility = 'hidden';
    else
      document.layers[object].visibility = 'visible';
  }

  else if (document.all) {
    if (document.all[object].style.visibility == 'visible')
      document.all[object].style.visibility = 'hidden';
    else
      document.all[object].style.visibility = 'visible';
  }

  return false;
}

function clickclear(thisfield, defaulttext) {
if (thisfield.value == defaulttext) {
thisfield.value = '';
}
}

function clickrecall(thisfield, defaulttext) {
if (thisfield.value == '') {
thisfield.value = defaulttext;
}
}


function chk()
{
  if (document.frmnl.txtemail.value=="")
  {
    alert("Please enter the EmailId")
	document.frmnl.txtemail.focus();
	return false;
  }
  if (document.frmnl.txtemail.value == "")
	{
		alert("Please enter email address.");
		document.frmnl.txtemail.focus();
		return (false );
	}

	else	
		{
			if(checkEmail(document.frmnl.txtemail.value)==0)		
				{
					document.frmnl.txtemail.select();
					document.frmnl.txtemail.focus();
					return false;
				}
		} 
  
  return true;
}
function checkEmail(myForm)
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm))
	{	
		return (true)
	}
	alert("Please enter valid email address.");
	return 0;
}


function loadText()
{
	document.frmnl.txtemail.value = "Your email address";
}



var checkit = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
var allValid;

function alphabetonly(checkStr)
{
	allValid=true
	for (i = 0; i < checkStr.length; i++)
	{
		ch1 = checkStr.charAt(i);
		for (j = 0; j < checkit.length; j++)
		if(ch1 == checkit.charAt(j))
			break;
		if (j == checkit.length)
		{
			allValid = false;
			break;
		}
	}
}
////////////////
var checkits = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'";
var allValid2;

function alphabetonly2(checkStr)
{
	allValid2=true
	for (i = 0; i < checkStr.length; i++)
	{
		ch1 = checkStr.charAt(i);
		for (j = 0; j < checkits.length; j++)
		if(ch1 == checkits.charAt(j))
			break;
		if (j == checkits.length)
		{
			allValid2 = false;
			break;
		}
	}
}
//////////////
var checkthis = "0123456789";
var allValid3;
function noalphabet(checkStr)
{
	allValid3=true
	for (i = 0; i < checkStr.length; i++)
	{
		ch1 = checkStr.charAt(i);
		for (j = 0; j < checkthis.length; j++)
		if(ch1 == checkthis.charAt(j))
			break;
		if (j == checkthis.length)
		{
			allValid3 = false;
			break;
		}
	}
}
var checkthis = "0123456789";
var allValid1;
function noalphabet(checkStr)
{
	allValid1=true
	for (i = 0; i < checkStr.length; i++)
	{
		ch1 = checkStr.charAt(i);
		for (j = 0; j < checkthis.length; j++)
		if(ch1 == checkthis.charAt(j))
			break;
		if (j == checkthis.length)
		{
			allValid1 = false;
			break;
		}
	}
}

function contactuschk()
{	
	  	// For First Name
	if(document.frmrequest.txt_fname.value=="")
	{
		alert("Please enter name!")
		document.frmrequest.txt_fname.focus();
		return false;
	}
	else if(document.frmrequest.txt_fname.value.charAt(0)==" " || document.frmrequest.txt_fname.value.charAt(document.frmrequest.txt_fname.value.length-1)==" ")
	{
		alert("Space is not allowed before or after name!");
		document.frmrequest.txt_fname.focus();
		document.frmrequest.txt_fname.select();
		return false;
	}
	else if(document.frmrequest.txt_fname.value.length<2)
	{
		alert("Please enter at least 2 characters for name!")
		document.frmrequest.txt_fname.focus()
		return false;
	}
	else
	{
		alphabetonly(document.frmrequest.txt_fname.value);
		if (!allValid)
		{
			alert("Please enter only alphabets for name!")
			document.frmrequest.txt_fname.focus();
			return false;
		}
	}  
	 
	  // For address
	if(document.frmrequest.address.value=="")
	{
		alert("please enter Address!")
		document.frmrequest.address.focus();
		return false;
	}

// For City
	if(document.frmrequest.city.value=="")
	{
		alert("Please enter city!");
		document.frmrequest.city.focus();
		return false;
	}
	else if(document.frmrequest.city.value.charAt(0)==" " || document.frmrequest.city.value.charAt(document.frmrequest.city.value.length-1)==" ")
	{
		alert("Space is not allowed before or after city!");
		document.frmrequest.city.focus();
		document.frmrequest.city.select();
		return false;
	}
	else if(document.frmrequest.city.value.length<2)
	{
		alert("Please enter at least 2 characters for city!")
		document.frmrequest.city.focus()
		return false;
	}
	else
	{
		alphabetonly(document.frmrequest.city.value);
		if (!allValid)
		{
			alert("Please enter only alphabets for city!")
			document.frmrequest.city.focus();
			return false;
		}
	}

	// For Country
	if(document.frmrequest.country.value==0)
	{
		alert("Please select your country!");
		document.frmrequest.country.focus();
		return false;
	}
	/*if(document.frmrequest.country.value=="")
	{
		alert("Please enter country!");
		document.frmrequest.country.focus();
		return false;
	}*/
	
// For telephone no.
	if (document.frmrequest.countrycode.value == "")
	{
		alert("Please enter country code!");
		document.frmrequest.countrycode.focus();
		return false;
	}
	else if(document.frmrequest.countrycode.value.length > 3 || document.frmrequest.countrycode.value.length < 2)
	{
		alert("The country code is invalid and should be atleast 2 digit number!")
		document.frmrequest.countrycode.focus()
		return false;
	}
	else
	{
		noalphabet(document.frmrequest.countrycode.value);
		if (!allValid1)
		{
			alert("The country code is invalid and should be atleast 2 digit number!")
			document.frmrequest.countrycode.focus();
			return false;
		}
	}  
	
	if (document.frmrequest.stdcode.value == "")
	{
		alert("Please enter city code!");
		document.frmrequest.stdcode.focus();
		return false;
	}
	else if(document.frmrequest.stdcode.value.length > 4 || document.frmrequest.stdcode.value.length < 2)
	{
		alert("The city code is invalid and should be atleast 2 digit number!")
		document.frmrequest.stdcode.focus()
		return false;
	}
	else
	{
		noalphabet(document.frmrequest.stdcode.value);
		if (!allValid1)
		{
			alert("The city code is invalid and should be atleast 2 digit number!")
			document.frmrequest.stdcode.focus();
			return false;
		}
	}  
	if (document.frmrequest.number.value == "")
	{
		alert("Please enter phone no.!");
		document.frmrequest.number.focus();
		return false;
	}
	else if(document.frmrequest.number.value.length < 6)
	{
		alert("The number is invalid and should be more than 6 digit")
		document.frmrequest.number.focus()
		return false;
	}
	else
	{
		noalphabet(document.frmrequest.number.value);
		if (!allValid1)
		{
			alert("The number is invalid and should be more than 6 digit")
			document.frmrequest.number.focus();
			return false;
		}
	}  

// For mobile no
	if (document.frmrequest.mphone.value == "")
	{
		alert("Please enter mobile no.!");
		document.frmrequest.mphone.focus();
		return false;
	}
	/*else	
	{
		if(validatePhone1(document.frmrequest.mphone.value)==0)		
		{
			document.frmrequest.mphone.select();
			document.frmrequest.mphone.focus();
			return false;
		}
	}*/ 
	else if(document.frmrequest.mphone.value.length > 11 || document.frmrequest.mphone.value.length < 10)
	{
		alert("The mobile number is invalid and should be atleast 10 digit number!")
		document.frmrequest.mphone.focus()
		return false;
	}
	else
	{
		noalphabet(document.frmrequest.mphone.value);
		if (!allValid1)
		{
			alert("The mobile number is invalid and should be atleast 10 digit number!")
			document.frmrequest.mphone.focus();
			return false;
		}
	}  
// For Email
	if (document.frmrequest.text_email.value == "")
	{
		alert("Please enter email address!");
		document.frmrequest.text_email.focus();
		return false;
	}
	else	
	{
		if(checkEmail(document.frmrequest.text_email.value)==0)		
		{
			document.frmrequest.text_email.select();
			document.frmrequest.text_email.focus();
			return false;
		}
	} 
	

	// For Comments
	if(document.frmrequest.comments.value=="")
	{
		alert("Please enter comments!");
		document.frmrequest.comments.focus();
		return false;
	}
}

function checkEmail(myForm)
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm))
	{	
		return true; 
	}
	alert("Please enter valid email address!");
	return 0;
}



function validatePhone(sPhone)
{
	if ((isNaN(sPhone)==true) || (sPhone.length > 3 || sPhone.length < 2))
	{

        alert("The Country code is invalid and should be atleast 2 digit number!");
       return 0;	
	}
	else
	{
		return 1;
	}
}

function validatePhonestd(sPhone)
{
	if ((isNaN(sPhone)==true) || (sPhone.length > 4 || sPhone.length < 2))
	{

        alert("The City Code is invalid and should be atleast 2 digit number!");
       return 0;	
	}
	else
	{
		return 1;
	}
}

function validatePhoneno(sPhone)
{
	if ((isNaN(sPhone)==true) || (sPhone.length > 7 || sPhone.length < 6))
	{

        alert("The number is invalid and should be atleast 7 digit number!");
       return 0;	
	}
	else
	{
		return 1;
	}
}

function validatePhone1(sPhone)
{
	if ((isNaN(sPhone)==true) || (sPhone.length > 11 || sPhone.length < 10))
	{
        alert("The mobile number is invalid and should be atleast 10 digit number!");
        return 0;	
	}
	else
	{
		return 1;
	}
}



function careerschk()
{	
	  	// For First Name
	if(document.frm.txt_fname.value=="")
	{
		alert("Please enter name!")
		document.frm.txt_fname.focus();
		return false;
	}
	else if(document.frm.txt_fname.value.charAt(0)==" " || document.frm.txt_fname.value.charAt(document.frm.txt_fname.value.length-1)==" ")
	{
		alert("Space is not allowed before or after name!");
		document.frm.txt_fname.focus();
		document.frm.txt_fname.select();
		return false;
	}
	else if(document.frm.txt_fname.value.length<2)
	{
		alert("Please enter at least 2 characters for name!")
		document.frm.txt_fname.focus()
		return false;
	}
	else
	{
		alphabetonly(document.frm.txt_fname.value);
		if (!allValid)
		{
			alert("Please enter only alphabets for name!")
			document.frm.txt_fname.focus();
			return false;
		}
	}  
	 
	  // For address
	if(document.frm.address.value=="")
	{
		alert("please enter Address!")
		document.frm.address.focus();
		return false;
	}

// For City
	if(document.frm.city.value=="")
	{
		alert("Please enter city!");
		document.frm.city.focus();
		return false;
	}
	else if(document.frm.city.value.charAt(0)==" " || document.frm.city.value.charAt(document.frm.city.value.length-1)==" ")
	{
		alert("Space is not allowed before or after city!");
		document.frm.city.focus();
		document.frm.city.select();
		return false;
	}
	else if(document.frm.city.value.length<2)
	{
		alert("Please enter at least 2 characters for city!")
		document.frm.city.focus()
		return false;
	}
	else
	{
		alphabetonly(document.frm.city.value);
		if (!allValid)
		{
			alert("Please enter only alphabets for city!")
			document.frm.city.focus();
			return false;
		}
	}

	// For Country
	/*if(document.frm.country.value=="")
	{
		alert("Please select your country!");
		document.frm.country.focus();
		return false;
	}*/
	if(document.frm.country.value==0)
	{
		alert("Please select your country!");
		document.frm.country.focus();
		return false;
	}

	
// For telephone no.
	if (document.frm.countrycode.value == "")
	{
		alert("Please enter country code!");
		document.frm.countrycode.focus();
		return false;
	}
	else if(document.frm.countrycode.value.length > 3 || document.frm.countrycode.value.length < 2)
	{
		alert("The country code is invalid and should be atleast 2 digit number!")
		document.frm.countrycode.focus()
		return false;
	}
	else
	{
		noalphabet(document.frm.countrycode.value);
		if (!allValid1)
		{
			alert("The country code is invalid and should be atleast 2 digit number!")
			document.frm.countrycode.focus();
			return false;
		}
	}  
	
	if (document.frm.stdcode.value == "")
	{
		alert("Please enter city code!");
		document.frm.stdcode.focus();
		return false;
	}
	else if(document.frm.stdcode.value.length > 4 || document.frm.stdcode.value.length < 2)
	{
		alert("The city code is invalid and should be atleast 2 digit number!")
		document.frm.stdcode.focus()
		return false;
	}
	else
	{
		noalphabet(document.frm.stdcode.value);
		if (!allValid1)
		{
			alert("The city code is invalid and should be atleast 2 digit number!")
			document.frm.stdcode.focus();
			return false;
		}
	}  
	if (document.frm.number.value == "")
	{
		alert("Please enter phone no.!");
		document.frm.number.focus();
		return false;
	}
	else if(document.frm.number.value.length > 7 || document.frm.number.value.length < 6)
	{
		alert("The number is invalid and should be 6 or 7 digit number!")
		document.frm.number.focus()
		return false;
	}
	else
	{
		noalphabet(document.frm.number.value);
		if (!allValid1)
		{
			alert("The number is invalid and should be 6 or 7 digit number!")
			document.frm.number.focus();
			return false;
		}
	}  

// For mobile no
	if (document.frm.mphone.value == "")
	{
		alert("Pleaseenter mobile no.!");
		document.frm.mphone.focus();
		return false;
	}
	else if(document.frm.mphone.value.length > 11 || document.frm.mphone.value.length < 10)
	{
		alert("The mobile number is invalid and should be atleast 10 digit number!")
		document.frm.mphone.focus()
		return false;
	}
	else
	{
		noalphabet(document.frm.mphone.value);
		if (!allValid1)
		{
			alert("The mobile number is invalid and should be atleast 10 digit number!")
			document.frm.mphone.focus();
			return false;
		}
	} 
// For Email
	if (document.frm.text_email.value == "")
	{
		alert("Please enter email address!");
		document.frm.text_email.focus();
		return false;
	}
	else	
	{
		if(checkEmail(document.frm.text_email.value)==0)		
		{
			document.frm.text_email.select();
			document.frm.text_email.focus();
			return false;
		}
	} 
	
// For Work Experience
	if(document.frm.expyear.value==0)
	{
		alert("Please enter work exp in year!");
		document.frm.expyear.focus();
		return false;
	}

	if(document.frm.monthsexp.value==0)
	{
		alert("Please enter work exp in months!");
		document.frm.monthsexp.focus();
		return false;
	}


	// For Comments
	if(document.frm.file_cv.value=="")
	{
		alert("Please upload CV!");
		document.frm.file_cv.focus();
		return false;
	}
}

function checkEmail(myForm)
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm))
	{	
		return true;
	}
	alert("Please enter valid email address!");
	return 0;
}


function validatePhone(sPhone)
{
	if ((isNaN(sPhone)==true) || (sPhone.length > 3 || sPhone.length < 2))
	{

        alert("The Country code is invalid and should be atleast 2 digit number!");
       return 0;	
	}
	else
	{
		return 1;
	}
}

function validatePhonestd(sPhone)
{
	if ((isNaN(sPhone)==true) || (sPhone.length > 4 || sPhone.length < 2))
	{

        alert("The City Code is invalid and should be atleast 2 digit number!");
       return 0;	
	}
	else
	{
		return 1;
	}
}

function validatePhoneno(sPhone)
{
	if ((isNaN(sPhone)==true) || (sPhone.length > 7 || sPhone.length < 6))
	{

        alert("The number is invalid and should be atleast 7 digit number!");
       return 0;	
	}
	else
	{
		return 1;
	}
}

function validatePhone1(sPhone)
{
	if ((isNaN(sPhone)==true) || (sPhone.length > 11 || sPhone.length < 10))
	{
        alert("The mobile number is invalid and should be atleast 10 digit number!");
        return 0;	
	}
	else
	{
		return 1;
	}
}
