

// stores the reference to the XMLHttpRequest object
var xmlHttp = createXmlHttpRequestObject();
// retrieves the XMLHttpRequest object
function createXmlHttpRequestObject()
{
// will store the reference to the XMLHttpRequest object
var xmlHttp;
// if running Internet Explorer
if(window.ActiveXObject)
{
try
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
xmlHttp = false;
}
}
// if running Mozilla or other browsers
else
{
try
{
xmlHttp = new XMLHttpRequest();
}
catch (e)
{
xmlHttp = false;
}
}
// return the created object or display an error message
if (!xmlHttp)
alert("Error creating the XMLHttpRequest object.");
else
return xmlHttp;
}

function subm(sor)
{
	
var jayy=document.getElementById("sor").checked;
var jayy2=document.getElementById("sor1").checked;
if(jayy==true){
sor=1;
var end = '<b>RS</b>';
}
else if(jayy2==true){

sor=2;
var end = '<b>SMS</b>';
}
else{
sor='';
}
document.getElementById("rr").innerHTML='<img src = "images/spinner_small.gif">';
	var amt=document.getElementById("amt").value;
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
{
xmlHttp.open("GET", "apppro2.php?sor=" + sor+"&amt="+amt+"&fun=meter", true);
xmlHttp.onreadystatechange = handleServerResponse;
xmlHttp.send(null);
}
else
setTimeout("subm()", 4000);
}
function process(){	
	var subject=document.getElementById("subject").value;
	var name=document.getElementById("name").value;
	var service=document.getElementById("service").value;
	var email=document.getElementById("email").value;
	var ph=document.getElementById("ph").value;
	var msg=document.getElementById("msg").value;
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
{
	//alert("msg="+msg+"&ph="+ph+"&subject="+subject+"&service="+service+"&email="+email);
xmlHttp.open("GET", "apppro2.php?msg="+msg+"&ph="+ph+"&subject="+subject+"&service="+service+"&email="+email+"&cont_sub="+'yes'+"&name="+name, true);
xmlHttp.onreadystatechange = handleServerResponse2;
xmlHttp.send(null);
}
else
setTimeout("process()", 4000);
}

function handleServerResponse()
{
// move forward only if the transaction has completed
if (xmlHttp.readyState == 4)
{
// status of 200 indicates the transaction completed successfully
if (xmlHttp.status == 200)
{
// extract the XML retrieved from the server

//alert(xmlHttp);

var xmldocs=xmlHttp.responseXML.documentElement;
var j=xmldocs.getElementsByTagName("result")[0];

if(j.childNodes[0].nodeValue!='xxx'){
	var k=j.getElementsByTagName("res1")[0].childNodes[0].nodeValue;
	var l=j.getElementsByTagName("res2")[0].childNodes[0].nodeValue;
	var m=j.getElementsByTagName("mid")[0].childNodes[0].nodeValue;
	var type=j.getElementsByTagName("type")[0].childNodes[0].nodeValue;
if(type==1){
var str = '<div class="res1" style="border:thin; border-color:#000000; border-style:solid"><b>'+k+'&nbsp;'+m+'&nbsp;'+l+'&nbsp;RS</b></div>';
}
else{var str = '<div class="res2" style="border:thin; border-color:#000000; border-style:solid"><b>'+k+'&nbsp;'+m+'&nbsp;'+l+'&nbsp;SMS</b></div>';}

}else{
var str  = '<div class="res2" style="border:thin; border-color:#000000; border-style:solid"><b>You did not enter any value</b></div>'
}
document.getElementById("result").innerHTML=str;
document.getElementById("rr").innerHTML='';

}
// a HTTP status different than 200 signals an error
else
{
alert("There was a problem accessing the server: " + xmlHttp.statusText);
}
}
}
function handleServerResponse2()
{
// move forward only if the transaction has completed
if (xmlHttp.readyState == 4)
{
// status of 200 indicates the transaction completed successfully
if (xmlHttp.status == 200)
{
// extract the XML retrieved from the server

//alert(xmlHttp);
var xmldocs=xmlHttp.responseXML.documentElement;
var j=xmldocs.getElementsByTagName("mail")[0];


if(j.childNodes[0].nodeValue=='mail sent'){
	document.getElementById("res").innerHTML='<table width="341" border="0" align="center" bgcolor="#FF9933"><tr><td height="199" colspan="2" valign="top"><p>Your message has been sent to our Customer supportOur customer care executive will contact you as soon as possible  </p><p>&nbsp;</p><p>Thanks</p><p>Cellnxt.in</p></td></tr></table>';
	
	
	}

}
// a HTTP status different than 200 signals an error
else
{
alert("There was a problem accessing the server: " + xmlHttp.statusText);
}
}
}

function minimise(){
document.getElementById("sms").innerHTML='<table width="200"  style="background:url(images/initial_gradient.gif);color:#000000;" border="0"><tr ><td width="165"><b>&nbsp;SMS METER</b><div id ="rr" class="pos_fixed"></div></td><td width="25"><img src="images/icon_min.png" alt="Maximize" onClick="maximise()"  style="cursor:pointer"></td></tr></table>';
}
function maximise(){
document.getElementById("sms").innerHTML='<div id="sms" class="pos_fixed"><table width="200" border="0" style="color:#000000;background:url(images/initial_gradient.gif);"><tr><td width="130">&nbsp;<b>SMS METER</b></td><td width="30"><div id ="rr" ></div></td><td width="26"><img src="images/icon_max.png" alt="Minimize" onClick="minimise()"  style="cursor:pointer"></td></tr></table><div class="outres">&nbsp;<input id="amt" name="amt" type="textfield" onKeyUp="subm();"><br>&nbsp;SMS<input type="radio" name="sor" id="sor"  value="5" checked="checked" onChange="subm('+"'"+'1'+"'"+')"> &nbsp;&nbsp;&nbsp;RS<input type="radio" name="sor" id="sor1" value="9" onChange="subm('+"'"+'2'+"'"+');"><!-- <input type="submit" value="Refresh"> --><div id="result" class="resul"></div></form> </div></div>';


}
function maximise1(){

document.getElementById("cc").innerHTML='<table width="200px" border="0" style="background:url(images/initial_gradient.gif);color:#000000; background-repeat:no-repeat;" ><tr ><td height="31" colspan="2" >&nbsp;<b>CUSTOMER CARE</b></td><td height="31" ><b><img src="images/icon_max.png" align="right" alt="Minimise" onclick="minimise1() "  style="cursor:pointer"/></b></td></table><div id="rr1"><embed src="http://w.digsby.com/dw.swf?c=fose1iyvjvht3qo0" type="application/x-shockwave-flash" wmode="transparent" width="200" height="300"></embed><div id="Layer1"><img src="images/logo.png" width="100%" height="100%" alt="sdsdsd" /></div></div>';

}
function minimise1(){
document.getElementById("cc").innerHTML='<table width="200" border="0" style="background:url(images/initial_gradient.gif);color:#000000;  background-repeat:no-repeat;" ><tr ><td height="31" colspan="2" >&nbsp;<b>CUSTOMER CARE</b></td><td height="31" ><b><img src="images/icon_min.png" align="right" alt="Maximise" onclick="maximise1()"  style="cursor:pointer"/></b></td></table>';
}



