﻿//init
$(document).ready(function () {
    $(".bloc_metier .titre_bloc").css("cursor", "pointer");
    $(".contenu_bloc").css("display", "none");
    $(".bloc_metier .titre_bloc").hover(
        function () {
            $(this).css("text-decoration", "underline");
        },
         function () {
             $(this).css("text-decoration", "none");
         });
    $(".titre_bloc").click(function () {
        $(".contenu_bloc").css("display", "none");
        $(this).nextUntil(".titre_bloc").css("display", "block");
        //$(this).parent().children(".contenu_bloc").css("display","block");

        /*var flashvars = {video:"OLIVIER.flv", img:"flash/img1.jpg"};
        var params = {menu: 'false', allowFullScreen:"true"};
        var attributes = {id: 'module_video'};
        swfobject.embedSWF('flash/PlayerVideo.swf', 'module_video', '251', '142', '9.0.45', './swf/expressinstall.swf', flashvars, params, attributes);*/
    });
    if ($("#carte").length > 0)
        initialize();

    $(".headerflag").hover(
        function () {
            $(this).attr("src_tmp", $(this).attr("src"))
            $(this).attr("src", $(this).attr("rel"))
        },
        function () {
            $(this).attr("src", $(this).attr("src_tmp"))
        });

   // $('#box-light').load('prehome.htm #main-lightbox');
    $('#btn_fermer').click(function () {
        hideprehome();
    });


});

function hideprehome() {
    $('#jquery-overlay').hide();
    $('#box-light').hide();
}
    function showprehome() {
      
        $('#box-light').show();
        var hauteur = "1280px";
    
         $('#jquery-overlay').css('height', hauteur);
        $('#jquery-overlay').show();
        var hauteur = $(window).height();

       
}
function initialize()
{
    var tab = new Array();
    var points_p = new Array();
                
    if (GBrowserIsCompatible()) 
    {
        var map = new GMap2(document.getElementById("carte"));
        var coordX = document.getElementById("carteCoordX").innerHTML;
        var coordY = document.getElementById("carteCoordY").innerHTML;
        var zoom = $.trim(document.getElementById("carteZoom").innerHTML);
        map.setCenter(new GLatLng(coordX, coordY), parseInt(zoom));
        map.setUIToDefault();
                    
        var blueIcon = new GIcon(G_DEFAULT_ICON);
        //blueIcon.image = "img/bg-tt-actu.png";
        blueIcon.image = "http://gmaps-samples.googlecode.com/svn/trunk/markers/blue/blank.png";

        markerOptions = 
        {
            icon: blueIcon
        };
                    
        tab = list_p;
        for (var n = 0; n < ((tab.length)); n++) 
        {
            points_p.push(new GLatLng(tab[n][1], tab[n][2]));
            var marker = new GMarker(points_p[n], blueIcon);
            map.addOverlay(marker);
            createMarker(new GLatLng(tab[n][1], tab[n][2]),tab[n][0]);
        }
    }
                
    function createMarker(point, id, user, distance, titre, icon)
    {
        var id_news = document.getElementById("div_id_news").innerHTML;
        var marker = new GMarker(point, icon);
        map.addOverlay(marker);
        GEvent.addListener(marker, "click", function()
        {
            document.location.href="index.aspx?news="+id_news+"&auto=1&id_ville="+id+"#divResultat";
		});
	}	
}

function getArgs() 
{
    var args = new Object();
    var query = location.search.substring(1);
    var pairs = query.split("&");
    for (var i=0;i<pairs.length;i++) 
    {
        var pos = pairs[i].indexOf('=');
        if (pos == -1) 
            continue;
        var argname = pairs[i].substring(0,pos);
        var value = pairs[i].substring(pos+1);
        args[argname] = unescape(value);
    }
    return args;
}
