//call all the onload function
function intialize(comboval) {
	disdate('Guest');
	if(comboval=="dth")
	{
		selectvalue('ezrechargemode','dth');
		choosemode('ezrechargemode');
	}
	else
	{
		selectvalue('ezservprov', comboval);
		document.getElementById("ezmobno").focus();
	}
}
function setmobno(mobno)
{
	disdate('Guest');
	document.getElementById("ezmobno").value = mobno;
	memmobloc('ezmobno');
	document.getElementById("ezservprov").focus();
}
/* validate activate account form */
function validateactaccount() {
	var errorfound = false;
	/* validate name */
	if(!validatedata("idactmobno", "actvalmono", false))
		errorfound = true;

	/* validate mobile number */
	if(!validatedata("idactcode", "actvalactcode", false))
		errorfound = true;
	
	/* checks the length */
	if(!checkfldlength("idactmobno", 10)) {
		document.getElementById("actvalmono").innerHTML = "<img src='../images/redx.png' />";
		errorfound = true;
	}
	if(!checkfldlength("idactcode", 4)) {
		document.getElementById("actvalactcode").innerHTML = "<img src='../images/redx.png' />";
		errorfound = true;
	}
	if (errorfound){
		return !errorfound;
	} else {
		actaccount();
	}
}
//activate the account 
function actaccount()
{
	//send the values for the verfication using ajax post method 
	var address = "cmobno=" +encodeURI(getvalue("idactmobno")) + "&cactcode=" +encodeURI(getvalue("idactcode"));
	ajaxpost('php/acvalidate.php',address,actaccount_callback);
}
function actaccount_callback()
{
	if (xmlobject.readyState==4 || xmlobject.readyState=="complete")
	{
		//get the return value from php
		var found = xmlobject.responseText;
		//check for the right information
		if (found.length > 2)
		{
			setvalue("cfrmno",getvalue("idactmobno"));
			var delimiter = found.indexOf("||")
			var name = found.substring(0, delimiter);
			var mail = found.substring(delimiter+2,found.length);
			document.getElementById("actinfotbl").style.visibility="visible";
			document.getElementById("acttbl").style.visibility="hidden";
			setvalue("dianame",name);
			setvalue("diaemail",mail);
		}else{
			alert ("Invalid Activation Code or Mobile Number"); 
		}
	}
}
//validate the sign up details given in the jquery dialog
function valsignup()
{
	//set the error flag
	var errorfound = false;
	//validate name
	if(!validatedata("dianame", "valdianame", false))
		errorfound = true;
	//validate email 
	if(!validatedata("diaemail", "valdiaemail", true))
		errorfound = true;
	//set the pass flag
	var pwdalert = false;
	//checks for field empty and also for length 5
	if(!validatedata("diapwd", "valdiapwd", false)) {
		errorfound = true;
	}else{
		if(!checkfldlength("diapwd", 6)) {
			showerror("valdiapwd");
			alert ("Password length must be greater than 5");
			errorfound = true;
			pwdalert = true;
		}
	}
	//checks for field empty and also for length 5
	if(!validatedata("diacpwd", "valdiacpwd", false)) {
		errorfound = true;
	}else{
		if(!checkfldlength("diacpwd", 6)) {
			showerror("valdiacpwd");
			if(!pwdalert)
				alert ("Password length must be greater than 5");
			errorfound = true;
		}
	}
	//validate two given password matches 
	if(!comparetxtfld("diapwd", "diacpwd")) {
			showerror("valdiacpwd");
			if(!pwdalert)
				alert ("Password are not matching");
			errorfound = true;
	}
	return !errorfound;
}
function actback() {
	//alert("Your Account is not Created");
	document.getElementById("actinfotbl").style.visibility="hidden";
	document.getElementById("acttbl").style.visibility="visible";
	document.getElementById("actinfo").style.visibility="visible";
}
//This Function will load the combo options by selecting DTH or Mobile Number
function choosemode(getid)
{	
	var rechtype = document.getElementById(getid).value;
	var sendrechtype = "rechtype="+encodeURI(rechtype);
	ajaxpost('php/rechtype.php',sendrechtype,choosemode_callback);
}
function choosemode_callback()
{
	if (xmlobject.readyState==4 || xmlobject.readyState=="complete")
	{
		var getrechtype = xmlobject.responseText;
		document.getElementById("loadservprov").innerHTML=getrechtype;
	}
}
