// JavaScript Document
miarray=new Array();
miarray[0]="1";
miarray[1]="2";
miarray[2]="3";
miarray[3]="4";
miarray[4]="5";
miarray[5]="6";
miarray[6]="7";
miarray[7]="8";
miarray[8]="9";
miarray[9]="10";
miarray[10]="11";
miarray[11]="12";


var browserName=navigator.appName;
var itemsUrl="index";

function menuZone(divZone){
	if (divZone=="menuDade"){
		if(document.getElementById('menuDade')){
		if(document.getElementById('menuDade').style.display == "block"){
			document.getElementById('menuDade').style.display = "none";
		} else {
			document.getElementById('menuDade').style.display = "block";
			if(document.getElementById('menuBroward')){
			document.getElementById('menuBroward').style.display = "none";
			}
		}
		}
	}
	if (divZone=="menuBroward"){
		if(document.getElementById('menuBroward')){
		if(document.getElementById('menuBroward').style.display == "block"){
			document.getElementById('menuBroward').style.display = "none";
		} else {
			document.getElementById('menuBroward').style.display = "block";
			if(document.getElementById('menuDade')){
				document.getElementById('menuDade').style.display = "none";
			}
		}
		}
	}
}
function menuMonth (divMonth){
	if(document.getElementById(divMonth).style.display == "block"){
		document.getElementById(divMonth).style.display = "none";
	} else {
		document.getElementById(divMonth).style.display = "block";
	}
}
function menuType(divType){
	if(document.getElementById(divType).style.display == "block"){
		document.getElementById(divType).style.display = "none";
	} else {
		document.getElementById(divType).style.display = "block";
	}
}
function closeAll(closers,closersMonth){
	if(closers==0){
		for (i=0;i<12;i++){
			varMonthDade="menuDade" + eval('miarray[i]');
			varMonthBrod="menuBroward" + eval('miarray[i]');
			if(document.getElementById(varMonthBrod)!="null" && document.getElementById(varMonthDade)!="null"){
				if(document.getElementById(varMonthBrod)){
					document.getElementById(varMonthBrod).style.display = "none";
				}
				if(document.getElementById(varMonthDade)){
					document.getElementById(varMonthDade).style.display = "none";
				}
				if(document.getElementById('menuDade')){	
					document.getElementById('menuDade').style.display = "none";
				}
				if(document.getElementById('menuBroward')){
					document.getElementById('menuBroward').style.display = "none";
				}
				if(document.getElementById(varMonthBrod + "Single")){
					document.getElementById(varMonthBrod + "Single").style.display = "none";
				}
				if(document.getElementById(varMonthBrod + "Condo")){
					document.getElementById(varMonthBrod + "Condo").style.display = "none";
				}
				if(document.getElementById(varMonthDade + "Single")){
					document.getElementById(varMonthDade + "Single").style.display = "none";
				}
				if(document.getElementById(varMonthDade + "Condo")){
					document.getElementById(varMonthDade + "Condo").style.display = "none";	
				}
				
			}
		}
	}
	urls=window.location.toString();
	if(urls.indexOf('broward')>-1){
		document.getElementById('menuBroward').style.display = "block";
		for(i=0;i<10;i++){
			if(urls.indexOf('forsalein0'+i+'0')>-1){
				if(document.getElementById('menuBroward'+i)){
					document.getElementById('menuBroward'+i).style.display = "block";
				}
				itemsUrl=document.getElementById('menuBroward'+i);
				if(urls.indexOf('condo')>-1){
					typeHome='Condo';
					if(document.getElementById('menuBroward'+i+'Condo')){
						document.getElementById('menuBroward'+i+'Condo').style.display = "block";				
					}
				}
				if(urls.indexOf('sfh')>-1){
					typeHome='Single';
					if (document.getElementById('menuBroward'+i+'Single')){
						document.getElementById('menuBroward'+i+'Single').style.display = "block";
					}
				}
			}
			if(urls.indexOf('forsalein1'+i+'0')>-1){
				if(document.getElementById('menuBroward1'+i)){
					document.getElementById('menuBroward1'+i).style.display = "block";
				}
				itemsUrl=document.getElementById('menuBroward1'+i);
				if(urls.indexOf('condo')>-1){
					typeHome='condo';
					document.getElementById('menuBroward1'+i+'Condo').style.display = "block";
				}
				if(urls.indexOf('sfh')>-1){
					document.getElementById('menuBroward1'+i+'Single').style.display = "block";
					typeHome='Single';
				}
			}	
		}
	}
	if(urls.indexOf('dade')>-1){
		document.getElementById('menuDade').style.display = "block";
		for(i=0;i<10;i++){
			if(urls.indexOf('forsalein0'+i+'0')>-1){
				document.getElementById('menuDade'+i).style.display = "block";
				itemsUrl=document.getElementById('menuDade'+i);
				if(urls.indexOf('condo')>-1){
					document.getElementById('menuDade'+i+'Condo').style.display = "block";
					typeHome="Condo";
				}
				if(urls.indexOf('sfh')>-1){
					document.getElementById('menuDade'+i+'Single').style.display = "block";
					typeHome="Single";
				}
			}
			if(urls.indexOf('forsalein1'+i+'0')>-1){
				document.getElementById('menuDade1'+i).style.display = "block";
				itemsUrl=document.getElementById('menuDade1'+i);
				if(urls.indexOf('condo')>-1){
					document.getElementById('menuDade1'+i+'Condo').style.display = "block";
					typeHome="Condo";
				}
				if(urls.indexOf('sfh')>-1){
					document.getElementById('menuDade1'+i+'Single').style.display = "block";
					typeHome="Single";
				}
			}
		}
	}	
	if(itemsUrl!="index"){
		itemsUrl.previousSibling.childNodes[0].src='http://www.realestatehomesale.org/img/layout/bulletmin.gif';		
		if(urls.indexOf('sfh')>-1){
			if(itemsUrl.childNodes[1].childNodes[1].nodeValue.indexOf('Single')>-1){
				itemsUrl.childNodes[1].childNodes[0].src='http://www.realestatehomesale.org/img/layout/bulletmin.gif';				
			} 
		}
		if(urls.indexOf('condo')>-1){
			if(itemsUrl.childNodes[1].childNodes[1].nodeValue.indexOf('Condo')>-1){
				itemsUrl.childNodes[1].childNodes[0].src='http://www.realestatehomesale.org/img/layout/bulletmin.gif';				
			}
			if(itemsUrl.childNodes[5]){
				if(itemsUrl.childNodes[5].childNodes[1].nodeValue.indexOf('Condo')>-1){
					itemsUrl.childNodes[5].childNodes[0].src='http://www.realestatehomesale.org/img/layout/bulletmin.gif';
				}
			}
		}
	}
}
//Menu plus signos

function menuItems(items){
	if(items.childNodes[0].src.indexOf('bulletplus.gif')>-1){
		items.childNodes[0].src='http://www.realestatehomesale.org/img/layout/bulletmin.gif';	
	} else {
		items.childNodes[0].src='http://www.realestatehomesale.org/img/layout/bulletplus.gif';	
	}
}

function showMonth(){
		document.getElementById('menuYear').style.display = "block";
}
function hideMonth(){
		document.getElementById('menuYear').style.display = "none";
}

function menuselect(year,month){
	urlsstring=window.location.toString();
	if(urlsstring.indexOf('broward')>-1){
		zones='broward';
	} else {
		zones='dade';
	}
	if(urlsstring.indexOf('sfh')>-1){
		types='home';
	} else {
		types='condo';
	}
	urls='/homeforsale/homesalesin' + year + '/' + zones + '/condoforsalein' +month+year+'/'+types+'101.html';	
	var isIE = false;
	var reqs;
	//	Primero vamos a ver si la urls es una urls :)
	
	var mydomain="http://"+window.location.hostname;
	//	Usuario inteligente...
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChanges;
		req.open("GET", mydomain+urls, true);
		req.send(null);
	//	...y usuario de Internet Explorer Windows
	} else if (window.ActiveXObject) {
		isIE = true;
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = processReqChanges;
			req.open("GET", mydomain+urls, true);
			req.send();
		}
	}
}

//	Funcion que se llama cada vez que se dispara el evento onreadystatechange
//	del objeto XMLHttpRequest
function processReqChanges(){
	var detalles = document.getElementById("trailimageid");
	if(req.readyState == 4){
		if(req.status==200){
			if(document.getElementById('trailimageid').style.visibility=="hidden"){
				document.getElementById('trailimageid').style.visibility="visible";
			}
			detalles.innerHTML = '<div style="position:absolute; top:250px; left:400px; background-color:#ffffff; border-style:solid; border-width:1px; height:90px; width:309px;"><div id="titleBar"><strong class="close" onclick="closeWidget()">X</strong></div><div align="center" style="color: #000066; font-weight: bold;"><br /><br />Please Wait</div></div>';
			window.location = "http://"+window.location.hostname+urls;	
		} else {
			if(document.getElementById('trailimageid').style.visibility=="hidden"){
				document.getElementById('trailimageid').style.visibility="visible";
			}
			detalles.innerHTML = '<div style="position:absolute; top:250px; left:400px; background-color:#ffffff; border-style:solid; border-width:1px; height:90px; width:309px;"><div id="titleBar"><strong class="close" onclick="closeWidget()">X</strong></div><div align="center" style="color: #000066; font-weight: bold;"><br /><br />Please select another Month</div></div>';
			document.getElementById('month').options.selectedIndex=0;
			document.getElementById('year').options.selectedIndex=0;
		}
	}
}
//	Vamos a presuponer que el usuario es una persona inteligente...
var isIE = false;

//	Creamos una variable para el objeto XMLHttpRequest
var req;

//	Creamos una funcion para cargar los datos en nuestro objeto.
//	Logicamente, antes tenemos que crear el objeto.
//	Vease que la sintaxis varia dependiendo de si usamos un navegador decente
//	o Internet Explorer
function cargaWord(url) {
	//	Primero vamos a ver si la URL es una URL :)
	if(url==''){
		return;
	}
	var mydomain="http://"+window.location.hostname+"/";
	//	Usuario inteligente...
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChanger;
		if(document.getElementById("myform")){
			var curDateTime = new Date(); //For IE
			var poststr = "word=" + encodeURI( document.getElementById("word").value ) +
			"&reference=" + encodeURI( document.getElementById("reference").value ) + 
			"&cur=" + curDateTime;
		}
		req.open("post", mydomain+url, true);
		if(poststr){
			req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			req.setRequestHeader("Content-length", poststr.length);
			req.setRequestHeader("Connection", "close");
			req.send(poststr);
		} else {
			req.send(null);
		}
	//	...y usuario de Internet Explorer Windows
	} else if (window.ActiveXObject) {
		isIE = true;
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = processReqChanger;
			if(document.getElementById("myform")){
				var curDateTime = new Date(); //For IE
				var poststr = "word=" + encodeURI( document.getElementById("word").value ) +
				"&reference=" + encodeURI( document.getElementById("reference").value ) +
				"&cur=" + curDateTime;
			}
			req.open("post", mydomain+url, true);
			if(poststr){
				req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				req.setRequestHeader("Content-length", poststr.length);
				req.setRequestHeader("Connection", "close");
				req.send(poststr);
			} else {
				req.send(null);
			}
		}
	}
}

//	Funcion que se llama cada vez que se dispara el evento onreadystatechange
//	del objeto XMLHttpRequest
function processReqChanger(){
	var detalles = document.getElementById("trailimageid");
	if(req.readyState == 4){
		detalles.innerHTML = req.responseText;
	} else {
		detalles.innerHTML = '<div id="QuickHomesSearch"><span id="loading">Loading...</span></div>';
	}
}