//--------------------------------------------------------------------------------------------
//
//	$Header: /projects/cfsm/cfsm_Web/includes/global.js 1     9/01/02 10:55a Pammyy $
//
//--------------------------------------------------------------------------------------------

var browserName = navigator.appName;
var browserVer  = parseInt(navigator.appVersion);

//if (window != window.top) {
//    top.location.href = self.location.href
//}

var alertMsg = "";
var NS4 = (document.layers) ? 1 : 0;
var IE4 = (document.all) ? 1 : 0;
var ver4 = (NS4 || IE4) ? 1 : 0;

function CheckField(curr_field, curr_image) {
	if ((browserName == 'Netscape'                    && browserVer >= 3) ||
		(browserName == 'Microsoft Internet Explorer' && browserVer >= 4)) {
			if (document.main.elements[curr_field].value == '') {
			    document.images[curr_image].src = '../images/forms/form_exclamationani.gif';
			} else {
			    document.images[curr_image].src = '../images/forms/form_blank.gif';
			}
    }
}

function confirmSubmit(confirmMessage)
{
	var returnValue = confirm(confirmMessage);

	if (returnValue)
		return true;
	else
		return false;
}

function preloadImages() {
  var d=document; if(d.images){ if(!d.WEB_p) d.WEB_p=new Array();
    var i,j=d.WEB_p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.WEB_p[j]=new Image; d.WEB_p[j++].src=a[i];}}
}

function WEB_swapImgRestore() {
  var i,x,a=document.WEB_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function WEB_findObj(n, d) {
  var p,i,x;  
	
	if(!d) d=document; 
	
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; 
		n=n.substring(0,p);
	}
  
	if(!(x=d[n])&&d.all) 
		x=d.all[n]; 
	
	for (i=0;!x&&i<d.forms.length;i++) 
		x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
		x=WEB_findObj(n,d.layers[i].document); 
		
	return x;
}

function WEB_swapImage() {
  var i,j=0,x,a=WEB_swapImage.arguments; 
	document.WEB_sr=new Array; 
	for(i=0;i<(a.length-2);i+=3)
  		if ( (x=WEB_findObj(a[i]))!=null )	{
			document.WEB_sr[j++]=x; 
			if(!x.oSrc) 
				x.oSrc=x.src; 
			x.src=a[i+2];}
}

function loadDocument(appRoot, documentID, pageID) {
	window.open(appRoot + 'scripts/viewer.asp?DID=' + documentID + '&PID=' + pageID, 'viewer', 'resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
	return(false);
}

function loadDocumentFromadmin(appRoot, documentID, pageID) {
	window.open(appRoot + 'scripts/viewer.asp?DID=' + documentID + '&PID=' + pageID + '&Prnt=admin', 'viewer', 'resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
	return(false);
}

function loadDocument2(appRoot, learningAreaOutcomeID, seriesID) {
	//window.open(appRoot + 'scripts/viewer.asp?LAO=' + learningAreaOutcomeID + '&SID=' + seriesID, 'viewer', 'resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
	window.open(appRoot + 'scripts/viewer.asp?DID=1&PID=1', 'viewer', 'resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
	return(false);
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
 
function closePopupWin(vParentWindow, vURL) { // closes the popup window and shows the master window
		
	if (!window.parent.opener.closed) {
		window.parent.opener.focus();
		if (vParentWindow=='') {
			var w = findWindow("cc_main");
			w.document.location = vURL;
		}
		
	}
	window.close();
	
}

function focusFeedback(appRoot, learningAreaOutcomeID) { // focus the parent window and load the feedback script
	
	var w = findWindow("cc_main");
	w.focus();
	w.top.location = appRoot + 'scripts/feedback.asp?LAO=' + learningAreaOutcomeID;
	
	//if (!window.parent.opener.closed) {
	//	//window.parent.opener.location=appRoot + 'scripts/feedback.asp?LAO=' + learningAreaOutcomeID;
	//	window.parent.opener.focus();
	//	window.parent.opener.top.location.href=appRoot + 'scripts/feedback.asp?LAO=' + learningAreaOutcomeID;
		
	//}
}

function openBackPack(vURL) { 
	var w = findWindow("cc_main");
	w.focus();
	w.top.location = vURL;
	//if (!window.parent.opener.closed) {
	//	window.parent.opener.focus();
	//	window.parent.opener.top.location.href = vURL;
		
	//}
}
function findWindow(name){
	return open("",name);
}