var fadddddd ="";
var theimage;
var url_img = "http://www.terraillon.fr/";
function show_liste_prod(id_ss_cat) {
	if (document.getElementById("span_"+id_ss_cat) && document.getElementById("ul_"+id_ss_cat)){	
	// TEST DES LIENS ACTIFS DU SOUS MENU (souligné) // 
	this.ssmenu = document.getElementById("haut_detail_nav");
	
	i=0;
	this.sp = this.ssmenu.getElementsByTagName("span");
		for (var i = 0; i < this.sp.length; i++){	
			if (this.sp[i].className == "titre_on") {		
			this.sp[i].className = "titre";
			}
		}// FIN BOUCLE  //			
	document.getElementById("span_"+id_ss_cat).className="titre_on";
		
	i=0;
	this.submenus = this.ssmenu.getElementsByTagName("ul");
		for (var i = 0; i < this.submenus.length; i++){	
			if (this.submenus[i].className == "ul_on") {		
			this.submenus[i].className = "ul_off";
			}
		}// FIN BOUCLE  //			
	document.getElementById("ul_"+id_ss_cat).className="ul_on";
	}
}

function show_zoom (id_image) {
	if (document.getElementById("zoom")) {
	document.getElementById("cache_zoom").style.visibility ="visible";	
	document.getElementById("zoom").style.visibility ="visible";
	scrollTo(0,0);
	alertSize("cache_zoom");
	change_zoom (id_image);
	}
}

function show_ow (id_ow) {
	if (document.getElementById("zoom_ow")) {
	document.getElementById("cache_zoom").style.visibility ="visible";	
	document.getElementById("zoom_ow").style.visibility ="visible";
	scrollTo(0,0);
	alertSize("cache_zoom");
	document.getElementById("zoom_ow").innerHTML = '<div><img src="img_com/'+id_ow+'" Onclick="close_zoom (\'zoom_ow\');" style="cursor:pointer;" title="Cliquez pour fermer la photo" alt="Cliquez pour fermer la photo"></div>';
	}
}


function alertSize(lay) {
	myHeight = 0;
	taille_doc = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
	taille_doc = document.body.clientHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
	taille_doc = document.body.clientHeight;
  }
  if (myHeight > taille_doc) {
  document.getElementById(lay).style.height = myHeight+"px";
  }else {
  document.getElementById(lay).style.height = taille_doc+"px";
  }
  
}

function close_zoom (lay) {
document.getElementById("cache_zoom").style.visibility ="hidden";
document.getElementById(lay).style.visibility ="hidden";
clearTimeout(fadddddd);
if (theimage) {
theimage.onload = function () {

}
}
id_image ="";
id_ow ="";

}

function change_zoom (id_image) {
theimage ="";
theimage = new Image;
theimage.src = url_img+"img_dyna/g-photo"+id_image+".jpg";
document.getElementById("zoom_centre").innerHTML='<br><br><br><br><br><br><br><br><br><br><img src="img_com/loading.gif" width="20" height="20" alt=""><br><br><br><br><br><br><br><br><br><br><br>';
	if (theimage.complete){
	initImage(id_image);
	} else {
		theimage.onload = function () {
		initImage(id_image);
		}
	}
}

// FADE HOME ACTU //
function initImage(id_image) {
  imageId = 'zoom_centre';
  image = document.getElementById(imageId);
  setOpacity(image, 0);
  //image.style.visibility = 'visible';
  document.getElementById("zoom_centre").innerHTML = '<div><img src="'+url_img+'img_dyna/g-photo'+id_image+'.jpg" Onclick="close_zoom (\'zoom\');" title="Cliquez pour fermer la photo" alt="Cliquez pour fermer la photo"></div>';

  fadeIn(imageId,0);
}




function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?100:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}


function fadeIn(objId,opacity) {
  if (document.getElementById(objId)) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
     
	 if (document.all) {
	  opacity += 20;
	  fadddddd =  window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 1);
	 }else {
	  opacity += 2;
	   fadddddd =  window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 10);
	 }
    }else {
	clearTimeout(fadddddd);
	}
  }
}

function vide_email() {
	if ( document.getElementById("email_news").value=="votre Email" || document.getElementById("email_news").value=="Your Email"){
	document.getElementById("email_news").value="";
	}
}

tab_ad = new Array;
tab_ad[1] = "<a href='mailto:Serviceconsommateurs@terraillon.fr'>Serviceconsommateurs@terraillon.fr</a>";
tab_ad[2] = "<a href='mailto:Sales@hansonuk.com'>Sales@hansonuk.com</a>";
tab_ad[3] = "<a href='mailto:Info@terraillon.de'>Info@terraillon.de</a>";
tab_ad[4] = "<a href='mailto:customerservice@terraillon-asia.com'>customerservice@terraillon-asia.com</a>";
tab_ad[5] = "<a href='mailto:customerserviceusa@tcorpusa.com'>customerserviceusa@tcorpusa.com</a>";


function menu_langue () {
$("#nav_langue").hover(function(){$(this).find('ul').slideDown("normal");$(this).find('span').addClass('bt_on');},function(){$(this).find('ul').slideUp("normal");$(this).find('span').removeClass('bt_on');})
}

function menu () {
	$("#nav_univers li").mouseover( function () {   
			$(this).addClass('active');        
    }); 
	
	$("#nav_univers li").mouseout( function () {      	        
			$(this).removeClass('active');        
    }); 		
	
	// Scroll horizontal scrollable_horizontal //
	$(function() {$(".scrollable").scrollable();});
	
	$(function() {
	// setup ul.tabs to work as tabs for each div directly under div.panes
	$("ul.tabs").tabs("div.panes > div");
	
	$("ul.tabs").tabs("div.panes > div", {effect: 'fade', fadeOutSpeed: 400});	
	});
	
	
	$("#menu_prod_gauche li.block_ss_cat > span").click( function () { 
		
        // Si le sous-menu était déjà ouvert, on le referme : 
        if ($(this).next("ul.ul_off:visible").length != 0) { 
            $(this).next("ul.ul_off").slideUp("normal"); 
			$(this).removeClass('active');
        } 
        // Si le sous-menu est caché, on ferme les autres et on l'affiche : 
        else { 
            $("ul.ul_off").slideUp("normal");
			$("#menu_prod_gauche li.block_ss_cat > span").removeClass('active');
	        $(this).next("ul.ul_off").slideDown("normal"); 
			$(this).addClass('active');
        } 
        // On empêche le navigateur de suivre le lien : 
        return false; 
    }); 
	
}

function init_scrollable () {

$(".scrollable").scrollable();
$(".items img").css("opacity",0.6);

/* ROLL OVER */
$(".items img").mouseover(function () {
	$(this).addClass("roll_on");
	$(this).css("opacity",1);
});
/* ROLL OUT */
$(".items img").mouseout(function () {
	$(this).removeClass("roll_on");
	if($(this).hasClass("active")==false) {
		$(this).css("opacity",0.6);
	}
});



$("#cadre_scrollable .items img:first").addClass("active");
$("#cadre_scrollable .items img:first").css("opacity",1);

$("#cadre_scrollable .items img").click(function() {
	// see if same thumb is being clicked
	//if ($(this).hasClass("active")) { return; }
	var id_image = $(this).attr("rel");	
	show_zoom(id_image);	
	
	$("#cadre_scrollable_ow").find("img").each(function () {
	$(this).removeClass("active");
	if ($(this).attr("rel")==id_image) {
	$(this).addClass("active");
	$(this).css("opacity",1);
	}
	
	});
});


$("#cadre_scrollable_ow .scrollable").scrollable();
$("#cadre_scrollable_ow  .items img").click(function() {
	// see if same thumb is being clicked
	$("#cadre_scrollable_ow  .items img").removeClass("active");
	$(this).addClass("active");
	var id_image = $(this).attr("rel");	
	change_zoom(id_image);	
});

}

















