$(document).ready(function() { 
	$("div.headlines ul").newsticker();
	
	$("a.screenshot").fancybox({
		'padding': 0,
		'imageScale': true,
		'zoomOpacity': true,
		'overlayShow': true,
		'overlayOpacity': 0.5,
		'centerOnScroll': true
	});
	
	$("a.screenshot").each(function() {$(this).css("background-image", "url("+$(this).find("img").attr("src")+")")});
	$("a.screenshot img").remove();
	
	$("a#topOfPage").click(function() {
		$('html,body').animate({scrollTop: 0}, 1200, 'easeInOutQuad');
		return false;
	});
	
	$("a.toggle + ul").hide();
	$("a.toggle").click(function() {
			$(this).next("ul").slideToggle("slow");
			return false;
		});
	
	$("div.input input").focus(function() {
		$(this).parent().addClass("curFocus");
		$(this).addClass("curFocus");
	});
	$("div.input input").blur(function() {
		$(this).parent().removeClass("curFocus");
		$(this).removeClass("curFocus");
	});
	$("div.input textarea").focus(function() {
		$(this).parent().addClass("curFocus");
		$(this).addClass("curFocus");
	});
	$("div.input textarea").blur(function() {
		$(this).parent().removeClass("curFocus");
		$(this).removeClass("curFocus");
	});
			
	$("input#ContactName").focus();
			
	$("div.search form").submit(function() {
		text = $("input#PostCriterio").val();
		window.location = $(this).attr("action") + "/" + text;
		
		return false;
	});
	
	$("div.bookmarks").bookmark({
		sites: ["delicious", "digg", "facebook", "friendfeed", "linkedin", "magnolia", "myspace", "reddit", "stumbleupon", "tumblr", "twitter"],
		icons: "/img/BMIcons.png",
		popup: false
	});
	
	$(".tweet").tweet({
        username: "intui",
        join_text: "auto",
        avatar_size: 0,
        count: 3,
        auto_join_text_default: "<br />",
        auto_join_text_ed: "<br />",
        auto_join_text_ing: "<br />",
        auto_join_text_reply: "<br />",
        auto_join_text_url: "<br />",
        loading_text: "Loading tweets..."
    });	

	list = $("#nav_zone ul");
	list.lavaLamp({ fx: "easeOutElastic", speed: 800, startItem: $("#nav_current").prevAll().size() });
	
	browser = false;
	ie = false;
	opera = false
	
	if($.browser.name=="camino" && $.browser.versionNumber>=2) browser = true;
	if($.browser.name=="firefox" && $.browser.versionNumber>=3) browser = true;
	if($.browser.name=="safari" && $.browser.versionNumber>=3) browser = true;
	if($.browser.name=="chrome" && $.browser.versionNumber>=4) browser = true;
	if($.browser.name=="msie" && $.browser.versionNumber<8) ie = true;
	if($.browser.name=="opera" && $.browser.versionNumber<9.6) opera = true;
	
	if(!$.cookie('browserCheck') && !browser) {
		text = "<div id='browserCheck'><div id='browserContent'>Dear User,<br />this site has been designed to take advantage of all the latest web technologies and, while it is anyway usable with all modern browsers, you could experience some minor issues and incomplete graphics with the browser you are currently using.<br />Consider upgrading to a recent version of <a href='http://www.mozilla.com'>Firefox</a> (version 3.0 or later for Linux, Mac, Windows), <a href='http://www.apple.com/safari/'>Safari</a> (version 3.0 or later for Mac, Windows), <a href='http://caminobrowser.org'>Camino</a> (version 2.0 for Mac) or <a href='http://www.google.com/chrome'>Google Chrome</a> (version 4.0 or later for Linux, Mac or Windows) for the best experience.<br />";
		if(ie) text += "You could also update <a href='http://www.microsoft.com/windows/internet-explorer/default.aspx'>Internet Explorer</a> to the latest version to improve its compatibility.<br />";
		if(opera) text += "You could also update <a href='http://www.opera.com'>Opera</a> to the latest version to improve its compatibility.<br />";
		text += "<br />Click to close this window.</div></div>"
		$("body").append(text);
		$("#browserCheck").css({'position':'absolute','width':'100%','height':'100%','top':'0','left':'0','z-index':50000});
		$("#browserContent").css({'position':'relative','width':'400px','top':'100px','margin':'auto','background-color':'#1e1e1e','border':'1px solid white','padding':'20px'});
		$.cookie('browserCheck', '1');
		$("#browserContent").click(function(){$("#browserContent").remove();});
	}
});
