function MM_preloadImages() { //v3.0
  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];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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 MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

function DisplayImages(picture,caption) {
	x = (screen.width-420)/2;
	y = (screen.height-320)/2;
	popupWin = window.open('','seriindo','width=420,height=330,left='+x+',top='+y);
	popupWin.document.open('text/html','replace');
	popupWin.document.write('<html><head><title>'+caption+' - Bali Real Estate - Bali’s leading fully integrated real estate agency</title><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"></head><body bgcolor="#660800"><a href="javascript:self.close()"><img src='+picture+' border=0 alt="close window"></a></body></html>');
     popupWin.focus();
}
function DisplayImages2(picture,caption) {
	x = (screen.width-770)/2;
	y = (screen.height-583)/2;
	popupWin = window.open('','seriindo','width=770,height=583,left='+x+',top='+y);
	popupWin.document.open('text/html','replace');
	popupWin.document.write('<html><head><title>'+caption+' - Bali Real Estate - Bali’s leading fully integrated real estate agency</title><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"></head><body bgcolor="#660800"><a href="javascript:self.close()"><img src='+picture+' border=0 alt="close window"></a></body></html>');
     popupWin.focus();
}


var aCh="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var dCh="0123456789-";
var sCh="ÀÂÃÄÅÆÇÈÉÊËÌÍÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿŠŒŽšœžŸ'_`~()^&*+-|=<>,./\{}[] ";
var asCh=aCh + dCh + "!\"#$%&'()*+,-./:;<=>?@[\]^_`{}~";

function isAlphaNum(S) {
	var AlphaNum=aCh + dCh;
	for (var i=0; i < S.length; i++) {
		if (AlphaNum.indexOf(S.charAt(i)) == -1)
			return false;
	}
	return true;
}

function isASCII(S) {
	for (var i=0; i < S.length; i++) {
		if (asCh.indexOf(S.charAt(i)) == -1)
			return false;
	}
	return true;
}

function isName(S) {
	var cName=aCh + dCh + sCh;
	for (var i=0; i < S.length; i++) {
		if (cName.indexOf(S.charAt(i)) == -1)
			return false;
	}
	return true;
}

function isEmail(S) {
	var pass=0;
	if (window.RegExp) {
		var tempS="a";
		var tempReg=new RegExp(tempS);
		if (tempReg.test(tempS)) pass=1;
	}
	if (!pass)
		return (S.indexOf(".") > 2) && (S.indexOf("@") > 0);

	var r1=new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2=new RegExp("^[a-zA-Z0-9\\.\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\}\\~]*[a-zA-Z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\}\\~]\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(S) && r2.test(S));
}

function RequestForm() {
	// Check Name
	cNameError = "";
	if (document.EntryForm.Name.value.length<1) {
		cNameError ="Your Name is empty.\n"; 
	} else {
		if (!isName(document.EntryForm.Name.value)){
			cNameError = "Name is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		}
	}
	// Check Address
	cAddressError = "";
	if (document.EntryForm.Address.value.length<1) { 
		cAddressError ="Your Address is empty.\n"; 
	} else {
		if (!isName(document.EntryForm.Address.value)){
			cAddressError ="Address is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		}
	}

	// Check City
	cCityError = "";
	if (document.EntryForm.City.value.length<1) { 
		cCityError ="City Name is empty.\n"; 
	} else {
		if (!isName(document.EntryForm.City.value)){
			cCityError = "City name is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		}
	}

	// Check State
	cStateError = "";
	if (document.EntryForm.State.value.length<1) { 
		cStateError ="State Name is empty.\n"; 
	} else {
		if (!isName(document.EntryForm.State.value)){
			cStateError ="State Name is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		}
	}

	// Check Country
	cCountryError = "";
	if (document.EntryForm.Country.value.length<1) { 
		cCountryError ="Country Name is empty.\n"; 
	} else {
		if (!isName(document.EntryForm.Country.value)){
			cCountryError ="Country Name is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		}
	}

	// Check Phone
	cPhoneError = "";
	if (document.EntryForm.Phone.value.length<1) { 
		cPhoneError ="Phone Number is empty.\n"; 
	} else {
		if (!isName(document.EntryForm.Phone.value)){
			cPhoneError ="Phone Number is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		}
	}

	// Check the Email
	cEmailError = "";
	if (document.EntryForm.Email.value.length <1) { 
		cEmailError ="Your email address is empty.\n";
	}	
	else { 
		if(!isEmail(document.EntryForm.Email.value)) {
			cEmailError ="Your email address is invalid.\ne.g. : (email@domainname.com).\n";
		}
	}

	// Check Message
	cMessageError = "";
	if (document.EntryForm.Message.value.length <1) { 
		cMessageError ="Your Message is empty.\n"; 
	}
	
	cError = cNameError + cAddressError + cCityError + cStateError + cCountryError + cPhoneError + cEmailError + cMessageError;
	
	if (cError.length>0) { 
		alert("Sorry, but you haven\'t filled out all fields required correctly.\n"+cError); 
		if (cNameError.length>0) { document.EntryForm.Name.focus(); } else {
		if (cAddressError.length>0) { document.EntryForm.Address.focus(); } else {
		if (cCityError.length>0) { document.EntryForm.City.focus(); } else {
		if (cStateError.length>0) { document.EntryForm.State.focus(); } else {
		if (cCountryError.length>0) { document.EntryForm.Country.focus(); } else {
		if (cPhoneError.length>0) { document.EntryForm.Phone.focus(); } else {	
		if (cEmailError.length>0) { document.EntryForm.Email.focus(); } else {
		if (cMessageError.length>0) { document.EntryForm.Message.focus(); } } } } } } } }
		return false; 
	}
	
	document.EntryForm.submit();
}


function checkForm() {
	if (document.mf.realname.value.length <1) { alert("Sorry, but you haven\'t filled out all fields required.\nPlease enter your name."); document.mf.realname.focus(); return false; }
	if (document.mf.email.value.length <1) { 
		alert("Sorry, but you haven\'t filled out all fields required.\nPlease enter your email address."); document.mf.email.focus(); return false; 
	}	
	else { 
		dmn = document.mf.email.value.substr(document.mf.email.value.indexOf("@")+1,document.mf.email.value.length);
		if((document.mf.email.value.indexOf("@")<1) ||(dmn.indexOf("@")>-1) || (dmn.indexOf(".")<1) || (dmn.indexOf(".")>dmn.length-2)) {
			alert("Please type a valid email address.\nEx : (email@domainname.com)."); document.mf.email.focus(); return false; 
		}
	}
	if (document.mf.comment.value.length <1) { alert("Sorry, but you haven\'t filled out all fields required.\nPlease enter your comment."); document.mf.comment.focus(); return false; }
	document.mf.submit();
}


function RequestForm2() {

	// Check the Adult people
	cAdultsError = "";
	if (document.EntryForm.Adults.value.length<1) { 
		cAdultsError = "Adult should not be empty.\n";
	} else {
		if (isNaN(document.EntryForm.Adults.value)) { 
			cAdultsError = "Adult should be numeric.\n";
		} else {
			if (document.EntryForm.Adults.value<0) { 
				cAdultsError = "Adult should not be negative.\n";
			}
		}
	}

	

	// Check the No Room
	cNoRoomError = "";
	if (document.EntryForm.NoRoom.value.length<1) { 
		cNoRoomError = "Room should not be empty.\n";
	} else {
		if (isNaN(document.EntryForm.NoRoom.value)) { 
			cNoRoomError = "Room should be numeric.\n";
		} else {
			if (document.EntryForm.NoRoom.value<0) { 
				cNoRoomError = "Room should not be negative.\n";
			}
		}
	}


	// Check Name
	cNameError = "";
	if (document.EntryForm.Name.value.length<1) {
		cNameError ="Your Name is empty.\n"; 
	} else {
		if (!isName(document.EntryForm.Name.value)){
			cNameError = "Name is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		}
	}
	// Check Address
	cAddressError = "";
	if (document.EntryForm.Address.value.length<1) { 
		cAddressError ="Your Address is empty.\n"; 
	} else {
		if (!isName(document.EntryForm.Address.value)){
			cAddressError ="Address is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		}
	}

	// Check City
	cCityError = "";
	if (document.EntryForm.City.value.length<1) { 
		cCityError ="City Name is empty.\n"; 
	} else {
		if (!isName(document.EntryForm.City.value)){
			cCityError = "City name is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		}
	}

	// Check State
	cStateError = "";
	if (document.EntryForm.State.value.length<1) { 
		cStateError ="State Name is empty.\n"; 
	} else {
		if (!isName(document.EntryForm.State.value)){
			cStateError ="State Name is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		}
	}

	// Check Country
	cCountryError = "";
	if (document.EntryForm.Country.value.length<1) { 
		cCountryError ="Country Name is empty.\n"; 
	} else {
		if (!isName(document.EntryForm.Country.value)){
			cCountryError ="Country Name is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		}
	}

	// Check Phone
	cPhoneError = "";
	if (document.EntryForm.Phone.value.length<1) { 
		cPhoneError ="Phone Number is empty.\n"; 
	} else {
		if (!isName(document.EntryForm.Phone.value)){
			cPhoneError ="Phone Number is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		}
	}

	// Check the Email
	cEmailError = "";
	if (document.EntryForm.Email.value.length <1) { 
		cEmailError ="Your email address is empty.\n";
	}	
	else { 
		if(!isEmail(document.EntryForm.Email.value)) {
			cEmailError ="Your email address is invalid.\ne.g. : (email@domainname.com).\n";
		}
	}

	// Check Message
	cMessageError = "";
	if (document.EntryForm.Message.value.length <1) { 
		cMessageError ="Your Message is empty.\n"; 
	}

	
	cError = cAdultsError + cNoRoomError + cNameError + cAddressError + cCityError + cStateError + cCountryError + cPhoneError + cEmailError + cMessageError;
	
	if (cError.length>0) { 
		alert("Sorry, but you haven\'t filled out all fields required correctly.\n"+cError); 
		if (cAdultsError.length>0) { document.EntryForm.Adults.focus(); } else {
		if (cNoRoomError.length>0) { document.EntryForm.NoRoom.focus(); } else {
		if (cNameError.length>0) { document.EntryForm.Name.focus(); } else {
		if (cAddressError.length>0) { document.EntryForm.Address.focus(); } else {
		if (cCityError.length>0) { document.EntryForm.City.focus(); } else {
		if (cStateError.length>0) { document.EntryForm.State.focus(); } else {
		if (cCountryError.length>0) { document.EntryForm.Country.focus(); } else {
		if (cPhoneError.length>0) { document.EntryForm.Phone.focus(); } else {	
		if (cEmailError.length>0) { document.EntryForm.Email.focus(); } else {
		if (cMessageError.length>0) { document.EntryForm.Message.focus(); } } } } } } } } } } 
		return false; 
	}
	
	document.EntryForm.submit();
}
function openwin(source) {
	popupWin = window.open(source, 'brepopup','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=200,height=50');
	popupWin.moveTo(screen.width-400,100)
	popupWin.focus();
}
function openwinPack(source) {
	popupWin = window.open(source, 'brepackages','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=500,height=400');
	popupWin.moveTo(screen.width-400,100)
	popupWin.focus();
}
function C_Show() { 
  var i,obj,args=C_Show.arguments;
  for (i=0; i<(args.length-2); i+=3) {
    if ((obj=MM_findObj(args[i]))!=null) {
      if (obj.style)
        obj=obj.style;
      obj.display='';
	}
  }
}

function C_Hide() { 
  var i,obj,args=C_Hide.arguments;
  for (i=0; i<(args.length-2); i+=3) {
    if ((obj=MM_findObj(args[i]))!=null) {
      if (obj.style)
        obj=obj.style;
      obj.display='none';
	}
  }
}






/*____________________________________________________________________________________________________________ 

MENU POPUP*/
/*
 | Browser object
 */
function b3kb_Browser() {
 d=document;
 this.agt=navigator.userAgent.toLowerCase();
 this.major = parseInt(navigator.appVersion);
 this.dom=(d.getElementById)?1:0; // true for ie6, ns6
 this.ns=(d.layers);
 this.ns4up=(this.ns && this.major >=4);
 this.ns6=(this.dom&&navigator.appName=="Netscape");
 this.op=(window.opera? 1:0);
 this.ie=(d.all);
 this.ie4=(d.all&&!this.dom)?1:0;
 this.ie4up=(this.ie && this.major >= 4);
 this.ie5=(d.all&&this.dom);
 this.win=((this.agt.indexOf("win")!=-1) || (this.agt.indexOf("16bit")!=-1));
 this.mac=(this.agt.indexOf("mac")!=-1);
}

var oBw = new b3kb_Browser();

/* begin new */
function b3kb_getH(o) { return (oBw.ns)?((o.height)?o.height:o.clip.height):((oBw.op&&typeof o.style.pixelHeight!='undefined')?o.style.pixelHeight:o.offsetHeight); }
function b3kb_setH(o,h) { if(o.clip) o.clip.height=h; else if(oBw.op && typeof o.style.pixelHeight != 'undefined') o.style.pixelHeight=h; else o.style.height=h; }
function b3kb_getW(o) { return (oBw.ns)?((o.width)?o.width:o.clip.width):((oBw.op&&typeof o.style.pixelWidth!='undefined')?w=o.style.pixelWidth:o.offsetWidth); }
function b3kb_setW(o,w) { if(o.clip) o.clip.width=w; else if(oBw.op && typeof o.style.pixelWidth != 'undefined') o.style.pixelWidth=w; else o.style.width=w; }
function b3kb_getX(o) { return (oBw.ns)?o.left:((o.style.pixelLeft)?o.style.pixelLeft:o.offsetLeft); }
function b3kb_setX(o,x) {
	if(oBw.ns) { 
		o.left=x;
	} else if(typeof o.style.pixelLeft != 'undefined') {
		o.style.pixelLeft=x;
	} else {
		thisPos = parseInt(x);			// preventing NS UNcaught Exception Error in strict.dtd mode: converting value to integer in case passed as string
		thisPos += "px";
		o.style.left = thisPos;
	}
}
function b3kb_getY(o) { return (oBw.ns)?o.top:((o.style.pixelTop)?o.style.pixelTop:o.offsetTop); }
function b3kb_setY(o,y) {
	if(oBw.ns) {
		o.top=y;
	} else if(typeof o.style.pixelTop != 'undefined') {
		o.style.pixelTop=y;
	} else {
		thisPos = parseInt(y);			// preventing NS UNcaught Exception Error in strict.dtd mode: converting value to integer in case passed as string
		thisPos += "px";
		o.style.top = thisPos;
	}
}
function b3kb_getPageX(o) { var x=0; if(oBw.ns) x=o.pageX; else { while(eval(o)) { x+=o.offsetLeft; o=o.offsetParent; } } return x; }
function b3kb_getPageY(o) { var y=0; if(oBw.ns) y=o.pageY; else { while(eval(o)) { y+=o.offsetTop; o=o.offsetParent; } } return y; }
function b3kb_getZ(o) { return (oBw.ns)?o.zIndex:o.style.zIndex; }
/* end new */

function b3kb_moveTo(o,x,y) { b3kb_setX(o,x);b3kb_setY(o,y); }
function b3kb_moveBy(o,x,y) { b3kb_setX(o,b3kb_getPageX(o)+x);b3kb_setY(o,b3kb_getPageY(o)+y); }

function b3kb_setZ(o,z) { if(oBw.ns)o.zIndex=z;else o.style.zIndex=z; }

function b3kb_setClip(o) { }

function b3kb_show(o,disp) { 
 (oBw.ns)? '':(!disp)? o.style.display="inline":o.style.display=disp;
 (oBw.ns)? o.visibility='show':o.style.visibility='visible';  
}
function b3kb_hide(o,disp) { 
 (oBw.ns)? '':(arguments.length!=2)? o.style.display="none":o.style.display=disp;
 (oBw.ns)? o.visibility='hide':o.style.visibility='hidden';  
}

function b3kb_setStyle(o,s,v) { if(oBw.ie5||oBw.dom) eval("o.style."+s+" = '" + v +"'"); }
function b3kb_getStyle(o,s) { if(oBw.ie5||oBw.dom) return eval("o.style."+s); }

function b3kb_getDocW() { }
function b3kb_getDocH() { }

function b3kb_addEvt(o,e,f,c){ if(o.addEventListener)o.addEventListener(e,f,c);else if(o.attachEvent)o.attachEvent("on"+e,f);else eval("o.on"+e+"="+f)}

function b3kb_writeHTML(o,h) { 
 if(oBw.ns){var doc=o.document;doc.write(h);doc.close();return false;}
 if(o.innerHTML)o.innerHTML=h; 
}

// w - beforeBegin,afterBegin,beforeEnd,afterEnd
// width - for ns 4 only
function b3kb_insertHTML(o,h,w) {
 if (oBw.op) return;
 if (o.insertAdjacentHTML) { 
  o.insertAdjacentHTML(w,h);
  return;
 }
 if (oBw.ns) {
  b3kb_writeHTML(o,h);
  return;
 }



 // mozilla
 var r = o.ownerDocument.createRange();
	r.setStartBefore(o);
	var frag = r.createContextualFragment(h);
	b3kb_insertObj(o,w,frag)
}


function b3kb_insertObj(o,w,node) {
	switch (w){
	case 'beforeBegin':
		o.parentNode.insertBefore(node,o)
		break;
	case 'afterBegin':
		o.insertBefore(node,o.firstChild);
		break;
	case 'beforeEnd':
		o.appendChild(node);
		break;
	case 'afterEnd':
		if (o.nextSibling){
			o.parentNode.insertBefore(node,o.nextSibling);
		} else {
			o.parentNode.appendChild(node)
		}
		break;
	}
}

/*____________________________________________________________________________________________________________ */

function b3k_setLayerLocation(div,href,offx,offy) {
//alert(div,href.name);
	var e = d.getElementById(div);
	//get position of link
	var x=b3kb_getPageX(href);
	var y=b3kb_getPageY(href);
	// check and set there is offset
	x= offx ? x + offx : x;
	y= offy ? y + offy : y;
	//move layer
	b3kb_moveTo(e,x,y);
}

objMenuPopUp = null;
objMenuPopUp3 = null;

/* untuk sub menu occassion*/
function b3k_popLayer(div,div2,href,offx,offy,offx2,offy2) {
	var e = d.getElementById(div);
	if (e.className.indexOf('hiddenlayer') != -1) {
		// if current popup is hidden, make sure all others are hidden.
		b3k_hidePopLayers('div','showlayer','hiddenlayer');	
		b3k_setLayerLocation(div,href,offx,offy);		
		e.className = 'showlayer'; //show layer	
	} else {
		clearTimeout(objMenuPopUp);
	}
	var e = d.getElementById(div2);
	if (e.className.indexOf('hiddenlayer') != -1) {
		// if current popup is hidden, make sure all others are hidden.
		b3k_hidePopLayers('div2','showlayer','hiddenlayer');	
		b3k_setLayerLocation(div2,href,offx2,offy2);		
		e.className = 'showlayer'; //show layer	
	} else {
		clearTimeout(objMenuPopUp3);
	}
}

function b3k_hideLayer(div) {
	var e = d.getElementById(div);
	if (e.className.indexOf('showlayer') != -1) {
		e.className = 'hiddenlayer';		
	} 
	MM_displayStatusMsg('');
}

function b3k_DelayPopup(){
	objMenuPopUp = setTimeout("b3k_hideLayer('baliland_list')",0);
	objMenuPopUp3 = setTimeout("b3k_hideLayer('baliland_over')",0);
}

function b3k_ClearTimeOut(){
	clearTimeout(objMenuPopUp);
	clearTimeout(objMenuPopUp3);
}

function b3k_hidePopLayers(elm,showclass,hideclass) {
	var elms = d.getElementsByTagName(elm);
	for (var i =  elms.length-1; i >=0; i--)	{
		if (elms[i].className.indexOf(showclass) != -1)	{
			// if a class contains 'showclass' set to 'hideclass'
			elms[i].className = hideclass;
		}
	}
}

