var randomnumber=Math.floor(Math.random()*11111);
function gotoCR()
{
var string = 'http://www.holidaycars.com/select_car.aspx?locationid=';
string += document.getElementById("locationId").value +'&currency=EUR&language=';
if (document.getElementById("languagecode"))  string += document.getElementById("languagecode").value + '&module=1716&pickupdate=';
else   string += 'nl'+ '&module=1716&pickupdate=';

var pickupdate = document.getElementById("pickupdate_DT").value;
var spickupdate = pickupdate.substring(0,4) + '/';
spickupdate += pickupdate.substring(5,7) + '/';
spickupdate += pickupdate.substring(8,10);
string += spickupdate  + '&pickuptime=';
string += document.getElementById("pickuptime").value + '&returndate=';
var dropoffdate = document.getElementById("dropoffdate_DT").value;
var sdropoffdate = dropoffdate.substring(0,4) + '/';
sdropoffdate += dropoffdate.substring(5,7) + '/';
sdropoffdate += dropoffdate.substring(8,10);
string += sdropoffdate+'&dropofftime=';
string +=  document.getElementById("dropofftime").value

window.open (string,'_self');

}


function Test() 
{
    if (GBrowserIsCompatible()) 
    {
        var map = new GMap2(document.getElementById("map"));
	    map.setCenter(new GLatLng(52.1, 5.0), 8);
	    map.addControl(new GSmallMapControl());
	     
	    
	    var request = GXmlHttp.create();
	    url = "data.xml?random="+randomnumber;
	    request.open("GET", url, true);
	    request.onreadystatechange = function() 
	    {  
	        if (request.readyState == 4) 
	        {    
	            var bounds = new GLatLngBounds();
	            var markers = request.responseXML.getElementsByTagName("marker");
	            var link = ""; 
	            var id;
	            var parentid;
	            var htmltext;
                var gmarkers = [];

	            for (var i = 0; i < markers.length; i++) 
	            {   
	                if (!(markers[i].getAttribute("lattitude")== "" || markers[i].getAttribute("longitude") == ""))
	                { 
	                    var point = new GLatLng(markers[i].getAttribute("lattitude"),markers[i].getAttribute("longitude"));
	                    bounds.extend(point);
	                    id = markers[i].getAttribute("id");
	                    parentid = markers[i].getAttribute("parent");
    	                
	                    if (parentid == "0")
	                    {
	                        link = "/select_car.aspx?module=1&language=nl&locationid=" + id;
	                    }
	                    else
	                    {
	                        link = "/select_car.aspx?module=1&language=nl&officeid=" + id;
	                    }
    	                
	                    verhuurder = markers[i].getAttribute("Supplier")
	                    htmltext = markers[i].getAttribute("html")
	                    
	                    html = "<table>"
	                    html = html + "<tr>"
	                    html = html + "<td rowspan=2><img src='/media/products/75x50/" + verhuurder + ".gif'/></td>"
	                    html = html + "<td><b>" + htmltext + "</b></td>"
	                    html = html + "</tr>"
	                    html = html + "<tr>"
	                    html = html + "<td><a href='" + link + "'>Toon het aanbod voor deze locatie</a></td>"
	                    html = html + "</tr>"
	                    html = html + "</table>"
	                    
	                    
	                    //html = "<div><div><img src='353.gif' width='75' height='27'/></div>"
	                    //html = html + "<div><b>" + htmltext + "</b><br /><br />";
	                    //html = html + "<a href='" + link + "'>Toon het aanbod voor deze locatie</a></div></div>"
                        
                        var test = createMarker(point,html,htmltext);
	                    map.addOverlay(test);
			            gmarkers[i] = test;
	                }
	            }
                map.setZoom(map.getBoundsZoomLevel(bounds));
                map.setCenter(bounds.getCenter());
                if ((markers[0].getAttribute("parent")== "0"))
                {}
                else
                {GEvent.trigger(gmarkers['0'], "click");}
	        }
	     }
	    request.send(null);
    }
}

function createMarker(point , html, htmltext)
{
    var marker = new GMarker(point,{title:htmltext});
    GEvent.clearInstanceListeners(marker)
    GEvent.addListener(marker,"click",function(){marker.openInfoWindowHtml(html);});
    return marker;
}

function getlocationcontent(letter)
{
document.getElementById('ALLlocation').className = 'pointer colortwo';
document.getElementById('Alocation').className = 'pointer colortwo';
document.getElementById('Blocation').className = 'pointer colortwo';
document.getElementById('Clocation').className = 'pointer colortwo';
document.getElementById('Dlocation').className = 'pointer colortwo';
document.getElementById('Elocation').className = 'pointer colortwo';
document.getElementById('Flocation').className = 'pointer colortwo';
document.getElementById('Glocation').className = 'pointer colortwo';
document.getElementById('Hlocation').className = 'pointer colortwo';
document.getElementById('Ilocation').className = 'pointer colortwo';
document.getElementById('Jlocation').className = 'pointer colortwo';
document.getElementById('Klocation').className = 'pointer colortwo';
document.getElementById('Llocation').className = 'pointer colortwo';
document.getElementById('Mlocation').className = 'pointer colortwo';
document.getElementById('Nlocation').className = 'pointer colortwo';
document.getElementById('Olocation').className = 'pointer colortwo';
document.getElementById('Plocation').className = 'pointer colortwo';
document.getElementById('Qlocation').className = 'pointer colortwo';
document.getElementById('Rlocation').className = 'pointer colortwo';
document.getElementById('Slocation').className = 'pointer colortwo';
document.getElementById('Tlocation').className = 'pointer colortwo';
document.getElementById('Ulocation').className = 'pointer colortwo';
document.getElementById('Vlocation').className = 'pointer colortwo';
document.getElementById('Wlocation').className = 'pointer colortwo';
document.getElementById('Xlocation').className = 'pointer colortwo';
document.getElementById('Ylocation').className = 'pointer colortwo';
document.getElementById('Zlocation').className = 'pointer colortwo';
document.getElementById(letter +'location').className = 'pointer colorthree';

	document.getElementById('search').style.display='none';
document.getElementById('searchcontainer').style.display='none';
document.getElementById('locationhead_selectedletter').style.display = 'block';
document.getElementById('locationhead_selectedletter').innerHTML = letter;




	var ns = document.getElementById('locationcont' + letter);
	var column_nr = "";
	var content = "";
	
	// AIRPORTS
	document.getElementById('airport_selectedletter_1').innerHTML = "";
	document.getElementById('airport_selectedletter_2').innerHTML = "";
	document.getElementById('airport_selectedletter_3').innerHTML = "";
	document.getElementById('airport_selectedletter').style.display = "none";
	column_nr = 1;
	
	var nairport = 0;
	var ncity = 0;
	for (i = 0; i < ns.childNodes.length; i++) 
	{
		var n3 = ns.childNodes.item(i); // div
		if (n3.nodeType == 1)
		{
		if (n3.attributes["type"] != null) itemIdName = n3.attributes["type"].value;
		if (itemIdName != "undefined" && itemIdName != "" && itemIdName == 'airport') nairport = nairport + 1;
		if (itemIdName != "undefined" && itemIdName != "" && itemIdName == 'city') ncity = ncity + 1;
		}}
		// alert ('airports' + nairport + '/n city' + ncity);
	
	
	
	for (i = 0; i < ns.childNodes.length; i++) 
	{
		var n2 = ns.childNodes.item(i); // div
		if (n2.nodeType == 1)
		{
			var itemIdName = new String();
			itemIdName = "undefined";
			
			if (n2.attributes["type"] != null) itemIdName = n2.attributes["type"].value;
			if (itemIdName != "undefined" && itemIdName != "" && itemIdName == 'airport')
			{
				document.getElementById('airport_selectedletter').style.display = "block";
				content = document.getElementById('airport_selectedletter_' + column_nr).innerHTML;
				document.getElementById('airport_selectedletter_' + column_nr).innerHTML = content + n2.innerHTML + "<br/>";
				if  (nairport > 5 || (nairport + ncity) > 10) column_nr = column_nr + 1;
				if (column_nr == 4 ) column_nr = 1;
			}
		}
	}
	
	// CITIES
	document.getElementById('city_selectedletter_1').innerHTML = "";
	document.getElementById('city_selectedletter_2').innerHTML = "";
	document.getElementById('city_selectedletter_3').innerHTML = "";
	document.getElementById('city_selectedletter').style.display = "none";
	column_nr = 1;
	
	for (i = 0; i < ns.childNodes.length; i++) 
	{
		var n2 = ns.childNodes.item(i); // div
		if (n2.nodeType == 1)
		{
			var itemIdName = new String();
			itemIdName = "undefined";
			
			if (n2.attributes["type"] != null) itemIdName = n2.attributes["type"].value;
			if (itemIdName != "undefined" && itemIdName != "" && itemIdName == 'city')
			{
				document.getElementById('city_selectedletter').style.display = "block";
				content = document.getElementById('city_selectedletter_' + column_nr).innerHTML;
				document.getElementById('city_selectedletter_' + column_nr).innerHTML = content + n2.innerHTML + "<br/>";
				if  (ncity > 5 || (nairport + ncity) > 10) column_nr = column_nr + 1;
				if (column_nr == 4) column_nr = 1;
			}
		}
	}
	document.getElementById('locations').style.display='none';
	if (letter=='ALL')
	{
	document.getElementById('locations').style.display='block';
	document.getElementById('locationhead_selectedletter').style.display = 'none';
	}
	syncdivs();
}

function showWaitingPage()
{
//fake;
}

function hideletters()
{
if (document.getElementById('locationcontALL')){} else document.getElementById('ALLlocation').style.display = "none";
if (document.getElementById('locationcontA')){} else document.getElementById('Alocation').style.display = "none";
if (document.getElementById('locationcontB')){} else document.getElementById('Blocation').style.display = "none";
if (document.getElementById('locationcontC')){} else document.getElementById('Clocation').style.display = "none";
if (document.getElementById('locationcontD')){} else document.getElementById('Dlocation').style.display = "none";
if (document.getElementById('locationcontE')){} else document.getElementById('Elocation').style.display = "none";
if (document.getElementById('locationcontF')){} else document.getElementById('Flocation').style.display = "none";
if (document.getElementById('locationcontG')){} else document.getElementById('Glocation').style.display = "none";
if (document.getElementById('locationcontH')){} else document.getElementById('Hlocation').style.display = "none";
if (document.getElementById('locationcontI')){} else document.getElementById('Ilocation').style.display = "none";
if (document.getElementById('locationcontJ')){} else document.getElementById('Jlocation').style.display = "none";
if (document.getElementById('locationcontK')){} else document.getElementById('Klocation').style.display = "none";
if (document.getElementById('locationcontL')){} else document.getElementById('Llocation').style.display = "none";
if (document.getElementById('locationcontM')){} else document.getElementById('Mlocation').style.display = "none";
if (document.getElementById('locationcontN')){} else document.getElementById('Nlocation').style.display = "none";
if (document.getElementById('locationcontO')){} else document.getElementById('Olocation').style.display = "none";
if (document.getElementById('locationcontP')){} else document.getElementById('Plocation').style.display = "none";
if (document.getElementById('locationcontQ')){} else document.getElementById('Qlocation').style.display = "none";
if (document.getElementById('locationcontR')){} else document.getElementById('Rlocation').style.display = "none";
if (document.getElementById('locationcontS')){} else document.getElementById('Slocation').style.display = "none";
if (document.getElementById('locationcontT')){} else document.getElementById('Tlocation').style.display = "none";
if (document.getElementById('locationcontU')){} else document.getElementById('Ulocation').style.display = "none";
if (document.getElementById('locationcontV')){} else document.getElementById('Vlocation').style.display = "none";
if (document.getElementById('locationcontW')){} else document.getElementById('Wlocation').style.display = "none";
if (document.getElementById('locationcontX')){} else document.getElementById('Xlocation').style.display = "none";
if (document.getElementById('locationcontY')){} else document.getElementById('Ylocation').style.display = "none";
if (document.getElementById('locationcontZ')){} else document.getElementById('Zlocation').style.display = "none";
syncdivs();
}

function getsearch(location,locationid)
{
document.getElementById('search').style.display='block';
document.getElementById('searchcontainer').style.display='block';
document.getElementById('location_ac').value=location;
document.getElementById('location').value=location;
document.getElementById('locationId').value=locationid;
document.getElementById('locationhead_selectedletter').style.display='none';
document.getElementById('airport_selectedletter').style.display='none';
document.getElementById('city_selectedletter').style.display='none';
document.getElementById('locations').style.display='none';
syncdivs();
}


function syncdivs(){
document.getElementById('rightcontent').style.height = 'auto';
document.getElementById('leftcontent').style.height = 'auto';
var DivHeighta = (document.getElementById('leftcontent').offsetHeight * 1) -20 ;
var DivHeightb = document.getElementById('rightcontent').offsetHeight ; 
if (DivHeighta > DivHeightb) document.getElementById('rightcontent').style.height = DivHeighta + 'px'; 
if (DivHeightb > DivHeighta) document.getElementById('leftcontent').style.height = DivHeightb + 'px'; 
}
