function disableEnterKey()
{
	if (event.keyCode==13)
		return false;
}

function leavingSite()
{
	if (confirm('You are leaving the Susquehanna web site. The site you have chosen is independent from Susquehanna.  Susquehanna does not control these sites and does not guarantee the accuracy, completeness, efficacy or timeliness of information contained therein.'))
		return true;
	else
		return false;
}

function exitWarningRedirect(ctrlObj)  {
  var msg = "You are leaving the Susquehanna web site.  The site you have chosen is independent from Susquehanna. Susquehanna does not control these sites and does not guarantee the accuracy, completeness, efficacy or timeliness of information contained therein."
  if(confirm(msg)) {
    window.location.href = ctrlObj;
  } else {
    // Do nothing
  }  
}

function openWindow(strURL, w, h, x, y, scrollbar)
{
	var newWindow = window.open(strURL, "Search", "toolbar=0,location=0,directories=0,status=0,scrollbars=" + scrollbar + ",resizable=yes,width=" + w + ",height=" + h);	
	newWindow.moveTo(x,y);
	newWindow.focus();
}

function PopupWindow() 
{
	var attributes = 'width=800,height=600,scrollbars=no';
	window.open('largeMap.aspx','2',attributes);
}


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_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_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.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 showbuttons() {   

    var agt       = navigator.userAgent.toLowerCase();
    var IEMAC     = ((agt.indexOf("msie") != -1) && agt.indexOf("mac")!=-1);
    var N6        = (agt.indexOf("netscape6") != -1 || (agt.indexOf("netscape/6") !=-1 ));

    if ( N6 ) {
      return "Netscape 6 is unable to support our detailed reports.  Please upgrade to Nescape 7.<P>";
    }
    if ( IEMAC ) {
      return "<P>";
    }

    return "<P><FORM><INPUT TYPE='button' value='Calculate' Name='btnCallCalc' onClick='document.calculator.calculate()'><INPUT TYPE='button' value='View Report' Name='btnOpenNote' onClick='openNote()'></FORM>";
}

function openNote()
 { 
 
 var agt=navigator.userAgent.toLowerCase(); 
 var is_aol   = (agt.indexOf("aol") != -1);

 leftpos=0;
 if (screen) {
   leftpos=screen.width/2 - 300;
 } 

 if (is_aol) {
   var s = " ";
   s=document.calculator.sJavaScriptReport('HTML');
    document.write(s);
 }
 else {
   var OpenWindow=window.open("","newwin","toolbar=yes,menubar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=380,left="+leftpos+",top=20");
   var s = " ";
   s=document.calculator.sJavaScriptReport('HTML');
   OpenWindow.document.write(s);
   OpenWindow.document.close(); 
   OpenWindow.focus();
 }
}

function OpenAsPopupWindow(options) {
    /// <summary>Causes the Anchor to be a popup window</summary>
    /// <param name="options" type="JSON/String">If no JSON object is passed, the URL as a string can be passed,
    /// otherwise it will use the HREF attribute of the calling object; 
    /// additional paramaters: 
    /// noDefault - don't use the default Attributes, 
    /// url - the url you want it sent to, 
    /// name - the window name to give it, 
    /// top &amp; left - position it is to show up</param>
    /// <returns type="boolean"></returns>
    var url = ""
                , sender = (e && e.target) || (window.event && window.event.srcElement)
                , strName = "SusquehannaPopup"
                , position = null
                , strAttributes = "toolbar=0,location=0,directories=0,status=0";
    if (sender.href) url = sender.href;
    if (typeof options == "object") {
        //scrollbar = (options.scrollbar ? options.scrollbar : scrollbar)
        if (options.url) {
            url = options.url;
            delete options.url;
        }
        if (options.top && options.left) {
            position = {
                top: options.top
                        , left: options.left
            };
        }
        if (options.name) {
            strName = options.name;
            delete options.name;
        }
        delete options.top;
        delete options.left;

        if (options.noDefaults) {
            alert('noDefaults');
            strAttributes = "";
            delete options.noDefaults;
        }

        for (var prop in options) {
            strAttributes += (strAttributes == "" ? "" : ",") + prop + "=" + options[prop];
        }
    } else if (typeof options == "string") {
        url = options;
    }

    var newWindow = window.open(url, strName, strAttributes);
    if (position != null) newWindow.moveTo(position.top, position.left);
    newWindow.focus();
    return false;
} //end function OpenAsPopupWindow

function getTopWithScroll(id) {
    /// <summary>This will return the 'top' of the passed element, in its relation to 
    /// the Window top (ie with scroll bars)</summary>
    /// <param name="id" type="string">The Element ID we want to find the top of</param>
    /// <returns type="number">Int Representing the Window Top..</returns>
    var el = document.getElementById(id);
    var intElTop = 0, intScrollTop = 0, 
        intElLeft = 0, intScrollLeft = 0;
    var rtnValue = { 'top': null, 'left': null };
    if (el.offsetParent) {
        // Scroll though all the elements, to find it's top...
        do {
            intElTop += el.offsetTop;
            intElLeft += el.offsetLeft;
            intScrollTop += (el.offsetParent ? el.offsetParent.scrollTop : 0);
            intScrollLeft += (el.offsetParent ? el.offsetParent.scrollLeft : 0);
        } while (el = el.offsetParent);
        // Now account for the Window height.....
        intScrollTop += (window.pageY || document.documentElement.scrollTop);
        intScrollLeft += (window.pagex || document.documentElement.scrollLeft);

        rtnValue.top = (intElTop - intScrollTop);
        rtnValue.left = (intElLeft - intScrollLeft);
    }
    return rtnValue;
} // end function getTopWithScroll
