var country;
var personCount;
var startDay;
var endDay;
var freeSearch;

function doNavigate()
{
	if (!country){
		countryElem = document.getElementsByName( "search:Country" )[0];
		personCountElem = document.getElementsByName( "search:PersonCount" )[0];
		country = countryElem.value;
		personCount = personCountElem.value;
	}
	if( country && country != -1 )
	{
		if (!personCount)
		{
			personCount = -1;	
		}	
		curUrl = document.location.href.split("/");	
		document.location = ''+ "//" + curUrl[2] + "/easyhome/result/" + country +  '?PersonCount=' + personCount;
	}
}

function doFreeSearch()
{
        if (!country){
                countryElem = document.getElementsByName( "search:Country" )[0];
                country = countryElem.value;
                if (!country){
                country = -1
                }
        }

        freeSearchElem = document.getElementById("search:freeSearch");
        retValue = freeSearchElem.value;
        if (retValue){
                curUrl = document.location.href.split("/");
                document.location = curUrl[0] + "//" + curUrl[2] + "/Vakantiehuizen/Alle-landen/" + '?FreeSearch=' + retValue;
        }

}

function doRefine()
{
	startDayElem = document.getElementById("results:extra_refine:fromInputDate");
	startDay = startDayElem.value;
	endDayElem = document.getElementById("results:extra_refine:untilInputDate");
	endDay = endDayElem.value;
	freeSearchElem = document.getElementById("results:extra_refine:freeSearch");
	freeSearch = freeSearchElem.value;
	if (!freeSearch)
		freeSearch = -1;
	if (!startDay)
		startDay = -1;
	if (!endDay)
		endDay = -1;
	curUrl = document.location.href.split("/");	
	document.location = curUrl[0] + "//" + curUrl[2] + "/" + curUrl[3] + "/" +curUrl[4] + "/" +curUrl[5] +  '?FreeSearch=' + freeSearch;
}