// Functie om de correcte naam/id van de flashmovie te verkrijgen

gBaseURL = "zoeken"; //default
gRegio = "";
gResultsPerPage = 5;

// Strip de regio uit de URL:
tmpDashIndex = document.location.href.indexOf("#",0);
tmpLastSlashIndex = document.location.href.lastIndexOf("/");
//alert(document.location.href.substr(tmpLastSlashIndex+1,6));
if (document.location.href.substr(tmpLastSlashIndex+1,6)=="zoeken") {
	// geen regio 
	//alert("Geen regio");
} else {
	if (tmpDashIndex>0) {
			gRegio = document.location.href.substr(tmpLastSlashIndex+1,tmpDashIndex-1-tmpLastSlashIndex);
	} else {
			gRegio = document.location.href.substr(tmpLastSlashIndex+1);
	}
	gBaseURL += "/"+gRegio; // bouw de BaseURL op volgens htaccess-rewrite
	
} 


 
function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
	     return window[movieName];
	} else {
	     return document[movieName];
	}
}

// Deze functie wordt vanuit de flash-gMap-app aangeroepen om zoekresultaten in HTML te tonen...
function mFlashAppCall(parametersIn) {
	ajaxGetZoekresultaten(parametersIn);
}
function mChangeHashId(parametersIn) {
	var tmpQuery = mBuildQueryString(parametersIn); 
	tmpQuery += "&hashid="+parametersIn.hashid;
	document.location.href =  gBaseURL+"#&"+tmpQuery;		
}
function ajaxGetZoekresultaten(parametersIn) {
	var tmpQuery = mBuildQueryString(parametersIn);
	$("#wrapper").load("ajax/zoeken.php?"+tmpQuery);
	document.location.href =  gBaseURL+"#&"+tmpQuery;
}
function mBuildQueryString(parametersIn) {
	var tmpQuery = "term="+parametersIn.zoekterm;
	tmpQuery +="&locatie_type_ids="+parametersIn.locatie_type_ids;
	tmpQuery +="&start="+parametersIn.start;
	tmpQuery +="&results_per_page="+gResultsPerPage;
	tmpQuery +="&capaciteit="+parametersIn.capaciteit;
	return tmpQuery;
}
// Deze functie wordt vanuit javascript aangeroepen om de flash-gMap-app te vertellen op welke resultatenpagina we ons bevinden... 
function mGo(paramIn) {
	thisMovie("flex_g_map").swfSetStartPage(paramIn);
}
function mTellFlexWhatTheCurrentURLIs() {
	thisMovie("flex_g_map").swfTellCurrentURL(document.location.href); 
}
