function sfunEnterKey( e ,div)
{
    var key;
    // if IE
    if (window.event)
    {
        // catch the event
        e = window.event;
        key = e.keyCode;
    }
    else if(e.which)
    {
        // netscape
        key = e.which;
    }
    // if key pressed is enter key
    if ( key == '13' )
    {
        var fdelement=div;
        evalstring="document.getElementById('"+fdelement+"')";
        var nextelement=eval(evalstring);
        nextelement.focus();
    }
}

function checkEmail(str) 
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str))
	{
		return (true)
	}
	alert("Invalid E-mail Address! Please Enter valid E-mail Address.");
	return (false)
}

function alphanumeric(alphane)
{
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {
		  }
		else	{
			 return false;
		  }
		}
	return true;
}

function validateCaptcha()
{
	
    challengeField = $("input#recaptcha_challenge_field").val();
    responseField = $("input#recaptcha_response_field").val();
    //alert(challengeField);
    //alert(responseField);
    //return false;
    var html = $.ajax({
    type: "POST",
    url: "./inc/reCAPTCHA/ajax.recaptcha.php",
    data: "recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField,
    async: false
    }).responseText;
    
    if(html == "success")
    {
		document.getElementById('captchaStatus').style.display="";
        $("#captchaStatus").html("Success. Submitting form.");
        //return false;
        // Uncomment the following line in your application
        return true;
    }
    else
    {
		document.getElementById('captchaStatus').style.display="";
        $("#captchaStatus").html("Your captcha is incorrect. Please try again");
        Recaptcha.reload();
        return false;
    }
}




/**
* This fuction is used to save details
*
* @access   public
* @param    null
*           
* @return   null
*/
function SaveContact()
{
	if(contactValidation())
	{
		document.getElementById("action").value="SaveContact";
        document.getElementById("pageform").submit();		
	}
}

/**
* This fuction is used to validate details
*
* @access   public
* @param    null
*           
* @return   true / false
*/

function contactValidation()
{
	if(document.getElementById("moreinfo").value=='new')	
	{
		alert("Please select more information on");
		document.getElementById("moreinfo").focus();
		return;
	}	
	else if(document.getElementById("prefix").value=='new')	
	{
		alert("Please select the prefix");
		document.getElementById("prefix").focus();
		return;
	}	
	else if(document.getElementById("firstname").value.match(/^ *$/))	
	{
		alert("Please enter first name");
		document.getElementById("firstname").focus();
		return;
	}	
	else if(document.getElementById("lastname").value.match(/^ *$/))	
	{
		alert("Please enter last name.");
		document.getElementById("lastname").focus();
		return;
	}
	else if(document.getElementById("company").value.match(/^ *$/))	
	{
		alert("Please enter your company.");
		document.getElementById("company").focus();
		return;
	}
	else if(document.getElementById("designation").value.match(/^ *$/))	
	{
		alert("Please enter your designation.");
		document.getElementById("designation").focus();
		return;
	}
	else if(checkEmail(document.getElementById("email").value)!=true)
	{
		//alert("*Invalid E-mail Address! Please Enter valid E-mail Address.");
		document.getElementById("email").value='';
		document.getElementById("email").focus();
		return;
	}
	else if(document.getElementById("city").value.match(/^ *$/))	
	{
		alert("Please enter your city.");
		document.getElementById("city").focus();
		return;
	}
	
	else if(document.getElementById("phone").value.match(/^ *$/))	
	{
		alert("Please enter your telephone number.");
		document.getElementById("phone").focus();
		return;
	}	
	else if(document.getElementById("hearAbout").value=='new')	
	{
		alert("Please select how did you hear about the congress?");
		document.getElementById("hearAbout").focus();
		return;
	}	
	
	return true;
}


function loginUser()
{

    if(document.getElementById("loginId").value.match(/^ *$/))

    {
        alert("Please enter the login name.");
        document.getElementById("loginId").focus();
        return;
    }

    else if(document.getElementById("password").value.match(/^ *$/))

    {
        alert("Please enter the password.");
        document.getElementById("password").focus();
        return;
    }
    document.getElementById("action").value="LoginUser";
    document.getElementById("pageform").submit();
}

function calculateAmount(){
	
	document.getElementById('displayAmount').innerHTML='';
	document.getElementById('displayAmount').innerHTML +="<div style='margin:5px 0px;font-size:9pt;color:#308E39'><b>Total</b>: ( <input type='text' name='netAmt' id='netAmt' style='border:none;width:30px;background:transparent;color:#308E39' readonly> ) + 10.3% Service Tax =&nbsp;<input type='text' name='totalAmt' id='totalAmt' style='border:none;color:#308E39;font-weight:bold;background:transparent;width:42px;text-align:right;font-size:15px' readonly>&nbsp;Euros</div>";
		
	document.getElementById("invest_1").value="1595";
	document.getElementById("invest_2").value="1095";
	document.getElementById("invest_3").value="2770";
	document.getElementById("invest_4").value="2995";
	document.getElementById("invest_5").value="3495";
	document.getElementById("invest_6").value="495";
	
	var totalAmount;
	var totalAmount1;
	
		totalAmount1=0;
		for(var i=1;i<7;i++)
		{
			id="invest_"+i;
			var dayId="pass"+i;
			
			if(document.getElementById(dayId).checked)
			{
				totalAmount1 =parseInt(totalAmount1)+parseInt(document.getElementById(id).value);
			}
		}
		//alert(totalAmount1);
		totalAmount =parseInt(totalAmount1)+(totalAmount1*0.1030);
		totalAmount = Math.round(totalAmount);
		
	document.getElementById("netAmt").value=totalAmount1;
	document.getElementById("totalAmt").value=totalAmount;	
}

function SaveCustomise()
{
	if(customiseValidation())
	{
		document.getElementById("action").value="SaveCustomise";
        document.getElementById("pageform").submit();		
	}
}

function customiseValidation()
{
	if(document.getElementById("name").value.match(/^ *$/))	
	{
		alert("Please enter your name");
		document.getElementById("name").focus();
		return;
	}	
	else if(document.getElementById("jobTitle").value.match(/^ *$/))	
	{
		alert("Please enter Job Title.");
		document.getElementById("jobTitle").focus();
		return;
	}
	else if(document.getElementById("company").value.match(/^ *$/))	
	{
		alert("Please enter your company.");
		document.getElementById("company").focus();
		return;
	}
	else if(document.getElementById("mobile").value.match(/^ *$/))	
	{
		alert("Please enter your mobile number.");
		document.getElementById("mobile").focus();
		return;
	}
	else if(checkEmail(document.getElementById("email").value)!=true)
	{
		//alert("*Invalid E-mail Address! Please Enter valid E-mail Address.");
		document.getElementById("email").value='';
		document.getElementById("email").focus();
		return;
	}
	else if(document.getElementById("pass1").checked==false)	
	{
		alert("Please choose registration for one organization");
		document.getElementById("pass1").focus();
		return;
	}
	else if(document.getElementById("pass3").checked==false && document.getElementById("pass4").checked==false && document.getElementById("pass5").checked==false)	
	{
		alert("Please choose one of the three options from among Category(2), Category(3) & Category(4)");
		document.getElementById("pass3").focus();
		return;
	}
	
	return true;
}



