<!--
// NAVIGATION IMAGES PRELOADER

image1off= new Image( ); image1off.src="/images/nav_home_off.gif";
image2on= new Image( ); image2on.src="/images/nav_apts_on.gif";
image3on= new Image( ); image3on.src="/images/nav_servs_on.gif";
image4on= new Image( ); image4on.src="/images/nav_news_on.gif";
image5on= new Image( ); image5on.src="/images/nav_promos_on.gif";
image8off= new Image( ); image8off.src="/images/search_tab_off.gif";
image9on= new Image( ); image9on.src="/images/favs_tab_on.gif";

// FUNCTION getElementsByClassName
function getElementsByClassName(oElm, strTagName, oClassNames){
    var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    var arrRegExpClassNames = new Array();
    if(typeof oClassNames == "object"){
        for(var i=0; i<oClassNames.length; i++){
            arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
        }
    }
    else{
        arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
    }
    var oElement;
    var bMatchesAll;
    for(var j=0; j<arrElements.length; j++){
        oElement = arrElements[j];
        bMatchesAll = true;
        for(var k=0; k<arrRegExpClassNames.length; k++){
            if(!arrRegExpClassNames[k].test(oElement.className)){
                bMatchesAll = false;
                break;                      
            }
        }
        if(bMatchesAll){
            arrReturnElements.push(oElement);
        }
    }
    return (arrReturnElements)
}

// END OF NAVIGATION IMAGES PRELOADER


// MY FAVOURITES JAVASCRIPT

//var fav1, fav2, fav3, fav4, fav5, fav6;
var isIE = navigator.appName == "Microsoft Internet Explorer";
var server = "http://" + document.location.host;
//	
//window.onload = function() {
//	fav1 = new fx.Combo('fav1', {height: true, opacity: true, duration: 500});
//	fav2 = new fx.Combo('fav2', {height: true, opacity: true, duration: 500});
//	fav3 = new fx.Combo('fav3', {height: true, opacity: true, duration: 500});
//	fav4 = new fx.Combo('fav4', {height: true, opacity: true, duration: 500});
//	fav5 = new fx.Combo('fav5', {height: true, opacity: true, duration: 500});
//	fav6 = new fx.Combo('fav6', {height: true, opacity: true, duration: 500});
//		
//	// Hide them to begin with
//	fav1.hide();
//	fav2.hide();
//	fav3.hide();
//	fav4.hide();
//	fav5.hide();
//	fav6.hide();
//}

// END OF MY FAVOURITES JAVASCRIPT

// SEARCH RESULTS PHOTO SLIDES JAVASCRIPT

var req;
var direction;
var result;


function createXMLHttpRequest() {
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
}

function requestPhotos(dir,numb) {
	direction = dir;
	result = numb;
	createXMLHttpRequest();
	req.onreadystatechange = handleStateChange;
	//req.open("GET", server + '/pages/search_result_photos.xml', true);
	req.text='<apartments><apartment><photo source="/images/apts/test1_160x110.jpg" /> <photo source="/images/apts/test1a_160x110.jpg" />   <photo source="/images/apts/test1b_160x110.jpg" />   </apartment></apartments>';
	req.send(null);
}

function handleStateChange() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			if(direction == 'previous')
				display_previous_photos();
			else if (direction == 'next')
				display_next_photos();
		} else {
			alert("There was a problem retrieving the XML data:\n" + req.statusText);
		}
	}
}


function requestPhotos2(index,dir,_array) {
    
    result = index;
    direction = dir;
   
    if(direction == 'previous')
		display_previous_photos2(_array);
	else if (direction == 'next')
		display_next_photos2(_array);

}

function display_next_photos2(photos){
	if (document.getElementById && document.getElementsByTagName) {
		
		var current_photo = getElementsByClassName(document, "div", "sresult")[result].getElementsByTagName('img')[0];
		        
		for (i = 0; i < photos.length; i++){
    	    if (isIE)
    	    {	            
    	        
			    if (unescape(current_photo.getAttribute('src')) == server + photos[i]){
				    break;
			    }
    	    }
    	    else {
			    if (unescape(current_photo.getAttribute('src')) == photos[i]){
				    break;
			    }
			}
		}		
			
		if (i < photos.length - 1){
			update_arrows(i + 1,photos.length - 1);			
			current_photo.setAttribute('src' , photos[i + 1]);
		}
		
	}
		
}

function display_previous_photos2(photos)
{
    if (document.getElementById && document.getElementsByTagName) {
		
		var current_photo = getElementsByClassName(document, "div", "sresult")[result].getElementsByTagName('img')[0];
	
		for (i = photos.length - 1; i >= 0; i--){
			if (isIE)
    	    {
			    if (unescape(current_photo.getAttribute('src')) == server + photos[i]){
					break;
				}
    	    }
    	    else {
				if (unescape(current_photo.getAttribute('src')) == photos[i]){
					break;
				}
			}
		}
		if (i > 0){
			update_arrows(i - 1,photos.length - 1);
			current_photo.setAttribute('src' , photos[i - 1])
		}
	}
}

function display_next_photos (){
	if (document.getElementById && document.getElementsByTagName) {
		var xmlStuff = req.responseXML;
		var apartments = xmlStuff.getElementsByTagName('apartments')[0].getElementsByTagName('apartment');
		
		var photos = apartments[result].getElementsByTagName('photo');
		
		var current_photo = getElementsByClassName(document, "div", "sresult")[result].getElementsByTagName('img')[0];
    
		for (i = 0; i < photos.length; i++){
    	    if (isIE)
    	    {	            
			    if (unescape(current_photo.getAttribute('src')) == server + photos[i].getAttribute('source')){
				    break;
			    }
    	    }
    	    else {
			    if (unescape(current_photo.getAttribute('src')) == photos[i].getAttribute('source')){
				    break;
			    }
			}
		}
		if (i < photos.length - 1){
			update_arrows(i + 1,photos.length - 1);
			current_photo.setAttribute('src' , photos[i + 1].getAttribute('source'))
		}
	}
		
}



function display_previous_photos (){
	if (document.getElementById && document.getElementsByTagName) {
		var xmlStuff = req.responseXML;
		var apartments = xmlStuff.getElementsByTagName('apartments')[0].getElementsByTagName('apartment');
		var photos = apartments[result].getElementsByTagName('photo');
		var current_photo = getElementsByClassName(document, "div", "sresult")[result].getElementsByTagName('img')[0];
	
		for (i = photos.length - 1; i >= 0; i--){
			if (isIE)
    	    {
			    if (unescape(current_photo.getAttribute('src')) == server + photos[i].getAttribute('source')){
					break;
				}
    	    }
    	    else {
				if (unescape(current_photo.getAttribute('src')) == photos[i].getAttribute('source')){
					break;
				}
			}
		}
		if (i > 0){
			update_arrows(i - 1,photos.length - 1);
			current_photo.setAttribute('src' , photos[i - 1].getAttribute('source'))
		}
	}
}


function update_arrows(upcoming_pic_number,max_number){
	//alert(upcoming_pic_number + " - " + max_number);
	//max_number = max_number - 1;
	if (document.getElementById && document.getElementsByTagName) {
		var arrow_forward = getElementsByClassName(getElementsByClassName(document, "div", "sresult")[result], "div", "inline_divs")[0].getElementsByTagName('div')[1];
		var arrow_backward = getElementsByClassName(getElementsByClassName(document, "div", "sresult")[result], "div", "inline_divs")[0].getElementsByTagName('div')[0];

		if (upcoming_pic_number == 0){
			if (isIE){
				arrow_forward.setAttribute('className','arrow_forward');
				arrow_backward.setAttribute('className','arrow_back_disabled');
			}
			else {
				arrow_forward.setAttribute('class','arrow_forward');
				arrow_backward.setAttribute('class','arrow_back_disabled');
			}
		}
		//else if (upcoming_pic_number < max_number){
		else if ((upcoming_pic_number > 0) && (upcoming_pic_number < max_number)){
			if(isIE){
				arrow_forward.setAttribute('className','arrow_forward');
				arrow_backward.setAttribute('className','arrow_back');
			}
			else {
				arrow_forward.setAttribute('class','arrow_forward');
				arrow_backward.setAttribute('class','arrow_back');
			}
		}
		else if (upcoming_pic_number == max_number){
			if(isIE){
				arrow_forward.setAttribute('className','arrow_forward_disabled');
				arrow_backward.setAttribute('className','arrow_back');
			}
			else {
				arrow_forward.setAttribute('class','arrow_forward_disabled');
				arrow_backward.setAttribute('class','arrow_back');
			}
		}
	}
}

// END OF SEARCH RESULTS PHOTO SLIDES JAVASCRIPT

// SHOW / HIDE INFORMATION

function toggle (switcher) {
	if(! document.getElementById){
		throw complainting("Your browser's JavaScript system is too old.  ","Please use an upgraded version of your browser!");
	}
	for(var i = 1; i < arguments.length; i++) {
    	var element;
		var el = document.getElementById(arguments[i] );
		if(!el) {
			throw complaining("Failed to find element with id='" + arguments[i] + "' in " + document.location );
		}

		var behidden;
		if(el.style.display == 'block') {
			el.style.display =  'none' ; behidden = true ; 
		}
		else {
			el.style.display =  'block'; behidden = false;
		}
	}

	if(switcher) {
		status_switcher_classchange(switcher, behidden);
		if ((switcher.childNodes[0].nodeType == document.TEXT_NODE) || (switcher.childNodes[0].nodeType == 3)){
			switcher.childNodes[0].data = behidden ? "show more" : "show less";
		}
	}
	return false;
}

function status_switcher_classchange (targetnode, behidden) {
	var class_to_add = behidden ? "toggleWillShow" : "toggleWillHide";
	var c = targetnode.className || '';
	var c_new =  c.replace( /\btoggleWill(Show|Hide)\b/, class_to_add );
	if( c_new == c) { 
		c_new = c + " " + class_to_add
	}
	targetnode.className = c_new;
	return;
}

function complaining () {
	var _ = [];
	for(var i = 0; i < arguments.length; i++) {
	 	_.push(arguments[i])
	 }
	  _ = _.join("");
	if(! _.length)
		out = "Unknown error!?!";
	void alert(_);
	return new Error(_,_);
}

// END OF SHOW / HIDE INFORMATION

function showLeftColSelectBoxes(){
	if(navigator.appName == "Microsoft Internet Explorer"){
		selects = document.getElementById("main_tabs").getElementsByTagName("select");
		for (i = 0; i != selects.length; i++) {
			selects[i].style.visibility = "visible";
		}
	}
	return true;
}

// ---------------------------------------------------

function hideLeftColSelectBoxes(){
	if(navigator.appName == "Microsoft Internet Explorer"){
		selects = document.getElementById("main_tabs").document.getElementsByTagName("select");
		for (i = 0; i != selects.length; i++) {
			selects[i].style.visibility = "hidden";
		}
	}
	return true;
}


//-->
