 // Main Java Source for DHSCH Web Page copyright 2005

        var initialized = false;
        var t = null;
	var tad = null;
	var tad2 = null;
	
        var refreshStartInd = "Y";
	var reloadStartInd = " ";
        var theAd=0;
        var theAd2=0;

	function initForms() 
	{

	        reloadStartInd = "N";

	}


                        function InitPage() {
                                if (!initialized) {
                                        var tickerSymbol = "index:indu,index:compx,index:spx.x";
                                }
                               	initialized = true;
                        }


                       function SaveTheData()
                       {
                          setCookie('DHSCHRefreshIndData', refreshStartInd, 8);
                       }

                       function RetrieveTheData( idit )
                       {
                          refreshStartInd = getCookie('DHSCHRefreshIndData');
			  // alert(idit + " " + document.cookie );
                       }
                       function SaveReloadInd()
                       {
                          setCookie('DHSCHReloadIndData', reloadStartInd, 1);
                       }

                       function RetrieveReloadInd( idit )
                       {
                          reloadStartInd = getCookie('DHSCHReloadIndData');
			  // alert(idit + " " + document.cookie + " " + reloadStartInd );
                       }
                       function DeleteReloadInd( idit )
                       {
                          deleteCookie('DHSCHReloadIndData');
			  // alert(idit + " " + document.cookie );
                       }
                       function setCookie(name, value, days)
                       {
                          var today = new Date();
                          var expire = new Date();
                          expire.setTime(today.getTime() + 1000*60*60*24*days);
                          document.cookie = name + "=" + escape(value) + ((expire == null) ? "" : ("; expires=" + expire.toGMTString() ) );
                       }

                       function getCookie(Name)
                       {
                         var search = Name + "=";
                         var offset = 0;
                         var end = 0;

                         if (document.cookie.length > 0)                        // if there are any cookies
                         {
                             offset = document.cookie.indexOf(search);

                             if (offset != -1)                                  // if cookie exists
                             {
                                 offset += search.length;                        // set index of beginning of value
                                 end = document.cookie.indexOf(";", offset);     // set index of end of cookie value
                                 if (end == -1) end=document.cookie.length;
                                 return unescape(document.cookie.substring(offset, end));
                              } else
                              {
                               }
                         }
                         return ''
                       }
		       function deleteCookie(name) {
   			if (GetCookie(name)) 
			{
                          document.cookie = name + "=" + escape(" ") + ((expire == null) ? "" : ("; expires=expires=Thu, 01-Jan-70 00:00:01 GMT") );     				
   			}
		       }

		function setColor(color) {
        		document.fgColor = color;
		}
function findDiv(n, d) 
{ 
	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=findDiv(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function toggleNav() 
{ 
  var i,p,v,obj,args=toggleNav.arguments;
  for (i=0; i<(args.length-2); i+=3) 
	if ((obj=findDiv(args[i]))!=null) 
	{ 
		v=args[i+2];
    		if (obj.style) { 
			obj=obj.style; 
			v=(v=='show')?'visible':(v='hide')?'hidden':v;
 		}
    		obj.visibility=v; 
	}
}

function hideAllDDs() 
{
	toggleNav('FloorPlans','','hide');
	toggleNav('StandardFeatures','','hide');
	toggleNav('ConstructionProcess','','hide');
	toggleNav('WealthLab','','hide');
	toggleNav('WealthLabCalc','','hide');
	toggleNav('WealthLabCalcFin','','hide');
	toggleNav('WealthLabFin','','hide');
	toggleNav('WealthLabVal','','hide');
}
function hideAllDDSubs() 
{
	toggleNav('WealthLabCalc','','hide');
	toggleNav('WealthLabCalcFin','','hide');
	toggleNav('WealthLabFin','','hide');
	toggleNav('WealthLabVal','','hide');
}

function hideDDSub(sect) 
{
	toggleNav(sect,'','hide');
	hideAllDDSubs();
}
function hideDD(sect) 
{
	toggleNav(sect,'','hide');
	hideAllDDs();
}
var sectionSetting = null;
var sectionSettingSub = null;
function setDDactive(sect) 
{
	toggleNav(sect,'','show');
	if (sectionSetting != null) 
	{
		window.clearTimeout(sectionSetting);
	}
}
function setDDactiveSub(sect) 
{
	if (sectionSettingSub != null) 
	{
		window.clearTimeout(sectionSettingSub);
	}
	hideAllDDSubs();
	toggleNav(sect,'','show');
}

function setDDTimeout(sect) 
{
	if (sectionSetting != null) 
	{
		window.clearTimeout(sectionSetting);
	}
	sectionSetting = window.setTimeout('hideDD("' + sect + '")',500);
}
function setDDTimeoutSub(sect) 
{
	if (sectionSettingSub != null) 
	{
		window.clearTimeout(sectionSettingSub);
	}
	sectionSettingSub = window.setTimeout('hideDDSub("' + sect + '")',500);
}


function prepaymentChart() {

alert('1');
	var D = new Diagram();
alert('2');
	D.SetFrame(80, 160, 540, 460);
alert('3');
	D.SetBorder(0, eval(2*Math.PI), -1, 1);
alert('4');
	D.SetText("", "", "<B>some functions</B>");
	D.XGridDelta=Math.PI/4;
	D.XScale="function MyXScale";
	D.YGridDelta=0.2;
	D.YSubGrids=2;
	D.SetGridColor("#FFFFFF", "#EEEEEE");
alert('5');
	D.Draw("#DDDDDD", "#000000", false);
alert('6');
	var i, j, x;
	for (i=80; i<=540; i++)
	{ x = D.RealX(i);
	  j= D.ScreenY(Math.sin(x));
	  new Pixel(i, j, "#FF0000");
	  j= D.ScreenY(Math.cos(x));
	  new Pixel(i, j, "#0000FF");
	}
	new Bar(560, 200, 680, 220, "#0000FF", "f(x)=cos(x)", "#FFFFFF");
	new Bar(560, 260, 680, 280, "#FF0000", "f(x)=sin(x)", "#000000");

	alert('2');
}
function showPopWin(url)
{
	var subWin = window.open("","DCsubwin","width=500,height=300,resizable=yes");
        if (location.host != "") {
		subWin.location.href = "http://" + location.host + url;
	} else {
	        subWin.location.href = "file:///C:/DHSCH_Website" + url;
	}        
	if (subWin.opener == null) subWin.opener = window;
	subWin.opener.name = "opener";
}
function showCalculator(cmode,params)
{
	var url = "/calculator/popup/calculator.htm";
	if (cmode) url += "?mode="+cmode;
	showPopWin(url);
}
function showGlossary(entry)
{
	var url = "/definitions/popup/glossary.htm";
	if (entry) url += "?entry="+entry;
	showPopWin(url);
}
function showAmazon(url)
{
	if (url == null)
	{
		url = "http://www.amazon.com/exec/obidos/redirect-home";
	}
	else if (url.length == 10)
	{
		var asin = url;
		url = "http://www.amazon.com/exec/obidos/ASIN/" + asin;
	}
	
	var y = 400;
	
	var ySc = 0;
	if (document.all != null && parseInt(navigator.appVersion) >= 4) //IE
		ySc = document.body.clientHeight - 20;

	if (ySc > y) y = ySc;
	
	var amznwin = window.open(url,"DHSCHAmznWin","location=yes,menubar=yes,scrollbars=yes,status=yes,toolbar=yes,resizable=yes,width=780,height=" + y + ",screenX=10,screenY=10,top=10,left=10");
	
	var ver = navigator.appVersion;
	var i = ver.indexOf("MSIE ");
	if (i >= 0) ver = ver.substring(i + 5);
	if (parseFloat(ver) >= 5)
		amznwin.focus();
}
//-->

