QuerystringParms = location.search.replace(/^\?/,"")
QuerystringParms = QuerystringParms.split('&');
Querystring = new Array()
var QuerystringParm = null;
for (var x = 0;x<QuerystringParms.length;x++)
	{QuerystringParm = QuerystringParms[x].split('=')
	if (QuerystringParm.length == 2)
		{Querystring[unescape(QuerystringParm[0]).toLowerCase()] = unescape(QuerystringParm[1])
		}
	}

/*  Christophe's hacked JS 25/04/2007 */
function GotoRegion(strRegion, strURL, region) {
	// hardcoded for Wales for now 
	region = 22;
	//
	var sUrl;
	sUrl = strURL;
	advSearchUrl = 'AdvancedListingSearch.aspx';
	officeSearchUrl = 'OfficeAgentSearch.aspx';
	//
	if (region != 'undefined' && region == 22) 
	{
		if (document.getElementById("SearchType2").checked) 
			{
			sUrl = sUrl + "?SearchType=O"
			//alert('Office Search for region '+region);
			// go to sub map
			location.href=sUrl;
			}
			else
			{			
			//alert('Property Search for region '+region);
			advSearchUrl = advSearchUrl + "?SearchType=P&regionid="+strRegion;
			// go to properties advanced search & pass in the region id
			location.href=advSearchUrl;
			}
	} 
	else 
	{
		if (document.getElementById("SearchType2").checked) 
			{
			sUrl = sUrl + "?SearchType=O"
			//alert('Office Search for region '+region);
			// go to office agent search & pass in the region id
			officeSearchUrl = officeSearchUrl+"?SearchType=O&regionid="+strRegion;
			location.href=officeSearchUrl;
			}
			else
			{			 
			//alert('Property Search for region '+region);
			// go to sub map
			sUrl = sUrl + "?SearchType=P"
			location.href=sUrl;
			}
	}

	//return false;
}



function DrillDown(SearchType, CityID) {
	//SearchType: P for property, O for Office

	//Lang = two character langauage code used throughout
	//OfficeID:  the office ID of the selected office, an ID of 0 (zero) indicates 'Coming Soon'
	//IsMultiOffice:  0 (zero) for no, one office per city; 1 (one) there is more than one office, show list
	//var SearchType;
	//SearchType = GetSearchType();
	var page;
	//don't use the City ID to find Offices in the same city
	switch (CityID) {
	    case 0:
	        page = "/ComingSoon.aspx?SearchType=" + SearchType;
	        break;
	    case 6533115:
	        page = "/maps/bratislava.aspx?PathVar=2&province=6533115&searchType=" + SearchType;
	        break;
	    case 'opensearch':
	        switch (SearchType) {
	            case "P":
	                page = "/AdvancedListingSearch.aspx";
	                break
	            default:
	                page = "/OfficeAgentSearch.aspx";
	                break;
	        }
	        break;
	    default:
	        switch (SearchType) {
	            case "P":
	                page = "/AdvancedListingSearch.aspx?CityID=" + CityID + "&SearchType=" + SearchType;
	                break
	            case "RP":
	                page = "/PublicListingList.aspx?CityID=" + CityID + "&SearchType=" + SearchType + "&TransactionType=For Rent/Lease";		
	                break
	            case "PL":
	                page = "/PublicListingList.aspx?CityID=" + CityID + "&SearchType=" + SearchType;		
	                break;
	            default:
	                page = "/OfficeList.aspx?CityID=" + CityID 
	                break;
	        }
	        break;
	}
	
	location.href=page;
}
		
function GetSearchType()
{
	
	//determines which radio button is selected and returns P or O (property or office)
	//to the DrillDown function

	var searchType = typeof(Querystring["searchtype"]) != 'undefined'?Querystring["searchtype"]:"";

	if (/pl/i.test(searchType))
	{
		return 'PL';
	} 
	else if (/p/i.test(searchType))
	{
		return 'P' 
	}
	else if(/o/i.test(searchType))
	{    
	return 'O';
	}
	else if (document.getElementById("SearchType1") != null)
	{
		if(document.getElementById("SearchType1").checked) 
		{
			return 'P' 
		}
	}
	else if(document.getElementById("SearchType2") != null)
	{ 
		if(document.getElementById("SearchType2").checked)
		{
			return 'O';
		}
	}
	else {
		return 'P';	
	}
}

function LocalZoneDrillDown(SearchType, LocalZoneID)
{
	//SearchType: P for property, O for Office
	var page;	
	
	//don't use the City ID to find Offices in the same city
	if (SearchType == "P") 
	{
		page = "/AdvancedListingSearch.aspx?SearchType=" + SearchType + "&LocalZoneID=" + LocalZoneID;
	} 
	else 
	{
		page = "/OfficeList.aspx?SearchType=" + SearchType + "&LocalZoneID=" + LocalZoneID;
	}
	location.href = page;
}

function GotoMapPage(strURL)
			{
	var sUrl
	sUrl = strURL;
	if (document.getElementById("SearchType2").checked) 
		sUrl = sUrl + "?SearchType=O"
	/*else if ((document.forms["frmSearchType"].SearchType3 != null) && (document.forms["frmSearchType"].SearchType3.checked)) // CR#13781 Currently used for Ireland Only
	{ 
		if (document.forms["frmSearchType"].SearchType3.checked)
			sUrl = sUrl + "&SearchType=RP&TransactionType=For Rent/Lease"
	}*/
	else
		sUrl = sUrl + "?SearchType=P"
	
	location.href=sUrl;
}

function GotoMapPageBelgium(strURL)
{
	var sUrl
	sUrl = strURL;

	searchTypeVal = GetSearchType();

	if (searchTypeVal == 'O') 
		sUrl = sUrl + "?SearchType=O"
	/*else if ((document.forms["frmSearchType"].SearchType3 != null) && (document.forms["frmSearchType"].SearchType3.checked)) // CR#13781 Currently used for Ireland Only
	{ 
		if (document.forms["frmSearchType"].SearchType3.checked)
			sUrl = sUrl + "&SearchType=RP&TransactionType=For Rent/Lease"
	}*/
	else
		sUrl = sUrl + "?SearchType=P"
	
	location.href=sUrl;
}


function GotoProvince(strProvince)
{				
	var bOffice = false;
	if (document.getElementById("SearchType2").checked) {
		
		bOffice = true;
		document.forms[0].action = '/officeagentsearch.aspx?ProvinceID='+strProvince;
	}
	else {
		
		document.forms[0].action = '/advancedlistingsearch.aspx?ProvinceID='+strProvince;
	}


	document.forms[0].submit();


}


function GotoSwedenProvince(strProvince, strRegion)
{
	var mapPage = "";
	var SearchTypeVal = "SearchType=" + (document.getElementById("SearchType2").checked?"O":"P")
	if (document.getElementById("SearchType2").checked) {
		//alert(strProvince);
		switch(strProvince)
		{
			/*case "3094":
				mapPage = "/maps/blekinge.aspx?" + SearchTypeVal
				break;*/
			case "3095":
				mapPage = "/maps/dalarna.aspx?" + SearchTypeVal
				break;
			case "3096":
				mapPage = "/maps/gavleborg.aspx?" + SearchTypeVal
				break;
		/*	case "3097":
				mapPage = "/maps/gotland.aspx?" + SearchTypeVal
				break;*/
			/*case "3098":
				mapPage = "/maps/halland.aspx?" + SearchTypeVal
				break;*/
			case "3099":
				mapPage = "/maps/jamtland.aspx?" + SearchTypeVal
				break;
			/*case "3100":
				mapPage = "/maps/konkoping.aspx?" + SearchTypeVal
				break;*/
		/*	case "3101":
				mapPage = "/maps/kalmar.aspx?" + SearchTypeVal
				break;*/
		/*	case "3102":
				mapPage = "/maps/kronoberg.aspx?" + SearchTypeVal
				break;*/
	/*		case "3103":
				mapPage = "/maps/norrbotten.aspx?" + SearchTypeVal
				break;*/
			case "3104":
				mapPage = "/maps/orebro.aspx?" + SearchTypeVal
				break;
			case "3105":
				mapPage = "/maps/ostergotland.aspx?" + SearchTypeVal
				break;
			case "3106":
				mapPage = "/maps/skane.aspx?" + SearchTypeVal
				break;
		/*	case "3107":
				mapPage = "/maps/sodermanland.aspx?" + SearchTypeVal
				break;*/
			case "3108":
				mapPage = "/maps/stockolm.aspx?" + SearchTypeVal
				break;
			case "3109":
				mapPage = "/maps/uppsala.aspx?" + SearchTypeVal
				break;
		/*	case "3110":
				mapPage = "/maps/varmland.aspx?" + SearchTypeVal
				break;*/
		/*	case "3111":
				mapPage = "/maps/vasterbotten.aspx?" + SearchTypeVal
				break;*/
			case "3112":
				mapPage = "/maps/vasternorrland.aspx?" + SearchTypeVal
				break;
			case "3113":
				mapPage = "/maps/vastmanland.aspx?" + SearchTypeVal;
				break;
		/*	case "3114":
				mapPage = "/maps/vastragotaland.aspx?" + SearchTypeVal
				break;*/
			default:
				mapPage = 'ComingSoon.aspx?SearchType=O';
				break;
		}
		location.href = mapPage;
	}
	else
	{
		location.href = 'AdvancedListingSearch.aspx?ProvinceID='+strProvince;
	}
}

function ProvinceDrillDown(SearchType, ProvinceID)
{
	//SearchType: P for property, O for Office
	var page;	
	
	//don't use the City ID to find Offices in the same city
	if (SearchType == "P") 
	{
		page = "/advancedlistingsearch.aspx?ProvinceID=" + ProvinceID + "&SearchType=" + SearchType;
	} 
	else 
	{
		page = "/OfficeList.aspx?ProvinceID=" + ProvinceID + "&SearchType=" + SearchType;
	}
	location.href = page;
}


