// JavaScript Document

$(document).ready(function() {
	//display JS version of language navigation (as dropdown)
	$('#langnav_js').show();

	//printpreview
	if (document.location.href.indexOf("printpreview=1") == -1) {
		//Hide inactive tabs of content navigation on product page
		$('#product').tabs({ fxAutoHeight: true });

		//call initialisation function for rollover navigation on homepage
		if (typeof(attachMouseEventsToHomeMenu) != "undefined") {
			attachMouseEventsToHomeMenu();
		}
	} else {
		//show print dialog
		window.print(self);
	}
	
	//enable zoom button
	$('#zoom').css('margin-left',0);
	
	//onclick numbers -> img switch
	$('ul.gallery li a.img').click(function() {
		
		//append or replace something in href of big image 4 thumbnail image path ...
		var littleimg = this.href + '?maxx=200&maxy=150';
		var tit = $(this).attr('title');
		
		$('#thumb').attr('src',littleimg);
		$('#thumb').attr('title',tit);
		$('#thumblabel').text(tit);
		$('#zoom a').attr('href',this.href);
		
		return false;
	});

	//image resize for table.blind-fixed-left200 td.first 
	var wmax = 200;
	$("table.blind-fixed-left200 td.first img").each(function(e) {
		var w = parseInt($(this).css("width")); //convert returned '123px' into number
		var h = parseInt($(this).css("height")); //convert returned '123px' into number
		if (w > wmax) {
			//resize width and store factor
			$(this).css("width",wmax);
			//resize height accordingly
			qh = h*wmax/w;
			$(this).css("height",qh);
		}
	});
	
});

//console.log
function log(text) {
	if ($.browser.mozilla) {
		console.log(text);
	}
}
