// JavaScript Document
function $(id) { return document.getElementById(id); }
function createXMLHttpRequest() 
 {
   try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
   try { return new XMLHttpRequest(); } catch(e) {}
   alert("XMLHttpRequest not supported");
   return null;
}
function dataLoading(id,str){
	$(id).innerHTML = '<table align="center"><tr><td style="background-color:#FFFFFF;border:2px solid #0D78AB; color:#000000; FONT-WEIGHT: bold; FONT-SIZE: 12px;" valign="middle" align="center" width="300px" height="150px"><img src="'+siteURL+'/images/progress_bar.gif" width="124" height="24" align="absmiddle">&nbsp;&nbsp;&nbsp;&nbsp;'+str+'</td></tr></table>';
}

var prospObj = createXMLHttpRequest();
function createDiv()
{
	var divObj = document.createElement("DIV");
	divObj.id = "divprospectus";
	divObj.style.left = '300px';
	divObj.style.top = '150px';
	divObj.style.position = 'absolute';
	divObj.style.display = '';
	divObj.style.zIndex = '1002';
	divObj.style.left = eval(getXCoord($("imgprospectus"))-275)+"px";
	divObj.style.top = eval(getYCoord($("imgprospectus"))-175)+"px";
	divObj.style.backgraoundColor = "#FF0000";
	document.body.appendChild(divObj);	
}
function showProspectus()
{
	if(!$("divprospectus"))
		createDiv();
	prospObj.open("GET", "prospectus.php", true);
	$("divprospectus").style.display = '';
	dataLoading("divprospectus","Loading....");
	prospObj.onreadystatechange = onProspectusResponse;
	prospObj.send(null);	
}
function onProspectusResponse()
{
	if (prospObj.readyState != 4)  { return; }
	var serverResponse = prospObj.responseText;
	$("divprospectus").innerHTML = serverResponse;
}

function closeProspectus()
{
	if($("divprospectus"))
		document.body.removeChild($("divprospectus"));
}

function postProspectus(frm)
{
	var qrystr = "txtname="+frm.txtname.value;
	qrystr += "&txtmobile="+frm.txtmobile.value;
	qrystr += "&txtemail="+frm.txtemail.value;
	prospObj.open("POST", siteURL+"/sendProspectus.php", true);
	prospObj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	$("innerDivProspectus").style.display = '';
	dataLoading("innerDivProspectus","Loading....");
	prospObj.onreadystatechange = onPostProspectusResponse;
	prospObj.send(qrystr);	
}
function onPostProspectusResponse()
{
	if (prospObj.readyState != 4)  { return; }
	var serverResponse = prospObj.responseText;
	$("innerDivProspectus").innerHTML = serverResponse;
}

function check_prospectus(frm)
{
	if(frm.txtname.value == '')
	{	
		alert("Name should not be empty");
		frm.txtname.focus();
		return;
	}
	if(!isValidPhone(frm.txtmobile, 'Mobile Number', 'yes'))
		return;
	if(!isValidEmail(frm.txtemail, 'yes'))
		return;
	postProspectus(frm);
}

function createDivProfile()
{
	var divObj = document.createElement("DIV");
	divObj.id = "divpprofile";
	divObj.style.left = '400px';
	divObj.style.top = '250px';
	divObj.style.position = 'absolute';
	divObj.style.display = '';
	divObj.style.zIndex = '1002';
	divObj.style.left = "150px";
	divObj.style.top = "100px";
	divObj.style.backgraoundColor = "#FF0000";
	document.body.appendChild(divObj);	
}

function view_profile(id)
{
	if(isNaN(id))
		return;
	if(!$("divpprofile"))
		createDivProfile();

	var scrollArray = getScrollXY();
	$("divpprofile").style.top = eval(scrollArray[1]+50)+"px";
	prospObj.open("GET", "../recruiters/student_profile.php?id="+id, true);
	$("divpprofile").style.display = '';
	dataLoading("divpprofile","Loading....");
	prospObj.onreadystatechange = onViewProfile;
	prospObj.send(null);	
}
function onViewProfile()
{
	if (prospObj.readyState != 4)  { return; }
	var serverResponse = prospObj.responseText;
	$("divpprofile").innerHTML = serverResponse;
}

function closeProfile()
{
	if($("divpprofile"))
		document.body.removeChild($("divpprofile"));
}

function cart_func(id)
{
	if(!$("divpprofile"))
		createDivProfile();
	prospObj.open("GET", "../recruiters/student_profile.php?act=cart&id="+id, true);
	$("divpprofile").style.display = '';
	dataLoading("divpprofile","Loading....");
	prospObj.onreadystatechange = onViewProfile;
	prospObj.send(null);	
}