/* Handle Flash */
function getSecureFlash(width, height, file, loop, alternate, classid)
{
	var MM_contentVersion = 6;
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	if ( plugin ) {
			var words = navigator.plugins["Shockwave Flash"].description.split(" ");
			for (var i = 0; i < words.length; ++i)
			{
			if (isNaN(parseInt(words[i])))
			continue;
			var MM_PluginVersion = words[i]; 
			}
		var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
	}

	if (MM_FlashCanPlay)
	{
		var oeTags = '<OBJECT CLASSID="' + classid + '"'
         + 'WIDTH="' + width + '" HEIGHT="' + height + '"'
		 + 'CODEBASE="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
         + '<PARAM NAME="MOVIE" VALUE="' + file + '">'
         + '<PARAM NAME="PLAY" VALUE="true">'
         + '<PARAM NAME="LOOP" VALUE="' + loop + '">'
         + '<PARAM NAME="QUALITY" VALUE="high">'
         + '<PARAM NAME="MENU" VALUE="false">'
         + '<EMBED SRC="' + file + '"'
         + 'WIDTH="' + width + '" HEIGHT="' + height + '"'
         + 'PLAY="true"'
         + 'LOOP="' + loop + '"'
         + 'QUALITY="high"'
         + 'MENU="false"'
         + 'TYPE="application/x-shockwave-flash"'
		 + 'PLUGINSPAGE="https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
         + '</EMBED>'
         + '</OBJECT>';
		document.write(oeTags);
	}
	else
	{
		var alternateContent = '<IMG SRC="' + alternate + '" HEIGHT="' + height + '" WIDTH="' + width + '" BORDER="0">'
		document.write(alternateContent);
	}
}

/* Handle E-Mail */

function isValidEmail(emailad) {

   var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
   var check=/@[\w\-]+\./;
   var checkend=/\.[a-zA-Z]{2,4}$/;
   if(((emailad.search(exclude) != -1) ||
       (emailad.search(check)) == -1) ||
       (emailad.search(checkend) == -1)){
      return false;
   } else {
      return true;
   }
}

/* Handle Phone Number */

function IsNumeric(sText)
{
   var ValidChars = "0123456789-.()";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;  
   }

/*  Main Validation */

function validate()
{
    //alert('u r in validation');
	var errorMessage = "Please fill the mandatory(*) fields: \n\n";
    var errorFound = 0;
	if (document.cntform.usrFirstName.value.length == 0) {errorMessage += "Enter your First Name\n"; errorFound = 1; }
    if (document.cntform.usrLastName.value.length == 0) {errorMessage += "Enter your Last Name\n"; errorFound = 1; }
	if (document.cntform.usrPhone.value.length == 0) {errorMessage += "Enter a Valid Phone Number\n"; errorFound = 1; }
	if (!IsNumeric(document.cntform.usrPhone.value)) {errorMessage += "Please enter only numbers in the Phone Number\n"; errorFound = 1; } 
	if (!isValidEmail(document.cntform.usrEmail.value)) {errorMessage += "Enter a Valid Email Address\n"; errorFound = 1; }
	if (!IsNumeric(document.cntform.usrPincode.value)) {errorMessage += "Please enter only numbers in the Pincode\n"; errorFound = 1; }
	
	if (errorFound == 1)
	{
        alert(errorMessage);
        return false;
    }
	else
	{
		return true;
    }
}

function validateCareer()
{
    //alert('u r in validation');
	var errorMessage = "Please fill the mandatory(*) fields: \n\n";
    var errorFound = 0;
	if (document.frmFaceBook.txtName.value.length == 0) {errorMessage += "Enter your Name\n"; errorFound = 1; }
	if (document.frmFaceBook.txtAge.value.length == 0) {errorMessage += "Enter your Age\n"; errorFound = 1; }
	if (!IsNumeric(document.frmFaceBook.txtAge.value)) {errorMessage += "Please enter only numbers in the Age\n"; errorFound = 1; } 
	if (document.frmFaceBook.txtMobile.value.length == 0) {errorMessage += "Enter your Phone/Mobile number\n"; errorFound = 1; }
	if (!IsNumeric(document.frmFaceBook.txtMobile.value)) {errorMessage += "Please enter only numbers in the Phone Number\n"; errorFound = 1; } 
	if (!isValidEmail(document.frmFaceBook.txtEmail.value)) {errorMessage += "Enter a Valid Email Address\n"; errorFound = 1; }
	if (document.frmFaceBook.txtQualification.value.length == 0) {errorMessage += "Enter your Educational Qualification\n"; errorFound = 1; }
	
	if (errorFound == 1)
	{
        alert(errorMessage);
        return false;
    }
	else
	{
		return true;
    }
}