var message="Function Disabled!";

function CheckIsIE() 
{ 
    if  (navigator.appName.toUpperCase() == 'MICROSOFT INTERNET EXPLORER')  { return true;} 
    else { return false; } 
  } 

function windowOpen(field) {
    var myWindow=window.open('/DGFLP/common/include/popupcal.asp?field=' + field,'windowRef','width=200,height=200');
    if (!myWindow.opener) myWindow.opener = self;
}

function passedopen(url,windowName,width,height,directories,location,menubar,scrollbars,status,toolbar,resizable) {
	var features =
	'width='        + width +
	',height='      + height +
	',directories=' + directories +
	',location='    + location +
	',menubar='     + menubar +
	',scrollbars='  + scrollbars +
	',status='      + status +
	',toolbar='     + toolbar +
	',resizable='   + resizable;
	window.open (url, windowName, features);
}


function MM_openSupportWindow(aboutcompany) {
	var popupURL = getCookie("website");
	popup = window.open(popupURL,adname,"");
	if(popup != null) {
		popup.location = popupURL;
		if( navigator.appName.substring(0,8) == "Netscape" ) {
			popup.location = popupURL;
			popup.opener = self;
		}
		if( navigator.appName == "Netscape" ) {
			popup.window.focus();
       }
       self.name = "main";
    }
}

///////////////////////////////////
function aboutUs(){
	var aboutus = getCookie("keyID");
	document.all.aboutcompany.src = '/DGFLP/keyid/' + aboutus + '/aboutcompany.htm';
	return	
}
///////////////////////////////////
function subLogo(){
	var sublogo = getCookie("keyID");
	if (document.logo.width == null){
	}
	else{
		document.logo.src = '/DGFLP/keyid/' + sublogo + '/logo.gif';
		// Add here a list of keyids that have a new header logo
		if ((sublogo == '11') || (sublogo == '0')){
			document.headerlogo.src = '/DGFLP/keyid/' + sublogo + '/mainheader.jpg';
		}
		else {
			document.headerlogo.src = '/DGFLP/images/spacer.gif';
		}
	}
	return
}

///////////////////////////////////
function mainLogo(){
	var mainlogo = getCookie("keyID");
	document.mainlogo.src = '/DGFLP/keyid/' + mainlogo + '/logo_home.gif';
	return
}

///////////////////////////////////
function contactUsLogo(){
	var contactuslogo = getCookie("keyID");
	document.contactus.src = '/DGFLP/keyid/' + contactuslogo + '/contact-us.jpg';
	return
}


///////////////////////////////////
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);
//alert(message);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
//alert(message);
document.onmousedown=clickIE4;
}

//document.oncontextmenu=new Function("alert(message);return false")
document.oncontextmenu=new Function("return false")

function hidestatus(){
//window.status=''
return true
}

function getXY() {
  if (document.body && document.body.clientWidth) {
    orgw = document.body.clientWidth;
    orgh = document.body.clientHeight;
  }
  else if (window.outerWidth) {
    orgw = window.outerWidth;
    orgh = window.outerHeight;
  }
}

function setXY() {
  if (resized) top.resizeTo(orgw,orgh);
}

function resize(x, y) {
//alert(orgw + ' ' + orgh);
  resized = true;
  top.resizeTo(x, y);
  return false;
}

function getArgs(){
	var args = new Object();
	var query = location.search.substring(1); //Get query String
	var pairs = query.split("&");		  	  //Greak at &
	for(var i = 0; i<pairs.length; i++) {
		var pos = pairs[i].indexOf('=');		// Look for "name=value"
		if (pos == -1) continue;
		var argname = pairs[i].substring(0,pos).toLowerCase(); // Extract the name
		var value = pairs[i].substring(pos+1); // extract the value
		args[argname] = unescape(value);
	}
	return args;
}

// Boolean variable specified if alert should be displayed if cookie exceeds 4KB
var caution = false

// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "")
if (!caution || (name + "=" + escape(value)).length <= 4000){
document.cookie = curCookie
}
else{
if (confirm("Cookie exceeds 4KB and will be cut!"))
document.cookie = curCookie
}
}

// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function get1Cookie(name) {
var prefix = name + "="
var cookieStartIndex = document.cookie.indexOf(prefix)
if (cookieStartIndex == -1)
return null
var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
if (cookieEndIndex == -1)
cookieEndIndex = document.cookie.length
return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}



function getCookie(cookiename) {

	var allcookies = document.cookie;
	var pos = allcookies.indexOf(cookiename);

	if (pos != -1){
		var start = pos + cookiename.length + 1  ;
		var end = allcookies.indexOf(";",start);
		if (end == -1) end = allcookies.length;
		var value = allcookies.substring(start,end);
		value = unescape(value);
		return value;
	}
}

// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds
function deleteCookie(name, path, domain) {
if (getCookie(name)) {
document.cookie = name + "=" + 
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT"
}
}

// date - any instance of the Date object
// * you should hand all instances of the Date object to this function for "repairs"
// * this function is taken from Chapter 14, "Time and Date in JavaScript", in "Learn Advanced JavaScript Programming"
function fixDate(date) {
var base = new Date(0)
var skew = base.getTime()
if (skew > 0)
date.setTime(date.getTime() - skew)
}


function bookmark(cookieName){

 var msg = winMessage("Please Be Patient",
    "Saving the Bookmark. Please be patient...",
    400, 30);
var sPage =window.location.pathname;
  var expire = new Date ();
  expire.setTime(expire.getTime() + (500 * 24 * 3600000));
  setCookie(cookieName, sPage, expire , "\\", "\\", 0)
  msg.close();
}

function QuizGrade(chapter,correct,incorrect){
 var msg = winMessage("Please Be Patient",
    "Saving the Quiz. Please be patient...",
    400, 30);
  var expire = new Date ();
  expire.setTime(expire.getTime() + (500 * 24 * 3600000));
  setCookie("C" + chapter, correct, expire , "", "", 0)
  //setCookie("I" + chapter, incorrect, expire , "", "", 0)
  msg.close();
}

 

function winMessage(title, contents, width, height) {
  var w = 480, h = 340;
  if (document.all || document.layers) {
    w = screen.availWidth;
    h = screen.availHeight;
  }
  var leftPos = (w - width)/2, topPos = (h - height)/2;
  var options = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no," +
    "resizable=no,width=" + width + ",height=" + height + ",top=" + topPos +
    ",left=" + leftPos + ",screenY=" + topPos + ",screenX=" + leftPos;
  msgWindow = window.open("","displayWindow",options);
  msgWindow.document.write("<head><title>" + title + "<\/title><\/head>");
  msgWindow.document.write('<div style="text-align: center; font: bold 12pt; color: blue">' +
    contents + "</div>");
  return msgWindow;
}

function saveForm() {
  var msg = winMessage("Please Be Patient",
    "Saving the Worksheet. Please be patient...",
    400, 30);
  var expire = new Date ();
  expire.setTime(expire.getTime() + (500 * 24 * 3600000));
  var strCookie = expire;
  var frm = document.worksheet;
  for (var i = 0; i < frm.elements.length; i++) {
    if (frm.elements[i].type == 'text') {
      strCookie += '`' + frm.elements[i].value;
    }
  }
  document.cookie = cookieName +"=" + escape(strCookie) + "; expires=" + expire.toGMTString() ;
  msg.close();
}
function keyHandler(e) {
  if (document.layers)
    Key = e.which;
  else
    Key = window.event.keyCode;
  if (currLoc) {
    var booCancel = 0;
    var objHere= currLoc.name;
    var strHere = '';
    if (((Key == 13) || (Key == 9)) || (Key == 40)) {
      objHere = objHere.substring(0,3) + ((objHere.substring(3,6) * 1) + 1);
      strHere = "if (document.worksheet." + objHere + ") document.worksheet." + objHere + ".focus();";
      booCancel = 1;
    }
    else if (Key == 38) {
      objHere = objHere.substring(0,3) + ((objHere.substring(3,6) * 1) - 1);
      strHere = "if (document.worksheet." + objHere + ") document.worksheet." + objHere + ".focus();";
      booCancel = 1;
    }
    else if (Key == 37) {
      var colHere = objHere.substring(0,3);
      for (var i=0; i < arrMonth.length; i++) {
        if (arrMonth[i] == colHere) {
          if (i > 0) {
            objHere = arrMonth[i-1] + objHere.substring(3,6);
          }
          else {
            objHere = 'bgt' + objHere.substring(3,6);
          }
          strHere = "if (document.worksheet." + objHere + ") document.worksheet." + objHere + ".focus();";
          booCancel = 1;
          break;
        }
      }
    }
    else if (Key == 39) {
      var colHere = objHere.substring(0,3);
      if (colHere == 'bgt') {
        objHere = 'jan' + objHere.substring(3,6);
      }
      else {
        for (var i=0; i < arrMonth.length; i++) {
          if (arrMonth[i] == colHere) {
            if (i < 11) objHere = arrMonth[i+1] + objHere.substring(3,6);
            break;
          }
        }
      }
      strHere = "if (document.worksheet." + objHere + ") document.worksheet." + objHere + ".focus();";
      booCancel = 1;
    }

    if (booCancel == 1) {
      eval(strHere);
      if (document.layers)
        e.which = 0;
      else
        window.event.keyCode = 0;
      window.event.cancelBubble = true;
      window.event.returnValue = false;
      return false;
    }
  }
}


function restoreForm() {
  cookieArray(getCookie(cookieName));
  var frm = document.TestProfile;
  var idx = 1;
  if (ckArray[0] != "*") {
    var msg = winMessage("Please Be Patient", 
      "Loading the Worksheet. Please be patient...",
      400, 30);
    document.TestProfile.reset();
    for (var i = 0; i < frm.elements.length; i++) {
      if ((frm.elements[i].type == 'text')) {
        if (ckArray[idx] != "") {
          frm.elements[i].value = ckArray[idx];
          var fldNo = frm.elements[i].name.substr(3,2);
        }
        idx++;
      }
    }
    //for (var i = 1; i <= 35; i++) {
    //  eval('if (frm.bgt' + i + '.value != "") { checkBudget(' + i + ') }');
    //}
    //checkBudget('inc');
    //checkBudget('exp');
    //checkBudget('cash');
    msg.close();
  }
}

function MM_openBrWindow(popupURL,nWidth,nHeight) {

	popup = window.open(popupURL,adname,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=" + nWidth +",height=" +nHeight);
	if(popup != null) {
		popup.location = popupURL;
		if( navigator.appName.substring(0,8) == "Netscape" ) {
			popup.location = popupURL;
			popup.opener = self;
		}
		if( navigator.appName == "Netscape" ) {
			popup.window.focus();
       }
       self.name = "main";
    }
}

function MM_opennewWindow(popupURL,nWidth,nHeight) {

	popup = window.open(popupURL,adname,"toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1,copyhistory=0,width=" + nWidth +",height=" +nHeight);
	if(popup != null) {
		popup.location = popupURL;
		if( navigator.appName.substring(0,8) == "Netscape" ) {
			popup.location = popupURL;
			popup.opener = self;
		}
		if( navigator.appName == "Netscape" ) {
			popup.window.focus();
       }
       self.name = "main";
    }
}



function nextsection(course,section,question,q1,q2,q3,q4,q5,q6,q7,q8,q9,q10,q11,q12,q13,q14,q15,q16,q17,q18,q19,q20) {
	// For when a Exam completes... the Chapter, Correct and Incorrect are passed so I can load up the Reasults page
	window.location.href = "/_includes/gradequiz.asp?exam=1&course=" + course + "&section=" + section + "&questions=" +question + "&q1=" + q1 + "&q2=" + q2 + "&q3=" + q3 + "&q4=" + q4 + "&q5=" + q5 + "&q6=" + q6 + "&q7=" + q7 + "&q8=" + q8 + "&q9=" + q9 + "&q10=" + q10 + "&q11=" + q11 + "&q12=" + q12 + "&q13=" + q13 + "&q14=" + q14 + "&q15=" + q15 + "&q16=" + q16 + "&q17=" + q17 + "&q18=" + q18 + "&q19=" + q19 + "&q20=" + q20 
}

function nextquiz(course,section,question,q1,q2,q3,q4,q5) {
	// For when a Exam completes... the Chapter, Correct and Incorrect are passed so I can load up the Reasults page
		window.location.href = "/_includes/gradequiz.asp?exam=0&chapter=1&course=" + course + "&section=" + section + "&questions=" +question + "&q1=" + q1 + "&q2=" + q2 + "&q3=" + q3 + "&q4=" + q4 + "&q5=" + q5 
}


function nextpage(ch1,ct1,in1) {
	QuizGrade(ch1,ct1,in1);
	// For when a quiz completes... the Chapter, Correct and Incorrect are passed so I can load up the Reasults page
	window.location.href = "/DGFLP/StudyCourses/Quiz/QuizResults.htm?chapter=" + ch1 + "&correct=" + ct1 + "&incorrect=" +in1

}

  function clearForm() 
  { 

     if (CheckIsIE() == true) 
      { 
         document.ebooks.focus(); 
         document.ebooks.clearForm(); 
      }      
      else 
       { 
          window.frames['ebooks'].focus(); 
          window.frames['ebooks'].clearForm(); 
        } 

   } 


hp_ok=true;
function hp_d00(s)
{
  if(!hp_ok)return;
  document.write(s)
}


function hp_ne()
{
  return true
}
onerror=hp_ne;
function hp_dn(a)
{
  return false
}
function hp_cm()
{
 // alert("\u0054\u0068\u0069\u0073\u0020\u0070\u0061\u0067\u0065\u0020\u0068\u0061\u0073\u0020\u0062\u0065\u0065\u006E\u0020\u0070\u0072\u006F\u0074\u0065\u0063\u0074\u0065\u0064\u002E\u0020\u0050\u0072\u0065\u0076\u0069\u0065\u0077\u0020\u006F\u006E\u006C\u0079\u002E");
  return false
}
function hp_de(e)
{
  return(e.target.tagName!=null&&e.target.tagName.search('^(INPUT|TEXTAREA|BUTTON|SELECT)$')!=-1)
};
function hp_md(e)
{
  mac=navigator.userAgent.indexOf('Mac')!=-1;
  if(document.all)
  {
    if(event.button==2||(mac&&(event.ctrlKey||event.keyCode==91)))
    {
      //alert("\u0054\u0068\u0069\u0073\u0020\u0070\u0061\u0067\u0065\u0020\u0068\u0061\u0073\u0020\u0062\u0065\u0065\u006E\u0020\u0070\u0072\u006F\u0074\u0065\u0063\u0074\u0065\u0064\u002E\u0020\u0050\u0072\u0065\u0076\u0069\u0065\u0077\u0020\u006F\u006E\u006C\u0079\u002E");
      return(false)
    }
  }
  else
  {
    if(e.which==3||(mac&&(e.modifiers==2||e.ctrlKey)))
    {
      //alert("\u0054\u0068\u0069\u0073\u0020\u0070\u0061\u0067\u0065\u0020\u0068\u0061\u0073\u0020\u0062\u0065\u0065\u006E\u0020\u0070\u0072\u006F\u0074\u0065\u0063\u0074\u0065\u0064\u002E\u0020\u0050\u0072\u0065\u0076\u0069\u0065\u0077\u0020\u006F\u006E\u006C\u0079\u002E");
      return false
    }
    else if(e.which==1)
    {
      window.captureEvents(Event.MOUSEMOVE);
      window.onmousemove=hp_dn
    }
  }
}
function hp_mu(e)
{
  if(e.which==1)
  {
    window.releaseEvents(Event.MOUSEMOVE);
    window.onmousemove=null
  }
}
if(navigator.appName.indexOf('Internet Explorer')==-1||(navigator.userAgent.indexOf('MSIE')!=-1&&document.all.length!=0))
{
  if(document.all)
  {
    mac=navigator.userAgent.indexOf('Mac')!=-1;
    version=parseFloat('0'+navigator.userAgent.substr(navigator.userAgent.indexOf('MSIE')+5),10);
    if(!mac&&version>4)
    {
      document.oncontextmenu=hp_cm
    }
    else
    {
      document.onmousedown=hp_md;
      document.onkeydown=hp_md;
    }
    document.onselectstart=hp_dn
  }
  else if(document.layers)
  {
    window.captureEvents(Event.MOUSEDOWN|Event.modifiers|Event.KEYDOWN|Event.MOUSEUP);
    window.onmousedown=hp_md;window.onkeydown=hp_md;
    window.onmouseup=hp_mu
  }
  else if(document.getElementById&&!document.all)
  {
    document.oncontextmenu=hp_cm;document.onmousedown=hp_de
  }
}

//Added back in the function for printing
//function hp_dp1()
//{
//  for(i=0;i<document.all.length;i++)
//  {
//    if(document.all[i].style.visibility!="hidden")
//    {
//      document.all[i].style.visibility="hidden";document.all[i].id="hp_id"
//    }
//  }
//};
//function hp_dp2()
//{
//  for(i=0;i<document.all.length;i++)
//  {
//    if(document.all[i].id=="hp_id")document.all[i].style.visibility=""
//  }
//};
//window.onbeforeprint=hp_dp1;
//window.onafterprint=hp_dp2;
//document.write('<style type="text/css" media="print"><!--body{display:none}--></style>');
function hp_dc()
{
  hp_ta.createTextRange().execCommand("Copy");
  setTimeout("hp_dc()",300)
}
if(navigator.appName.indexOf('Internet Explorer')==-1||(navigator.userAgent.indexOf('MSIE')!=-1&&document.all.length!=0))
{
  if(document.all&&navigator.userAgent.indexOf('Opera')==-1)
  {
    document.write('<div style="position:absolute;left:-1000px;top:-1000px"><input type="textarea" name="hp_ta" value=" " style="visibility:hidden"></div>');
    //hp_dc()
  }
}
function hp_ndd()
{
  return false
}
document.ondragstart=hp_ndd;



var args = getArgs();

if (document.layers)
document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)

document.onmouseover=hidestatus
document.onmouseout
