// Loading at startup 

$(document).ready(function(){
	showThumb();
	extWindows();
	menuFix();
	referees();
	//equalHeights();
});

function menuFix (){
	$("#header li:first").css("border", "0");
}

function referees(){
	$("#miniReferees a").click(function(e){		
		e.preventDefault();		
		var thumb = $(this).attr("href"),
			titel = $(this).attr("title"),
			text = $("img", this).attr("alt");
		
		$("#referee img").attr("src", thumb);
		
		$("#referee h2").html(titel);
		$("#referee p").html(text);
		//equalHeights();	
	});	
}

function showThumb(){
	if($('#picSwap').length){
		$("#picSwap div.productBox3 a").click(function(e){	
			e.preventDefault();
			var source = $(this).attr("href"), 
				text = $("img", this).attr("alt");
			
			$("#bigPic").attr("src", source);
			$("#bigPic").attr("alt", text);
						
			$("#picTxt").html(text);	
		});
	}
	else {
		$(".thumbs .productBox3 a").click(function(e){
			e.preventDefault();
			var source = $(this).attr("href"), text = $("img", this).attr("alt");
			$("#bigPic").attr("src", source);
			$("#bigPic").attr("alt", text);
		});
	}
		
}

function extWindows(){
	$("a[rel=external]").attr("target","_blank");	
}

function equalHeights() {
	//if(document.getElementById('referee').length){

		var left = $('#referee'), 
			right = $('#miniReferees');
			
		right.height('auto');
		
		console.log(left.height())
		console.log(right.height())
		
		if (left.height() > right.height()) {
			right.height('auto');
			right.height(left.height() - 30);
		}
		else {
			right.height('auto');			
		}
	//}
}
