﻿function newWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}
 
function newWindowQuick(theURL, myWidth, myHeight) { 
	var winName = "newWindowQuick"
	var isCenter = 'true'
	var features = 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes'
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}

function logOut() {
	bodyTags = document.getElementsByTagName("body");
	bodyTags[0].style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
	var agree = confirm("Are you sure you wish to logout?");
	if (agree) {
	   return true;	
	} else {
		bodyTags[0].style.filter = "";
		return false;
	}
}
 
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function preloadImage(imgPath) {
	if (document.images) {
		rslt = new Image();
		rslt.src = imgPath;
		return rslt;
	}
}

function toggleElementDisplay(theElementID) {
	var theElement = document.getElementById(theElementID);	
	var displayStyle = theElement.style.display
	if (displayStyle == '') {
		theElement.style.display = "none";
	} else {
		theElement.style.display = "";
	}
}

document.write('<img align="right" width="1" height="1" src="/images/log_analysis_screen_info.jpg?width=' + screen.width + '&height=' + screen.height + '&depth=' + screen.colorDepth + '">\n');

function calcTotalOptResult(mathBoxId, writingBoxId, readingBoxId, scienceBoxId, socialStudyBoxId, totalBoxId) {
    var mathBox = document.getElementById(mathBoxId);
    var readingBox = document.getElementById(readingBoxId);
    var scienceBox = document.getElementById(scienceBoxId);
    var socialStudyBox = document.getElementById(socialStudyBoxId);
    var writingBox = document.getElementById(writingBoxId);
    var totalBox = document.getElementById(totalBoxId);
    var grandTotal = 0;
    
    var mathBoxValue = mathBox.value;
    var readingBoxValue = readingBox.value;
    var scienceBoxValue = scienceBox.value;
    var socialStudyBoxValue = socialStudyBox.value;
    var writingBoxValue = writingBox.value;
    
    if (IsNumeric(mathBoxValue)) {
        grandTotal += parseInt(mathBoxValue);
    }
    
    if (IsNumeric(readingBoxValue)) {
        grandTotal += parseInt(readingBoxValue);
    }
    
    if (IsNumeric(scienceBoxValue)) {
        grandTotal += parseInt(scienceBoxValue);
    }
    
    if (IsNumeric(socialStudyBoxValue)) {
        grandTotal += parseInt(socialStudyBoxValue);
    }
    
    if (IsNumeric(writingBoxValue)) {
        grandTotal += parseInt(writingBoxValue);
    }
    
  
    if (grandTotal > 0) {
        totalBox.innerHTML = grandTotal;
    } else {
        totalBox.innerHTML = "TBD";
    }
}


function IsNumeric(sText)
{
    if (sText == "") {
        return false;
    }  else {
       var ValidChars = "0123456789.";
       var IsNumber=true;
       var Char;

	         for (i = 0; i < sText.length && IsNumber == true; i++) 
              { 
              Char = sText.charAt(i); 
              if (ValidChars.indexOf(Char) == -1) 
                 {
                 IsNumber = false;
                 }
        }
       
       return IsNumber;
   
   }
   
}

function EnableElementDisplay(theElementID) {
	//alert(theElementID);

	var theElement = document.getElementById(theElementID);
	//theElement.setAttribute("style", "display:block;");
	//alert(theElement.getAttribute("style"));
	
	theElement.style.display = "";
}



// GIVES US SCREEN DIMENSIONS, ETC FOR STAT ANALYSIS
document.write('<img align="right" width="1" height="1" src="/images/log_analysis_screen_info.jpg?' +
 'width=' + screen.width + '&height=' + screen.height + '&depth=' + screen.colorDepth + '">\n');
 
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

//----------------------

// centergy stuff
var jaxMenu; // global variable
function CentergyStatusBar() {
    this.currentMsg = "steve loading test...";
    this.containerHtml = '<div id="jaxStatusContainer" class="ui-corner-bottom" style="display:none">TEST</div>';
    $("body").append(this.containerHtml);
    this.container = $("body div#jaxStatusContainer")

    this.SetStatus = function (txt) {
        this.currentMsg = txt;
        this.container.html(this.currentMsg);
        this.container.show();
        //alert(this.container.html());
    }

    this.ClearStatus = function () {
        this.container.hide();
        this.container.html("");
    }

    this.ClearWithSizzle = function (goodbyeTxt, duration) {
        // clear background url noise
        //var oldbackgroundUrl = this.container.css("background-image");

        //this.container.css("background-image", "none");
        this.currentMsg = goodbyeTxt;
        this.container.html(goodbyeTxt);
        this.container.delay(duration).slideUp('fast');

        // put background image back in
        //this.container.css("background-image", oldbackgroundUrl);
    }
}
