/*
* this file holds the scripts for series and families pages
*/

// blank image path for the pngfix
var blankImg = "/Contents/Toshiba_de/DE/Others/portal_families/common/images/blank.gif";

// detect the browser type
var browser = "";
if ($.browser.msie && $.browser.version.substr(0,1)<7) { browser = "ie6"; }
else if ($.browser.msie && $.browser.version.substr(0,1)<8) { browser = "ie7"; }

// set the extension type
var ext = "";
if (browser == "ie6") { ext = "gif"; }
else{ ext = "png"; }

// CUFON. font replacement
Cufon.replace('h1', { fontFamily: 'eurostile' });
Cufon.replace('h2', { fontFamily: 'eurostile' });
Cufon.replace('h3', { fontFamily: 'eurostile' });
Cufon.replace('.subline', { fontFamily: 'eurostile' });
Cufon.replace('.button a', { fontFamily: 'eurostile', fontWeight: 'bold' });
/*Cufon.replace('#breadcrumb a', { fontFamily: 'helvetica' });	
Cufon.replace('#breadcrumb li', { fontFamily: 'helvetica' });	


Cufon.replace('#menu_series a', { fontFamily: 'eurostile' });*/
Cufon.replace('#menu_main a', { fontFamily: 'eurostile',hover:true,hoverables:{a:true} });
Cufon.replace('#breadcrumb a', { fontFamily: 'helvetica',hover:true,hoverables:{a:true} });	
Cufon.replace('#breadcrumb li', { fontFamily: 'helvetica',hover:true,hoverables:{a:true} });	
Cufon.replace('#menu_series a', { fontFamily: 'eurostile',hover:true,hoverables:{a:true} });

// stores the amount of links using cufon
var linksAmount = 0;
var cufon_status;
// Jquery document ready
$(document).ready(function() {
	
	// binds the hover events on the button class
	$(".button a").hover(
		function () {
			Cufon.replace(this, {color:"#ffffff", fontFamily: 'eurostile', fontWeight: 'bold'});
			$(this).css("background-image","url(/Contents/Toshiba_de/DE/Others/portal_families/common/images/bg_a_leftpart_over."+ext+")");
			$(this).parent().css("background-image","url(/Contents/Toshiba_de/DE/Others/portal_families/common/images/bg_a_rightpart_over."+ext+")");
		},
		function () {
			Cufon.replace(this, {color:"#e11b22", fontFamily: 'eurostile', fontWeight: 'bold'});
			$(this).css("background-image","url(/Contents/Toshiba_de/DE/Others/portal_families/common/images/bg_a_leftpart."+ext+")");
			$(this).parent().css("background-image","url(/Contents/Toshiba_de/DE/Others/portal_families/common/images/bg_a_rightpart."+ext+")");
		}
	);
	
	// creates the rel attributes for each link using cufon in the menu_main
	$("#col_left a").each(function(i){
		if($(this).attr("rel") != "button"){
			$(this).attr("rel", i);
			linksAmount++;
		}
	});
	
	/*$("#col_left a").hover(
		function (){
			cufon_status = "over";	
			highlightCufonLink($(this));
		},
		function () { 
			cufon_status = "out";
			unhighlightCufonLink();
		}
	);


	$("#breadcrumb a").hover(
		function () {
			Cufon.replace(this, {color:"#e11b22", fontFamily: 'helvetica', fontWeight: 'bold'});
		},
		function () {
			Cufon.replace(this, {color:"#808284", fontFamily: 'helvetica', fontWeight: 'bold'});
		}
	);*/
	
	// Cufon requires too much time to replace the font on Mouse Over.
	// this function let us control the color displayed on the links

	/*function highlightCufonLink(e){
		if(cufon_status == "over"){
			var id = e.attr("rel");
			var elt;
			var font;
			for (l = 0; l <= linksAmount; l++){
				elt =  $("#col_left a[rel="+l+"]");
				if(elt.attr("class") != "active"){
					font = $("#col_left a[rel="+l+"]").css("font-family");
					if(l != id){ Cufon.replace(elt, {color:"#808284", fontFamily:font}); }
					else{ 		 Cufon.replace(elt, {color:"#e11b22", fontFamily:font}); }
				}
			}
		}
	}
	
	function unhighlightCufonLink(){
		var elt;
		var font;		
		for (l = 0; l <= linksAmount; l++){
			elt = $("#col_left a[rel="+l+"]");
			if(elt.attr("class") != "active"){
				font = $("#col_left a[rel="+l+"]").css("font-family");
				Cufon.replace(elt, {color:"#808284", fontFamily:font});
			}
		}
	}*/
	
	$("div.more-info").hide();

	$("a.toggle").click(function(){
		$(this).prev("div.more-info").slideToggle("slow");
	});
	
});