// JavaScript Document

var  lms_urlString_global;
var courseID;
var lessonNo;
function saveVideo(urlString)
{
		lms_urlString_global=urlString;
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
		  	xmlhttp=new XMLHttpRequest();
		}
		else
		{// code for IE6, IE5
		  	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=saveWatchedVideo;
		
		//Getting course ID
		var index = urlString.indexOf("course=", 0);
		index = index + 7;
		var to1= index +7;
		courseID = urlString.substring(index,to1);
		
		//Getting lesson number
		var index2 = urlString.indexOf("file=", 0);
		index2 = index2 + 5;
		var to2= index2 + 3;
		lessonNo = urlString.substring(index2,to2);
		
		function saveWatchedVideo()
		{
		  	if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
				//var urlString_text = lms_urlString_global;
				//document.getElementById(urlString_text).innerHTML=xmlhttp.responseText;
				//var res=xmlhttp.responseText;
				//document.write(res);
				//document.write("hi");
				
			}
		}
		
		xmlhttp.open("GET","/petromin/php/updateLessonsViewedCount.php?courseid="+courseID+"&lesson_no="+lessonNo,false);
		xmlhttp.send();
	//top.opener.document.location.reload();
		//document.getElementById(courseID+"-"+lessonNo).innerHTML='<img  class="checkmark" src="../../images/preview/gray_checkmark.jpg" alt="watched" border="0" align="left" title="watched" height="12" width="13" />';
		//top.document.getElementById(courseID+"-"+lessonNo).innerHTML='<img  class="checkmark" src="../../images/preview/lesson_checkmark.jpg" alt="watched" border="0" align="left" title="watched" height="12" width="13" />';
}
var old_window="";
function openWindow2(loc){
		var urlString=loc;
		saveVideo(urlString);
		old_window=window.open(loc,'','left=20,top=20,width=810,height=715,toolbar=0,resizable=0');
	
}
function openWindow3(loc){
	var urlString=loc;
	saveVideo(urlString);
	parent.location.href=loc;
	//top.opener.document.location.reload();
	top.opener.document.getElementById(courseID+"-"+lessonNo).innerHTML='<img  class="checkmark" src="/images/preview/gray_checkmark.jpg" alt="watched" border="0" align="left" title="watched" height="12" width="13" />';
}
	
function handleOver(name) { 
	switch(name){
		case 'Home':
				document.getElementById(name).src="/images/nav_home_over.jpg";
				break;
		case 'Pricing':
				document.getElementById(name).src="/images/nav_pricing_over.jpg";
				break;
		case 'GroupRate':
				document.getElementById(name).src="/images/nav_group_over.jpg";
				break;
		case 'Testimonials':
				document.getElementById(name).src="/images/nav_testimonials_over.jpg";
				break;
		case 'Certification':
				document.getElementById(name).src="/images/nav_certification_over.jpg";
				break;
		case 'About':
				document.getElementById(name).src="/images/nav_about_over.jpg";
				break;
		case 'Contact':
				document.getElementById(name).src="/images/nav_contact_over.jpg";
				break;	
	}
	return;
}

function handleOut(name) { 
 		switch(name)
		{
			case 'Home':
					document.getElementById(name).src="/images/nav_home.jpg";
					break;
			case 'Pricing':
					document.getElementById(name).src="/images/nav_pricing.jpg";
					break;
			case 'GroupRate':
					document.getElementById(name).src="/images/nav_group.jpg";
					break;
			case 'Testimonials':
					document.getElementById(name).src="/images/nav_testimonials.jpg";
					break;
			case 'Certification':
					document.getElementById(name).src="/images/nav_certification.jpg";
					break;
			case 'About':
					document.getElementById(name).src="/images/nav_about.jpg";
					break;
			case 'Contact':
					document.getElementById(name).src="/images/nav_contact.jpg";
					break;				
					
				
		}
			
		return;
}

