$(document).ready(function() {
	$("nav a").hover(
    function() {
        $(this).stop().animate({color:'#0A90FE', borderBottomColor:'#0A90FE'}, 500);
        }, function () {
        $(this).stop().animate({color:'#3a3a3a', borderBottomColor:'#3a3a3a'}, 500);
    });

	$("div.smallContent ul").newsticker();
		
	$("a#topOfPage").click(function() {
		$('html,body').animate({scrollTop: 0}, 1200, 'easeInOutQuad');
		return false;
	});
	
	$("a.toggle + div").hide();
	$("a.toggle").click(function() {
			$(this).next("div").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;
	});
	
	$(".screenshotLeft, .screenshotRight").fancybox({padding:0, margin:40,scrolling:'no',hideOnContentClick:true,titleShow:false,showCloseButton:false,showNavArrows:false,overlayColor:'#444',autoScale:true,autoDimensions:true,width:'75%'});

	$(".productIntroBox .productIntro").hover(function() {
		clearTimeout(IWSlideshowTimer); 
		IWSlideshowTimer = null;
	}, function() {
		if (IWSlideshowDir == 1) IWSlideshowTimer = setTimeout(productSlideshow, 5000);
		else IWSlideshowTimer = setTimeout(productSlideshow, 250);
	});
	if ($(".productIntroBox").length) IWSlideshowTimer = setTimeout(productSlideshow, 5000);
	
	if (!Modernizr.borderradius || !Modernizr.opacity) {
		$('header').after('<div id="browserWarning">Your browser does not support some features used by this site, so while it will work correctly anyway, it will not look exactly as designed and it may show some graphic glitches. Consider updating to the latest version of Chrome, Firefox, Internet Explorer, Opera or Safari for the best and safest browsing experience on intuiware.com.</div>')
	}
});

var IWSlideshowPos = 0;
var IWSlideshowDir = 1;
var IWSlideshowTimer = null;

productSlideshow = function productSlideshow() {
	product = $(".productIntroBox .productIntro:eq("+IWSlideshowPos+")");
	text = $(".text", product);
	mac = $(".mac", product);
	ribbon = $(".bigRibbon", product);
	
	if (IWSlideshowDir > 0) {
		mac.animate({right: "-450px"}, {duration: 500, easing: 'swing', queue: true});
		ribbon.animate({left: "-240px", bottom: "-182px"}, {duration: 500, easing: 'linear', queue: true});
		text.animate({top: "-400px"}, {duration: 500, easing: 'swing', queue: true, complete: function() {
			IWSlideshowPos++;
			if (IWSlideshowPos >= $(".productIntroBox .productIntro").length) IWSlideshowPos = 0;
			IWSlideshowDir = 0;
			product.css('z-index', 1);
			IWSlideshowTimer = setTimeout(productSlideshow, 250);
		}});
	} else {
		mac.animate({right: "40px"}, {duration: 800, easing: 'swing', queue: false});
		ribbon.animate({left: "-40px", bottom: "18px"}, {duration: 900, easing: 'linear', queue: false});
		text.animate({top: "100px"}, {duration: 500, easing: 'swing', queue: false, complete: function() {
			product.css('z-index', 2);
		
			IWSlideshowDir = 1;
			IWSlideshowTimer = setTimeout(productSlideshow, 5000);
		}});
	}
}

