var xhr;
function createRequestObject()
{
    var http;
    if (window.XMLHttpRequest)
    { // Mozilla, Safari, IE7 ...
        http = new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    { // Internet Explorer 6
        http = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return http;
}
//-------------------- map ---

function viewmap(){
	document.getElementById('listdiv').style.display = 'none'
	document.getElementById('mapdiv').style.display = 'block'
	//document.getElementById('cartelink').style.backgroundImage='url(/images/bg-carteH.png)' 
	//document.getElementById('cartelink').style.color='#fff'
	//document.getElementById('inflink').style.backgroundImage='url(/images/bg-inf.png)' 
	//document.getElementById('inflink').style.color='#787882' 
		
}
function viewmaplink(){
	document.getElementById('cartelink').style.backgroundImage='url(/images/bg-carteH.png)' 
	document.getElementById('cartelink').style.color='#fff'
	document.getElementById('inflink').style.backgroundImage='url(/images/bg-inf.png)' 
	document.getElementById('inflink').style.color='#787882' 
}
function viewlist(){
	document.getElementById('listdiv').style.display = 'block'
	document.getElementById('mapdiv').style.display = 'none'
	
}
function viewlistlink(){
	document.getElementById('inflink').style.backgroundImage='url(/images/bg-infH.png)' 
	document.getElementById('inflink').style.color='#fff' 
	document.getElementById('cartelink').style.backgroundImage='url(/images/bg-carte.png)' 
	document.getElementById('cartelink').style.color='#787882'
}
function createMarker(row) {
  	var latlng = new google.maps.LatLng(parseFloat(row.getAttribute("lat")),
          parseFloat(row.getAttribute("lng")));
	var html = row.childNodes[0].childNodes[0].data;
	var ref = row.getAttribute("ref")
	var name = row.getAttribute("name")
  	var image = '/images/gmap/'+row.getAttribute("type")+'.png';
  	if(image == null) var image = '/images/gmap/gmap_blue_icon.png';
    var marker = new google.maps.Marker({position: latlng, map: map,icon: image});
    google.maps.event.addListener(marker, "click", function() {
      if (infowindow) infowindow.close();
      infocontent = '<a class="maplink" href="/product/view/ref/'+ref+'" >'+name +'</a><br>'+html;
      infowindow = new google.maps.InfoWindow({content: infocontent});
      infowindow.open(map, marker);
    });
    return marker;
}
function timeMsg()
{
var t=setTimeout("viewlist()",500);
}
//--- code popup ---
function openPopup() {
    $(this).clone(false).appendTo($("#_code"));
    $("#_code").show();
}

function closePopup() {
    $("#_code").html("");
    $("#_code").hide();
}

function initCode() {
    $(".code").click(openPopup);
    $(".code").css({cursor: "pointer"});
    $('body').append('<div id="_code"></div>');
    $('#_code').css( { 'text-align': "justify", position: "fixed", 
                        left:0, top:0, width: "100%", height: "100%", 
                        "background-color": "rgba(0, 0, 0, 0.8)", 'z-index':2000, 'padding':'3px'} );
    $('#_code').hide();
    $('#_code').click(closePopup);
}
