
//var requestedUsername='<%=session("myvar")%>';

 /**
 * The 3 functions below - disable_right_click(), check_mousekey, trap_events
 *		are for disabling the mouse right-click
 */
function disable_right_click(e) //right click not allowed
{
    var browser = navigator.appName.substring ( 0, 9 );
    var event_number = 0;
    if (browser=="Microsoft")
        event_number = event.button;
    else if (browser=="Netscape")
        event_number = e.which;
    if ( event_number==2 || event_number==3 )
    {        
		alert ("www.w3varsity.com");
        return (false);
    }
    return (true);
}

function fullScreen(theURL) {
window.open(theURL, '', 'fullscreen=no, scrollbars=1,height=540,width=700,top=0,left=0');
}

function check_mousekey ()
{
if(document.activeElement.name=="IeLabel1") return;
    var mouse_key = 93;
    var keycode = event.keyCode;
	/*if(event.ctrlKey) {
		if(document.activeElement.name=="textarea1" || document.activeElement.name=="txtEnter") return;
		window.clipboardData.clearData();		
		var clipmsg="Can't copy."; //(requestedUsername!=null?"Dear " + requestedUsername:"") + 
		window.clipboardData.setData("text",clipmsg);
		event.keyCode=0;    
	}  */    
    if ( keycode == mouse_key )		
        alert ( "www.w3varsity.com" );
    else if(keycode == 37){
		if(document.images["imgPrevPageNav"]!=null) document.images["imgPrevPageNav"].click();}       
	else if(keycode == 39){
		if(document.images["imgNextPageNav"]!=null) document.images["imgNextPageNav"].click();}
}

function navigationKeys(){
if(document.activeElement.name=="IeLabel1" || document.activeElement.name=="textarea1") return;
    var keycode = event.keyCode;
    if(keycode == 63 || keycode==191){
		if(document.images["imgHelp"]!=null) document.images["imgHelp"].click();}        
	else if(keycode == 73 || keycode == 105){
		if(document.images["imgIndex"]!=null) document.images["imgIndex"].click();}
	else if(keycode == 83 || keycode == 115){
		if(document.images["imgSearch"]!=null) document.images["imgSearch"].click();}
	else if(keycode == 67 || keycode == 99){
		if(document.images["imgChat"]!=null) document.images["imgChat"].click();}
	else if(keycode == 71 || keycode == 103){
		if(document.images["imgGlossary"]!=null) document.images["imgGlossary"].click();}
	else if(keycode == 81 || keycode == 113){
		if(document.images["imgQuery"]!=null) document.images["imgQuery"].click();}
	else if(keycode == 70 || keycode == 102){
		if(document.images["imgFaq"]!=null) document.images["imgFaq"].click();}
	else if(keycode == 80 || keycode == 112){
		if(document.images["imgPrint"]!=null) document.images["imgPrint"].click();}
	else if(keycode == 69 || keycode == 101){
		if(document.images["imgExit"]!=null) document.images["imgExit"].click();}
}

function trap_events()
{ 	
    var browser = navigator.appName.substring ( 0, 9 );    
    document.onmousedown = disable_right_click;	
    if ( browser == "Microsoft" ){		    
        document.onkeydown = check_mousekey;
    }
    else if ( browser == "Netscape" )
        document.captureEvents( Event.MOUSEDOWN );
}

function protectCopy(){
	window.clipboardData.clearData();
	var clipmsg="Dear " + requestedUsername + ", Don't try to copy.";
	window.clipboardData.setData("text",clipmsg);
	alert(window.clipboardData.getData());
}
//window.setInterval("protectCopy();",1);

////window.onload = trap_events;
////document.onload = formatCodeImgNoPop;
document.onkeydown = check_mousekey;
document.onkeypress = navigationKeys;
//window.onfocus = trap_events;

/**** End of trapping right-click *****/

/**
 * Draws the Continue and Exit buttons for the Introduction page of a course.
 * sContinuePath - filename of the next page ie the Index page of a course.
 */
function showContinueExit (sContinuePath) {

	document.write("<center><blockquote><blockquote>");
	document.write("<a href='"+ sContinuePath +"'><img src='/images/continue.gif' border=0></a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
	document.write("<a href='javascript:window.close()'><img src='/images/exit.gif' border=0></a>");
	document.write("</blockquote></blockquote></center>");

}

/**
 * Draws a status bar in the middle of navigation bar. and says 'x of y' below the bar.
 * nPresentPage - current page no. integer.
 * nTotalPages - total no of pages in a course.
 */
function drawBar (nPresentPage, nTotalPages, sPrevPath, sNextPath, sQuiz) {
	//var Username = <%=session("myvar")%>;
	var nPresent = nPresentPage*100/nTotalPages;
	var bar = "<table border='0' cellpadding='4' cellspacing='0'>" +
			"<tr><td valign='middle' align='center' bgcolor='#cccccc'>" +
			"<img src='/scripts/js/images/black.gif' width='"+ nPresent/1.3 +"' height='12'></img>" +
			"<img src='/scripts/js/images/white.gif' width='"+ (100-nPresent)/1.3 +"' height='12'></img>" +
			"<br>" +
			"<a href='"+ sPrevPath +"'><img align='middle' name=imgPrevPageNav src='/scripts/js/images/previousSmall.jpg' border=0 alt='Previous page'></img></a>&nbsp;" +
			"<font size='-2' color='black'>"+ nPresentPage +" of "+ nTotalPages +"</font>&nbsp;" 

	if(sNextPath == ".")
	{	
		bar = bar + "<a href='javascript:void(window.close());' ><img align='middle' name=imgNextPageNav src='/scripts/js/images/nextSmall.jpg' height=12 border=0 alt='Quit'></img></a>"
		//bar = bar + "<a href='javascript:window.close();openWindowSmall(\""+ sQuiz +"&close=1\",750,450)' ><img src='/scripts/js/images/nextSmall.jpg' height=12 border=0 alt='Quiz'></img></a>"
	}
	else if(sNextPath.charAt(1) == ".")
	{	
		bar = bar + "<a href='javascript:openWindowSmall1(\""+ sQuiz +"&close=1\",750,450);' ><img align='middle' name=imgNextPageNav src='/scripts/js/images/nextSmall.jpg'  border=0 alt='Quiz'></img></a>"
	}
	else
	{
		bar = bar + "<a href='"+ sNextPath +"'><img align='middle' name='imgNextPageNav' src='/scripts/js/images/nextSmall.jpg' border=0 alt='Next page'></img></a>"
	}
		bar = bar + "</td></tr></table>";
	return bar;
}

/**
 * Draws the navigation bar at the bottom for all the pages. The actual code for moving the bar is in 
 *		bottomLayer.js file. 
 * sTopPath - link to the top of a page
 * sPrevPath - filename of the previous page
 * sNextPath - filename of the next page
 * sIndex - filename of index page. This will be the same for entire course.
 * nPresentPage - current page no
 * nTotalPages - total no of pages in a course
 * sGlossary - glossary page filename. This will be the same for entire course.
 * sQuiz - filename of quiz page. This will be different for each chapter in a course
 * This function has to be called before writing code to display the bar in bottomLayer.js file. 
 */

function showArrows (sTopPath, sPrevPath, sNextPath, sIndex, nPresentPage, nTotalPages, sGlossary, sQuiz, sSelect) 
{
	var message = "<table border='0'><tr>" +
			"<td><a href='javascript:openWindowSmall(\"/common/help/help.asp" + (sIndex!=""?"":"?fm=dcr") + "\" ,450,400)'><img name=imgHelp src='/scripts/js/images/help.gif' border=0 alt='Help'></img></a></td>" + 
		(sIndex!=""?"<td><a href='"+ sIndex +"'><img name=imgIndex src='/scripts/js/images/index.gif' border=0 alt='Index'></img></a></td>":"") + 
		(sSelect!=""?"<td><a href='javascript:openWindowSmall(\"/aspsimplesearch/search2.asp?show=small&cboSelect="+ sSelect +"\",750,450)'><img name=imgSearch src='/scripts/js/images/search.gif' border=0 alt='Search'></img></a></td>":"") +
			"<td><a href='javascript:openWindowSmall(\"/chat/default.asp?name=" + "\",750,450)'><img name=imgChat src='/scripts/js/images/chat.gif' border=0 alt='chat'></img></a></td>" + 
		(sGlossary!=""?"<td><a href='javascript:openWindow(\""+ sGlossary  +"\")' ><img name=imgGlossary src='/scripts/js/images/glossary.gif' border=0 alt='Glossary'></img></a></td>":"") +
		(sIndex!=""?"<td>" + drawBar(nPresentPage, nTotalPages, sPrevPath, sNextPath, sQuiz) + "</td>":"") +
			"<td><a href='javascript:openWindowSmall(\"/FAQ/Course/Bulletin_QuesAns.asp\",750,450)' ><img name=imgQuery src='/scripts/js/images/query.gif' border=0 alt='Query'></img></a></td>" +
			"<td><a href='javascript:openWindowSmall(\"/FAQ/Course/FAQ_QuesAns.asp\",750,450)' ><img name=imgFaq src='/scripts/js/images/faq.gif' border=0 alt='FAQ'></img></a></td>" +
//			"<td><a href='javascript:openWindowSmall(\""+ sQuiz +"\",750,450)' ><img src='/scripts/js/images/question.gif' border=0 alt='Quiz'></img></a></td>" +
		(sIndex!=""?"<td><a href='javascript:window.print();'><img name=imgPrint src='/scripts/js/images/print.gif' border=0 alt='Print the Screen'></img></a></td>":"") +
			"<td><a href='javascript:closered()'><img name=imgExit src='/scripts/js/images/exit.gif' border=0 alt='Close Window'></img></a></td>" +
			"<td><img src='/images/smalllogo.gif' border=0></img></td>" +  //height=36 
			"</tr></table>";
		//alert(message);
	return message;		
}

function showArrows1 (sTopPath, sPrevPath, sNextPath, sIndex, nPresentPage, nTotalPages, sGlossary, sQuiz, sSelect) 
{
	var message = "<table border='0'><tr>" +
			"<td><a href='javascript:history.go(-1)'><img src='/scripts/js/images/arrow.gif' border=0 alt='Back'></img></a></td>" +
//			"<td><a href='"+ sTopPath +"'><img src='/scripts/js/images/top.gif' border=0 alt='Top of the Page'></img></a></td>" +
//			"<td><a href='javascript:history.go(0)'><img src='/scripts/js/images/refresh.gif' border=0 alt='Refresh'></img></a></td>" +
//			"<td><a href='"+ sPrevPath +"'><img src='/scripts/js/images/previous.gif' border=0 alt='Previous Page'></img></a></td>" +
//			"<td><a href='"+ sNextPath +"'><img src='/scripts/js/images/next.gif' border=0 alt='Next Page'></img></a></td>" +
			"<td><a href='javascript:openWindowSmall(\"/search/search-popup.asp?show=small&cboSelect="+ sSelect +"\",600,300)'><img src='/scripts/js/images/search.jpg' border=0 alt='Search'></img></a></td>" +
//new code added for chat starts here			
			"<td><a href='javascript:openWindowSmall(\"/chat/default.asp?name= "+"\",640,480)'><img src='/scripts/js/images/chat.gif' border=0 alt='chat'></img></a></td>" + 
//new code added for chat ends	here		
			"<td>" + drawBar(nPresentPage, nTotalPages, sPrevPath, sNextPath, sQuiz) + "</td>" +
			"<td><a href='"+ sIndex +"'><img src='/scripts/js/images/index.gif' border=0 alt='Index'></img></a></td>" + 
			"<td><a href='javascript:openWindow(\""+ sGlossary  +"\")' ><img src='/scripts/js/images/glossary.gif' border=0 alt='Glossary'></img></a></td>" +
			"<td><a href='javascript:openWindowSmall(\""+ sQuiz +"\",550,350)' ><img src='/scripts/js/images/question.gif' border=0 alt='Quiz'></img></a></td>" +
//			"<td><a href='"+ sGlossary +"' target='_blank'><img src='/scripts/js/images/glossary.gif' border=0 alt='Glossary'></img></a></td>" +
//			"<td><a href='"+ sQuiz +"' target='_blank'><img src='/scripts/js/images/question.gif' border=0 alt='Quiz'></img></a></td>" +
			"<td><a href='javascript:openWindowSmall(\"/FAQ/Course/query.asp\",600,420)' ><img src='/scripts/js/images/query.jpg' border=0 alt='Query'></img></a></td>" +
			"<td><a href='javascript:openWindowSmall(\"/FAQ/Course/FAQ.asp\",750,500)' ><img src='/scripts/js/images/faq.gif' border=0 alt='FAQ'></img></a></td>" +
//				"<td><a href='javascript:openWindowSmall(\"refer.asp\",500,300)' ><img src='/scripts/js/images/refer.jpg' border=0 alt='Reference'></img></a></td>" +
//new code added for help starts here			
//			"<td><a href='javascript:openWindowSmall(\"/navhelp1.asp\",535,445)'><img src='/scripts/js/images/help.gif' border=0 alt='Help'></img></a></td>" + 
//new code added for help ends	here
			"<td><a href='javascript:closered()'><img src='/scripts/js/images/cross.gif' border=0 alt='Close Window'></img></a></td>" +
			"<td> &nbsp;&nbsp;&nbsp; </td>" +
			"<td><img src='/images/smalllogo.gif' height=36 border=0></img></td>" +
			"</tr></table>";
		//alert(message);
	return message;		
}

function showTopicBand(strTopic, strImage) {

	document.write("<table border=0 width='100%' cellpadding=5 bgcolor='#ccccff'>");
	document.write("<tr>");
	if (strImage != "") {
		document.write("<td align='right'><img border='0' src='"+ strImage +"'  height='50'></img></td>");
		document.write("<td align='left' valign='bottom'><font name='Arial,Verdana' size=+4><b>"+ strTopic +"</b></font></td>");
	} else {
		document.write("<td align='center' valign='bottom'><font name='Arial,Verdana' size=+2><b>"+ strTopic +"</b></font></td>");
	}
	document.write("</tr></table>");
}

function openWindow(str)
{		
	w1 = window.open(str,"w2","toolbar=no,addressbar=no,scrollbars=yes,resizable=yes,location=0,height=500,width=800,top=0,left=0") 
}		
function openWindowSmall(str,w,h)
{		
	window.open(str,"_blank","scrollbars=yes,resizable=yes,location=0,height="+ h +",width="+ w +",top=0,left=0") 
}		

function openWindowSmall1(str,w,h)
{		
	//window.open(str,"quiz","fullscreen=1") 
	window.location.href=str;
}		

function openWindowSmall99(str,w,h)
{		
	window.open(str,"_blank","scrollbars=no,resizable=no,location=0,height="+ h +",width="+ w +",top=0,left=0") 
}	

/**
 * Opens HTML Editor
 */
 
function openEditor(sLink,sText)
{	
	 //alert(sText);	
	newWindow =window.open(sLink,"editorWindow","scrollbars=yes,resizable=yes,height=450,width=700"); 
	//newWindow =window.open(sLink,"editorWindow","scrollbars=yes,resizable=yes,location=yes,height=450,width=700"); 
	
	//newWindow.resizeTo(750,500);
	//newWindow.onload = setTextValue(sText);
	//setTimeout("",3000);
	//newWindow.frame1.document.frm.txtEnter.value = sText;
}		

/**
 * Displays a text in yellow background.
 * Clicking the link opens a HTML Editor. Calls openEditor to open a new Window.
 * Parameter - sText - Text to be dispalyed in the TextArea.
 */
function showEditor(sText,sProg) {
    //'CODE ADDED-08/11/2001:STARTS sharan
    if (sProg ="undefined")
      {
	    document.write ("<table border=0 bgcolor=yellow width='250'>" +
					"<tr><td align=center>" +
					
					// (original code)"<font size=3 face='Arial, Helvetica, sans-serif' color=black><a href='javascript:openEditor(\"/common/utils/html-frameset.asp\",\""+ sText +"\")' class='none'>Click  here to try this piece of code </a></font>" +
					//modified by sharan
					"<font size=2 face='Arial, Helvetica, sans-serif' color=black><a href='javascript:openEditor(\"/common/utils/html-frameset.asp?Name="+ sText +"\")' class='none'>Click  here to try this piece of code </a></font>" +
					"</td></tr></table></center>");
	  }
	  
	 else
	   {
	     //displays a test in yellow background and when we clicked on it,it opens a text editor for C program
	     // code added by sharan
	     sText = escape(sText)
	          document.write ("<table border=0 bgcolor=yellow width='250'>" +
					"<tr><td align=center>" +
					// (original code)"<font size=3 face='Arial, Helvetica, sans-serif' color=black><a href='javascript:openEditor(\"/common/utils/html-frameset.asp\",\""+ sText +"\")' class='none'>Click  here to try this piece of code </a></font>" +
					//modified by sharan
					"<font size=3 face='Arial, Helvetica, sans-serif' color=black><a href='javascript:openEditor(\"/courses/professional/cprg/frmgetcode.asp?Scode="+ sText +"\")' class='none'>Click  here to try this piece of code </a></font>" +
					"</td></tr></table></center>");
	   } 				
}
//'CODE ADDED-08/11/2001:ENDS
  
/**
 * This function will be used in Windows 98 course.
 * Just displays a message to the User. 
 * No work is done by this function.
 */
function showMouseOver() {
	document.write ("<table border=0 bgcolor=yellow width='400'>" +
					"<tr><td align=center>" +
					"<font size=2 face='Arial, Helvetica, sans-serif' color=black>Move your MOUSE over the yellow spots for more interaction</font>" +
					"</td></tr></table></center>");
}
/**
 * Opens C Editor.
 * sLink - specifies the file to open
 * sText - specifies the title for the link
 */
function showCEditor(sLink,sText) {
	document.write ("<table border=0 bgcolor=yellow width='300'>" +
					"<tr><td align=center>" +
					"<font size=3 face='Arial, Helvetica, sans-serif' color=black><a href='javascript:openWindowSmall(\"/common/utils/"+ sLink +"\")' class='none'>Click here to practice "+ sText +" </a></font>" +
					"</td></tr></table></center>");
}


function openWindow99(str){window.open(str,"_blank","status=no,resizable=no,scrollbars=no,location=0,height=280,width=405,top=10,left=10")
}


function showASPEditor() {
	document.write ("<table border=0 bgcolor=yellow width='300'>" +
					"<tr><td align=center>" +
					"<font size=3 face='Arial, Helvetica, sans-serif' color=black><a href='javascript:openWindowSmall(\"/common/utils/asp-frameset.asp\",700,450)' class='none'>Click here to try this piece of code </a></font>" +
					"</td></tr></table></center>");
}
function showSQLEditor() {
	document.write ("<table border=0 bgcolor='yellow' >" +
					"<tr><td align='center'>" +
					"<font size=2 face='Arial, Helvetica, sans-serif' color='black'><a href='javascript:openWindowSmall99(\"/common/utils/Sqlquery.asp\",405,280)' class='none'>Click here to try sql queries </a></font>" +
					"</td></tr></table></center>");
}



function closered()
{
		window.close();
		//window.location = "/courses.asp";
}

function openProp(url) 
{
var prop=window.open(url,"prop","height=450,width=650,scrollbars=yes,directories=no,resizable=no,top=75,left=75,status=no,toolbar=no,menubar=no,location=no");
prop.focus();
}

function openPop(url) 
{
window.showModalDialog(url,'','help:no;unadorned:yes;resizable:no;edge:sunken;scroll:yes;status:no;center:yes;dialogWidth:650px;dialogHeight:450px');
}

function formatCodeImg(){
	for(i=0;i<document.images.length;i++){
		document.images[i].style.cursor="hand";
	}
	for(i=0;i<document.all.tags("CODE").length;i++){
		document.all.tags("CODE")(i).style.fontSize="12px";
	}
}

function formatCodeImgNoPop(){
	for(i=0;i<document.all.tags("CODE").length;i++){
		document.all.tags("CODE")(i).style.fontSize="12px";
	}
}

/* a function to check the validation for sql injection*/
function check_sqlinject(strval)
{
	var blnflag, intitr ;
	blnflag = true;
	for (intitr = 0; intitr <= strval.length; intitr++)
	{
		if ((strval.charAt(intitr) == "'") || (strval.charAt(intitr) == "\"") || (strval.charAt(intitr) == ";"))
		{
			alert("The String you entered contains Special Characters, which is not allowed");
			blnflag = false;
			break;
		}	
	}
	return blnflag;
}