var xmlhttp;

function getapplication(lang,engid,ct,ul,rw)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
 var url="getapplication.php";
url=url+"?lang="+lang+"&engid="+engid+"&con="+ct+"&ul="+ul+"&rw="+rw;;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
	document.getElementById("txtHint").innerHTML="<h5>Page Loading</h5>"
if (xmlhttp.readyState==4)
{

	//alert(id+" "+engid)//alert(xmlhttp.responseText);
	var result=xmlhttp.responseText;
	//alert("value of result"+result)
	var doc=result.split("###",4);
	var ids=doc[0].split("$$",2);
	//alert(doc[1]);
	//alert(ids[0])
	//alert(ids[1])
	
		
document.getElementById("txtHint").innerHTML=doc[1];
for(var j=1;j<=doc[3]-1;j++)
	{
	if(j==doc[2])
		{
		//alert("in if"+j)
document.getElementById(j).className="current"
		}else{
			//alert("out of if"+j)
document.getElementById(j).className=""
		}
	}
document.getElementById("rtid").value=ids[0];
document.getElementById("rtenid").value=ids[1];
initLightbox();
//alert("in lightbox")

}
}

//popup
function stateChanged1() 
{ 
	if (xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete")	{ 
		document.getElementById("somediv").style.display="";
		document.getElementById("somediv").innerHTML="";
		document.getElementById("somediv").innerHTML="<div id='somediv_val' class='popupbg'>"+xmlHttp1.responseText+"</div>"			
		divwin=dhtmlwindow.open('divbox', 'div', 'somediv', 'Save Wishlist', 'width=300px,left=380px,top=200px,height=150px,scrolling=0'); 
	} 
}

//session start
function getsession(lang,engid,ct,id)
{
	//alert("in session")
xmlhttp1=GetXmlHttpObject();
if (xmlhttp1==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var part=document.getElementById(id).value;
var q="q"+id;
var qty=document.getElementById(q).value;
  var url="session_cart_aj.php";
 url=url+"?eid="+engid+"&cart=add&lang="+lang+"&selectp="+part+"&qty="+qty
//url=url+"?lang="+lang+"&engid="+engid+"&con="+ct;
url=url+"&sid="+Math.random();

//window.location.href="session_cart_aj.php?eid="+eid+"&cart=add&lang=<?=$lang?>&selectp="+value

xmlhttp1.onreadystatechange=stateChangedsess;
xmlhttp1.open("GET",url,true);
xmlhttp1.send(null);
}
//session close


function stateChangedsess()
{
	document.getElementById("msg").innerHTML="<table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='25' >&nbsp;</td></tr><tr><td height='1' bgcolor='#ffffff'><img src='images/paper.gif' width='1' height='1'></td> </tr> <tr> <td height='40' bgcolor='#ffffff' class='product'><div align='center'>	<p style='font-size:11px; font-family:Arial, Helvetica, sans-serif;'><img src='js/loading.gif'></p></div></td></tr></table></div>";		
		agewindow=dhtmlwindow.open('agebox', 'span', 'msg', 'Processing..!', 'width=250px,height=5px,center=1,resize=0,scrolling=0'); 
if (xmlhttp1.readyState==4)
{
		document.getElementById("mydiv1").innerHTML="";
		document.getElementById("mydiv1").innerHTML=xmlhttp1.responseText;
		//document.getElementById("mydiv1").innerHTML="<table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='25' >&nbsp;</td></tr><tr><td height='1' bgcolor='#ffffff'><img src='images/paper.gif' width='1' height='1'></td> </tr> <tr> <td height='40' bgcolor='#ffffff' class='product'><div align='center'>	<p style='font-size:11px; font-family:Arial, Helvetica, sans-serif;'>"+xmlhttp1.responseText+"<br/><br/><input type='button' name='continue' value='Continue Shopping' onclick='fnclose()'><input type='button' name='check' value='View Shopping Cart' onclick='fncheckout()'></p></div></td></tr></table></div>";	
		//agewindow=dhtmlmodal.open('agebox', 'div', 'mydiv1', 'Congratulations', 'width=500px,left=250px,top=250px,height=50px,scrolling=0'); 
		agewindow=dhtmlmodal.open('agebox', 'span', 'mydiv1', 'Congratulations', 'width=500px,height=50px,center=1,resize=0,scrolling=0'); 
		//document.write("<div id='mydiv1' style='display:none;' ></div>");
		//window.open ("alert.php","mywindow","menubar=1,resizable=1,width=350,height=250"); 
		 
	/*//alert("value of result"+result)
	var doc=result.split("###",2);
	var ids=doc[0].split("$$",2);
	//alert(doc[1]);
	//alert(ids[0])
	//alert(ids[1])
document.getElementById("txtHint").innerHTML=doc[1];
document.getElementById("rtid").value=ids[0];
document.getElementById("rtenid").value=ids[1];*/
}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}
