
function NewWindow(mypage,myname,w,h,scroll){
	var win = null;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
	win = window.open(mypage,myname,settings)
	if(win.window.focus){win.window.focus();}
}

function MM_openBrWindow(theURL,winName,features) { //v1.2
	window.open(theURL,winName,features);
}

function EmiratesProperty_Search_Currency_OnChange(o){
	document.getElementById("scPriceRanges").src = "Js/pricerange.js.asp?currency="+o.value;
}

function Search_Arrays_Contains(sourcearray, val){
	for(var i=0; i < sourcearray.length; i++){
		if ( sourcearray[i].toString() == val.toString() ){
			return true;
		}
	}
	return false;
}
	
function Search_Item_SetValue(name, id, isvalid){
	var value = "";
	// test to see if we have a value set by the client
	if ( RequestQueryString(name).length > 0 ) { value = RequestQueryString(name) }
	// otherwise see if we can load the value from cache
	if ( oFormsManager.Item(id).length > 0 ) { value = oFormsManager.Item(id) } 

	if ( value.length > 0 && isvalid ){
		// if isvalid is passed then we must check that the value loaded is a present value in the select control
		for (var i=0; i < document.getElementById(id).options.length; i ++ ){
			var oitem = document.getElementById(id).options[i];
			if ( oitem.value.toString() == value.toString() ){
				// its valid so return the value
				return value;
			}
		}
		value = "";
	}

	return value;
}

function RequestQueryString(Key){
	//returns the querystring value of the key provided
	var queryString;
	queryString = document.location.href;
	if (queryString.toUpperCase().indexOf(Key.toUpperCase()) >= 0){
		var queryParams = queryString.split("?");
		var queryStringParams = queryParams[1].split("&");
		for (i=0;i<queryStringParams.length;i++){
			var queryParam = queryStringParams[i].split("=");
			if (queryParam[0].toUpperCase() == Key.toUpperCase()){
				return queryParam[1];
			}
		}
	}
	return "";
}
