function formatAsMoney(montant)
{

    montant -= 0;
    montant = (Math.round(montant*100))/100;
    montant = (montant == Math.floor(montant)) ? montant + '.00'
              : ( (montant*10 == Math.floor(montant*10)) ?
                       montant + '0' : montant);

    return montant;

}
function popup(url, titre, largeur, hauteur, scrol, left, top, toll, loc, status, resize) 
			{
				window.open(url, titre, 'width=' + largeur + ', height=' + hauteur + ', scrollbars=' + scrol + ', left=' + left + ', top=' + top + ', toolbar=' + toll + ', location=' + loc + ', status=' + status +', resizable=' + resize);
			}
function popup_zoomimage(nom_de_la_page)
{
    window.open (nom_de_la_page, 'zoom_image', config='width=300, height=300, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no')
}


function zoom(element, rep, id, id_y, haut){

        req_page_post('pages/zoomImage.php', 'id_pizza='+id+'&rep='+rep); //Demande les infos sur la pizza 'id'
        $('#zoom').show();
        $('#zoom').css('left',(120+(element.offsetLeft/2))+"px");
        $('#zoom').css('top', (200+(id_y*haut)) + "px");
}

function dezoom(){
        $('#zoom').hide();
        $('#zoom').html('');

}

function redrawPNG(){
var arVersion = navigator.appVersion.split("MSIE");
var version = parseFloat(arVersion[1]);

if ((version >= 5.5) && (document.body.filters)) 
{
   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 req_page_post(file,params){
if(window.XMLHttpRequest)
    xhr_object = new XMLHttpRequest();
else if(window.ActiveXObject)
    xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else
    return(false);
    xhr_object.open("POST", file, true);

    //Send the proper header information along with the request
    xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xhr_object.setRequestHeader("Content-length", params.length);
    xhr_object.setRequestHeader("Connection", "close");
    xhr_object.onreadystatechange = function() {//Call a function when the state changes.
        if(xhr_object.readyState == 4 && xhr_object.status == 200) {
            $('#zoom').html(xhr_object.responseText);

            var arVersion = navigator.appVersion.split("MSIE");
            var version = parseFloat(arVersion[1]);
            if ((version >= 5.5) && (document.body.filters)) redrawPNG();
        }
        else{
            $('#zoom').html('<p><img src="../img/communes/loading_pizzas.gif" alt="Chargement" /></p>');
        }
    }
    xhr_object.send(params);

}


function showLayerPate(){
    $("#typePates").show();
    $("#starPizza").css('visibility','hidden');
    var url = window.location.href.split('#')
    window.location.href = url[0]+'#pate'; 
}

function hideLayerPate(){
    $("#typePates").hide();
    $("#starPizza").css('visibility','visible');
}