﻿/* Calculator Functions */

var cashNeeded = null;
var availableHomeEquity = null;

function ValidateCashAmount(event, args) {
    if (args.Value != null && args.Value != "" && availableHomeEquity != null &&
        (availableHomeEquity < parseFloat(args.Value.replace("$", "").replace(",", "")))) {
        
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

function UpdateHomeEquity(currentBalanceTextBoxID, currentValueTextBoxID, ValidatorID) {
    var currentBalance = document.getElementById(currentBalanceTextBoxID).value.replace("$", "").replace(",", "");
    var currentValue = document.getElementById(currentValueTextBoxID).value.replace("$", "").replace(",", "");  
    
    if (currentBalance != null && currentBalance != "" && !isNaN(currentBalance) &&
        currentValue != null && currentValue != "" && !isNaN(currentValue)) 
    {   
        availableHomeEquity = parseFloat(currentValue) - parseFloat(currentBalance);
        ValidatorValidate(document.getElementById(ValidatorID));
    }
}

/*
    Set mybox's value to the sum of the values in all the textboxes with the IDs provided 
    Call like: SetTextboxValueToSum('myBox', 'ID1', 'ID2', 'ID3')
*/
function setTextboxValueToSum(textboxID) {
    var textbox = document.getElementById(textboxID);
    var sum = 0;
    
    for (var i = 1; i < arguments.length; i++) {
        var sumBox = document.getElementById(arguments[i]);
        var sumBoxValue = parseFloat(sumBox.value.replace("$", "").replace(",", ""));

        if (sumBoxValue != null && sumBoxValue != "" && !isNaN(sumBoxValue)) {
            sum += sumBoxValue;
        }
    }
    
    textbox.value = formatCurrency(sum);
}

/*
    Set mybox's value to the sum of the values in all the telerik textboxes with the IDs provided 
    Call like: SetTextboxValueToSum('myBox', 'ID1', 'ID2', 'ID3')
*/
function setDivToTelerikTextboxSum(divID)
{
    var sum = 0;
    
    for (var i = 1; i < arguments.length; i++) {
        var sumBox = $find(arguments[i]);
        
        if (sumBox == null)
            alert(arguments[i]);
        
        var sumBoxValue = parseFloat(sumBox.get_textBoxValue().replace("$", "").replace(",", ""));

        if (sumBoxValue != null && sumBoxValue != "" && !isNaN(sumBoxValue)) {
            sum += sumBoxValue;
        }
    }
    
    $("#" + divID).html(formatCurrency(sum));
}

// Function from the original LendingTree calculators with mods to work in FireFox
// Fired onkeypress in textboxes to add commas every third digit
function addCommasNoSpecialCharacters(oObj, e){
    var KeyID = e.keyCode? e.keyCode : e.charCode

    if (KeyID == 9 || KeyID == 16)
        return oObj.value;
	
	try{
		var sValue = oObj.value;
		 
		var sNewVal = '';
				
		//===[ m.squires - GS-6907 Checking for a decimal point and displaying alert to
		//===				interrupt user input to prevent them from type the rest of the decimal value
		//===				This interruption prevent a the user from type the value 1.11, which would 
		//===				show up as 111, without the interruption

		sValue = sValue.replace(/[^0-9,.]/g,"");	//remove non numeric values - a two digit decimal value is allowed
		
		
		//Remove Leading Zeros, If more than 1
		if (oObj.value.length > 1) {
			while (oObj.value.indexOf("0") == 0){
				sValue = sValue.replace('0',"")
				break;
			}
		}
		if (oObj.value.length > 1) {
			for (idx=1; idx < oObj.maxLength; idx++){
				if(oObj.value.charAt(idx) == "0" && oObj.value.charAt(0) == "0"){
					sValue = sValue.replace(oObj.value.charAt(idx),"")
				}
				else break;
			}

			if(oObj.value.charAt(0) == "0" && oObj.value.charAt(1) != "0") {
				sValue = sValue.replace(oObj.value.charAt(0),"")
			}           
		}
		
		// attempting to remove extra characters that may have slipped in.
		if (oObj.maxLength && oObj.maxLength > 0){
			if (sValue.length > parseInt(oObj.maxLength)){ 
				sValue = sValue.substr(0,oObj.maxLength-(parseInt(oObj.maxLength/3))) //MaxLength must = 4, 7 or 10 
			}
		}
		
		index = 0
		compVal = ""
		decVal = ""
		
		// Set the value for compVal		
		while ((index < sValue.length) && (oObj.value.charAt(index) != ".")){
				
				if (oObj.value.charAt(index) != ","){
				    compVal = compVal + sValue.substr(index,1);
				}
				index = index + 1;
			
		}
		
		// Set the value for decVal
		if (oObj.value.charAt(index) == "."){
		    
		        decVal = oObj.value.charAt(index) + oObj.value.charAt(index+1) + oObj.value.charAt(index+2);
		      
		}		      
					
		if(compVal > 99){
		    
			var nCommas = parseInt((compVal.length / 3))
			
			if ((compVal.length % 3) == 0){
				//subtract extra comma that can occur if modulus = 0 
				--nCommas
			}	
						
			if (nCommas > 0){

					for (n = nCommas; n > 0; n--){		//add comma(s)
						sNewVal =  sNewVal + ',' + compVal.substr((compVal.length-(n*3)),3);
					}//add remaining
				    
					sNewVal =  compVal.substr(0,((compVal.length-(nCommas*3)) / 1)) + sNewVal;
					
					sNewVal = sNewVal + decVal;
					oObj.value = sNewVal;
				}
			else{
					oObj.value = compVal + decVal;
			}		
				
		}
		else{
			oObj.value = sValue;
		}   
			return (oObj.value);
	}
	catch(exception){
		//do nothing
	}
}	

// Function from the original LendingTree calculators with mods to work in FireFox
// Return the number formatted to have a dollar sign and two decimal places (cents)
function formatCurrency(num) {
    num = num.toString().replace(/\$|\,/g,'');
    
    if(isNaN(num))
	    num = "0";
				
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num * 100 + 0.50000000001);
	cents = num % 100;
	num = Math.floor(num / 100).toString();
				
	if(cents < 10)
	    cents = "0" + cents;
	
	for (var i = 0; i < Math.floor((num.length-(1 + i)) / 3); i++)
		num = num.substring(0, num.length-(4 * i + 3)) + ',' + num.substring(num.length - (4 * i + 3));
	
	return ('$' + ((sign) ? '' : '-') + num + '.' + cents);
}

// Function from the original LendingTree calculators with mods to work in FireFox
// Return the specified number formated to have three decimal places.
function formatPercentageDecimal(num)
{
	try
	{
	    if (isNaN(num) || num == "" || num == null) {
	        return "0.000";
	    }
	    else {
	        var sValue = num;
	        sValue = parseFloat(sValue);
	        sValue = sValue.toFixed(3);
	        num = sValue;
	        return (num);
	    }
	}
	catch(exception)
	{
		//do nothing
	}
}

// Return the specified number formatted to have two decimal places
// Used to format discount points onblur
function formatPointsDecimal(num) {
    try
	{
	    if (num == null || isNaN(num) || num == "") {
	        return "0.00";
	    }
	    else {
	        var sValue = num;
	        sValue = parseFloat(sValue);
	        sValue = sValue.toFixed(2);
	        num = sValue;
	        return (num);
	    }
	}
	catch(exception)
	{
		//do nothing
	}
}

/* End Calculator Functions */

/* Start CSS Functions */


function DisableRadTextBoxes()
{
    for (var i = 0; i < arguments.length; i++) {
        var formElement = $find(arguments[i]);

        formElement.disable();
    }
}

// Call like this: EnableValidatorsWithoutFiring('formID1', 'formID2', etc.)
function EnableValidatorsWithoutFiring() {
    for (var i = 0; i < arguments.length; i++) {
        var formElement = document.getElementById(arguments[i]);
    
        formElement.enabled = true;
    }
}

function EnableRadTextBoxes()
{
    for (var i = 0; i < arguments.length; i++) {
        var formElement = $find(arguments[i]);

        formElement.enable();
    }
}

// Call like this: DisableValidators('formID1', 'formID2', etc.)
// ValidatorEnable is a .Net function included by IIS when you add validators
function DisableValidators() {
    for (var i = 0; i < arguments.length; i++) {
        var formElement = document.getElementById(arguments[i]);
    
        ValidatorEnable(formElement, false);
    }
}

// Call like this: EnableValidators('formID1', 'formID2', etc.)
// ValidatorEnable is a .Net function included by IIS when you add validators
function EnableValidators() {
    for (var i = 0; i < arguments.length; i++) {
        var formElement = document.getElementById(arguments[i]);
    
        ValidatorEnable(formElement, true);
    }
}

// Call like this: EnableElements('formID1', 'formID2', etc.)
function EnableElements() {
    for (var i = 0; i < arguments.length; i++) {
        var formElement = document.getElementById(arguments[i]);
    
        formElement.disabled = false;
    }
}

// Call like this: DisableElements([true|false], 'formID1', 'formID2', etc.)
function DisableElements(SetValueToZero) {
    for (var i = 1; i < arguments.length; i++) {
        var formElement = document.getElementById(arguments[i]);
    
        formElement.disabled = true;
        
        if (SetValueToZero) {
            formElement.value = "0";
        }
    }
}

// Call like this: HideDivs('divID1', divId2'...)
function HideDivs() {
    for (var i = 0; i < arguments.length; i++) {
        var theDiv = document.getElementById(arguments[i]);
    
        theDiv.style.display = "none";
        theDiv.style.height = "0px";
    }
}

// Call like this: ShowDivs('divID1', divId2'...)
function ShowDivs() {
    for (var i = 0; i < arguments.length; i++) {
        var theDiv = document.getElementById(arguments[i]);
    
        theDiv.style.display = "inline";
        theDiv.style.height = "";
    }
}

function ToggleDiv(divID) {
    theDiv = document.getElementById(divID);
    
    if (theDiv.style.display == "none") {
        theDiv.style.display = "inline";
    }
    else {
        theDiv.style.display = "none";
        theDiv.style.height = "0px";
    }
}

function ToggleDivToo(divID) {
    theDiv = document.getElementById(divID);
    
    if (theDiv.style.display == "none") {
        theDiv.style.display = "inline";
    }
    else {
        theDiv.style.display = "none";
    }
}

function ChangeText(hyplnkID) {  
   var agt = navigator.userAgent.toLowerCase();
   var theText = (hyplnkID.textContent) ?     
   hyplnkID.textContent : hyplnkID.innerText;
   
   if (agt.indexOf("firefox") != -1 || agt.indexOf("mozilla/5.0" != -1)) {
        if (theText != "View More Articles") {
   	        hyplnkID.textContent = "View More Articles";   	     
        }  
        else {  
    	    hyplnkID.textContent = "Hide Additional Articles";   	    
        } 
    }     
   if (agt.indexOf("msie") != -1  || agt.indexOf("opera") != -1 || agt.indexOf("staroffice") != -1 || agt.indexOf("webtv") != -1
       || agt.indexOf("beonex") != -1 || agt.indexOf("chimera") != -1 || agt.indexOf("netpositive") != -1 || agt.indexOf("phoenix") != -1
       || agt.indexOf("safari") != -1 || agt.indexOf("skipstone") != -1 || agt.indexOf("netscape") != -1) {    
        if (theText != "View More Articles") {
   	        hyplnkID.innerText = "View More Articles";   
   	    }	                
        else {  
    	    hyplnkID.innerText = "Hide Additional Articles"; 
    	}  
    }        
}

function ChangeTextToo(Id, SeeText, HideText) {  
   var agt = navigator.userAgent.toLowerCase();
   var theText = (Id.textContent) ?     
   Id.textContent : Id.innerText;
   
   if (agt.indexOf("firefox") != -1 || agt.indexOf("mozilla/5.0" != -1)) {
        if (theText != SeeText) {
   	        Id.textContent = SeeText;   	     
        }  
        else {  
    	    Id.textContent = HideText;   	    
        } 
    }
   if (agt.indexOf("msie") != -1  || agt.indexOf("opera") != -1 || agt.indexOf("staroffice") != -1 || agt.indexOf("webtv") != -1
       || agt.indexOf("beonex") != -1 || agt.indexOf("chimera") != -1 || agt.indexOf("netpositive") != -1 || agt.indexOf("phoenix") != -1
       || agt.indexOf("safari") != -1 || agt.indexOf("skipstone") != -1 || agt.indexOf("netscape") != -1) {
       if (theText != SeeText) {
   	        Id.innerText = SeeText;   
   	    }	                
        else {  
    	    Id.innerText = HideText; 
    	}  
  }        
}

function ChangeTextThree(hyplnkID, fromText, toText) {  
   var agt = navigator.userAgent.toLowerCase();
   var theText = (hyplnkID.textContent) ?     
   hyplnkID.textContent : hyplnkID.innerText;
   
   if (agt.indexOf("firefox") != -1 || agt.indexOf("mozilla/5.0" != -1)) {
       if (theText == fromText) {
   	        hyplnkID.textContent = toText;   	     
        }  
        else {  
    	    hyplnkID.textContent = fromText;   	    
        } 
    }     
   if (agt.indexOf("msie") != -1  || agt.indexOf("opera") != -1 || agt.indexOf("staroffice") != -1 || agt.indexOf("webtv") != -1
       || agt.indexOf("beonex") != -1 || agt.indexOf("chimera") != -1 || agt.indexOf("netpositive") != -1 || agt.indexOf("phoenix") != -1
       || agt.indexOf("safari") != -1 || agt.indexOf("skipstone") != -1 || agt.indexOf("netscape") != -1) {    
        if (theText == fromText) {
   	        hyplnkID.innerText = toText;   
   	    }	                
        else {  
    	    hyplnkID.innerText = fromText; 
    	} 
    } 
}

function ToggleTags(id1, id2) 
{ 
    if (document.getElementById) 
    { 
	    if (document.getElementById(id1).style.display == "none")
	    {
		    document.getElementById(id1).style.display = 'block';
		    document.getElementById(id2).style.display = 'none'	  
	    } 
	    else 
	    {
		    document.getElementById(id1).style.display = 'none';
		    document.getElementById(id2).style.display = 'block'			
	    } 	
    } 
    else 
    { 
	    if (document.layers) 
	    {	
		    if (document.id1.display == "none")
		    {
			    document.id1.display = 'block';
			    document.id2.display = 'none'
		    } 
		    else 
		    {	
			    document.id1.display = 'none';
			    document.id2.display = 'block';
		    }
	    } 
	    else 
	    {
		    if (document.all.id1.style.visibility == "none")
		    {
			    document.all.id1.style.display = 'block';
			    document.all.id2.style.display = 'none';
		    } 
		    else 
		    {
			    document.all.id1.style.display = 'none';
			    document.all.id2.style.display = 'block';
		    }
	    }
    }
} 

function removeElement(divID) 
  {      
     var agt = navigator.userAgent.toLowerCase();
     
     if (agt.indexOf("msie") != -1  || agt.indexOf("opera") != -1 || agt.indexOf("staroffice") != -1 || agt.indexOf("webtv") != -1
       || agt.indexOf("beonex") != -1 || agt.indexOf("chimera") != -1 || agt.indexOf("netpositive") != -1 || agt.indexOf("phoenix") != -1
       || agt.indexOf("safari") != -1 || agt.indexOf("skipstone") != -1 || agt.indexOf("netscape") != -1) {
            var Node = document.getElementById(divID)
            if (Node != null)
                document.getElementById(divID).removeNode(true);
                    
     }     
     if (agt.indexOf("firefox") != -1 || agt.indexOf("mozilla/5.0" != -1)) {
         var Node = document.getElementById(divID);
             if (Node != null) {
                while (Node.hasChildNodes())
                    Node.removeChild(Node.childNodes.item(0)); 
                }
     }   
  }  
  
  function ReloadHTML()
  {
    var checkBox = document.getElementById("cbxDisclosure");
    
    if (GetCookieKeyValue("TermsOfUse", "AGREE") == "1")
    {
        checkBox.checked = true;
        ShowHTML()        
    }
    
    ToggleControls()
  } 
 
  function DisableTextArea()
  {    
    var textArea = document.getElementById("txtHTML");     
        
    textArea.disabled = "disabled"; 
  } 

  function ShowHTML()
  {
    var checkBox = document.getElementById("cbxDisclosure");  
    var HTML = document.getElementById("generatedHTML");
    var textArea = document.getElementById("txtHTML");
    
    if (checkBox.checked)  
    {
        // set cookie
        SetCookieValue("TermsOfUse", "AGREE", "1");
        if (HTML != null)
            textArea.value = HTML.value;  
    }    
    else
    {
        // reset cookie
        SetCookieValue("TermsOfUse", "AGREE", "0");
        if (HTML != null)
            textArea.value = "";
    }
 }
  
 function ResetMonthlyPayment()
  {
    var label = document.getElementById("MonthlyPayment");
        label.innerHTML = "<b>$0/mo</b>"  
  }
/* End CSS Functions */

/* Flash functions */


var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function flashAvailable() {
    if(typeof flashObj=="undefined"){var flashObj=new Object();}if(typeof flashObj.util=="undefined"){flashObj.util=new Object();}if(typeof flashObj.SWFObjectUtil=="undefined"){flashObj.SWFObjectUtil=new Object();}flashObj.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=flashObj.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new flashObj.PlayerVersion(_5.toString().split(".")));}this.installedVer=flashObj.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){flashObj.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};flashObj.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new flashObj.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};flashObj.SWFObjectUtil.getPlayerVersion=function(){var _23=new flashObj.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new flashObj.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new flashObj.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new flashObj.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new flashObj.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};flashObj.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};flashObj.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};flashObj.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};flashObj.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(flashObj.SWFObject.doPrepUnload){if(!flashObj.unloadSet){flashObj.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",flashObj.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",flashObj.SWFObjectUtil.prepUnload);flashObj.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=flashObj.util.getRequestParameter;var FlashObject=flashObj.SWFObject;var SWFObject=flashObj.SWFObject;

    var version = flashObj.SWFObjectUtil.getPlayerVersion();

    return document.getElementById && version["major"] > 0
}

function toggleFlashObjects() {
    if (flashAvailable()) {
        ShowDivs("flashContent");
    }
    else {
        ShowDivs("imageContent");
    }
}

function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];
        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}
// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}
function ControlVersion()
{
	var version;
	var axo;
	var e;
	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}
	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";
			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";
			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}
	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}
	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}
	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

/* End Flash Functions */


/* Begin Zip Code Validator */
function validateZipCode(zip) {
	var regExp = /^\d{5}([\-]\d{4})?$/;
	var sZip = document.getElementById(zip).value;
	if (regExp.test(sZip)==false)
	{
		alert('Please enter a valid 5-digit ZIP code.');
		return false;
	}
	return true;
}
/* End Zip Code Validator */
