/*********************
//* 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', '', 25], right:['rightarrowclass', '']}

var jquerycssmenu={

fadesettings: {overduration: 400, outduration: 200}, //duration of fade in/ out animation, in milliseconds

buildmenu:function(menuid, arrowsvar){
	jQuery(document).ready(function($){
		var $mainmenu=$("#"+menuid+">ul")
		
		var $headers=$mainmenu.find("ul").parent();
		$('div.sliderGallery').css('z-index','2'); // IE FIX FOR Z-INDEX -- elespacio
		$headers.css('z-index','99');
		$headers.each(function(i){
			var $curobj=$(this)
			var $subul=$(this).find('ul:eq(0)')
			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.hover(
				function(e){
					$('select').css({ 'visibility' : 'hidden' });
					var $targetul=$(this).children("ul:eq(0)")
					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
					// CHEQUEAR
					if(($.os.name == 'mac') && ($.browser.name == 'firefox')){
						$targetul.css({left:menuleft-1+"px"}).show();
					 } else {
						$targetul.css({left:menuleft-1+"px"}).fadeIn(jquerycssmenu.fadesettings.overduration);
					 }
					$curobj.css({backgroundColor:"#999999"})
					$curobj.find("a:eq(0)").css({color:"#FFFFFF"})
				},
				function(e){
					$('select').css({ 'visibility' : 'visible' });
					if(($.os.name == 'mac') && ($.browser.name == 'firefox')){
						$(this).children("ul:eq(0)").hide();
					 } else {
						$(this).children("ul:eq(0)").fadeOut(jquerycssmenu.fadesettings.outduration)
					 }
					$curobj.css({backgroundColor:""})
					$curobj.find("a:eq(0)").css({color:""})
				}
			) //end hover
		}) //end $headers.each()
		$mainmenu.find("ul").css({display:'none', visibility:'visible'})
	}) //end document.ready
}
}

//build menu with ID="myjquerymenu" on page:
jquerycssmenu.buildmenu("mainNav", arrowimages);
//------------------------------------------------------------------------------------------------------------------------------------------------------
//* INICIO MENU BOTON
//------------------------------------------------------------------------------------------------------------------------------------------------------
function InicioMenuBoton(){
	$("#mainNav>a>div.inici").hover(
      function () {
       // alert('in');
		$(this).addClass('inici_roll');
      }, 
      function () {
       //alert('out');
	   $(this).removeClass('inici_roll');
      }
    );
}
//------------------------------------------------------------------------------------------------------------------------------------------------------
//* TOP MENUS SCRIPT
//------------------------------------------------------------------------------------------------------------------------------------------------------
function TopMenuDisplay(){
	 /*
	 $("#Header>#TopMenu>#clientes .cistella").mouseover(function(){
		 if(($.os.name == 'win') && ($.browser.name == 'firefox')){
			$("#Header>#cistellaTop").css({right:242});
			$("#Header>#cistellaTop>div.title").css({width:101});
		 }
		 if(($.os.name == 'mac') && ($.browser.name == 'firefox')){
		  	$("#Header>#cistellaTop").show();
		 } else {
	 	 	$("#Header>#cistellaTop").fadeIn(500);
		 }
		  
	 });
	 $("#Header>#cistellaTop").mouseout(function(){
	 	if(($.os.name == 'mac') && ($.browser.name == 'firefox')){
		 	$("#Header>#cistellaTop").hide();
		} else {
	 	  	$("#Header>#cistellaTop").fadeOut(300);
		}
	 });
	*/	 //--- quan es faixi un click
     $('#PageContainer table #Header #TopMenu #clientes .tmbg .named').text(global_sUsuario);
     $('#PageContainer table #Header #TopMenu #clientes .tmbg .first').click(function(){
        //--llançam el post per eliminar l'usuari
//          var sUrl = document.location;
//          $.ajax({type: "POST",url: "/kernel/target.asp",data: "COMMAND=AUTH_UNLOGIN&GOTOURL=" + sUrl});
//         $.ajax({type: "POST",url: "/kernel/target.asp",data: "COMMAND=AUTH_UNLOGIN&GoToURL=/html/_templates/majoral_theme/inici.asp#?TiempoActual=" + TiempoActual});
        if (global_sUsuario != 0)
        {
         var oForm =document.getElementById('DESLOGUEAR');
         oForm.submit();
        }
     });
     //-- gestió de l'idioma sel.leccionat
     switch (iIdioma)
     {
        case 9 : //-- català
            $('#PageContainer table #Header #TopMenu .idiomas .tmbg ul').find('li:eq(0)').find('a:eq(0)').attr('class','selected');
            break;
        case 2 : //-- anglés
            $('#PageContainer table #Header #TopMenu .idiomas .tmbg ul').find("li:eq(1)").find('a:eq(0)').attr('class','selected');
            break;
        default: //-- castellà
            $('#PageContainer table #Header #TopMenu .idiomas .tmbg ul').find("li:eq(2)").find('a:eq(0)').attr('class','selected');
            break;
     }

	 $("#Header>#TopMenu>#clientes .cistella a").click(function(){
	 /*
	    var dWidth = window.screen.availWidth;
        var dHeight = window.screen.availHeight - 45;
	    window.showModalDialog('carrito.asp',null,'dialogTop:0px;dialogLeft:0px;dialogWidth:' + dWidth + 'px;dialogHeight:' + dHeight + 'px;');
	   */
	   document.location = 'carrito.asp';
	 });

}

