// Tutorial Launch page Javascript

// A simple open window function
function openWindow(url, name, myWidth, myHeight){
	xloc = screen.width/2 - ( myWidth/2);
	yloc = screen.height/2 - (myHeight/2);
	window.open(url,null, 'height=' + myHeight + ', width=' + myWidth + ',status=no,toolbar=no,menubar=no,location=no,left=' + xloc + ',top=' +yloc);
}


// openCourseWindow function opens the player window
// url - path to player html file
// flcourseid - path to flash course folder
// audio - boolean value that tells the player if there is audio (V.1.1 of tutorial player)
function openCourseWindow(url, flcourseid, audio){
	/*Cox Tracking
		newUrl = url+"?flcourseID=" + flcourseid + "&userid=" + userid + "&courseID=" + CourseID + "&unitID=" + UnitID
	*/
	if(!audio){
		audio = 0;
	}
	newUrl = url+"?flcourseID=" + flcourseid + "&playAudio=" + audio + "&userid=" + 'guest' + "&courseID=" + CourseID 
	openWindow(newUrl, "Course Player", "742", "545");
}


//********************************************************************************
/*
	COX TRACKING
	In order to get the values for the user, unit and course, 
	the custom course will need to use the following functions or something similar. 
*/

//Retrieves the QueryString value for the user_id.
function GetUserID(){
	var str = new String (self.location.href);
	var theleft = str.indexOf('user_id') + 8;
	var theright = str.indexOf('&', theleft);
//alert('substring' + str.substring(theleft, theright));
	return(str.substring(theleft, theright));
}
//Retrieves the QueryString value for the course_id.
function GetCourseID(){
	var str = new String (self.location.href);
	var theleft = str.indexOf('course_id') + 10;
	//Since the course_id is the last value, we don't need a right end point.
	return(str.substring(theleft));
}
//Retrieves the QueryString value for the material_id.
function GetUnitID(){
	var str = new String (self.parent.location.href);
	var theleft = str.indexOf('material_id') + 12;
	var theright = str.indexOf('&', theleft);
	//alert('substring' + str.substring(theleft, theright));
	return(str.substring(theleft, theright));
}

var userid = GetUserID()
var CourseID = GetCourseID()
var UnitID = GetUnitID()

//DEUBG VALUES
//var userid = "userID_test"
//var CourseID = "courseID_test"
//var UnitID = "unitID_test"

var rNum = 0;
function addNumber(){
	rNum++
	return document.write(rNum);
}
// END COX TRACKING *******************************************************************