/*------------Current order function--------
//Description: This function helps to show the current order window.
----------------------------------------------------------------*/
function showlayer(getid)
{
    document.getElementById(getid).style.visibility = "visible";
	//getcurrentorder();
}
function setext(getid)
{
    document.getElementById(getid).style.color = "#ffcc33";
}
function defaultext(getid)
{
    document.getElementById(getid).style.color = "#FFFFFF";
}
/*------------order history function--------
//Description: This function helps to show the order history window.
----------------------------------------------------------------*/
function hidelayer(getid)
{
	document.getElementById(getid).style.visibility = "hidden";
}
function closebox(closeid)
{
        document.getElementById(closeid).style.visibility = "hidden";
		show_rcpanel();
}
function showdiv(getid)
{
        document.getElementById(getid).style.visibility = "visible";
}
function hidediv(getid)
{
        document.getElementById(getid).style.visibility = "hidden";
}
function hide_rcpanel()
{
        document.getElementById("memrechargepanel").style.zIndex="-1";
        document.getElementById("idrechargeform").style.zIndex="-1";
        document.getElementById("idmemstatustracker").style.zIndex="-1";
        document.getElementById("ezservprov").style.visibility = "hidden";
        document.getElementById("ezlocation").style.visibility = "hidden";
        document.getElementById("cendivider").style.zIndex="-1";
        document.getElementById("crntorders").style.zIndex="-1";
        document.getElementById("ordershis").style.zIndex="-1";
}
function show_rcpanel()
{
        document.getElementById("memrechargepanel").style.zIndex="0";
        document.getElementById("idrechargeform").style.zIndex="0";
        document.getElementById("idmemstatustracker").style.zIndex="-1";

		var checkvisible = document.getElementById("idrechargeform").style.visibility;
		if(checkvisible == "visible")
		{
			document.getElementById("ezservprov").style.visibility = "visible";
			document.getElementById("ezlocation").style.visibility = "visible";
		}
        document.getElementById("cendivider").style.zIndex="0";
        document.getElementById("crntorders").style.zIndex="0";
        document.getElementById("ordershis").style.zIndex="0";
}
function setmemmobno(mobno)
{
	document.getElementById("ezmobno").value = mobno;
	memmobloc('ezmobno');
	document.getElementById("ezservprov").focus();
}
//This Function Counts the No of Characters in a  SMS Text Area
function countsmschar(counttext,countsmsbody,smsmaxSize)
{
        var smscontedtext = counttext ? counttext : "smstext";
        var smscountedbody = countsmsbody ? countsmsbody : "countresult";
        var maxchar = smsmaxSize ? smsmaxSize : 160;
        var smscharlength = document.getElementById(smscontedtext);
        if (smscharlength && smscharlength.value.length >= maxchar)
		{
				alert("Maximum 160 Characters exceeds");
				smscharlength.value = smscharlength.value.substring(0, maxchar);
        }
        var loadnochar = document.getElementById(smscountedbody);
		if (loadnochar)
		{ 
			loadnochar.innerHTML = smscharlength.value.length;
        }
}
//This function will send the sms from their sms credit
function memezsms(getsmsmobno,getsmsbody)
{
	if(document.getElementById("sendsmsmail").checked)
	{
		//alert("hi");
		var smsmobno = document.getElementById(getsmsmobno).value;
		var smsbody = document.getElementById(getsmsbody).value;
		if((smsmobno != "")&&(smsbody != ""))
		{
			var sendezsms = "sendsmsmail="+"&smsmobno="+encodeURI(smsmobno)+"&smsbody=" +encodeURI(smsbody);
			ajaxpost('php/memezsms.php',sendezsms,memezsms_callback);
		}
		else
		{
			alert("Please fill the Blank Fields");
		}
	}
	else
	{
		var smsmobno = document.getElementById(getsmsmobno).value;
		var smsbody = document.getElementById(getsmsbody).value;
		if((smsmobno != "")&&(smsbody != ""))
		{
			var sendezsms = "smsmobno="+encodeURI(smsmobno)+"&smsbody=" +encodeURI(smsbody);
			ajaxpost('php/memezsms.php',sendezsms,memezsms_callback);
		}
		else
		{
			alert("Please fill the Blank Fields");
		}	
	}
}
function memezsms_callback()
{
	if (xmlobject.readyState==4 || xmlobject.readyState=="complete")
	{
		//get the return value from php
		//alert(xmlobject.responseText)
		var updatesmscredit = xmlobject.responseText;
		//alert(updatesmscredit);
		if(updatesmscredit =="0")
		{
			document.getElementById("smscreditvalue").innerHTML = updatesmscredit;
			document.getElementById("smsrespup").innerHTML = updatesmscredit;
			document.getElementById("respsms").innerHTML = "Insufficient SMS Credits";
			document.getElementById("respsms").style.color = "#ff0000";
			document.getElementById("smsto").value = "";
			document.getElementById("smstext").value = "";			
		}
		else
		{
			document.getElementById("smscreditvalue").innerHTML = updatesmscredit;
			document.getElementById("smsrespup").innerHTML = updatesmscredit;
			document.getElementById("respsms").innerHTML = "SMS Sent";
			document.getElementById("smsto").value = "";
			document.getElementById("smstext").value = "";
		}
	}
}
function clrscr()
{
	document.getElementById("respsms").innerHTML = "";
}
function chksmspack()
{
	if(document.getElementById("ezsms100").checked)
	{
		return true;
	}
	else if(document.getElementById("ezsms500").checked)
	{
		return true;
	}
	else if(document.getElementById("ezsms1000").checked)
	{
		return true;
	}else
	{
		alert("Please Select the ezSMS pack"); 
		return false;
	}
}