<!--
function addInputSubmitEvent(form, input) {
    input.onkeydown = function(e) {
        e = e || window.event;
        if (e.keyCode == 13) {
            form.submit();
            return false;
        }
    };
}

window.onload = function() {
    var forms = document.getElementsByTagName('form');

    for (var i=0;i < forms.length;i++) {
        var inputs = forms[i].getElementsByTagName('input');

        for (var j=0;j < inputs.length;j++)
            addInputSubmitEvent(forms[i], inputs[j]);
    }
};

var popUp;

function toggle_visibility(id) {
       var e = document.getElementById(id);
       if(e.style.display == 'block')
          e.style.display = 'none';
       else
          e.style.display = 'block';
}

function changeImage(id,url)
{
	 document.getElementById(id).src=url;
}

function OpenWin(theURL,winName,theWidth,theHeight,scrollable,menu,resize){
			window.open(theURL, winName,'width='+theWidth+',height='+theHeight+',scrollbars='+scrollable+',menubar='+menu+',resizable='+resize+'');
}
function OpenWinFooter(theURL,winName,theWidth,theHeight,scrollable,menu,resize){			
			window.open(theURL, winName,'width='+theWidth+',height='+theHeight+',scrollbars='+scrollable+',menubar='+menu+',resizable='+resize+'');
}

function OpenWinPos(theURL,winName,theWidth,theHeight,scrollable,menu,resize,XPos,YPos){			
			window.open(theURL, winName,'width='+theWidth+',height='+theHeight+',scrollbars='+scrollable+',menubar='+menu+',resizable='+resize+',top='+XPos+',left='+YPos+'');
}
function showexp(id1){
			document.getElementById(id1).style.display = "block";
		}
function closeexp(id1){
		document.getElementById(id1).style.display = "none";
	} 
		
function searchStMatByCat() {	
	var Cat_ID = document.getElementById("Cat_ID").options[document.getElementById("Cat_ID").selectedIndex].value;
	var Sch_ID = document.getElementById("Sch_ID").options[document.getElementById("Sch_ID").selectedIndex].value;
	AJAXUrlCall("/student/incs/s_mat_list.asp?sid="+Math.random()+"&Cat_ID="+Cat_ID+"&Sch_ID="+Sch_ID,"mat_list");
}

function searchStMatBySch() {
	var Sch_ID = document.getElementById("Sch_ID").options[document.getElementById("Sch_ID").selectedIndex].value;
	var Cat_ID = document.getElementById("Cat_ID").options[document.getElementById("Cat_ID").selectedIndex].value;
	//AJAXUrlCall("/student/incs/s_mat_list.asp?sid="+Math.random()+"&Sch_ID="+Sch_ID+"&Cat_ID="+Cat_ID,"mat_list");
	window.location = "/student/s_browse_mat.asp?sid="+Math.random()+"&Cat_ID="+Cat_ID+"&Sch_ID="+Sch_ID;
}

function searchPubMatByCat() {	
	var Cat_ID = document.getElementById("Cat_ID").options[document.getElementById("Cat_ID").selectedIndex].value;
	var Pub_ID = document.getElementById("Pub_ID").options[document.getElementById("Pub_ID").selectedIndex].value;	
	if (Cat_ID=="##") {
		alert("Main subject contains too many materials. Please select a secondary subject")
	}
	else {		
		//alert("student/incs/s_pub_mat_list.asp?sid="+Math.random()+"&Cat_ID="+Cat_ID+"&Pub_ID="+Pub_ID)
		//AJAXUrlCall("/student/incs/s_pub_mat_list.asp?sid="+Math.random()+"&Cat_ID="+Cat_ID+"&Pub_ID="+Pub_ID,"pub_mat_list");
		window.location = "/student/s_browse_pub_mat.asp?sid="+Math.random()+"&Cat_ID="+Cat_ID+"&Pub_ID="+Pub_ID;
	}
}

function sortLibrary(SortType,SortMethod) {	
	AJAXUrlCall("/student/incs/s_mat_library.asp?sid="+Math.random()+"&SortBy="+SortType+"&Method="+SortMethod,"work_area");
}

function sortGroups(SortType,SortMethod) {	
	AJAXUrlCall("/groups/incs/browse_groups.asp?sid="+Math.random()+"&SortBy="+SortType+"&Method="+SortMethod,"work_area");
}

function sortMat(QuerryStr,SortField,SortType) {		
	var newQStr="";
	if (QuerryStr=="") {
		newQStr="?sid="+Math.random()+"&SortField="+SortField+"&SortType="+SortType
	}
	else {
		newQStr="?"+QuerryStr+"&SortField="+SortField+"&SortType="+SortType+"&sid="+Math.random()
	}		
	AJAXUrlCall("/student/incs/s_mat_list.asp"+newQStr,"mat_list");
}

function sortPubMat(QuerryStr,SortField,SortType) {		
	var newQStr="";
	if (QuerryStr=="") {
		newQStr="?sid="+Math.random()+"&SortField="+SortField+"&SortType="+SortType
	}
	else {
		newQStr="?"+QuerryStr+"&SortField="+SortField+"&SortType="+SortType+"&sid="+Math.random()
	}		
	AJAXUrlCall("/student/incs/s_pub_mat_list.asp"+newQStr,"pub_mat_list");
}

function sortInstrPubMat(QuerryStr,SortField,SortType) {		
	var newQStr="";
	if (QuerryStr=="") {
		newQStr="?sid="+Math.random()+"&SortField="+SortField+"&SortType="+SortType
	}
	else {
		newQStr="?"+QuerryStr+"&SortField="+SortField+"&SortType="+SortType+"&sid="+Math.random()
	}		
	AJAXUrlCall("/instructor/incs/i_browse_instr_pub_mat.asp"+newQStr,"work_area");
}

function delUplMaterial(Mat_ID){
	if (confirm("This material will still be available to any user who has already purchased it. Are you sure you want to delete this material?")){		
		AJAXUrlCall("/student/del_upl_material.asp?sid="+Math.random()+"&Mat_ID="+Mat_ID,"work_area");
	}


}

function ChangeFile(){	
	document.getElementById("chgFile").style.display = "none";
	document.getElementById("FileDiv").style.display = "block";
}

function HideFile(){	
	document.getElementById("chgFile").style.display = "block";
	document.getElementById("FileDiv").style.display = "none" ;
	document.getElementById("Upl_File").value = "";
}

function changeFileType(formName) {	
	var fileName = document.getElementById("Upl_File").value;
	var fileNameArr = fileName.split(".");
	var n = fileNameArr.length;
	var fileExt = fileNameArr[n-1];
	var fileExtLow = fileExt.toLowerCase(); 	
	var MatType="";
	for (i=formName.Mat_Type.length-1; i > -1; i--) {
		MatType = formName.Mat_Type[i].value		
		if (MatType.indexOf(fileExtLow)>0) {
			formName.Mat_Type[i].checked=true;
		}		
	}	
}

function showMatDet(Mat_ID,Mat_Source,Cat_Name){
	
	
	if (screen.height > 750) {
	AJAXUrlCall("/student/incs/s_upl_mat_det.asp?sid="+Math.random()+"&Mat_ID="+Mat_ID+"&src="+Mat_Source+"&Cat_Name="+Cat_Name,"mat_det_popup_body")
	//document.getElementById("materialMoreInfo").style.display = "block";
	showPopup("materialMoreInfo");
	document.getElementById("Mat_search").style.display = "none";
	//document.getElementById("Sch_ID").style.display = "none";
	} else {
		window.open("/student/incs/s_upl_mat_det.asp?sid="+Math.random()+"&Mat_ID="+Mat_ID+"&src="+Mat_Source+"&Cat_Name="+Cat_Name,"Material Info",width=600,height=500,scrollbars='yes',menubar='no',resizable='no')
	}
	
}

function showPubMatDet(Mat_ID,MatSource,Cat_Name){
	if (screen.height > 750) {
		AJAXUrlCall("/student/incs/s_pub_mat_det.asp?sid="+Math.random()+"&Mat_ID="+Mat_ID+"&src="+MatSource+"&Cat_Name="+Cat_Name,"mat_det_popup_body")
		//document.getElementById("materialMoreInfo").style.display = "block";
		document.getElementById("PopHeader").innerHTML="Material Information";
		showPopup("materialMoreInfo");
		document.getElementById("Mat_search").style.display = "none";
	} else {
		window.open("/student/incs/s_pub_mat_det.asp?sid="+Math.random()+"&Mat_ID="+Mat_ID+"&src="+MatSource+"&Cat_Name="+Cat_Name,"Material Info",width=600,height=500,scrollbars='yes',menubar='no',resizable='no')
	}
	
}

function showMatReview(Mat_ID,MatSource){	
	if (screen.height > 750) {
	AJAXUrlCall("/student/incs/s_rate_mat.asp?sid="+Math.random()+"&Mat_ID="+Mat_ID+"&src="+MatSource,"mat_det_popup_body")		
		document.getElementById("PopHeader").innerHTML="Material Rating";
		showPopup("materialMoreInfo");
		if (MatSource=="browse"){
			document.getElementById("Mat_search").style.display = "none";
		}
	} else {
		window.open("/student/incs/s_rate_mat.asp?sid="+Math.random()+"&Mat_ID="+Mat_ID+"&src="+MatSource,"Material Info",width=600,height=500,scrollbars='yes',menubar='no',resizable='no')
	}	
	
}

function showMatLibrDet(Mat_ID,Status,Pub_ID){
	var url = "";
	if (Pub_ID==0){
			 url="/student/incs/s_upl_mat_det.asp?src=Library&sid="+Math.random()+"&Mat_ID="+Mat_ID + "&Status="+Status
		}else {
			url="/student/incs/s_pub_mat_det.asp?src=Library&sid="+Math.random()+"&Mat_ID="+Mat_ID + "&Status="+Status
		}
	if (screen.height > 750) {
		if (Status=="PD") {
			document.getElementById("PopHeader").innerHTML="Purchased Material Information";
		} else {
			document.getElementById("PopHeader").innerHTML="Published Material Information";
		}
		showPopup("materialMoreInfo");
		if (Pub_ID==0){
			AJAXUrlCall(url,"mat_det_popup_body")
		}else {
			AJAXUrlCall(url,"mat_det_popup_body")
		}
		document.getElementById("materialMoreInfo").style.display = "block";	
	} else {
		//alert(url)
		window.open(url,"Material Info",width=600,height=500,scrollbars='yes',menubar='no',resizable='no');
	}
}


function showInstMatLibrDet(Mat_ID,Pub_ID){
	var url = "";
	//if (Pub_ID==0){
			 url="/instructor/incs/i_mat_det.asp?sid="+Math.random()+"&Mat_ID="+Mat_ID + "&Pub_ID=" + Pub_ID
		//}else {
		//	url="/student/incs/s_pub_mat_det.asp?src=Library&sid="+Math.random()+"&Mat_ID="+Mat_ID + "&Status="+Status
		///}
	if (screen.height > 750) {
		if (Pub_ID==30000029) {
			document.getElementById("PopHeader").innerHTML="Published Material Information";
		} else {
			document.getElementById("PopHeader").innerHTML="Uploaded Material Information";
		}
		showPopup("materialMoreInfo");
		//if (Pub_ID==0){
			AJAXUrlCall(url,"mat_det_popup_body")
		//}else {
			//AJAXUrlCall(url,"mat_det_popup_body")
		//}
		document.getElementById("materialMoreInfo").style.display = "block";	
	} else {
		//alert(url)
		window.open(url,"Material Info",width=600,height=500,scrollbars='yes',menubar='no',resizable='no');
	}
}

function showInstMatAddCrsDet(Mat_ID,Crs_ID,Ssn_ID,Sch_ID){
	var url = "";	
		url="/instructor/i_publ_mat_details1.asp?sid="+Math.random()+"&Mat_ID="+Mat_ID + "&Crs_ID=" + Crs_ID + "&Ssn_ID=" + Ssn_ID + "&Sch_ID=" + Sch_ID
		
	if (screen.height > 750) {
		document.getElementById("PopHeader").innerHTML="Material Information";
		showPopup("materialMoreInfo");		
		AJAXUrlCall(url,"mat_det_popup_body");		
		document.getElementById("materialMoreInfo").style.display = "block";	
	} else {
		//alert(url)
		window.open(url,"Material Info",width=600,height=500,scrollbars='yes',menubar='no',resizable='no');
	}
}

function showMatRate(Mat_ID,Mat_Name){	
	AJAXUrlCall("/student/incs/s_mat_rate.asp?sid="+Math.random()+"&Mat_ID="+Mat_ID+"&Mat_Name="+Mat_Name,"mat_det_popup_body")
	document.getElementById("mat_det_popup").style.display = "block";
}


function closeMatDet(id1){
	document.getElementById(id1).style.display = "none";
	document.getElementById("Mat_search").style.display = "block";
	//document.getElementById("Sch_ID").style.display = "block";
} 
 function toggleVisibilityOn(id) {
       var e = document.getElementById(id);
       if(e.style.display == 'block')
          e.style.display = 'block';
       else
          e.style.display = 'block';
    }
    function toggleVisibilityOff(id) {
       var e = document.getElementById(id);
       if(e.style.display == 'none')
          e.style.display = 'none';
       else
          e.style.display = 'none';
    }
	
	function SaleDetails(Trans_ID){
		AJAXUrlCall("/student/incs/sale_details.asp?sid="+Math.random()+"&Trans_ID="+Trans_ID,"materialSales")
		document.getElementById("materialSales").style.display = "block";
	}
	
	function PurchDetails(Ord_ID){
		AJAXUrlCall("/student/incs/purch_detail.asp?sid="+Math.random()+"&Ord_ID="+Ord_ID,"materialSales")
		document.getElementById("materialSales").style.display = "block";
	}
	
	function DelMatFromLibrary(Mat_ID,Status) {
		if (confirm("Are you sure you want to delete this material from your library?")){
			
			AJAXUrlCall("/student/incs/del_mat.asp?sid="+Math.random()+"&Mat_ID="+Mat_ID+"&Status="+Status,"mat_det_popup_body")
			var t=setTimeout("window.location=window.location",1000);
			
		}
		
	}
	
	function StMatPurch(Mat_ID,Mat_Name,Price){			
		
		var NameTxt = encodeURI(Mat_Name);		
		var parameters = "Itm_Price=" + Price + "&Mat_Name=" + NameTxt
		var url="/student/s_mat_add_action.asp?Mat_ID="+Mat_ID		
			url=url+"&sid="+Math.random()
		AJAXFormPost(url,parameters,"add_mat_link_"+Mat_ID)		
		opener.document.getElementById("scDisp").innerHTML = "<a style='color:#ffffff; margin:0 10px 0 0; font-size:10px;border:none; position:relative;' href='/shopcart/view_cart.asp'>cart&nbsp;&nbsp;<img style='position:relative; top:2px; border:none;' src='/new_lounge/images/shoppingCartGraphic.gif' alt='' /></a>|	";
	}
	
	function StMatPurch1(Mat_ID,Mat_Name,Price){			
		
		var NameTxt = encodeURI(Mat_Name);
		var parameters = "Itm_Price=" + Price + "&Mat_Name=" + NameTxt
		var url="/student/s_mat_add_action.asp?Mat_ID="+Mat_ID		
			url=url+"&sid="+Math.random()
		AJAXFormPost(url,parameters,"add_mat_link_"+Mat_ID)
		
		document.getElementById("scDisp").innerHTML = "<a href='/shopcart/view_cart.asp' class='NormalLinks'><img src='/images/general/cart_white.jpg' alt='' border='0'></a><img src='/images/spacer.gif' alt='' height='1' width='36'>";
	}
	
	function StMatReview(Mat_ID){		
		var rateFlag=false;	
		for (i=document.Mat_Rate.mat_rating.length-1; i > -1; i--) {
			if (document.Mat_Rate.mat_rating[i].checked) {
				var mat_score = document.Mat_Rate.mat_rating[i].value;
				 rateFlag=true;
			}
		}
		if (!rateFlag){ 
			alert ("Please rate the material to proceed");
			return false;
		}
		var mat_comm = encodeURI(document.getElementById("comm").value);				
		var parameters = "Score=" + mat_score + "&Comments=" + mat_comm		
		var url="/student/s_mat_rate_action.asp?Mat_ID="+Mat_ID		
			url=url+"&sid="+Math.random()
		AJAXFormPost(url,parameters,"mat_det_popup_body")
		setTimeout('window.location=window.location;',1000)
		
	}

	function GetSubcategories(){
		var Cat_ID = document.getElementById("Main_Cat_ID").options[document.getElementById("Main_Cat_ID").selectedIndex].value;	
		AJAXUrlCall("/student/incs/s_get_sub_cats.asp?sid="+Math.random()+"&Cat_ID="+Cat_ID,"SubCats")
	}
	
	function GetSubCats(){
		var Cat_ID = document.getElementById("Main_Cat_ID").options[document.getElementById("Main_Cat_ID").selectedIndex].value;			
		AJAXUrlCall("/incs/get_sub_cats.asp?sid="+Math.random()+"&Cat_ID="+Cat_ID,"SubCats");
	}
	
	function GetInstrSubSubjects(){
		
		var Cat_ID = document.getElementById("Main_Cat_ID").options[document.getElementById("Main_Cat_ID").selectedIndex].value;	
		AJAXUrlCall("/instructor/incs/i_get_sub_cats.asp?sid="+Math.random()+"&Cat_ID="+Cat_ID,"SubCats")
	}

function showPopup(DivName) {   	
	if (popUp == null)
		popUp = document.getElementById(DivName);	
	Interval = window.setInterval("checkScroll()", 500);
	//checkScroll();
    popUp.style.display = "block";
}

function checkScroll() {	
	//var browserName=navigator.appName;	
	//alert(BrowserDetect.browser)
	if (BrowserDetect.browser == "Safari" || BrowserDetect.browser == "Mozilla" ) {		
		popUp.style.top = Math.round((document.documentElement.clientHeight/2)-(popUp.style.height/2)+document.body.scrollTop- screen.height/3.0)+'px';
   		 popUp.style.left= "85px"
		 //popUp.style.left = Math.round((document.documentElement.clientWidth/2)-(popUp.style.width/2)- screen.width/2.8)+"px";		 
	}
	else
	{	
		
    	if (BrowserDetect.browser == "Explorer")
		{
			popUp.style.top = Math.round((document.documentElement.clientHeight/2)-(popUp.style.height/2)+document.documentElement.scrollTop- screen.height/3.1)+'px';
			popUp.style.left= "90px"
		} else {
			popUp.style.top = Math.round((document.documentElement.clientHeight/2)-(popUp.style.height/2)+document.documentElement.scrollTop- screen.height/3.2)+'px';
			popUp.style.left= "85px"
		}  		
		
		//alert(popUp.style.top)
	}
}

function LoginFocus() {
	if (document.getElementById("ulogin").value == "email login"){
		document.getElementById("ulogin").value="";
	}
}

function PassFocus() {	
		if 	(window.navigator.userAgent.indexOf ( "MSIE " ) <  0) {
			document.getElementById("upassword").style.marginLeft = "9px";
		}
		toggleVisibilityOff("password-text");
		toggleVisibilityOn("upassword");				
		document.getElementById("upassword").focus();
	
}

function LoginBlur() {
	if (document.getElementById("ulogin").value == ""){
		document.getElementById("ulogin").value="email login";
	}
}

function PassBlur() {
	if (document.getElementById("upassword").value == ""){		
		if 	(window.navigator.userAgent.indexOf ( "MSIE " ) <  0) {
			document.getElementById("password-text").style.marginLeft = "9px";
		}
		toggleVisibilityOff("upassword");
		toggleVisibilityOn("password-text");
		
	}
}

function changeInputType(oldObject, oType,txtValue) {
  var newObject = document.createElement('input');
  newObject.type = oType;
  if(oldObject.size) newObject.size = oldObject.size;
  if(oldObject.value) newObject.value = txtValue;
  if(oldObject.name) newObject.name = oldObject.name;
  if(oldObject.id) newObject.id = oldObject.id;
  if(oldObject.size) newObject.style = "font-size:9px; height:20px; width:168px;";
  //if(oldObject.className) newObject.className = oldObject.className;
  alert(newObject.value);
  oldObject.parentNode.replaceChild(newObject,oldObject);
  return newObject;
}

function showMaterialDesc(obj,Mat_ID,Mat_Source,Cat_Name) {   	
	//alert(oDict.getVal(Mat_ID))
	//AJAXUrlCall("/student/incs/quick_mat_info.asp?sid="+Math.random()+"&Mat_ID="+Mat_ID+"&src="+Mat_Source+"&Cat_Name="+Cat_Name,"mat_pop_det")	
	var browser=navigator.appName;
	if (browser=='Microsoft Internet Explorer') {
		document.getElementById("jcMoreMatInfoAlt").style.top =(parseInt(findPos(obj))-110) + "px";	
	}else {
		document.getElementById("jcMoreMatInfoAlt").style.top =(parseInt(findPos(obj))-105) + "px";	
	}
	document.getElementById("mat_pop_det").innerHTML = oDict.getVal(Mat_ID)	
	document.getElementById('jcMoreMatInfoAlt').style.display = 'block';
	////setTimeout("document.getElementById('jcMoreMatInfoAlt').style.display = 'block'; ",1000) 
}

function hideMaterialDesc(DivName) {   		
	 document.getElementById(DivName).style.display = "none";
}
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	//alert (curleft)
	return (curtop);

}

function refreshParent(url) {
  if (url=="") {
 	 window.opener.location.href = window.opener.location.href;
 } else {
 	 window.opener.location.href = url;
 }
  	

  if (window.opener.progressWindow)
		
 {
    window.opener.progressWindow.close()
  }
  window.close();
}

function closeLoungeDivs() {
			toggleVisibilityOff('jcLoungeWhyUse');
            toggleVisibilityOff('jcLoungeNews');
            toggleVisibilityOff('jcLoungeResources');
            toggleVisibilityOff('jcLoungeReferences');
            toggleVisibilityOff('jcLoungeCool');
}

function admin_edit_frm(Frm_ID,Div_ID){			
		
		var PostTxt = encodeURI(document.getElementById("FrmBody_"+Frm_ID).value);
		var parameters = "FrmPost_Body=" + PostTxt
		var url="/admin/incs/a_edit_frm_post.asp?Frm_ID="+Frm_ID		
			url=url+"&sid="+Math.random()
		AJAXFormPost(url,parameters,Div_ID)		
	
	}
	function AdminPubSaleDet(Trans_ID){
	AJAXUrlCall("/admin/incs/pub_trans_det.asp?sid="+Math.random()+"&Trans_ID="+Trans_ID,"materialSales")
	document.getElementById("materialSales").style.display = "block";
}

function secuirityWarn(){
	
	var fileName1 = document.getElementById("Upl_File").value;
	var fileNameArr1 = fileName1.split(".");
	var n1 = fileNameArr1.length;
	var fileExt1 = fileNameArr1[n1-1];
	var fileExtLow1 = fileExt1.toLowerCase();
	 
	if (fileExtLow1 !="pdf"){
		//alert("NoPdf")
		document.getElementById("secwarn").style.visibility="visible";
	}
	else {
		//alert("YesPdf")
		document.getElementById("secwarn").style.visibility="hidden";
	}
} 

function closeSecBox() {
	var UsrSel=false;
	//if (document.getElementById("secuirCheck").checked==true){
		//UsrSel = true;
	//}
	//alert(UsrSel);
	document.getElementById("secwarn").style.visibility="hidden";
}
//-->
