////////////////////////////////////////////////////// DEALER FLASH MODULE  ////////////////////////////////////////////////////// 

function loadDealerModule(id, countrylist, extra, cnt){
	//create holder
	var object = document.getElementById(id);
	object.innerHTML = '<div id="world"></div>';
	//write module
	var flashvars = {file: "/ajax?m=GETCOUNTRIES", countryList: countrylist, cntry: extra, cnt:cnt};
	var params = {wmode: "transparent", allowScriptAccess: "always"};
	swfobject.embedSWF("/media/swf/world.swf", "world", "100%", "100%", "9.0.0", "/media/swf/expressInstall.swf", flashvars, params);
}
function loadWorld(id){
	var fla = document.getElementById('world');
	fla.loadWorldJS();
	clearCountryList();
}
function loadContinent(id){
	var fla = document.getElementById('world');
	fla.loadContinentJS(id);
	clearCountryList();
}
function loadCountry(id){
	var fla = document.getElementById('world');
	fla.loadCountryJS(id);
}
function setContinentList(id){
	if(id>=0){
		$('#dealernavcontinents li a').css({'color': '#222222'});
		$('#dealernavcontinents li:eq('+id+') a').css({'color': '#ff0000'});
		$('#dealernavworld li a').css({'color': '#222222'});
	}else{
		$('#dealernavcontinents li a').css({'color': '#222222'});
		$('#dealernavworld li a').css({'color': '#ff0000'});
	}
}
function setCountryList(id){
	//alert("ok");
	$('#dealernavcountries ul.minicol li a').css({'color': '#222222'});
	$('#dealernavcountries ul.minicol li:eq('+id+') a').css({'color': '#ff0000'});
}
function loadCountryList(arr){
	var obj = document.getElementById("dealernavcountries");
	var temp = arr.split(",");
	var html = "<ul class='minicol'>";
	for(i=0; i<temp.length; i++){
		if(i != 0 && i/7 == Math.round(i/7)){
			html += "</ul><ul class='minicol'>";
		}
		html += "<li><a href='javascript:loadCountry("+i+");' title='show "+temp[i]+"'>"+temp[i]+"</a></li>";
	}
	html += "</ul>";
	obj.innerHTML = html;
}
function clearCountryList(){
	//clear country list
	var obj = document.getElementById("dealernavcountries");
	obj.innerHTML = "";
}
function setDealers(country,area){
	//alert(html);
	hidePostalCode();
	//var obj = document.getElementById("dealers");
	if(country == 'Belgium'){
		$('#dealers').html('');
		//showPostalCode();
	}else{
		$.ajax({
			type	: 'POST',
			url		: '/ajax.php',
			data	: {
				m		: 'INTERDEALERS',
				country	: country,
				area : area
			},
			success	: function(data){
				$('#dealers').html(data);
				//alert('data')
			}
		})
	}
	/*//build html
	if (window.XMLHttpRequest){
		xhttp=new XMLHttpRequest();
	}else{ // Internet Explorer 5/6
		xhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xhttp.open("GET","/media/xml/dealers.xml",false);
	xhttp.send("");
	xmlDoc=xhttp.responseXML; 
	//
	var continentNode = xmlDoc.getElementsByTagName("xml")[0].childNodes[0].nodeValue;
	alert(continentNode);
	var htmlOutput = "<div><h1>Dealers in "+continentNode.childNodes[countryActive].attributes.nme+"</h1></div>";
	var tempNode = continentNode.childNodes[countryActive];
	var tempAddressArr = new Array('','','','<br />tel.: ','fax: ');
	for(var i=0; i<tempNode.childNodes.length; i++){
		//check each dealer
		htmlOutput += "<div class='col'>";
		if(tempNode.childNodes[i].childNodes[0].childNodes[0].nodeValue){
			htmlOutput += "<div><strong>"+tempNode.childNodes[i].childNodes[0].childNodes[0].nodeValue+"</strong></div>";
		}
		for(var j=1; j<5; j++){
			if(tempNode.childNodes[i].childNodes[j].childNodes[0].nodeValue && tempNode.childNodes[i].childNodes[j].childNodes[0].nodeValue != ""){
				htmlOutput += "<div>"+tempAddressArr[j]+tempNode.childNodes[i].childNodes[j].childNodes[0].nodeValue+"</div>";
				if(j==2){
					htmlOutput += "<div>"+continentNode.childNodes[countryActive].attributes.nme+"</div>";
				}
			}
		}
		if(tempNode.childNodes[i].childNodes[5].childNodes[0].nodeValue && tempNode.childNodes[i].childNodes[5].childNodes[0].nodeValue != " "){
			htmlOutput += "<div><a href='mailto:"+tempNode.childNodes[i].childNodes[5].childNodes[0].nodeValue+"'>"+tempNode.childNodes[i].childNodes[5].childNodes[0].nodeValue+"</a></div>";
		}
		htmlOutput += "</div>";
	}
	//set html*/
	//obj.innerHTML = html;
	
}
function loadPostalCode(){
	var obj = document.getElementById("dealerpostal");
	obj.style.display = "block";
}
function hidePostalCode(){
	var obj = document.getElementById("dealerpostal");
	obj.style.display = "none";
}
