/* for IE5 */ 
  onerror = handleErr;
  var divToCloseArray = new Array();
  function handleErr(msg,url,l) {return false;}
  
  function javascriptErrorMessage(msg) { window.setTimeout('alert("'+msg+'")',400); }
  
  function javascriptConfirmMessage(msg) { window.setTimeout('alert("'+msg+'")',400); }

  function showHideTabs(id,numTab){
		for (i=1; i<= numTab; i++) {
			if (id!=i && (document.getElementById('tabcontent'+i)) && (document.getElementById('tabcontent'+i).style.display!='none')){
				document.getElementById('tabcontent'+i).style.display='none';
			}
			$('#tab'+i).removeClass("focus");
			$('#tab'+i).removeClass("preactive");
		}

		if (document.getElementById('tabcontent'+id).style.display=='none'){
			$('#tabcontent'+id).customFadeIn('slow' , function() {});
		}
		$('#tab'+id).addClass("focus");
		if (id>1) $('#tab'+(id-1)).addClass("preactive");
  }
  
  
  
(function($) {
	$.fn.customFadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeOut = function(speed, callback) {
		$(this).fadeOut(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
})(jQuery);  
  
  
  function openClose(id){
     if (document.getElementById(id).style.display=='none')
	$('#'+id).customFadeIn ('slow' , function() {} );
     else
  	$('#'+id).customFadeOut ('slow');
  }


  function openCloseDocuments(id,toCloseArray){
     
     var prevStatusOpened=document.getElementById(id).style.display=='';
     
     if (toCloseArray!=null) for (i=0; i< toCloseArray.length; i++){
	      $('#'+toCloseArray[i]+'-TITLE').removeClass("documenti-open");
        $('#'+toCloseArray[i]+'-TITLE').addClass("documenti-close");  

	      $('#MAINDIV-'+toCloseArray[i]).removeClass("documenti_opened");
        $('#MAINDIV-'+toCloseArray[i]).addClass("documenti_closed");  
           
        document.getElementById(toCloseArray[i]).style.display='none';
     }	
     
     if (prevStatusOpened==false){
     
		     if (document.getElementById(id).style.display=='none'){
			     $('#'+id).customFadeIn('slow' , function() {});
			     $('#'+id+'-TITLE').removeClass("documenti-close");
		       $('#'+id+'-TITLE').addClass("documenti-open");     
		       
    	     $('#MAINDIV-'+id).removeClass("documenti_closed");
           $('#MAINDIV-'+id).addClass("documenti_opened");  
		       
		       
		     }else{
		  	   $('#'+id).customFadeOut('slow', function() {} );
			     $('#'+id+'-TITLE').removeClass("documenti-open");
		       $('#'+id+'-TITLE').addClass("documenti-close");     
		     }		
	}	     
  }
  
  
 /* dropdown header menus BEGIN */
  $(document).ready(function(){
    $("div.open-box").css("display","none");

 /* top menu */
    $("ul.top-menu a").mouseover(function () {
      var id1 = $(this).attr("id");
      $("ul.top-menu a").removeClass("active");
      $("ul.main-menu a").removeClass("active");
      $(this).addClass("active");
      $("div.open-box").css("display","none");
      if (id1) {
        var id1split = id1.split("-");
        var id1str = id1split[0];
        $("#"+id1str).css("display","block");
      }
    });
    
    
    $("ul.top-menu a").mouseout(function () {
      var id1 = $(this).attr("id");
      if (id1) {
        var id1split = id1.split("-");
        var id1str = id1split[0];
        $("#"+id1str).css("display","block");
      }
    });
 /* main menu */
 

    $("ul.main-menu a").mouseover(function () {
      var id2 = $(this).attr("id");
      $("ul.main-menu a").removeClass("active");
      $("ul.top-menu a").removeClass("active");
      $(this).addClass("active");
      $("div.open-box").css("display","none");
      if (id2) {
        var id2split = id2.split("-");
        var id2str = id2split[0];
        $("#"+id2str).css("display","block");
      }
    });

    
    
 /* menu items */
 
    
    $("div.open-box").mouseover(function () {
      var id3 = $(this).attr("id");
      $(this).css("display","block");
      $("ul.top-menu a[id="+id3+"-href]").addClass("active");
      $("ul.main-menu a[id="+id3+"-href]").addClass("active");
    });
    $("div.open-box").mouseout(function () {
      var id4 = $(this).attr("id");
      $(this).css("display","none");
      $("ul.top-menu a[id="+id4+"-href]").removeClass("active");
      $("ul.main-menu a[id="+id4+"-href]").removeClass("active");
    });
    
    
 /* dropdown header menus END */
  
 /* stretchs the central content box if there is no right buttons box */
/*
    var box1c = $("div#side-right").children();
    var box2c = $("div#images-box").children();
    var box1 = $("div#side-right").text();
    var box2 = $("div#images-box").text();
    
    console.log(box1);
    console.log(box1c);
    console.log(box2);
    console.log(box2c);
    
    
    if (!box1 || (box1c!=null && box1c!="undefined")) {
      if (!box2  || (box2c!=null && box2c!="undefined")) { $("div#central-content").css("width","750px");}
      else { $("div#central-content").css("width","560px");}
    }
    else {
      if (!box2  || (box2c!=null && box2c!="undefined")) { $("div#central-content").css("width","600px");}
    }
*/

	var resolutionType = $('#mainStyleSheet').attr('title');
	if(resolutionType!='1024' && resolutionType!='800') resolutionType='1024';

    var box1c = $("div#side-right").children();
    var box2c = $("div#images-box").children();
    var box1 = $("div#side-right").text();
    var box2 = $("div#images-box").text();
    
    if (!box1 && (box1c==null || box1c=="undefined" ||  box1c.length==0)) {
      if (!box2  && (box2c==null || box2c=="undefined"  ||  box2c.length==0)) {
				if(resolutionType=='800') {
					$("div#central-content").not('.productsDetail').css("width","555px");
					$("#main-content-products div#central-content").not('.productsDetail').css("width","555px");
				}
				else {
					$("div#central-content").not('.productsDetail').css("width","750px");
					$("#main-content-products div#central-content").not('.productsDetail').css("width","740px");
				}
      }
      else {
                if ($("#fullDimension") && ($("#fullDimension").children().length>0)){
                    var v800 =400;
                    var v1024=620;
                } else {
                    var v800 =400;
                    var v1024=560;
                }
				if(resolutionType=='800') {
					$("#main-content div#central-content").css("width",v800+"px");
					$("#main-content-products div#central-content").not('.productsDetail').css("width",v800+"px");
				}
				else {
					$("#main-content div#central-content").css("width",v1024+"px");
					$("#main-content-products div#central-content").not('.productsDetail').css("width",v1024+"px");
				}
      }
    }
    else {
      if (!box2  && (box2c==null || box2c=="undefined"  ||  box2c.length==0)) { $("#main-content div#central-content").css("width","600px");}
    }
    
    
    
  $("a[rel^='prettyPhoto']").prettyPhoto();
  
  $('#privacy').jqm();
  
    
  });