//Copyright © Vega Information Systems.
//::::::: VERSION 1.0 :::::::


//Global variables
var errorMes='Launch Failed!'+'\nCheck your browser version and screen resolution';
var scrRes=screen.width;
var url='crc/index.html'
var url1='index.html';
var setName="vega";
var setPass="vega";

//Set the rubric if the student's score feedback needs to be included
var feedBack80='' // When score is more than 80%
var feedBack60='' // When score is more than 60% and less than 80%
var feedBack40='' // When score is less than 60%


//var setCookie;

function setCookie(name,data)
{
	var cookieEnabled=(navigator.cookieEnabled)? true : false

	//if not IE4+ nor NS6+
	if(typeof navigator.cookieEnabled=="undefined" && !cookieEnabled)
	{ 
		alert('cookies not enabled');
	}
	else
	{
		var cookieName=name;
		document.cookie=cookieName+'='+data;
	}
}

var cook = new setCookie("location", document.location);
var navwindow;
//function to open Notes page
function openNotes(fileName)
{
	navwindow=window.showModelessDialog("crc"+fileName+"notes.html","navwindow","dialogHeight: 340px; dialogWidth: 250px; dialogTop: 240px; dialogLeft: 620px; padding-top: 10px; edge: Raised; center: no; help: No; resizable: Yes; status: no; ");

}

//function to open Examples page
function openEg(fileName)
{
	navwindow=window.open("crc"+fileName+"example.html","navwindow","width=250,height=400,screenX=20,left=670,screenY=0,top=240,scrollbars=yes,menubar=no,status=no,resizable=no,statusbar=no,toolbar=no")
}

//function to open Audio Script page
function openVoice(fileName)
{
	
	navwindow=window.showModelessDialog("crc"+fileName+"voice.html","navwindow","dialogHeight: 250px; dialogWidth: 350px; dialogTop: 218px; dialogLeft: 535px; padding-top: 10px; edge: Raised; center: no; help: No; resizable: Yes; status: no; ");
	
}

//function to open the requested question 
function openQuestion(Qno)
{
	navwindow=window.open("crc"+fileName+"notes.html","navwindow","width=250,height=240,screenX=20,left=620,screenY=0,top=240,scrollbars=yes,menubar=no,status=no,resizable=no,statusbar=no,toolbar=no")

}

function openTips(fileName)
{
	navwindow=window.showModelessDialog("crc"+fileName+"tips.html","navwindow","dialogHeight: 250px; dialogWidth: 400px; dialogTop: 240px; dialogLeft: 570px; padding-top: 10px; edge: Raised; center: no; help: No; resizable: Yes; status: no; ");
}
	
function showHelp()
{
	navwindow=window.open("crc/help.html","navwindow","width=400,height=400,screenX=20,left=470,screenY=0,top=240,scrollbars=yes,menubar=no,status=no,resizable=no,statusbar=no,toolbar=no")
}

function openModule(no)
{
	fileName='crc'+no+'.html';
	window.open(fileName,"main");
	//top.main1.history.go(0);
	return false;
}

//Image swap function
function swapImages(imageNo)
{
	var imgName = "rollover"+imageNo	
			
	if (document.images)
		{
			swap = new Image
			swap.src = "../../images/swap/swap"+imageNo+".gif"
			document.images[imgName].src=swap.src
		}
		
	
 }


//Image restore function
function revSwap(imageNo)
{
	var imgName = "rollover"+imageNo
	
	 
		 if(document.images)
		{
			unswap = new Image
			unswap.src = "../../images/swap/unswap"+imageNo+".gif"
			document.images[imgName].src=unswap.src
		}
	 
 }

var r1,r2,r3,slider;

 function onBeforePrint()
 {
	 if(document.getElementById("rollover1"))
		r1=document.getElementById("rollover1").style.visibility;
	 if(document.getElementById("rollover2"))
		 r2=document.getElementById("rollover2").style.visibility;
	 if(document.getElementById("rollover3"))
		 r3=document.getElementById("rollover3").style.visibility;
	 if(document.getElementById("myMovieName"))
		slider=document.getElementById("myMovieName");
	 
	 if(document.getElementById("rollover1"))
	 {
	 document.getElementById("rollover1").style.visibility="hidden";
	 }
	 if(document.getElementById("rollover2"))
		 document.getElementById("rollover2").style.visibility="hidden";
	 if(document.getElementById("rollover3"))
		document.getElementById("rollover3").style.visibility="hidden";
	 if(document.images["rollover4"])
		 document.images["rollover4"].style.visibility="hidden";
	 if(document.images["rollover5"])
		 document.images["rollover5"].style.visibility="hidden";
	 //document.body.style.marginLeft="-10px";
	 //document.body.style.width="80%";
	 document.body.style.innerWidth="200";
	 if(slider)
		slider.style.visibility="hidden";
	 if(document.getElementById("win"))
	 {
		document.getElementById("win").className="divClassOff";
	 }
	
 }
 
 function afterPrint()
 {
	 if(document.getElementById("rollover1"))
	 {
	 document.getElementById("rollover1").style.visibility=r1;
	 document.getElementById("rollover3").style.visibility=r3;
	 }

	 if(document.getElementById("rollover2"))
	 {
		document.getElementById("rollover2").style.visibility=r2;	 
	 }
	 if(document.images["rollover4"])
	 {
		document.images["rollover4"].style.visibility="visible";
		document.images["rollover5"].style.visibility="visible";
	 }
	 
	 if(slider)
		 slider.style.visibility="visible";
	 if(document.getElementById("win"))
	 {
		document.getElementById("win").className="divClassOn";
	 }
 }
 
 function printPage()
 {
	 onBeforePrint();
	 window.print();
	 afterPrint();
 }


function openTest(no)
{
	filename='selfTest'+no+'_1.html';
	window.open(filename,'_self');
}
 

//Button Disable function
function disableButton(imgNo)
{
	var img1 = ' <img src="../../images/swap/greyed1.gif" name="rollover1" id="rollover1" style="visibility: hidden;">'
	var img2 = ' <a href="#"  onMouseOver="swapImages(2)" onMouseOut="revSwap(2)" onClick="printPage()"><img src="../../images/swap/unswap2.gif" name="rollover2" id="rollover2" alt="Print this page" border="0" style="visibility: visible;"></a>'
	var img3 = ' <img src="../../images/swap/greyed3.gif" name="rollover3" id="rollover3" style="visibility: hidden;">'
	

		if(imgNo==1)
		{
			document.write(img1)
		}
		else if(imgNo==2)
		{
			document.write(img2)
		}
		else if(imgNo==3)
		{
			document.write(img3)
		}		
}

//Button Enable function
function enableButton(imgNo,fileName)
{
	var file="'"+fileName+"'" //String sent from openNotes() shud have '' 

	var img1 = '<a href="#" onMouseOver="swapImages(1)" onMouseOut="revSwap(1)" onClick="openNotes('+file+')"><img src="../../images/swap/unswap1.gif" name=rollover1 id=rollover1 alt="Notes" border="0"></a>';
	
	var img2 = '<a href="#" onMouseOver="swapImages(2)" onMouseOut="revSwap(2)" onClick="openEg('+file+')"><img src="../../images/swap/unswap2.gif" name=rollover2 id=rollover2 alt="Print this page" border="0"></a>';

	var img3 = '<a href="#" onMouseOver="swapImages(3)" onMouseOut="revSwap(3)" onClick="openVoice('+file+')"><img src="../../images/swap/unswap3.gif" name=rollover3 id=rollover3 alt="Audio Script" border="0"></a>';

		
		if(imgNo==1)
		{
			document.write(img1);
			
		}
		else if(imgNo==2)
		{
			document.write(img2);
		}
		else if(imgNo==3)
		{
			document.write(img3);
		}

}


//function to check for browser version
function browserCheck()
{
	var detect = navigator.userAgent.toLowerCase();
	var OS,browser,version,total,thestring;
	
	if (checkIt('konqueror'))
	{
		browser = "Konqueror";
		OS = "Linux";
	}

	else if (checkIt('msie')) browser = "Internet Explorer"
	else if (!checkIt('compatible'))
	{
		browser = "Netscape Navigator"
		version = detect.charAt(8);
		version=parseInt(version)+2;
	}
	else browser = "An unknown browser";

	if (!version) 
		version = detect.charAt(place + thestring.length);

	if (!OS)
	{
		if (checkIt('linux')) OS = "Linux";
		else if (checkIt('x11')) OS = "Unix";
		else if (checkIt('mac')) OS = "Mac"
		else if (checkIt('win')) OS = "Windows"
		else OS = "an unknown operating system";
	}

	function checkIt(string)
	{
		place = detect.indexOf(string) + 1;
		thestring = string;
		return place;
	}

	return version;
}


//function to open Javascript window
function openWin(URL)
{
	aWindow=window.open (URL,'awindow', 'height=740, width=1017, left=0, top=0, toolbar=no, menubar=no, scrollbar=yes, resize=yes, location=no, directories=no, status=no');
	aWindow.focus();

}

//function to launch the course from the launch page
function launchCourse()
{
	
	var b=navigator.appName;
	//var em='This course may not work properly in Netscape. Please view it in Internet Explorer v.6.0 or above.';
	
	if(browserCheck()>=6 && scrRes>=1024 && b=="Microsoft Internet Explorer")
	{
		document.write('<a href="#" onClick="openWin(url)"><img border="0" src="crc/images/Launch-Course.gif" width="207" height="32"></a>')
		
	}
	
	else
	{
		if(b=="Netscape")
		{
			errorMes='This course may not work properly in Netscape. Please install Internet Explorer v6.0 or above. Click on "Help" for assistance';
		}
		document.write('<a href="#" onClick="alert(errorMes)"><img border="0" src="crc/images/Launch-Course.gif" width="207" height="32"></a>')
				
	}
}


function launchCourse1(text,fontSize)
{
	
	var b=navigator.appName;
	
	if(browserCheck()>=6 && scrRes>=1024 && b=="Microsoft Internet Explorer")
	{
		document.write('<a href="#" onClick="openWin(url1)"><font size='+fontSize+'><b><u>'+text+'</u></b></font></a>')
		
	}
	else
	{
		if(b=="Netscape")
		{
			errorMes='This course may not work properly in Netscape. Please install Internet Explorer v6.0 or above. Click on "Help" for assistance';
		}
		
		document.write('<a href="#" onClick="alert(errorMes)"><font size='+fontSize+'><b>'+text+'</b></font></a>')
		
	}
}

function openAQ(pNo)
{
	var fName = "assess"+pNo+"_1.html"
	window.open(fName,"main");
	return true;
}

function noTurningBack()
{
	history.go(+1);
}



document.ondragstart = function()
{
	return false;
}

document.onselectstart = function()
{
	return false;
}



//Disable right click


var message="Function Disabled!";

function clickIE4(){
if (event.button==2){
//alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
//alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("return false")

