﻿function openClass(windowURL) {
if ((navigator.appVersion.indexOf("Mac") != -1)) {
	newWindow = window.open(windowURL,'Classroom','toolbar=no,location=no,menubar=no,width=475,height=550,scrollbars=yes,resizable=no');
} else {
	newWindow = window.open(windowURL,'Classroom','toolbar=no,location=no,menubar=no,width=494,height=550,top=0,left=0,scrollbars=yes,resizable=no');
}
}

function openPlayerSelection(windowURL) {
if (navigator.appName=="Microsoft Internet Explorer") {
	resizeParam = 0;
} else {
	resizeParam = 1;
}
	windowURL = windowURL + "?fsection=Videos&ck=t";
	playerSelectWin = window.open(windowURL,'playerSelectWin','toolbar=no,titlebar=no,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable='+resizeParam+',width=320,height=480,top=20,left=10');
} 

function findarticleRedirect() {
	if (document.forms[2].findarticle.options[document.forms[2].findarticle.selectedIndex].value != "^")
	parent.location = document.forms[2].findarticle.options[document.forms[2].findarticle.selectedIndex].value;
}
function enableButton(){
  //if (document.calculator.savings.value != 0)
    document.getElementById('btnImage').style.display = 'none';
    document.getElementById('submitBtn').style.display = 'block';    
}
var oRequest;

function calculateSavings(){  
  oRequest=GetXmlHttpObject()
  
  if (oRequest==null){
    alert ("Your browser does not support AJAX!");
    return;
  } 
  var url = "/hpWebService/calculate.aspx";
  url = url + "?age=" + document.calculator.age.value;
  url = url + "&income=" + document.calculator.income.value;
  url = url + "&savings=" + document.calculator.savings.value;    
  oRequest.open("GET",url,true);  
  oRequest.onreadystatechange = function(){    
    if (oRequest.readyState == 4){            
      var display = document.getElementById('resultDisplay');     
      var txt = oRequest.responseText;      
      display.innerHTML = txt;
           
      document.calculator.age.options[0].selected = true;
      document.calculator.income.options[0].selected = true;
      document.calculator.income.disabled = true;
      document.calculator.savings.options[0].selected = true;
      document.calculator.savings.disabled = true;
      document.getElementById('btnImage').style.display = 'block';
      document.getElementById('submitBtn').style.display = 'none';
    }  
  }  
  oRequest.send(null);  
} 

function GetXmlHttpObject(){
  var xmlHttp=null;
  try{
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
  }catch (e){    
    // Internet Explorer
    try{
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }catch (e){
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  return xmlHttp;
}

function setIncomeOptions2() {
  var chosen = document.calculator.age.value;
  var incomebox = document.calculator.income;

  if (chosen >= 5) {
    //alert(chosen);      
    incomebox.options[5] = new Option("$100,000", "100000"); 
    incomebox.remove(6);   
  }

  if (chosen >= 9) {
    //alert(chosen);    
    incomebox.options[6] = new Option("$120,000", "120000");    
  }

  if (chosen<5){
    incomebox.remove(6);
    incomebox.remove(5);
  }
  incomebox.disabled=false;
}

function setIncomeOptions() { 
var incomebox = document.calculator.income;
incomebox.disabled=false; 
}

function Get_Cookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) &&
	( name != document.cookie.substring( 0, name.length ) ) )
	{
	return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}



