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_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_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];}
	}
	//-->

//window.onload = initialize();
var childTitleArr = new Array('page-title','middlebar-title','rightbar-title');

function initialize() {
	try{
	init();
	//alert(navigator.userAgent.indexOf( 'MSIE' ));
	if(navigator.userAgent.indexOf( 'MSIE' ) != -1 && ver<=6.0)
		adjust_position();
	enablingIds = "page-body,middlebar-body,rightbar-body";
	envArr = enablingIds.split(",");
	//alert($($(envArr[1]).parentNode.id));
	//el = $($(envArr[1]).parentNode.id).childNodes[0].id;
	//alert(el)
	//el_obj = $(el);
	//alert($($(envArr[1]).parentNode.id).getElementsByClassName('icon').length);
	//alert(el_obj.getElementsByTagName('a').href);
//	document.getElementsByTagName('a')
//alert(isIndex);
	if(isIndex == 'yes'){
			if(envArr.length > 0){ 
					$('flashContent').show();
					for(i=0;i<envArr.length; i++){
						$(envArr[i]).hide();

						if($(childTitleArr[i]).getElementsByClassName('icon').length > 0){	
						if($(childTitleArr[i]).getElementsByClassName('icon')[0].getElementsByTagName('a').length > 0)
							checkForActiveToggle($(childTitleArr[i]).getElementsByClassName('icon')[0].getElementsByTagName('a')[0],childTitleArr[i]);
						}
					}
					
				}
	}
	else{
			
			if(envArr.length > 0){ 
					$('flashContent').hide();
					for(i=0;i<envArr.length; i++){
							$(envArr[i]).show();
						
						if($(childTitleArr[i]).getElementsByClassName('icon').length > 0){	
						if($(childTitleArr[i]).getElementsByClassName('icon')[0].getElementsByTagName('a').length > 0)
							checkForActiveToggle($(childTitleArr[i]).getElementsByClassName('icon')[0].getElementsByTagName('a')[0],childTitleArr[i]);
						}
					}
						
					
				}
		}	
	// set focus to logon form's username box.
	/*if( document.logon_form ) {
		document.logon_form.username.focus();
	}*/
	}catch(e){//alert('a');
	}

}

function historyChange(newLocation, historyData) {
	if(!historyData){
		historyData=new Array();
		historyData['url']='flux.php';
	}
	debug("A history change has occurred: "
		+ "newLocation="+newLocation
		+ ", url="+historyData["url"]
		+ ", handler="+historyData["handler"]
		+ ", body="+historyData["body"], false);
	loadXMLDoc(historyData["url"], historyData["handler"], historyData["body"], false);
}

/** Displays messages to the screen. */
function debug(msg, alertme) {
	if (alertme == true)
		alert(msg);
        else {
//		  alert("history changed");// do nothing
        }
}

////
function updateSearchSubmit(target) {
	if( target.value == "servicecall" ) {
		document.searchForm.page.value="ServiceCall.php";
	} else {
		document.searchForm.page.value="Page.php";
	}
}
function flux_rent(type) {
	dd=document.getElementById('rc_day');
	ww=document.getElementById('rc_week');
	mm=document.getElementById('rc_month');
	yy=document.getElementById('rc_year');
	var perday=0, perweek=0, permonth=0, peryear=0;
	switch(type) {
		case 1:
			rent = parseFloat(dd.value);
			break;
		case 2:
			rent = parseFloat(ww.value);
			break;
		case 3:
			rent = parseFloat(mm.value);
			break;
		case 4:
			rent = parseFloat(yy.value);
			break;
	}
	if(isNaN(rent)) {
		dd.value="";
		ww.value="";
		mm.value="";
		yy.value="";
		return false;
	}
	switch(type) {
		case 1:
			perday = rent;
			perweek = perday * 7;
			peryear = perday * 365;
			permonth = peryear / 12;
			ww.value = perweek.toFixed(2);
			mm.value = permonth.toFixed(2);
			yy.value = peryear.toFixed(2);
			break;
		case 2:
			perweek = rent;
			perday = perweek / 7;
			peryear = perday * 365;
			permonth = peryear / 12;
			dd.value = perday.toFixed(2);
			mm.value = permonth.toFixed(2);
			yy.value = peryear.toFixed(2);
			break;
		case 3:
			permonth = rent;
			peryear = permonth * 12;
			perday = peryear / 365;
			perweek = perday * 7;
			dd.value = perday.toFixed(2);
			ww.value = perweek.toFixed(2);
			yy.value = peryear.toFixed(2);
			break;
		case 4:
			peryear = rent;
			permonth = peryear / 12;
			perday = peryear / 365;
			perweek = perday * 7;
			dd.value = perday.toFixed(2);
			ww.value = perweek.toFixed(2);
			mm.value = permonth.toFixed(2);
			break;
	}
}

function preload() {}


	function fix_bottom(){
		$d = document.getElementById('flux-footer-container');
		if($d)
			$d.style.top = (window.innerHeight - 52);
	}
	function fix_position(id, top, left, height, width){
		e = document.getElementById(id);
		if(!e){ return; alert(id + ' not found'); return;}
		if(top)
			e.style.top = top+'px';
		if(left)
			e.style.left = left+'px';
		if(height)
			e.style.height = height+'px';
		if(width)
			e.style.width = width+'px';
	}
	var isRightHidden=false;
	function adjust_position(){
		size = getWindowSize();	
		//if(isRightHidden) right=20;
		//else right=200;
		//fix_position('menu', 0, 2, null, 550);
		if(ver<=6.0)
			fix_position('logo-holder', null, (size[0]/2 + 365), null, 107);
		//fix_position('menu-header', 55, 100, null, size[0] - 200);
		//fix_position('menu-header2', 140, 100, null, size[0] - 200);
		//fix_position('main-container', -50, 100, null, size[0] - 200);
		//fix_position('footer-container', null, 100, null, size[0] - 200);
		//fix_position('footer', null, 100, null, size[0] - 200);
		/*fix_position('footer-shaded', null, null, null, size[0] - 240);
		fix_position('main-container', null, 100, null, size[0] - 240);
		fix_position('pagemenu-container', null, null, 15, size[0] - right - 250);
		fix_position('content', null, 100, null, size[0] - right - 270);
		fix_position('fluxlet-right', null, size[0] - 230, null, right);
		fix_position('footer-shaded-div', null, null, null, right);
		fix_position('page-body', null, null, null, size[0] - right - 280);
		fix_position('page-title', null, null, null, size[0] - right- 280);*/
	}
	function getWindowSize(){
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}
		return new Array(myWidth, myHeight);
	}
	function showhide(div){
		a = document.getElementById(div+'_a');
		if(!a){ alert(div+'_a not found!'); return; }
		b = document.getElementById(div+'_b');
		if(!b){ alert(div+'_b not found!'); return; }
		subs = document.getElementById(div+'_body');
		if(!subs){ alert(div+'_body not found!'); return; }
		if(subs.style.display=='none'){
			a.style.display = '';
			b.style.display = 'none';
			subs.style.display = '';
			return;
		}
		a.style.display = 'none';
		b.style.display = '';
		subs.style.display = 'none';
	}
	function FluxHighlight(me, checkbox){
		if(checkbox.checked){
			me.className = '';
			checkbox.checked = false;
			return;
		}
		me.className = 'pHover';
		checkbox.checked = true;
		return;
	}
	function HighlightPageMenu(menu, theitem){
		try{
		d = document.getElementById(menu);
		if(!d) return;
		uls = d.getElementsByTagName('li');
		for(i in uls)
			if(uls[i].className != 'active')
				uls[i].oldclass= uls[i].className;
			else
				uls[i].className = uls[i].oldclass;
		
		a = document.getElementById(theitem);
		if(!a) return;
		a.className='active';
		}catch(e){alert(e)}
	}
	function ActivatePageMenu(menudiv, active){
		d = document.getElementById(menudiv);
		if(!d) return;
		uls = d.getElementsByTagName('ul');
		for(i in uls)
			if(uls[i].style)
				uls[i].style.display='none' ;
		
		a = document.getElementById(active);
		if(!a) return;
		a.style.display='';
	}

	function ActivateGlobalMenu(divid){
		$p = $("#"+divid).parent();
		$("#"+divid).css("left", $p.position().left);
		$("#"+divid).css("top", $p.height()+$p.position().top);
		$("#"+divid).show();
		return false;
	}
	function DeActivateGlobalMenu(divid){
		$("#"+divid).hide();
		return false;
	}
	
	details = new Array();
	details['Property'] = new Array('Agreement', 'Landlord', 'Tenancy', 'Tenant');
	details['Contact'] = new Array('Agreement', 'Landlord', 'Tenancy', 'Tenant');

	function ShowDetails(checkbox, me, myid){
	}
	
	function ResetDetails(){
	}

	function showhide_rightmenu(div){
			a = document.getElementById(div+'_a');
			if(!a){ alert(div+'_a not found!'); return; }
			b = document.getElementById(div+'_b');
			if(!b){ alert(div+'_b not found!'); return; }
			subs = document.getElementById('fluxlet-right');
			divs = subs.getElementsByTagName('li');
			if(subs.style.width=='20px'){
				a.style.display = '';
				b.style.display = 'none';
				subs.style.width = '200px';
				for(i=0; i<divs.length; i++){
					d = divs[i];
					if(d.className=='fluxlet')
						d.style.display='';
				}
				isRightHidden = false;
				adjust_position();
				return;
			}
			a.style.display = 'none';
			b.style.display = '';
			subs.style.width = '10px';
			for(i=0; i<divs.length; i++){
				d = divs[i];
				if(d.className=='fluxlet')
					d.style.display='none';
			}
			isRightHidden = true;
			adjust_position();
	}

function movediv(id){
	d = document.getElementById(id);
	if(!d) return;
	d.style.border='';
}
function showmove(id){
	d = document.getElementById(id);
	if(!d) return;
	d.style.border='1px dotted #4C4D4F';
}
function resetads(id){
		elms = document.getElementById(id);
		elms.innerHTML = "";
		elms.style.display = 'none';
	}
	
function collapseFlash(obj,id,enablingIds){
		elms = $(id);
		envArr = enablingIds.split(",");
		if(elms.style.display =='none' )
			window.location = obj.href;
		else{
			/*new Effect.Parallel([
    				new Effect.Fade(id), 
    				new Effect.SlideDown(envArr[0])
  					]);*/

			//new Effect.Fold(id,{delay:5});
			$(id).hide();
			if(envArr.length > 0){ 
				for(i=0;i<envArr.length; i++){
					if(i == 0)			
							Effect.SlideDown(envArr[i],{delay:0.25,duration:1});//$(envArr[i]).show();
					else	
							$(envArr[i]).show();
				}

			}
			isIndex = 'no';
			initialize();
			return false;
		}
		
			
	}	
function toggleIt(obj,id){
		
		//if(checkForActiveToggle(obj,id) != true)
		//	return false;
		if(obj.title == 'hideMe'){
			obj.innerHTML = '<img src="images/expand.gif" align="right" border="0" height="12">';
			obj.title = 'showMe';
		}
		else{
			obj.innerHTML = '<img src="images/collapse.gif" align="right" border="0" height="12">';
			obj.title = 'hideMe'
		}
		new Effect.toggle(id,'Slide', {duration: 0.25}); 
		
	}	
function checkForActiveToggle(obj,id){
		
		if(!$('flashContent').style.display && (id == childTitleArr[0] || id == childTitleArr[1] || id == childTitleArr[2]) ){
			obj.hide();
			return false;
		}
		else
			obj.show();
		
		return true;
	}	