$(function() {
	//if($('#map_canvas').length>0){
		//initialize() /*onunload="GUnload()"*/;
	//}
    $('#topmenu-students').click(function() {
        $(this).addClass('active');
        $.blockUI({ 
            message: $('#submenu-students'), 
            css: {
                top: '24px',
                width: '800px',
                left: ($(window).width() - 800) /2 + 'px',
                border: 'none',
                cursor: 'auto'
            },
            overlayCSS:  {
                opacity: 0.75,
                cursor: 'pointer'
            }
        });
        $('.blockOverlay').attr('title','Fermer').click(function(){
            $('.topmenu .active').removeClass('active');
            $.unblockUI()
        ;
        }
        );
    }); 
    $('#topmenu-managers').click(function() {
        $(this).addClass('active');
        $.blockUI({ 
            message: $('#submenu-managers'), 
            css: {
                top: '24px',
                width: '800px',
                left: ($(window).width() - 800) /2 + 'px',
                border: 'none',
                cursor: 'auto'
            },
            overlayCSS:  {
                opacity: 0.75,
                cursor: 'pointer'
            }
        });
        $('.blockOverlay').attr('title','Fermer').click(function(){
            $('.topmenu .active').removeClass('active');
            $.unblockUI()
        ;
        }
        );
    }); 
    $('#topmenu-businesses').click(function() {
        $(this).addClass('active');
        $.blockUI({ 
            message: $('#submenu-businesses'), 
            css: {
                top: '24px',
                width: '800px',
                left: ($(window).width() - 800) /2 + 'px',
                border: 'none',
                cursor: 'auto'
            },
            overlayCSS:  {
                opacity: 0.75,
                cursor: 'pointer'
            }
        });
        $('.blockOverlay').attr('title','Fermer').click(function(){
            $('.topmenu .active').removeClass('active');
            $.unblockUI()
        ;
        }
        );
    });
    
    /* Accordion */
    $('#right-accordion').accordion({
        autoHeight: false
    });
    $('#inscri-accordion').accordion({
        autoHeight: false
    });
    $('#accordion-prog').accordion({
        autoHeight: false
    });
    $('#accordion-prog-2').accordion({
        autoHeight: false
    });
    $('#datepicker').datepicker();
    /* End Accordion */
    /* Selectmenu */		
    $('#top-selectmenu').selectmenu({
        width: 200
    });
    $('#top-selectmenu').change(function(){
        if( $(this).val() != "#" && $(this).val() != "/" )
            window.location = $(this).val();
    });
    $('.four-selectmenu').selectmenu({
        width: 290
    });
    /* End Selectmenu */
    /* Scrollbar */
    if( $('.scroll-content').length ){
        $('.scroll-content').jScrollPane();
    }
    if( $('.a-venir').length ){
	$('.a-venir').jScrollPane();
    }
    /* End Scrollbar */
    
    /* SubMenu */
    $('.mainmenu ul li').hover(function(){
        $(this).addClass('hover');
        $('ul:first',this).css('display', 'block');
    }, function(){
        $(this).removeClass('hover');
        $('ul:first',this).css('display', 'none');
    });
    /*$(".mainmenu ul li ul li:has(ul)").find("a:first").append("<!--<img src='<?php echo $this->baseUrl(); ?>/styles/img/arrow-sub-menu.png' alt='arrow' />-->");*/
    $(".mainmenu ul li ul li:has(ul)").find("a:first").addClass('arrow');
    /* End SubMenu */
    /* Tabs */
    $("#tabs").tabs();
    /* End Tabs */
    /* prog tabs */
    $('.prog-tab-1').click(function(){
        $('ul li a', $(this).parent().parent().parent()).removeClass('active');
        $(this).addClass('active');
        $('.prog-tabs-content div', $(this).parent().parent().parent().parent()).hide();
        $('.prog-tab-content-1', $(this).parent().parent().parent().parent()).show();
    })
    $('.prog-tab-2').click(function(){
        $('ul li a', $(this).parent().parent().parent()).removeClass('active');
        $(this).addClass('active');
        $('.prog-tabs-content div', $(this).parent().parent().parent().parent()).hide();
        $('.prog-tab-content-2', $(this).parent().parent().parent().parent()).show();
    })
    $('.prog-tab-3').click(function(){
        $('ul li a', $(this).parent().parent().parent()).removeClass('active');
        $(this).addClass('active');
        $('.prog-tabs-content div', $(this).parent().parent().parent().parent()).hide();
        $('.prog-tab-content-3', $(this).parent().parent().parent().parent()).show();
    })
    /* end prog tabs */
    /* Right menu */
    $("#rightmenu").treeview({
        collapsed: false,
        animated: "medium",
        control:"#sidetreecontrol",
        persist: "location"
    });
    /* end Right menu */	
    /* explorermenu */
    $("#explorermenu").treeview({
        collapsed: false,
        animated: "medium",
        control:"#sidetreecontrol",
        persist: "location"
    });
    $("#explorermenu-2").treeview({
        collapsed: false,
        animated: "medium",
        control:"#sidetreecontrol",
        persist: "location"
    });
    $("#explorermenu-3").treeview({
        collapsed: false,
        animated: "medium",
        control:"#sidetreecontrol",
        persist: "location"
    });
    /* end explorermenu */
    /* Gallery */
    $('#ad-gallery').adGallery({
        width: 630,
        height: 306,
        effect: 'fade',
        enable_keyboard_move: true,
        cycle: true
    })
    /* Gallery */
    /* Onglets Préinscription */
    $('.log-tabs a').click(function(){
        $(".log-block > div", $(this).parent().parent()).hide();
        $('.content-' + $(this).attr("rel"), $(this).parent().parent()).show();
        $('a', $(this).parent()).removeClass('active');
        $(this).addClass('active');
        if( $(this).attr("href") == "#" ) return false;
    });
    /* Fin Onglets Préinscription */
    /* search-in-esca */
    $('#search-in-esca').focus(function() {
        if( ($(this).val() == 'Rechercher ...') || ($(this).val() == 'Search ...') ){
            $(this).val('');
        }
    });
    $('#search-in-esca').blur(function() {
        if( $(this).val() == '' ){
            var location = window.location;
            if( location.href.indexOf('/en/', 0) != -1 ) $(this).val('Search ...');
            else $(this).val('Rechercher ...');
        }
    });
    $("#searchForm").submit(function(){
        if( $("#search-in-esca").val() ){
            window.location = $(this).attr("action") + "/q/" + $("#search-in-esca").val();
            return false;
        } else {
            return false;
        }
    });
    /* Search */
    $(".search > button").click(function(){
        window.location = $("#search-url").val() + "/q/" + escape($("#search-in-esca").val());
    });
    /* end search-in-esca */
    /* Newsletter */
    $('#email').focus(function() {
        if( $(this).val() == 'Email...' ){
            $(this).val('');
        }
    });
    $('#email').blur(function() {
        if( $(this).val() == '' ){
            $(this).val('Email...');
        }
    });
/* end Newsletter */
/* top menu */
/* end top menu */
});
