
var AjaxDataPageID;

$(function()
{
  FB.init({
    appId  : 'YOUR APP ID',
    status : true, // check login status
    cookie : true, // enable cookies to allow the server to access the session
    xfbml  : true  // parse XFBML
  });

$("#DealerSearchLocation").focus(
 function()
 {
  if(this.value == this.defaultValue)
  {
   this.select();
  }
 }
)
}
);

function SetAjaxDataPageID(id)
{
	AjaxDataPageID = id;
}

function showCarrousel(name)
{
	var GroupId;
	var Position;
	switch(name)
	{
		case "gas": GroupId = "GROUP1"; Position = "20px"; break;
		case "charbon": GroupId = "GROUP3"; Position = "163px";break;
		case "electric": GroupId = "GROUP4"; Position = "500px";break;
		case "weber": GroupId = "GROUP25"; Position = "423px";break;
		case "accessories": GroupId = "GROUP19"; Position = "260px";break;
	}
	
	LoadCarrousel(GroupId, Position);
}

var timeout;

function LoadCarrousel(GroupId, Position)
{
	$.get("Default.aspx?ID="+AjaxDataPageID+"&GroupId=" + GroupId, 
			function(data){
				var car = data.split("|CUTHERE|");
			  
				document.getElementById("carousel-container").innerHTML = car[1];
				document.getElementById("carousel-container").style.display = "block";
				document.getElementById("carousel-container").style.left = Position;
                if (document.all && !window.opera && !window.XMLHttpRequest)
                {
                    correctPNG();
                }
				activateCarAccueil();		  
			});
}

  function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
   {
//   alert('1');
	for(var i=0; i<document.images.length; i++)
      {
      
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	     {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
	     }
      }
   }
   
  
function hideCarrousel()
{
	document.getElementById("carousel-container").style.display = "none";
}

function TimerStart()
{
	timeout = setTimeout('hideCarrousel()', 3000);
}

function show()
{
	clearTimeout(timeout);
	document.getElementById("carousel-container").style.display = "block";
}
