// part of ajax
var xmlHttp

//function stateChanged(){

//key for ready state
//0=uninitialized
//1=loading
//2=loaded
//3=interactive
//4=complete
// if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
	//set the div you wan the results to show up in
// document.getElementById("txtHint").innerHTML=xmlHttp.responseText
	//alert ("here");
// }
//}

function GetXmlHttpObject(){
var objXMLHttp=null
	if (window.XMLHttpRequest){
	objXMLHttp=new XMLHttpRequest()
	}else if (window.ActiveXObject){
	objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
return objXMLHttp
}

// ************ dont modify above this comment ****************//


//this is for adding to itinerary

function addrecord(mtgid,datestr,st,et,wd,evt,room,crs,yesno,conflict) {

// params
// mtgid = Unique Event ID (I'll assure this)
// datestr = Date string (YYYYMMDD)
// st = Start time of event (military)
// et = End time of event (military) minus one minute
// wd = day of event
// evt = Event Time (for display)
// room = where the course is
// crs = Course Description
// yesno = this is return value whether to add course or not if there is a conflict (0 or yes)
// conflict = perform Conflict resolution  (1 or 0)

//for navigation
currentbody = "'"+unescape(top.body.document.URL)+"'";
top.currentpage = '../'+currentbody.substring(currentbody.indexOf('~')+2,currentbody.length-1);
xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
	alert ("Browser does not support HTTP Request")
	return
	}

//sets processing page
var url = "addtocart.asp?mtgID="


	var myRandom = parseInt(Math.random()*99999999);  // cache buster

	xmlHttp.onreadystatechange=handleHttpResponseaidtype;

	xmlHttp.open("GET", url + escape(mtgid) +"&datestr=" + escape(datestr) +"&st=" + escape(st) +"&et=" + escape(et) + "&wd=" + escape(wd) + "&evt=" + escape(evt) + "&room=" + escape(room) + "&crs=" + escape(crs) + "&yesno=" + escape(yesno) + "&conflict=" + escape(conflict) +"&rand=" + myRandom, true);
	xmlHttp.send(null)

}


// results returned
function handleHttpResponseaidtype() {
	 if (xmlHttp.readyState == 4) {


	msg=xmlHttp.responseText.split('|');

	//split response and assign to vars
	msgtext=msg[0];
	strmsg=msg[1];
	if (msgtext=="conflict" ||msgtext==""){
	//alert ("there is a time conflict");
	document.write(strmsg);

	}else if (msgtext=="login"){

	msg=xmlHttp.responseText.split('|');

	//split response and assign to vars
	msgtext=msg[0];
	mtgid=msg[1];
	datestr=msg[2];
	st=msg[3];
	et=msg[4];
	tttt=msg[5];
	evt=msg[6];
	room=msg[7];
	crs=msg[8];
	yesno=msg[9];
	conflict=msg[10];
	strmsg=msg[11];

	//alert ("please login");
//alert('../usrlogin.asp?mtgid='+mtgid+'&datestr='+datestr+'&st='+st+'&et='+et+'&wd='+tttt+'&evt='+evt+'&room='+room+'&crs='+crs+'&yesno=yes&conflict='+conflict+'');
top.body.location.replace('usrlogin.asp?mtgid='+mtgid+'&datestr='+datestr+'&st='+st+'&et='+et+'&wd='+tttt+'&evt='+evt+'&room='+room+'&crs='+crs+'&yesno=yes&conflict='+conflict+'');


	}else if (msgtext=="done"){
	//alert ("item was added");

	top.ttop.document.images['but8'].src = 'images/but8h.gif';
	//call the timer function
	InitializeTimer()

		}
//use for debugging
	else{

	alert (msgtext);	}

	}//end if
}//end handleHttpResponseaidtype function


function disableconflict(con) {


xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
	alert ("Browser does not support HTTP Request")
	return
	}

//sets processing page
var url = "disableconflict.asp?disconflict="


	var myRandom = parseInt(Math.random()*99999999);  // cache buster

	xmlHttp.onreadystatechange=conflictdisabled;

	xmlHttp.open("GET", url + escape(con) +"&rand=" + myRandom, true);
	xmlHttp.send(null)

}

// resluts returned
function conflictdisabled() {
	 if (xmlHttp.readyState == 4) {


	msgd=xmlHttp.responseText.split('|');
	msgtxtd=msgd[0];
	path=msgd[1];

	}
	if (msgtxtd=="done"){
//msgd=xmlHttp.responseText.split('|');

//msgtxtd=msgd[0];

// alert ("conflict resolution has been disabled");

	top.ttop.document.images['but8'].src = 'images/but9h.gif';

	//call the timer function
	InitializeTimer()
currentbody = "'"+unescape(top.body.document.URL)+"'";
top.currentpage = '../'+currentbody.substring(currentbody.indexOf('~')+2,currentbody.length-1);
top.body.location.replace(top.currentpage);




	}

}//end if




function hideme(){

	 document.getElementById("statusmsg").style.visibility="hidden";

}

function nextpage(url){

	 window.location=url;
}


//timer stuff for displaying/hiding event added image

var secs
var timerID = null
var timerRunning = false
var delay = 1000

function InitializeTimer()
{
	 // Set the length of the timer, in seconds
	 secs = 2
	 StopTheClock()
	 StartTheTimer()
}

function StopTheClock()
{
	 if(timerRunning)
		  clearTimeout(timerID)
	 timerRunning = false
}

function StartTheTimer()
{
	 if (secs==0)
	 {
		  StopTheClock()
 //change image back to original state
		top.ttop.document.images['but8'].src = 'images/spacer.gif';

	 }
	 else
	 {
		  self.status = secs
		  secs = secs - 1
		  timerRunning = true
		  timerID = self.setTimeout("StartTheTimer()", delay)
	 }
}

