var PopWin;
var ExHelp;
var PrintPageWin,PrintTopicWin;
function changeGrade()
{
	var value,url,gid,eid;
	value = new String(document.frmChangeGrade.changeGrade.options[document.frmChangeGrade.changeGrade.selectedIndex].value);
	
	eid = value.split(",")[0];
	gid = value.split(",")[1];

	var url = "/apps/auto/CBmemPage.jsp?gid=" + gid + "&chg=" + gid;
	window.location = url;
}

function submitFeedback(fdOption)
{
	alert("Thank you for giving us your valuable feedback.");
}

function openPopup(filename,winName)
{
	if (!PopWin || PopWin.closed)
		PopWin = window.open(filename,winName,'width=640,height=400,status=yes,scrollbars=yes');
	else
		PopWin.focus();
		
}

function displayChapter(frmName)
{
	var gid,sid,cid,value;
	value = new String(eval("document."+frmName+".selectChapter.options[document."+frmName+".selectChapter.selectedIndex].value"));
	if (value != "0")
	{
		gid = value.split(",")[0];
		sid = value.split(",")[1];
		cid = value.split(",")[2];
		var url = "/apps/auto/CBchapter.jsp?gid=" + gid + "&sid=" + sid + "&cid=" + cid;
		window.location = url;
	}
}

function displayChapterTest(frmName)
{
	var gid,sid,cid,value,serid,testno;
	value = new String(eval("document."+frmName+".selectChapter.options[document."+frmName+".selectChapter.selectedIndex].value"));
	if (value != "0")
	{
		gid = value.split(",")[0];
		sid = value.split(",")[1];
		cid = value.split(",")[2];
		serid = value.split(",")[3];
		testno = value.split(",")[4];
		var url = "/apps/auto/CBchapterTest.jsp?serid="+serid+"&gid=" + gid + "&sid=" + sid + "&cid=" + cid + "&testno=" + testno;
		window.location = url;
	}
}

function displayTopic(frmName)
{
	var gid,sid,cid,tid,value;
	value = new String(eval("document."+frmName+".selectTopic.options[document."+frmName+".selectTopic.selectedIndex].value"));
	if (value != "0")
	{
		gid = value.split(",")[0];
		sid = value.split(",")[1];
		cid = value.split(",")[2];
		tid = value.split(",")[3];
		var url = "/apps/auto/CBtopic.jsp?gid=" + gid + "&sid=" + sid + "&cid=" + cid + "&tid=" + tid;
		window.location = url;
	}
}

function openBrWindow(theURL,winName,features) 
{
  window.open(theURL,winName,features);
}

function printFile(filePath,writeHtml,winName,features)
{
	if (!PrintPageWin || PrintPageWin.closed)
		PrintPageWin = window.open('/apps/auto/CBPrintPage.jsp?fn=' + filePath + '&wh=' + writeHtml,winName,features);
	else
		PrintPageWin.focus();
}

function printTopic(filePath,subjectId,chapterId,topicId)
{
	if (!PrintTopicWin || PrintTopicWin.closed)
		PrintTopicWin = window.open('/apps/auto/CBPrintTopic.jsp?fn=' + filePath + '&sid=' + subjectId+ '&cid=' + chapterId + '&tid=' + topicId,'PrintTopic','width=640,height=400,status=yes,scrollbars=yes');
	else
		PrintTopicWin.focus();
}



function showAll(object)
{
	for(var i=0;i<object.length;i++)
		show(object[i]);
}
function show(object) 
{
    if (document.layers && document.layers[object] != null)
        document.layers[object].visibility = 'visible';
    else if (document.all)
        document.all[object].style.visibility = 'visible';
}
function hide(object) 
{
    if (document.layers && document.layers[object] != null)
        document.layers[object].visibility = 'hidden';
    else if (document.all)
        document.all[object].style.visibility = 'hidden';
} 


function replace(sourceString,findChar,replaceChar)
{
	var returnString = '';
	for(i=0;i<sourceString.length;i++)
	{
		if (sourceString.charAt(i) == findChar)
			returnString += replaceChar;
		else
			returnString += sourceString.charAt(i);
	}
	return returnString;
}

function sendMail(title,to,msg,sub)
{
	var url = '/apps/auto/CBSendMail.jsp?'      + 
			  'title=' + replace(title,' ','+') + 
			  '&to='   + replace(to,' ','+')    + 
			  '&msg='  + replace(msg,' ','+')   + 
			  '&sub='  + replace(sub,' ','+');
	openBrWindow(url,'mailSender','width=500,height=355,status=yes,scrollbars=no');
}


function valSendMail(mailFrm)
{
	if(ChkBlank(mailFrm + '.frommailid','Must provide your e-mail address.'))
	{
		if(ChkEmail(mailFrm + '.frommailid','Invalid mail address provided.'))
		{
			if(ChkBlank(mailFrm + '.mailbody','Mail Body cannot be blank.'))
			{
				eval("String(document."+mailFrm+".submit())");
			}
		}
	}
}

function openEXHelp(filename)
{
/*	if (!ExHelp || ExHelp.closed)
		ExHelp = window.open(filename,'ExamHelpLine','width=640,height=400,status=yes,scrollbars=yes,menubar=yes');
	else
		ExHelp.focus();*/
	window.open(filename,'','width=640,height=400,status=yes,scrollbars=yes,menubar=yes');
}