var quote_to_img_probability = 0.3;
Modernizr._fontfaceready(function(bool){
	if (!bool){
			Cufon.replace('.steelfish');
	}
});
$(document).ready(function(){
	if($.browser.msie){
		Cufon.replace('.steelfish, h1, #menu li');
	}
	$(".spamprotected").each(function(){
		address = $(this).attr("href");
		at = address.indexOf('@');
		beforeat = address.substring(0, at);
		afterat = address.substring(at+10, address.length);
		if("mailto:"+$(this).text() == beforeat+'@antyspam.'+afterat){
			stripmailto = beforeat.substring(7);
			$(this).text(stripmailto+"@"+afterat);
		}
		$(this).attr("href", beforeat+"@"+afterat);
	});
	if($.browser.webkit){
		$("#basia-foto").attr("style", "margin-top:0");
	}
	$("#menu li").append('<div class="hover"></div>');
	$("#menu li").hover(function(){
		if($.browser.msie){
			$(this).children('div').show();
		}
		else{
			$(this).children('div').fadeIn("normal");
			$(this).children('a').animate({color: '#fff'}, "normal");
		}
	},
	function(){
		if($.browser.msie){
			$(this).children('div').hide();
		}
		else{
			$(this).children('div').fadeOut("normal");
			$(this).children('a').animate({color: '#00d3e8'}, "normal");
		}
	});
	$("#zamow a").hover(function(){
		$(this).parent().css("background-position", "-159px 0px");
	},
	function(){
		$(this).parent().css("background-position", "0px 0px");
	})
	if($('html').get(0).clientWidth < 827){
		$('#top').css('left', '430px');
	}
	$(".local-scroll").click(function(){
		$("html,body").animate({scrollTop: $($(this).get(0).hash).get(0).offsetTop - 137}, 700);
		return false;
	});
	if(typeof(quotes) != "undefined"){
		quote_number = Math.round(Math.random()*((quotes.length - 1)));
		note_number = Math.round(Math.random()*((notes.length - 1)));
		note_or_img = Math.round(Math.random()*100);
		if(note_or_img <= 100*quote_to_img_probability){
			$("#content-mid").prepend('<div id="note"><div id="note-wrapper"><blockquote></blockquote><p id="quote-cite"><cite></cite></p></div></div>');
			if($.browser.webkit){
				$("#note").css("width", "250px");
			}
		}
		else{
			$("#content-mid").prepend('<img id="note-img" src="img/notes/' + notes[note_number] +'" alt="" />');
		}
		$("#quote-cite cite").html(quotes[quote_number].cite).parent().prev().html(quotes[quote_number].quote);
	}
	$(window).resize(function(){
		if($('html').get(0).clientWidth < 827){
			$('#top').css('left', '435px');
		}
		else{
			$('#top').css('left', '50%');
		}
	});
	$(window).scroll(function(){
		if($('html').get(0).clientWidth < 827){
			setleft = -1*($('html').get(0).scrollLeft) + 435;
			$('#top').css('left', setleft + 'px');
		}
	});
});
