// JavaScript Document
function menu_button(id)
{
	var url;
	if(typeof(id)=='undefined' || id==null)
	{
		url='menu_button.php';
	}else
	{
		url='menu_button.php?id='+id;
	}
	p=window.open(url,'menuButton','left=550,top=30,scrollbars=yes,resizable=yes,width=580,height=270');
	p.focus();		
}
function footer_link(id)
{
	p=window.open('footer_link.php?id='+id,'footerLink','left=550,top=30,scrollbars=yes,resizable=yes,width=580,height=230');
	p.focus();
}
function logo_show()
{
	p=window.open('logo_show.php','logoShow','left=550,top=30,scrollbars=yes,resizable=yes,width=670,height=300');
	p.focus();
}
function wwPopup(url, w, h, winName, location, toolbar, scrollBar, resizable)
{
	location = (location) ? ",location=yes":",location=no";
	toolbar = (toolbar) ? ",toolbar=yes":",toolbar=no";
	scrollBar = (scrollBar) ? ",scrollbars=yes":",scrollbars=no";
	resizable = (resizable) ? ",resizable=yes":",resizable=no";

	w=open(url,winName,'width='+w+',height=' + h + location + toolbar + scrollBar + resizable);
	
	if (w==null || typeof(w)=="undefined")
	{
		alert("A popup blocker has prevent this website\nfrom showing you relevant information.\nPlease allow popups for this site.");
	}
	else
	{
		w.focus();
	}
}
var W3CDOM = (document.createElement && document.getElementsByTagName);
function initFileUploads() {
	if (!W3CDOM)
	{
		return;
	}
	var fakeFileUpload = document.createElement('div');
	fakeFileUpload.className = 'fakefile';
	fakeFileUpload.appendChild(document.createElement('input'));
	fakeFileUpload.style.cursor = "pointer";
	var image = document.createElement('img');
	image.src =WEBSITE_URL+'images/ww/btn-sml-choose-file.png';
	image.style.marginLeft ="220px";
	image.border="0";
	fakeFileUpload.appendChild(image);
	
	var fakeFileUpload2 = document.createElement('div');
	fakeFileUpload2.className = 'fakefile';
	fakeFileUpload2.appendChild(document.createElement('input'));
	fakeFileUpload2.style.cursor = "pointer";
	var image2 = document.createElement('img');
	image2.src = WEBSITE_URL+'images/ww/btn-sml-choose-file.png';
	image2.style.marginLeft = "220px";
	image2.border="0";
	fakeFileUpload2.appendChild(image2);	
	
	var x = document.getElementsByTagName('input');
	for (var i=0;i<x.length;i++) {
		if (x[i].type != 'file') continue;
		if (x[i].parentNode.className == 'fileinputs'
			|| x[i].parentNode.className == 'fileinputs2')
		{
			x[i].className = 'file hidden';
			var toUse = x[i].parentNode.className == 'fileinputs' ? fakeFileUpload:fakeFileUpload2;
			
			var clone = toUse.cloneNode(true);
			x[i].parentNode.appendChild(clone);
			x[i].relatedElement = clone.getElementsByTagName('input')[0];
			x[i].relatedElement.style.border = "1px solid #006";
			x[i].relatedElement.style.backgroundColor = "";
			x[i].relatedElement.style.fontSize = "11px";
			x[i].relatedElement.style.color = "#000000";
			x[i].relatedElement.style.fontFamily = "Verdana, Arial, Helvetica";
			x[i].relatedElement.style.position = "absolute";
			x[i].relatedElement.style.top = "1px";
			x[i].relatedElement.style.left = "0px";
			x[i].relatedElement.style.width = "210px";
			
			x[i].onchange = x[i].onmouseout = function () {
				this.relatedElement.value = this.value;
			}			
		}
	}
}
window.onload = function(){
	initFileUploads();
};
function newAjax(){
	var xmlhttp=false;
	try{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}catch(e){
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}catch(E){
			xmlhttp = false;
		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	
	return xmlhttp;
}
function call_url(url,popup)
{
	if(popup=='yes')
	{
	    wwPopup(url, 800,800, '', 1, 1, 1, 1);
	}else
	{
		window.location.href=url;	
	}
}

function SetOpacity(object,opacityPct)
{
  // IE.
  object.style.filter = 'alpha(opacity=' + opacityPct + ')';
  // Old mozilla and firefox
  object.style.MozOpacity = opacityPct/100;
  // Everything else.
  object.style.opacity = opacityPct/100;
}
function ChangeOpacity(id,msDuration,msStart,fromO,toO)
{
  var element=document.getElementById(id);
  var msNow = (new Date()).getTime();
  var opacity = fromO + (toO - fromO) * (msNow - msStart) / msDuration;
  if (opacity>=100)
  {
    SetOpacity(element,100);
    element.timer = undefined;
  }
  else if (opacity<=0)
  {
    SetOpacity(element,0);
    element.timer = undefined;
  }
  else 
  {
    SetOpacity(element,opacity);
    element.timer = window.setTimeout("ChangeOpacity('" + id + "'," + msDuration + "," + msStart + "," + fromO + "," + toO + ")",10);
  }
}
function wwOpenSubCategory(catID,url)
{
	var status = document.getElementById("td"+catID).getAttribute("openStatus");
	
	document.getElementById("arrow"+catID).src = (status == "closed") ?  url+"images/ww/arrow-down.png":utl+"images/ww/arrow-side.png";
	document.getElementById("tbl"+catID).style.display = (status == "closed") ? "":"none";
	
	var newStatus = status == "closed" ? "open":"closed";
	document.getElementById("td"+catID).setAttribute("openStatus", newStatus);
}
function wwWarnAndSend(url,popup)
{
	alert("You are about to be redirected to a website that is not moderated by Centro Properties Group.\n"+
		"The views expressed on this site are those of the authors alone.\n"+
		"They do not represent the views of Centro Properties Group or its staff.");
	
	if(url.indexOf("http://") == -1)
	{
		url = "http://www."+url;
	}	
	if(popup=='yes')
	{
	    wwPopup(url, 800,800, '', 1, 1, 1, 1)
	}else
	{
		window.location.href=url;	
	}
}