﻿
function Path() {

    var path = window.location.pathname;

    var Splitedpath = path.split('/');

    //alert(path  + Splitedpath.length);
    var result = "";
    for (i = 2; i <= Splitedpath.length; i++) {
        result += "../";
    }

    return result;
}



var menuHack;
$(document).ready(function() {
    menuHack = 1;
    initMainMenu();
    iniBizform();


    if ($('.ClassTestimonials').length != 0) {
        if ($('.GeneralTestimonials').length != 0) {
            if ($.random(10) >= 6)
                $('.GeneralTestimonials').hide();
            else
                $('.ClassTestimonials').hide();

        } else
            $('.GeneralTestimonials').hide();
    }


    $("IMG").each(function() {
        //$(this).attr('title', 'Width=' + $(this).width() + '  Height=' + $(this).height());
        $(this).attr('title', '');
    });

    $("[background^=/app]").each(function() {
        //$(this).attr('title', 'Width=' + $(this).width() + '  Height=' + $(this).height());
        $(this).attr('title', '');
    });

    $('.EmailFormPlaceHolder').append($('.FormtoMove'));
    $('.ProfileEmail>div>INPUT').attr('value', $('.ProfileToEmail>a').html());

    $('.RequestSubject').attr('value', $('.TitlePosition>span.titreblanc').text());


    //    $("IMG").mouseover(function(e) {



    //        $('.showSize').html('Width=' + $(this).width() + '  Height=' + $(this).height());

    //        //show the popup message and hide with fading effect
    //        $('.showSize').fadeIn(200);


    //    }).mouseout(function() {
    //        $('.showSize').fadeOut(1000);
    //    });


    swapValues = [];
    $(".swap_value").each(function(i) {
        swapValues[i] = $(this).val();

        $(this).keypress(function(e) {

            if (e.which == 10 || e.which == 13) {
                $(this).next('img').trigger('click');
            }
        });



        $(this).focus(function() {
            if ($(this).val() == swapValues[i]) {
                $(this).val("")
            }
        }).blur(function() {
            if ($.trim($(this).val()) == "") {
                $(this).val(swapValues[i])
            }
        })
    })


    $('#TabControlItemLeft_0,#TabControlItemLeft_1,#TabControlItemLeft_2,#TabControlItemLeft_3,#TabControlItemLeft_4,#TabControlItemLeft_5,#TabControlItemLeft_6,#TabControlItemLeft_7,#TabControlItemLeft_8,#TabControlItemLeft_9,#TabControlItemLeft_10,#TabControlItemLeft_11,#TabControlItemLeft_12')
    .remove();

    if ($.browser.msie && $.browser.version == "7.0")
        $('.MenuDroite>table>tbody>tr>td').css('height', '31px');
    if ($.browser.msie && $.browser.version == "7.0")
        $('.MenuGauche>table>tbody>tr>td').css('height', '31px');

    var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
    var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
    if ($.browser.msie && (ie55 || ie6)) {
        //$('.TeaserImageToChangeToGif').each(function() { $(this).attr('src', $(this).attr('src').replace('png', 'gif')); });

        $('.topcenteruni>DIV:first').css('background-image', 'url(/app_themes/ppgmvp/images/fonds/menu.gif)');
        $('.topcenterbleu>DIV:first').css('background-image', 'url(/app_themes/ppgmvp/images/fonds/menu.gif)');
        $('.topcentergris>DIV:first').css('background-image', 'url(/app_themes/ppgmvp/images/fonds/menu.gif)');
        $(document).pngFix();
    }
    $(".loginHead>a").addClass("liensearch");
});


function OpenSearch(valeur) {
    window.open("/pages/search.aspx?searchtext=" + valeur + "&searchmode=AnyWord", "_self");
}

function iniBizform() {


    $('.Send>input').css('background','url(/app_themes/ppgmvp/images/all/send.jpg) no-repeat')
    .css('cursor','pointer').css('width','70px').css('height','26px').css('border','none').attr('value','');
}

function initMainMenu() {

    $('.Level1CMSListMenuLI, .Level1CMSListMenuHighlightedLI').each(function() {

        var pad = 10;
        var hack = 122;
        switch (menuHack) {
            case 1:
                hack = 84;
                pad = 22;
                break;
            case 2:
                hack = 119;
                pad = 20;
                break;
            case 3:
                hack = 118;
                pad = 30;
                break;
            case 4:
                hack = 119;
                pad = 22;
                break;
            case 5:
                hack = 119;
                pad = 28;
                break;
            case 6:
                hack = 97;
                pad = 22;
                break;
            case 7:
                hack = 97;
                pad = 12;
                break;
            case 8:
                hack = 97;
                pad = 25;
                break;
            case 9:
                hack = 93;
                pad = 20;
                break;

        }

        //$(this).css('margin-left', menuHack + 'px');
        //$(this).html("<table width='100%' cellpadding='0' cellspacing='0'><tr><td width='" + hack + "px'>&nbsp;</td><td class='MenuCenter'>" + $(this).html() + "</td></tr></table>");
        $(this).html("<table width='" + hack + "px' cellpadding='0' border='0' cellspacing='0'><tr><td style='text-align:left;width:" + hack + "px;padding-left:" + pad + "px' class='MenuCenter'>" + $(this).html() + "</td></tr></table>");
        menuHack++;
    });
    //build menu with ID="myjquerymenu" on page:
}






/*********************
//* jQuery Multi Level CSS Menu (horizontal)- By Dynamic Drive DHTML code library: http://www.dynamicdrive.com
//* Menu instructions page: http://www.dynamicdrive.com/dynamicindex1/ddlevelsmenu/
//* Last modified: Sept 6th, 08'. Usage Terms: http://www.dynamicdrive.com/style/csslibrary/tos/
*********************/

//Specify full URL to down and right arrow images (25 is padding-right to add to top level LIs with drop downs):
var arrowimages = { down: ['../downarrowclass', '../arrow-down.gif', 25], right: ['../rightarrowclass', '../arrow-right.gif'] };

var jquerycssmenu = {

    fadesettings: { overduration: 100, outduration: 100 }, //duration of fade in/ out animation, in milliseconds

    buildmenu: function(menuid, arrowsvar) {
        jQuery(document).ready(function($) {
        var $mainmenu = $(".Level1CMSListMenuUL")



        var $headers = $mainmenu.find("ul").parent()
            $headers.each(function(i) {
                var $curobj = $(this)
                var $subul = $(this).find('.Level2CMSListMenuUL');
                this._dimensions = { w: this.offsetWidth, h: this.offsetHeight, subulw: $subul.outerWidth(), subulh: $subul.outerHeight() };
                this.istopheader = $curobj.parents("ul").length == 1 ? true : false;
                $subul.css({ top: this.istopheader ? this._dimensions.h + "px" : 0 });
                /*$curobj.children("a:eq(0)").css(this.istopheader ? { paddingRight: arrowsvar.down[2]} : {});*/
                $curobj.hover(
				function(e) {
                var $targetul = $(this).children(".Level2CMSListMenuUL");
				    this._offsets = { left: $(this).offset().left, top: $(this).offset().top };
				    var menuleft = this.istopheader ? 0 : this._dimensions.w;
				    menuleft = (this._offsets.left + menuleft + this._dimensions.subulw > $(window).width()) ? (this.istopheader ? -this._dimensions.subulw + this._dimensions.w : -this._dimensions.w) : menuleft;
				    $targetul.fadeIn(jquerycssmenu.fadesettings.overduration);
				},
				function(e) {
				$(this).children(".Level2CMSListMenuUL").fadeOut(jquerycssmenu.fadesettings.outduration);
				}
			) //end hover
            }) //end $headers.each()
            $mainmenu.find(".Level2CMSListMenuUL").css({ display: 'none', visibility: 'visible' });
        }) //end document.ready
    }
}

jquerycssmenu.buildmenu("myjquerymenu", arrowimages);


jQuery.extend({
    random: function(X) {
        return Math.floor(X * (Math.random() % 1));
    },
    randomBetween: function(MinV, MaxV) {
        return MinV + jQuery.random(MaxV - MinV + 1);
    }
});