// JavaScript Document

function LoademUp(){
fluidLayers('HeaderPicRight','150','0','auto','auto',0,0,0,0);
fluidLayers('HeaderPicLeft','0','0','auto','auto',0,0,0,0);
fluidLayers('HeaderHamiltonMill','100','20','auto','auto',0,0,0,0); fluidLayers('HamiltonMillBar','100','20','auto','auto',0,0,0,0); fluidLayers('HeaderCenter','100','0','auto','auto',0,0,0,0); fluidLayers('HeaderHamiltonMillText','100','85','auto','auto',0,0,0,0);fluidLayers('HeaderHamiltonMillText2','100','105','auto','auto',0,0,0,0); fluidLayers('copyright','0','0','200','13',0,0,0,0); fluidLayers('chat','0','auto','200','200',0,0,0,13); fluidLayers('buyerbase','220','220','auto','auto',0,0,0,0); 
fluidLayers('sellerbase','440','220','auto','auto',0,0,0,0);
fluidLayers('sellerbar','440','220','auto','auto',0,0,0,0);
fluidLayers('buyerbar','440','220','auto','auto',0,0,0,0);fluidLayers('hmillhvform','0','220','auto','auto',0,0,0,0); fluidLayers('clientLogin','0','220','auto','auto',0,0,0,0); fluidLayers('searchform','0','220','auto','auto',0,0,0,0); fluidLayers('hmillAmenities','0','220','auto','auto',0,0,0,0); fluidLayers('hmillArea','0','220','auto','auto',0,0,0,0); fluidLayers('backgroundPic','0','220','auto','auto',0,0,0,0); fluidLayers('backgroundPicTwo','0','220','auto','auto',0,0,0,0); Flashover(); HmillUpdateOptions(); fluidLayers('hmillwords','200','158','auto','auto',0,0,0,0); fluidLayers('browserData','0','27','200','200',0,0,0,13);fluidLayers('Featured','100','105','auto','auto',0,0,0,0); fillSearchID(); viewTimeNonSearch(3000);
}

function LoademUpTemplate(){
fluidLayers('HeaderPicRight','150','0','auto','auto',0,0,0,0);
fluidLayers('HeaderPicLeft','0','0','auto','auto',0,0,0,0);
fluidLayers('HeaderHamiltonMill','100','20','auto','auto',0,0,0,0); fluidLayers('HamiltonMillBar','100','20','auto','auto',0,0,0,0); fluidLayers('HeaderCenter','100','0','auto','auto',0,0,0,0); fluidLayers('HeaderHamiltonMillText','100','85','auto','auto',0,0,0,0); fluidLayers('HeaderHamiltonMillText2','100','105','auto','auto',0,0,0,0); fluidLayers('copyright','0','0','200','13',0,0,0,0); fluidLayers('chat','0','auto','200','200',0,0,0,13); fluidLayers('backgroundPic','0','220','auto','auto',0,0,0,0); fluidLayers('backgroundPicTwo','0','220','auto','auto',0,0,0,0); Flashover(); fluidLayers('browserData','0','27','200','200',0,0,0,13); fluidLayers('pagetitle','100','105','auto','auto',0,0,0,0); fluidLayers('pagetitlebar','100','105','auto','auto',0,0,0,0); fluidLayers('pagesubtitle','100','105','auto','auto',0,0,0,0);fluidLayers('pagecontent','100','105','auto','auto',0,0,0,0); fillSearchID(); viewTimeNonSearch(3000);
}

function showhide(vari){
	//alert(vari);
	
var ns4 = (document.layers) ? true:false ;
var ie4 = (document.all) ? true:false;
var ng5 = (document.getElementById) ? true:false; 
var count = 0;
var number = vari;

Layers = new Array(2);
Layers[0] = new Array(15);//show
Layers[1] = new Array(15);//hide

Layers[0][1] = new Array("hmillAmenitiesHover");
Layers[1][1] = new Array();
Layers[0][2] = new Array();
Layers[1][2] = new Array("hmillAmenitiesHover");
Layers[0][3] = new Array();
Layers[1][3] = new Array("hmillAmenitiesHover");

if (ns4) {
	for(count=0;count<Layers[0][number].length;count++){
	document.Layers[0][number][count].visibility = "show";
	}
	for(count=0;count<Layers[1][number].length;count++){
	document.Layers[1][number][count].visibility = "hide";
	}
}else if (ng5) {
	for(count=0;count<Layers[0][number].length;count++){
	document.getElementById(Layers[0][number][count]).style.visibility = "visible";
	}
	for(count=0;count<Layers[1][number].length;count++){
	document.getElementById(Layers[1][number][count]).style.visibility = "hidden";
	}
}else if (ie4) {
	for(count=0;count<Layers[0][number].length;count++){
	Layers[0][number][count].style.visibility ="visible";
	}
	for(count=0;count<Layers[1][number].length;count++){
	Layers[1][number][count].style.visibility ="hidden";
	}
}
}


// layer name, left, top, width, height (these are numbers or the word 'auto')
// then, left margin, right margin, top margin, bottom margin
function fluidLayers(el,lp,tp,wp,hp,lm,rm,tm,bm) { 
	var x,g,d,sw,sh,xx,yy,ww,hh,pa='',t="','",u=",";
	var ns4 = (document.layers) ? true:false ;
	var ie4 = (document.all) ? true:false;
	var ng5 = (document.getElementById) ? true:false; 
	if((g=MM_findObj(el))==null){return;}
	if((parseInt(navigator.appVersion)>4 || navigator.userAgent.indexOf("MSIE")>-1)&& !window.opera){pa="px";}
	var tS="fluidLayers('"+el+t+lp+t+tp+t+wp+t+hp+"',"+lm+u+rm+u+tm+u+bm+")";
	if(window.innerWidth) {sw= window.innerWidth;sh = window.innerHeight;
	}else if(document.body) {sw=document.body.clientWidth;sh=document.body.clientHeight;
    if(document.body.offsetWidth == sw && document.documentElement && document.documentElement.clientWidth) {
	 sw=document.documentElement.clientWidth;}
    if(document.body.offsetHeight == sh && document.documentElement && document.documentElement.clientHeight) {
     sh=document.documentElement.clientHeight;}}
	if(!g.fluid) {g.fluid=true;g.fluidw=0;g.fluidh=0;}
	if(sw==g.fluidw && sh==g.fluidh) {setTimeout(tS,20);return;}
	d=(document.layers)?g:g.style;
	if(wp=='auto') {if(lp=='auto'){ww=sw-lm-rm;}else{ww=sw-lp-rm;}}else{ww=wp;}
	if(hp=='auto') {if(tp=='auto'){hh=sh-tm-bm;}else{hh=sh-tp-bm;}}else{hh=hp;}
	if(lp=='auto') {if(wp=='auto'){xx=lm;}else{xx=sw-wp-rm;}}else{xx=lp;}
	if(tp=='auto') {if(hp=='auto'){yy=tm;}else{yy=sh-tp-bm;}}else{yy=tp;}
	
	if(sh<900){
		sh=900;	
	}
	
	
	if(el == 'HeaderPicRight'){
		yy=-25;
		if(((sw-340)/2)>=350){
			ww=350;	
			document.headerRight.width = ww;
			document.headerRight.height = (ww*(2/3));
		}else{
			ww = ((sw-340)/2);
			if((ww*(2/3))<=175){
			yy=0;
			ww=225;
			document.headerRight.width = 225;
			document.headerRight.height = 150;	
			}else{
			document.headerRight.width = ww;
			document.headerRight.height = (ww*(2/3));
			}
		}
	xx=sw - ww;
	
	
	}
	if(el == 'HeaderPicLeft'){
		yy=-25;
		if(((sw-340)/2)>=350){
			ww=350;	
			document.headerLeft.width = ww;
			document.headerLeft.height = (ww*(2/3));
		}else{
			ww = ((sw-340)/2);
			if((ww*(2/3))<=175){
			yy=0;
			ww=225;
			document.headerLeft.width = 225;
			document.headerLeft.height = 150;	
			}else{
			document.headerLeft.width = ww;
			document.headerLeft.height = (ww*(2/3));
			}
		}
	xx=0;
	
	
	}
	if(el == 'HeaderHamiltonMill'){
	ww =320;
	xx =(sw/2)-(ww/2);
	}
	if(el == 'HamiltonMillBar'){
	ww =290;
	hh =2;
	yy =75;
	xx =(sw/2)-(ww/2);
	}
	if(el == 'HeaderCenter'){
	ww =360;
	xx =(sw/2)-(ww/2);
	hh=150;
	}
	if(el == 'HeaderHamiltonMillText'){
	ww =350;
	xx =(sw/2)-(ww/2);
	hh =50;
	}
	if(el == 'HeaderHamiltonMillText2'){
	hh =50;
	ww =350;
	xx =(sw/2)-(ww/2);
	}
	if(el=='chat'){
	ww='200';
	hh='200';
	xx='0';
	yy=sh-200;
	}
	if(el=='copyright'){
	ww='300';
	hh='13';
	xx=(sw/2)-(ww/2);
	yy=sh-13;
	}
	if(el=='hmillwords'){
	ww=sw-200;
	if(ww>=900){
	ww=900;	
	//hmillwords.style.fontSize = '8px';
	document.getElementById('hmillwords').style.fontSize = '18px';
	}else{
	var vv = ((5/300)*ww)+3;
	if(vv<=12){
	vv=12;
	ww=sw-(sw-520);
	if(ww>=sw){
	ww=sw;	
	}
	}
	document.getElementById('hmillwords').style.fontSize = vv+'px';
	}
	xx=(sw/2)-(ww/2);
	yy=158;
	hh=80;
	}
	
	if(el=='buyerbase'){
	if(sw>=1100){
		ww=(sw/3);
		xx=(sw/3)-(ww/2);
	}else{
		ww=((sw-200)/2);
		xx=((sw-200)/4)-(ww/2)+200;
	}
	if(sw>=1000 && sh>=750){
	yy=300;
	}else{
		if(((.1878*sw)+112.2)<=((.2439*sh)+117.07)){
			yy=((.1878*sw)+112.2);
		}else{
			yy=((.2439*sh)+117.07);
		}
		if(yy<=246){
		yy=246;	
		}
	}
	hh=35;	

	}
	if(el=='buyerbar'){
		var move=35;
		if(sw>=1100){
		ww=(sw/4);
		xx=(sw/3)-(ww/2);
	}else{
		ww=((sw-200)/4);
		xx=((sw-200)/4)-(ww/2)+200;
	}
	if(sw>=1000 && sh>=750){
	yy=300+move;
	}else{
		if(((.1878*sw)+112.2+move)<=((.2439*sh)+117.07+move)){
			yy=((.1878*sw)+112.2+move);
		}else{
			yy=((.2439*sh)+117.07+move);
		}
		if(yy<=(246+move)){
		yy=246+move;	
		}
	}
	
	hh=2;
	}
	if(el=='sellerbase'){
		if(sw>=1100){
		ww=(sw/3);
		xx=((sw/3)*2)-(ww/2);
	}else{
		ww=((sw-200)/2);
		xx=(((sw-200)/4)*3)-(ww/2)+200;
	}
	if(sw>=1000 && sh>=750){
	yy=300;
	}else{
		if(((.1878*sw)+112.2)<=((.2439*sh)+117.07)){
			yy=((.1878*sw)+112.2);
		}else{
			yy=((.2439*sh)+117.07);
		}
		if(yy<=246){
		yy=246;	
		}
	}
	hh=35;		
	}
	
	if(el=='sellerbar'){
		var move=35;
		if(sw>=1100){
		ww=(sw/4);
		xx=((sw/3)*2)-(ww/2);
	}else{
		ww=((sw-200)/4);
		xx=(((sw-200)/4)*3)-(ww/2)+200;
	}
	if(sw>=1000 && sh>=750){
	yy=300+move;
	}else{
		if(((.1878*sw)+112.2+move)<=((.2439*sh)+117.07+move)){
			yy=((.1878*sw)+112.2+move);
		}else{
			yy=((.2439*sh)+117.07+move);
		}
		if(yy<=(246+move)){
		yy=246+move;	
		}
	}
	hh=2;
	}
	
	if(el=='hmillhvform'){
		var move=50;
	if(sw>=1100){
		ww=(sw/3);
		xx=((sw/3)*2)-(ww/2);
	}else{
		ww=((sw-200)/2);
		xx=(((sw-200)/4)*3)-(ww/2)+200;
	}
		if(((.1878*sw)+112.2+move)<=((.2439*sh)+117.07+move)){
			yy=((.1878*sw)+112.2+move);
		}else{
			yy=((.2439*sh)+117.07+move);
		}
		if(yy<=(246+move)){
		yy=246+move;	
		}
	hh=160;	
	}
	
	if(el=='Featured'){
		var move=50;
	if(sw>=1100){
		ww=(sw/3);
		xx=((sw/3)*2)-(ww/2);
	}else{
		ww=((sw-200)/2);
		xx=(((sw-200)/4)*3)-(ww/2)+200;
	}
		if(((.1878*sw)+312.2+move)<=((.2439*sh)+317.07+move)){
			yy=((.1878*sw)+312.2+move);
		}else{
			yy=((.2439*sh)+317.07+move);
		}
		if(yy<=(446+move)){
		yy=446+move;	
		}
	hh=300;	
	}
	
	if(el=='searchform'){
		var move=50;
	if(sw>=1100){
		ww=(sw/3);
		xx=(sw/3)-(ww/2);
	}else{
		ww=((sw-200)/2);
		xx=((sw-200)/4)-(ww/2)+200;
	}
	if(sw<=880){
	ww=340;	
	}

		if(((.1878*sw)+112.2+move)<=((.2439*sh)+117.07+move)){
			yy=((.1878*sw)+112.2+move);
		}else{
			yy=((.2439*sh)+117.07+move);
		}
		if(yy<=(246+move)){
		yy=246+move;	
		}

	hh=135;	
	}
	
	if(el=='clientLogin'){
		var move=200;
	if(sw>=1100){
		ww=(sw/3);
		xx=(sw/3)-(ww/2);
	}else{
		ww=((sw-200)/2);
		xx=((sw-200)/4)-(ww/2)+200;
	}
	if(((.1878*sw)+112.2+move)<=((.2439*sh)+117.07+move)){
			yy=((.1878*sw)+112.2+move);
		}else{
			yy=((.2439*sh)+117.07+move);
		}
		if(yy<=(246+move)){
		yy=246+move;	
		}
		
	hh=60;
	}
	
	if(el=='hmillAmenities'){
		if(sw>=1000 && sh>=750){
			hh=60;	
			yy=230;
			ww=(sw/3);
			xx=(sw/3)-(ww/2);
		}else{
			hh=60;
			if(((32.5/250)*sw+100)<=((32.5/200)*sh+108)){
			yy=((32.5/250)*sw+100);
			}else{
			yy=((32.5/200)*sh+108);
			}
			if(yy<=195){
			yy=195;	
			}
			ww=(sw/2);
			xx=(sw/4)-(ww/2);
		}
	}
	if(el=='browserData'){
	//	 Record screen resolution
	clickLog('Browser '+sw+'x'+sh,0);
	}
	if(el=='hmillArea'){
		//document.hvform.hvname.value = sw;
		//document.hvform.hvemail.value = sh;
		if(sw>=1000 && sh>=750){
			hh=60;	
			yy=230;
			ww=(sw/3);
			xx=((sw/3)*2)-(ww/2);
		}else{
			hh=60;	
			if(((32.5/250)*sw+100)<=((32.5/200)*sh+108)){
			yy=((32.5/250)*sw+100);
			}else{
			yy=((32.5/200)*sh+108);
			}
			if(yy<=195){
			yy=195;	
			}
			ww=(sw/2);
			xx=((sw/4)*3)-(ww/2);
		}
	}
	
	if(el=='backgroundPic'){
	xx=0;
	yy=150;
	hh=sh-yy;
	ww=sw;
	if((hh*(3/2))<=ww){
		
		document.background.width = ww;
		document.background.height = (ww*(2/3));
	}
	if((ww*(2/3))<=hh){
		document.background.height = hh;
		document.background.width = (hh*(3/2));
	}
	
	}
	
	if(el=='backgroundPicTwo'){
	xx=0;
	yy=150;
	hh=sh-yy;
	ww=sw;
	}
	if(el=='pagetitle'){
		xx=205;
		yy=160;
		ww=sw-205;
		hh=50;
		
	}
	if(el=='pagetitlebar'){
		ww=450;
		xx=((sw-205)/2)+205-(ww/2);
		yy=195;
		hh=2;
	}
	if(el=='pagesubtitle'){
		xx=205;
		yy=200;
		ww=sw-205;
		hh=50;	
	}
	if(el=='pagecontent'){
		xx=205+25;
		yy=235;
		ww=sw-xx-20;
		hh=sh-yy-20;	
	}
	d.left=xx+pa;d.top=yy+pa;
	if(document.layers){g.clip.height=hh;g.clip.width=ww;
	}else if(window.opera){g.style.pixelHeight=hh;g.style.pixelWidth=ww;
	}else{d.width=ww+pa;d.height=hh+pa;}
	g.fluidw=sw;g.fluidh=sh;
	setTimeout(tS,20);
}

function MM_reloadPage(init) {  //Updated by PVII. Reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) history.go(0);
}
MM_reloadPage(true);

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 Flashover(){
theObjects = document.getElementsByTagName("object");
for (var i = 0; i < theObjects.length; i++) {
theObjects[i].outerHTML = theObjects[i].outerHTML;
}
}


function HmillUpdateOptions(){
	
Price=new Array(2);
Price[0]=new Array("$150,000","$175,000","$200,000","$225,000","$250,000","$275,000","$300,000","$325,000","$350,000","$375,000","$400,000","$450,000","$500,000","$550,000","$600,000","$650,000","$700,000","$750,000","$800,000","$850,000","$900,000","$950,000","$1,000,000","$1,250,000");

Price[1]=new Array(150000,175000,200000,225000,250000,275000,300000,325000,350000,375000,400000,450000,500000,550000,600000,650000,700000,750000,800000,850000,900000,950000,1000000,1250000);

Bed=new Array(2);
Bed[0]=new Array();
Bed[1]=new Array(1,2,3,4,5,6,7);

Bath=new Array(2);
Bath[0]=new Array();
Bath[1]=new Array(1,2,3,4,5);

var MinPricevalue = parseFloat(document.hmillsearchform.MinPrice.value);
var MinPricetext = document.hmillsearchform.MinPrice.options[document.hmillsearchform.MinPrice.selectedIndex].text;
var MaxPricevalue = parseFloat(document.hmillsearchform.MaxPrice.value);
var MaxPricetext = document.hmillsearchform.MaxPrice.options[document.hmillsearchform.MaxPrice.selectedIndex].text;
var MinBed = parseFloat(document.hmillsearchform.MinBedrooms.value);
var MinBath = parseFloat(document.hmillsearchform.MinBathrooms.value);


pos = 0;
for(ctr=0;ctr<Price[1].length;ctr++){
if(MinPricevalue<=Price[1][ctr]){
document.hmillsearchform.MaxPrice.options[pos]=new Option(Price[0][ctr],Price[1][ctr]);
if(MaxPricevalue == Price[1][ctr]){
sel = pos;
}
pos++;
}
}
document.hmillsearchform.MaxPrice.selectedIndex = sel;

pos = 0;
for(ctr=0;ctr<Price[1].length;ctr++){
if(MaxPricevalue>=Price[1][ctr]){
document.hmillsearchform.MinPrice.options[pos]=new Option(Price[0][ctr],Price[1][ctr]);
if(MinPricevalue == Price[1][ctr]){
sel = pos;
}
pos++;
}
}
document.hmillsearchform.MinPrice.selectedIndex = sel;

pos = 0;
for(ctr=0;ctr<Bed[1].length;ctr++){
document.hmillsearchform.MinBedrooms.options[pos]=new Option(Bed[1][ctr],Bed[1][ctr]);
if(MinBed == Bed[1][ctr]){
sel = pos;
}
pos++;
}
document.hmillsearchform.MinBedrooms.selectedIndex = sel;

pos = 0;
for(ctr=0;ctr<Bath[1].length;ctr++){
document.hmillsearchform.MinBathrooms.options[pos]=new Option(Bath[1][ctr],Bath[1][ctr]);
if(MinBath == Bath[1][ctr]){
sel = pos;
}
pos++;
}
document.hmillsearchform.MinBathrooms.selectedIndex = sel;


}


function hvfSubmit(){
	var missed="";
	var format="";
	
	if("" == document.hvform.hvaddress.value || null ==document.hvform.hvaddress.value){
		missed = " address";
		document.hvform.hvaddress.focus();
	}
	if("" == document.hvform.hvcity.value || null ==document.hvform.hvcity.value){
		if(missed != ""){
		missed = missed+",";	
		}
		missed = " city";
		document.hvform.hvcity.focus();
	}
	if("" == document.hvform.hvbeds.value || null ==document.hvform.hvbeds.value){
		if(missed != ""){
		missed = missed+",";	
		}
		missed = missed+" bedrooms";
		document.hvform.hvbeds.focus();
	}
	if("" == document.hvform.hvbaths.value || null ==document.hvform.hvbaths.value){
		if(missed != ""){
		missed = missed+",";	
		}
		missed = missed+" bathrooms";
		document.hvform.hvbaths.focus();
	}
	if("" == document.hvform.hvname.value || null ==document.hvform.hvname.value){
		if(missed != ""){
		missed = missed+",";	
		}
		missed = missed+" name";
		document.hvform.hvname.focus();
	}
	if("" == document.hvform.hvemail.value || null ==document.hvform.hvemail.value){
		if(missed != ""){
		missed = missed+",&";	
		}
		missed = missed+" email";
		document.hvform.hvemail.focus();
	}else if(echeck(document.hvform.hvemail.value)==false){
		format = "Please check your email address";
	}
	
	if(missed!=""||format!=""){
		if(missed!=""){
		alert("Please fill in"+missed);	
		}else{
		alert(format);	
		document.hvform.hvemail.focus();
		}
	}else{
		hvdata();

	alert('Your Home Value Request Has Been Sent. Thank You');
	document.hvform.hvaddress.value = '';
	document.hvform.hvcity.value = '';
	document.hvform.hvbeds.value = '';
	document.hvform.hvbaths.value = '';

	}
}


function hvdata(){
	var url = "emailData.php";
	var http;
	if (window.ActiveXObject){
		/* Create the object using MSIE's method */
	http = new ActiveXObject("Microsoft.XMLHTTP");
	}else if (window.XMLHttpRequest) {
		/* Create the object using other browser's method */
		http = new XMLHttpRequest();
	}
	var params = "hvaddress="+document.hvform.hvaddress.value+"&hvcity="+document.hvform.hvcity.value+"&hvbeds="+document.hvform.hvbeds.value+"&hvbaths="+document.hvform.hvbaths.value+"&hvbasement="+document.hvform.hvbasement.value+"&hvname="+document.hvform.hvname.value+"&hvemail="+document.hvform.hvemail.value+"&domain="+document.hvform.domain.value;
	
	http.open("POST", url, true);

//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");

http.onreadystatechange = function() {//Call a function when the state changes.
	if(http.readyState == 4 && http.status == 200) {
		//alert(http.responseText);
	}
}
http.send(params);	
}
