function toggleTextOut(e,txtval) {
	if(e.value=="") e.value = txtval;
	
}
function toggleTextIn(e,txtval) {
	if(e.value==txtval) e.value="";
	else e.select();
}

var detect = navigator.userAgent.toLowerCase();
var OS,browser,total,thestring;
var version = 0;

if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

function PreloadImage()
{ 
  	var args = PreloadImage.arguments;
 	document.imageArray = new Array(args.length);
 	for(var i=0; i<args.length; i++)
	{
	document.imageArray[i] = new Image;
	document.imageArray[i].src = args[i];
  	}
}

function signup(url)

{

	var email = document.newsletter.txtNewsletter.value;

	if(email == '') {

		alert('Email Required.');

		document.newsletter.txtNewsletter.focus();

		return false;

	} else {

		if(!isValidEmail(email)) {

			alert('Valid Email Required.');

			document.newsletter.txtNewsletter.focus();

			return false;

		}

	}

	var params = 'emailid=' + email;

	url = url + '?' + params;

	window.location=url;

	return false;

}


function isValidEmail(str) {
	filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	return(filter.test(str));

}


function GetData(id)
{
	var content = document.getElementById(id);
	if(content == null)
		return("");
	return(content.innerHTML);
}
function Print(printPage, id, title)
{
	if(title == '')
		title = document.title;
	var url = printPage + "?id=" + id + "&title=" + title
	var p = window.open(url, "print", "width=600, height=600, left=100, top=100, location=no, menubar=no, resizable=no, scrollbars=yes, status=no, toolbar=no, fullscreen=no");
}
	
function PrintThisPage(id, printId)
{
	var content = document.getElementById(printId);
	if(content == null)
		return;
	if(window.opener == null)
		return;
	var html = window.opener.GetData(id);
	html = DisableHyperlinks(html);
	content.innerHTML = html;
	make_visible();
	window.print();
}

function DisableHyperlinks(html)
{
	return(html.replace(/href\s*=\s*\"*[^\">]*"/ig,"href=\"#\""));
}

/* email specific functions */

function Email(url)
{
	url = url;
	var p = window.open(url, "email", "width=400, height=440, left=100, top=100, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no, fullscreen=no");
}

function minimise(id,id1) {
	var area = document.getElementById(id);
	var others = document.getElementById(id1);
	var icon = document.getElementById('min');
	if(area.style['height'] != '22px' ) {
	area.style['height'] = '22px';
	others.style['display'] = 'none';
	icon.title="Maximize";
	icon.className="maximise";
	} else { 
	area.style['height'] = '240px';	
	others.style['display'] = 'block';
	icon.title="Minimize";
	icon.className="minimise";
	}
}

function toggleVisibility(id)
{	
	
	if (document.getElementById(id).style.display=='block') 
	{		
		document.getElementById(id).style.display='none';
	}
	else 
	{
		document.getElementById(id).style.display='block';
	}
} 

function toggleVisibilityBrandcentral(key)
{	
	var url = '/etastar/wp-content/includes/ajax-brandcenter.php';
	
	if(key == 'Business Bay - The inspiring business capital'){
		sendRequest(url + '?params=476','', brandcentralcallback, 'GET');	
		
	}else if(key == 'The Offices - A world of lofty ambitions'){
		sendRequest(url + '?params=480','', brandcentralcallback, 'GET');
		
	}else if(key == 'Starhill Gallery - A gallery of rich experiences'){
		sendRequest(url + '?params=481','', brandcentralcallback, 'GET');
	}else if(key == 'Hotel & Hotel Apartments - A bouquet of indulgences'){
		sendRequest(url + '?params=482','', brandcentralcallback, 'GET');
		
	}else if(key == 'Facilities'){
		sendRequest(url + '?params=483','', brandcentralcallback, 'GET');
		
	}else if(key == 'Payment Terms'){
		sendRequest(url + '?params=484','', brandcentralcallback, 'GET');
	}else if(key == 'currency'){
		sendRequest(url + '?params=486','', brandcentralcallback, 'GET');
	}else if(key == 'time'){
		sendRequest(url + '?params=485','', brandcentralcallback, 'GET');
	}
	
/*	
	
	
	if(key == 'Overview'){
		sendRequest(url + '?params=476','' , brandcentralcallback, 'GET');	
	}else if(key == 'Office'){
		sendRequest(url, 'params=477', brandcentralcallback, 'GET');
	}else if(key == 'test 1'){
		sendRequest(url, 'params=478', brandcentralcallback, 'GET');
	}*/
}


function brandcentralcallback(){

			var ready=req.readyState;
			var data=null;
			if (ready==READY_STATE_COMPLETE) {
				data=req.responseText;
				eval(data);
			}
}

function brandcentralcall(){

			var ready=req.readyState;
			var data=null;
			if (ready==READY_STATE_COMPLETE) {
				data=req.responseText;
				eval(data);
			}
}

function contact()
		{
			var url = 'http://www.amlaki.ae/amlakiApp/etastar/etastarcontactus.htm'; 
			var p = window.open(url, "Contact", "width=730, height=800, left=100, top=100, location=no, menubar=no, resizable=no, scrollbars=yes, status=no, toolbar=no, fullscreen=no");
		}

function MM_preloadImages() {
  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];}}
}

var req=null;
		var READY_STATE_COMPLETE=4;
		
		function sendRequest(url, params, callback, HttpMethod)
		{
			if(!HttpMethod) {
				HttpMethod="GET";
			}
			req=initXMLHTTPRequest();
			if(req) {
				req.onreadystatechange=callback;
				req.open(HttpMethod,url,true);
				req.setRequestHeader("Content-Type", "text/html");
				req.send(params);
			}
		}
		function initXMLHTTPRequest()
		{
			var xRequest=null;
			if(window.XMLHttpRequest) {
				xRequest=new XMLHttpRequest();
			}
			else if(window.ActiveXObject) {
				xRequest=new ActiveXObject("Microsoft.XMLHTTP");
			}
			return(xRequest);
		}
	 	
		function fill_projects()
		{	//alert("test1");
			var url = "/servlet/AjaxProject";
			//alert("url  : " + url );
			removeOptionLast();
			//alert("6");
					if(document.userMain1.country.value == "") {
						alert("Please Select Country");
						document.psearch.country.focus;
						return false;
					} else {	
					//	alert("7");	
					var params = document.userMain1.country.value;
					url = url + '?' + params;
					//alert("url 8 " + url );
					sendRequest(url, '', onReadyState, 'GET');			
				}
		}
		
		function onReadyState()
		{
			var ready=req.readyState;
			var data=null;
			if (ready==READY_STATE_COMPLETE) {
				data=req.responseText;
				ProcessData(data);
			}
		}
				
		
		function ProcessData(data)
		{
			//alert(data);
			//alert("test9");
			var val = new Array();
				//alert("test10");
			val = data.split(',');
				//alert("test11");
				//alert(val);
			for (y=0; y < val.length; y++)
			{			
				if(val[y] != "")
				{	//alert(val[y]);
					appendOptionLast(val[y]);
				}
			}	
			
		}
	
		function ProcessKey(e,url)
		{
			if(e.keyCode == 13) {
				Password(url);
				return(false);
			}
			return(true);
		}
		
		function search_validate() {
			if(document.search.s.value == "Keyword") {
				document.search.s.focus();
				alert('No Keyword to search');
				return false; 
			} else {
				return true;
			}
		}
		
		function customercare() {
			var url = 'http://www.etastar.com/wp-content/includes/customer-care.php'; 
			var p = window.open(url, "Contact", "width=515, height=592, left=100, top=100, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no, fullscreen=no");
		}

		function cityscape() {
			window.open('/wp-content/includes/city-scape.php', "popup", "width=620, height=550, location=no, menubar=no, resizable=no, scrollbars=yes, status=no, toolbar=no, fullscreen=no");
		}