
var debugString = "";
var debug = true;

Cufon.replace('#topnavigation a', { fontFamily: 'FFMaxTFSemiBold', hover: true });
Cufon.replace('.shortcuts h3', { fontFamily: 'FFMaxTFSemiBold' });

Cufon.replace('.appetizer_large h1', { fontFamily: 'FFMaxTFLight' });
Cufon.replace('.appetizer_small h1', { fontFamily: 'FFMaxTFLight' });

Cufon.replace('.news h3', { fontFamily: 'FFMaxTFLight' });

Cufon.replace('.shortcuts_items li a', { fontFamily: 'FFMaxTFLight', hover: true });

Cufon.replace('.box h3', { fontFamily: 'FFMaxTFLight' });

Cufon.replace('.linkfooter h3', { fontFamily: 'FFMaxTFLight' });

Cufon.replace('.article h1', { fontFamily: 'FFMaxTFLight' });
Cufon.replace('.article span.article_digest', { fontFamily: 'FFMaxTFLight' });
Cufon.replace('.article_related h3', { fontFamily: 'FFMaxTFLight' });


$(function()
{
    // wait for the document to load, 
    // since Webbit browsers loads js and css in parrallel
    if (jQuery.browser.safari){
        $(window).load(function(){
            setAppetizerHeights();
        });
    }else{
        setAppetizerHeights();
    }
	if (debug && !self.console && debugString.length > 0) alert(debugString);
});

function setAppetizerHeights()
{
	if ($(".appetizer_large").length > 0 && $(".appetizers_small").length > 0)
	{
		var maxHeight = $(".page_body").height();
		var appetizerLargeHeight = $(".appetizer_large").height();
		var noBottomHeight = $(".sidebar .noBottom").height();
		var shortcutsHeight = $(".sidebar .shortcuts_container").height();


		$(".sidebar .last .box").height(maxHeight - noBottomHeight - shortcutsHeight - 10 - 14 - 15 - 4 - 2);
		$(".appetizers_small .appetizer_small").each(function() {
			var imgHeight = 98;
			if ($(this).find("img").height() > 0) imgHeight = $(this).find("img").height();
			if (!(window.ie6HeightOffset === undefined)) imgHeight += ie6HeightOffset;
			$(this).find(".appetizer_text").height(maxHeight - imgHeight - 14 - 38 - 4 - 1 - 15 - 4 - appetizerLargeHeight);
		});
	}
}

function printing()
{
	var u = printurl();
	w = window.open(u,'print','width=650,height=680,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no');
	w.focus();
}

function printurl()
{
	var u = document.location.href;
	if(u.indexOf('#') > 0)
	{
		u = u.split('#');
		u = u[0];
	}
	u += (u.indexOf('?') >0) ? '&':'?';
	u += 'print=1';
	return u;
}


function log(s)
{
	var now = new Date();
	var s = (now.getTime() + '').substr(9) + ": " + s;
	if (debug && self.console)
		console.log(s);
	else if (debug)
		debugString += s + "\n";
}
