

function onSearch(_dir){
	var trans;
	var sub_id;
	var loc;
	var min;
	var max;
	var freq = "month";
	var order = "price_h";
	
	
	
	
	
	trans = getValue(document.getElementById("trans_dd"));
	
	
	if(trans == "sale"){
		
		sub_id = getValue(document.getElementById("house_type_dd_sale"));
		
		loc = getName(document.getElementById("location_dd_sale"));
		
		
		if(getValue(document.getElementById("location_dd_sale")) == "uk"){
			
			min = getValue(document.getElementById("min_price_dd_sale"));
			max = getValue(document.getElementById("max_price_dd_sale"));
			
			
		}else{
		
			min = getValue(document.getElementById("min_price_dd_sale_overseas"));
			max = getValue(document.getElementById("max_price_dd_sale_overseas"));
		
		
		}
		
		
		
		window.location.href = _dir + "?" + 
								"trans=" + trans + "&" + 
								"sub_id=" + sub_id + "&" + 
								"loc=" + loc + "&" + 
								"min=" + min + "&" + 
								"max=" + max + "&" + 
								"order=" + order
								
								
								;
		
	}
		
	if(trans == "let"){
		
		sub_id = getValue(document.getElementById("house_type_dd_let"));
		
		loc = getName(document.getElementById("location_dd_let"));
		
		
		
		if(getValue(document.getElementById("location_dd_let")) == "uk"){
			
			min = getValue(document.getElementById("min_price_dd_let"));
			max = getValue(document.getElementById("max_price_dd_let"));
			
			
		}else{
		
			min = getValue(document.getElementById("min_price_dd_let_overseas"));
			max = getValue(document.getElementById("max_price_dd_let_overseas"));
		
		
		}
		
		
		
		
		window.location.href = _dir + "?" + 
								"trans=" + trans + "&" + 
								"sub_id=" + sub_id + "&" + 
								"loc=" + loc + "&" + 
								"min=" + min + "&" + 
								"max=" + max + "&" + 
								"order=" + order + "&" + 
								"freq=" + freq
								
								
								;
		
	}
	
	
	
}

function search_result_orderByPrice(_dir){

    var myindex2  = document.getElementById("price_dd_sub").selectedIndex;
    var SelValue = document.getElementById("price_dd_sub").options[myindex2].value;

    var baseURL  = currentUrl + 'order=' + SelValue;
    top.location.href = baseURL;

    return true;
}

function search_result_change_frequency(_dir){
	
	var myindex2  = document.getElementById("freq_dd_sub").selectedIndex;
    var SelValue = document.getElementById("freq_dd_sub").options[myindex2].value;



	var baseURL  = urlWithoutFrequency + 'freq=' + SelValue;
    top.location.href = baseURL;

    return true;
}

function getValue(_dd){
	
	
	var locIndex = _dd.selectedIndex;
	var locValue = _dd.options[locIndex].value;

	return locValue;
	
}

function getName(_dd){
	
	
	var locIndex = _dd.selectedIndex;
	var locValue = _dd.options[locIndex].text;

	return locValue;
	
}














SwapArea = function(){}

var sa = SwapArea.prototype;

sa.area_content_0 = null;
sa.area_content_1 = null;

sa.key_0 = null;
sa.key_1 = null;

sa.opacityTween = null;
sa.opacityTween1 = null;

sa.onTransChange = function(_dropdown){


	
	var myindex  = _dropdown.selectedIndex;
	var SelValue = _dropdown.options[myindex].value;

	if(SelValue == this.key_0){
		this.fadeOut(0);
	}
	if(SelValue == this.key_1){
		this.fadeOut(1);
	}


			
}

sa.fadeOut = function(_index){
	
	var a = new Object();
	
	if(_index == 0){
		
		this.opacityTween = new OpacityTween(this.area_content_1, Tween.cubicEaseOut, 100, 0, 0.2);
		a.onMotionFinished = Delegate.create(this, this.onFadeIn_0);	
		
	}
	
	if(_index == 1){
		
		this.opacityTween = new OpacityTween(this.area_content_0, Tween.cubicEaseOut, 100, 0, 0.2);
		a.onMotionFinished = Delegate.create(this, this.onFadeIn_1);	
		
	}
	
	this.opacityTween.addListener(a);
	this.opacityTween.start();

}

sa.onFadeIn_0 = function(){
	
	
	this.area_content_1.style.display = "none";
	this.area_content_0.style.display = "block";
//	this.area_content_1.removeClass("visible");
//	this.area_content_1.addClass("invisible");
	
	this.area_content_1.style.visibility = "hidden";
	this.area_content_0.style.visibility = "visible";
	
	this.opacityTween1 = new OpacityTween(this.area_content_0, Tween.cubicEaseOut, 0, 100, 0.2);
	this.opacityTween1.start();
	
	

}

sa.onFadeIn_1 = function(){
	
	
	this.area_content_0.style.visibility = "hidden";
	this.area_content_1.style.visibility = "visible";
	
	
	this.area_content_0.style.display = "none";
	this.area_content_1.style.display = "block";
//	this.area_content_0.removeClass("visible");
//	this.area_content_0.addClass("invisible");
	
	
	
	this.opacityTween1 = new OpacityTween(this.area_content_1, Tween.cubicEaseOut, 0, 100, 0.2);
	this.opacityTween1.start();

}






















function isValidEmail(strEmail){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;

   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) 
   {
      return false;
    } 
    return true; 
}


function enq_delayProcess(){
	setTimeout("enq_processEnd()",500);
}


function enq_processEnd() {
		

	if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
		

		document.getElementById('enq_preloadarea').innerHTML = '';
		
		opacityTween = new OpacityTween(document.getElementById('enq_field'),Tween.cubicEaseOut, 100, 0, 0.2);
		opacityTween.start();
		
		
		
		var a = new Object();
		a.onMotionFinished = enq_onFadeOutEnd;

		opacityTween.addListener(a);
		

	}

	
	
	
	
}


function enq_onFadeOutEnd(){
	document.getElementById('enq_field').style.display = "none"
	
	document.getElementById('enq_thankyou_field').style.display = "block"
	
//	document.getElementById('enq_thankyou_field').innerHTML = '';
	
	finTween = new OpacityTween(document.getElementById('enq_thankyou_field'),Tween.cubicEaseOut, 0, 100, 0.2);
	
	finTween.start();
	
	var fini = new Object();
	
	fini.onMotionFinished = enq_fadeOutFini;
		
	finTween.addListener(fini);


}


function enq_fadeOutFini(){
	
	
	setTimeout("close_accordion()", 3000);
	setTimeout("enq_resetForm()", 3000);
	
}



function enq_resetForm(){
	document.getElementById('enq_field').style.display = "block"
	
//	document.getElementById('enq_thankyou_field').innerHTML = '';
	finTween = new OpacityTween(document.getElementById('enq_field'),Tween.cubicEaseOut, 0, 100, 0.1);
	finTween.start();
	
	
	
	finTween2 = new OpacityTween(document.getElementById('enq_thankyou_field'),Tween.cubicEaseOut, 100, 0, 0.2);
	finTween2.start();
	
	
	
	document.getElementById('enq_name').value = '';
	document.getElementById('enq_address').value  = '';
	document.getElementById('enq_tel').value  = '';
	document.getElementById('enq_email').value  = '';
	document.getElementById('enq_enquiry').value  = '';



	
}

//===============================================================================



function fd_delayProcess(){
	setTimeout("fd_processEnd()",500);
}


function fd_processEnd() {
		

	if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
		

		document.getElementById('fd_preloadarea').innerHTML = '';
		
		opacityTween = new OpacityTween(document.getElementById('fd_field'),Tween.cubicEaseOut, 100, 0, 0.2);
		opacityTween.start();
		
		
		
		var a = new Object();
		a.onMotionFinished = fd_onFadeOutEnd;

		opacityTween.addListener(a);
		

	}

	
	
	
	
}


function fd_onFadeOutEnd(){
	
	document.getElementById('fd_field').style.display = "none";
	document.getElementById('fd_thankyou_field').style.display = "block";
	
//	document.getElementById('enq_thankyou_field').innerHTML = '';
	
	finTween = new OpacityTween(document.getElementById('fd_thankyou_field'),Tween.cubicEaseOut, 0, 100, 0.2);
	
	finTween.start();
	
	var fini = new Object();
	
	fini.onMotionFinished = fd_fadeOutFini;
		
	finTween.addListener(fini);


}


function fd_fadeOutFini(){
	
	
	setTimeout("close_accordion()", 3000);
	setTimeout("fd_resetForm()", 3000);
	
}



function fd_resetForm(){
	document.getElementById('fd_field').style.display = "block";
	
//	document.getElementById('enq_thankyou_field').innerHTML = '';
	finTween = new OpacityTween(document.getElementById('fd_field'),Tween.cubicEaseOut, 0, 100, 0.1);
	finTween.start();
	
	
	
	finTween2 = new OpacityTween(document.getElementById('fd_thankyou_field'),Tween.cubicEaseOut, 100, 0, 0.2);
	finTween2.start();
	
	
	
	document.getElementById('fd_yourname').value = '';
	document.getElementById('fd_friendsemail').value  = '';


	
}


function openPopUp(_link, _width, _height, _title,  _toolbar){

	var page = _link;
	var width = _width;
	var height = _height;
	
	if(_toolbar == true){
		
		var openWin = window.open(page, '', "toolbar=yes, menubar=yes ,location=yes, scrollbars=yes, resizable=yes, width=" + width + ", height=" + height + ", top=" + (screen.height/2 - height/2) + ", left=" + (screen.width/2 - width/2) + "\""); 
		
	}else{
		var openWin = window.open(page, '', "toolbar=no, menubar=no ,location=no, scrollbars=yes, resizable=yes, width=" + width + ", height=" + height + ", top=" + (screen.height/2 - height/2) + ", left=" + (screen.width/2 - width/2) + "\""); 
		
	}

//	alert(artistname + " " + itemname);

}


//=============================================================================== 

