// DD_roundies
/*DD_roundies.addRule('#header .nav .drop', '5px', true);

// Search Field Placeholder
$(document).ready(function(){
	$("input[type=text]").focus(function(){
		if($(this).val() == $(this).attr("defaultValue"))
		{
		$(this).val("");
		}
	});

	$("input[type=text]").blur(function(){
		if($(this).val() == "")
		{
		$(this).val($(this).attr("defaultValue"));
		}
	});
});*/

// Header Navigation Links
$(document).ready(function(){
	$("#header .nav .drop ul li a").hover(function(){
		$(this).addClass("active");
	}, function(){
		$(this).removeClass("active");
	});
});

// Header Navigation Drops
$(document).ready(function(){
	$("#header .nav ul li .arrowDown").css({
		opacity: 0
	});
	$("#header .nav ul li").hoverIntent({
		sensitivity: 3,
		interval: 100,
		timeout: 100,
		over:function(){
			$(".drop",this).slideDown(200);
			$(".arrowUp",this).fadeIn(200);
			$(".arrowDown",this).animate({
				opacity: 1,
				top: '+=5'
			});
		},
		out: function(){
			$(".drop",this).fadeOut(200);
			$(".arrowUp",this).fadeOut(200);
			$(".arrowDown",this).animate({
				opacity: 0,
				top: '-=5'
			});
		}
	});
});

// Home Page Slideshow
$(document).ready(function(){
	$("#marquee .slideshow").cycle({
		fx: "scrollVert",
		rev: 1,
		prev: "#marquee .prev",
		next: "#marquee .next",
		pager: "#marqueeNav",
		timeout: 10000,
		speed: 500,
		autostop: 1,
		autostopCount: 6,
		before: onBefore,
		after: onAfter
	});
	function onBefore() {
		$("#marquee .slide .content").hide();
	}
	function onAfter() {
		$("#marquee .slide .content").fadeIn();
	}
});

// Home Page Area Tabs
$(document).ready(function(){
	$("#areas .tabs a").click(function(){
		$("#areas .tabs a").removeClass("active");
		$(this).addClass("active");
		return false;
	});
	$("#areas .tabYourFocus").click(function(){
		$("#areas .tab").hide();
		$("#areas .yourFocus").show();
		return false;
	});
	$("#areas .tabOurProducts").click(function(){
		$("#areas .tab").hide();
		$("#areas .ourProducts").show();
		return false;
	});
	$("#areas .tabHealthcareIssues").click(function(){
		$("#areas .tab").hide();
		$("#areas .healthcareIssues").show();
		return false;
	});
	$("#areas .tab ul li a").hover(function(){
		$(".arrow",this).css("backgroundPosition","bottom");
	}, function(){
		$(".arrow",this).css("backgroundPosition","top");;
	});
});

// Home Page Tweets
$(document).ready(function(){
	var tweetDate;

        function parseDate(str) {
          var v = str.split(' ');
          return v[1] + ". " + v[2];
        }

	$.getJSON('http://twitter.com/status/user_timeline/quantros.json?count=5&callback=?', function(data){
		$.each(data, function(index, item){
			tweetDate = parseDate(item.created_at);
			$('#tweets .tweet').append('<div><strong>' + tweetDate + ':</strong> ' + item.text.linkify() + '</div>');
		});
		$("#tweets .tweet").cycle({
			fx: "scrollVert",
			prev: "#tweets .arrowUp",
			next: "#tweets .arrowDown",
			timeout: 0,
			rev: 1
		});
		$(function(){
			$("#tweets .tweet a").attr("target","_blank");
		});
	});
	String.prototype.linkify = function() {
		return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(m) {
			return m.link(m);
		});
	};
});

// Colorbox
$(document).ready(function(){
	$("a[rel='samples']").colorbox();
});
