t_browser=false
t_browserver=0
IE4=!!document.all
W3C=DOM=!!document.getElementById
NS4=!!document.layers
Mac=(navigator.appVersion.indexOf("Mac")!=-1)
if((i=navigator.userAgent.indexOf('Opera'))!=-1){
	t_browser='opera'
	t_browserver=parseFloat(navigator.userAgent.substr(i + 6, 3))
}else if((i=navigator.userAgent.indexOf('MSIE'))!=-1){
	t_browser='msie'
	t_browserver=parseFloat(navigator.userAgent.substr(i + 5, 3))
}else if(NS4){
	t_browser='ns4'
}

m_yPos 		= (NS4)?139:139;
m_xPos 		= 0;
t_contentW	=780

function getObj(id) {
	return W3C?document.getElementById(id):
		IE4?document.all[id]:
		NS4?document[id]:false;
} 
 
function t_offset(){
	var t_winW
	if(t_browser=='gecko')
		t_winW=document.body.offsetWidth
	else if(window.innerWidth)
		t_winW=window.innerWidth-(NS4&&!Mac?16:0)
	else if(document.body&&document.body.clientWidth)
		t_winW=document.body.clientWidth
	else
		t_winW=100
	
	return(t_winW<t_contentW)?0:Math.floor((t_winW-t_contentW)/2)
}

function show(layernavn) {
var el = getObj(layernavn);
if(el)
	el.style.visibility="visible";
else
	document.layers[layernavn].visibility = "show";		
}

function hide(layernavn) {
var el = getObj(layernavn);
if(el)
	el.style.visibility="hidden";
else
	document.layers[layernavn].visibility = "hide";
}


function main_selected(maincategory) {
	var form = document.forms[0];

	var l = subcategories[maincategory].length;

	form.subcategory.options.length = l;
	form.subcategory.selectedIndex = 0;
	if(l == 0) {
		form.subcategory.options[0] = new Option('Unfortunately no sub categories', 0);
	} else {
		for (i = 0; i < l; i++) {
			form.subcategory.options[0] = new Option('Please choose', 0);
			var information = subcategories[maincategory][i].split(":");
			var category_id = information[0];
			var category 	= information[1];
			form.subcategory.options[i + 1] = new Option(category, category_id);
		}
	}
	form.subcategory.selectedIndex = 0;
}


function sub_selected(subcategory) {
	var form = document.forms[0];
	for(i = 0 ; i < form.subcategory.options.length ; i++) {
		if(form.subcategory.options[i].value == subcategory) {
			form.subcategory.selectedIndex = i;
		}
	}
}


function winopen(windowURL,windowname,w,h){
popup = window.open(windowURL,windowname,"width="+w+",height="+h+",toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes");
popup.focus();
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function popImage(img) {
	var titre;
	var w;
	titre="Palms Luxury Homes";
	w=open("",'image','width=535,height=335,toolbar=no,scrollbars=yes,resizable=yes');	
	w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>");
	w.document.write("<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+12,document.images[0].height+30); window.focus();} else { setTimeout('check()',250) } }</"+"SCRIPT>");
	w.document.write("<BODY leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><IMG src='"+img+"' border=0>");
	w.document.write("");
	w.document.write("</body></html>");
	w.document.close();
}

function validEmail(email) {
invalidChars = " /:,;"
if (email == "") {
    return false
}

for (i=0; i<invalidChars.length; i++) {
    badChar = invalidChars.charAt(i)
    if (email.indexOf (badChar,0) != -1) {
        return false
    }
}  // for (i=o.. 

atPos = email.indexOf ("@",1)

if (atPos == -1) {
    return false
}

if ( email.indexOf ("@", atPos+1) != -1) {
    return false
}
periodPos = email.indexOf (".", atPos)

if ( periodPos == -1) {
    return false
}

if ( periodPos+3 > email.length)    {
    return false
}
return true
}  // validEmail 


function FlashInstalled()
{
	result = false;

	if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"])
	{
		result = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
	}
	else if (document.all && (navigator.appVersion.indexOf("Mac")==-1))
	{
		// IE Windows only -- check for ActiveX control, have to hide code in eval from Netscape (doesn't like try)
		eval ('try {var xObj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if (xObj)	result = true; xObj = null;	} catch (e)	{}');
	}
	return result;
}

function FlashWrite(url,width,height)
{
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"');
	document.write('  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" ');
	document.write('  width="' + width + '" height="' + height + '">');
	document.write(' <param name="movie" value="' + url + '"> <param name="quality" value="high"> <param name="bgcolor" value="#013B75">  '); 
	document.write(' <embed src="' + url + '" quality="high" bgcolor="#013B75"  ');
	document.write(' swliveconnect=false width="' + width + '" height="' + height + '"');
	document.write(' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash">');
	document.write(' </embed></object>');
}

function FlashWriteWhite(url,width,height)
{
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"');
	document.write('  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" ');
	document.write('  width="' + width + '" height="' + height + '">');
	document.write(' <param name="movie" value="' + url + '"> <param name="quality" value="high"> <param name="bgcolor" value="#ffffff">  '); 
	document.write(' <embed src="' + url + '" quality="high" bgcolor="#ffffff"  ');
	document.write(' swliveconnect=false width="' + width + '" height="' + height + '"');
	document.write(' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash">');
	document.write(' </embed></object>');
}

function checkForm() {
	var formen = document.forms[0];
	message = '';
	if(formen.fname.value == '') {
		message += "First Name is compulsory\n";
	}
	if(formen.lname.value == '') {
		message += "Last Name is compulsory\n";
	}
	if(formen.country.value == '') {
		message += "Country is compulsory\n";
	}
	if(formen.currency.value == '') {
		message += "Currency is compulsory\n";
	}
	if(formen.occupation.value == '') {
		message += "Occupation is compulsory\n";
	}
	if(!validEmail(formen.email.value)) {
		message += "Email is not a valid address\n";
	}
	if(formen.phone.value == '') {
		message += "Phone is compulsory\n";
	}	
	if(formen.postal.value == '') {
		message += "Postal is compulsory\n";
	}	
	
	if(message == '') {
		winopen('','member',500,250);
		return true;
	} else {
		alert(message);
		return false;
	}
}

function check() {
	var form, message;
	form = document.contact;
	message = '';
	for(i = 0 ; i < form.elements.length ; i++) {
		if(form.elements[i].value == '' || form.elements[i].value == 0) {
			if(form.elements[i].name != 'undefined') {
				message += form.elements[i].name + " needs input\n";
			}
		}
	}
	
	if(message == '' || message == 'undefined') {
		return true;
	} else {
		alert(message);
		return false;
	}
}

var Chaser = 
{
	// you set these paramaters!
	hover	: 30,
	divisor	: 10,
	callRate: 40,
	layer	: getObj('rightbanner')
}

Chaser.paint = function() {
var scmenulayer = getObj('rightbanner');
/*
// browser specific way to check amount window has scrolled by.
if(document.all) {
targetY = document.body.scrollTop + Chaser.hover;
targetY = (targetY < m_yPos)?m_yPos + Chaser.hover:document.body.scrollTop + Chaser.hover;
} else if (document.getElementById) {
targetY = scmenulayer.style.top + Chaser.hover;
} else {
targetY = window.pageYOffset + Chaser.hover;
targetY = (targetY < m_yPos)?m_yPos + Chaser.hover:window.pageYOffset + Chaser.hover;
}
*/
// browser specific way to check chaser's position.
if(document.all) {
currentY = scmenulayer.style.pixelTop;
} else if (document.getElementById) {
currentY = scmenulayer.style.top;
} else {
currentY = document.layers['rightbanner'].top;
}
	targetY  = 137;
	difference = currentY - targetY;
	decrement = Math.round(difference / Chaser.divisor);
	
	// browser-specific method of moving chaser
	if (document.all) {
		scmenulayer.style.pixelTop -= decrement
	} if (document.getElementById) {
	
	
	} else {
		document.layers['rightbanner'].top -= decrement;
	}
}
window.setInterval("Chaser.paint()", Chaser.callRate)
