// JavaScript Document
<!--
$(document).ready(function() {
	
	
	$(".sideCol").hover(function () {
		//do this on hover
		$(this).toggleClass("sidecol-hard");
		}, function() {
		//do this on hover out
		$(this).removeClass("sidecol-hard");
	
	});
	
	
	$(".compiled-number").hover(function () {
		//do this on hover
		$(this).toggleClass("compiled-hover");
		}, function() {
		//do this on hover out
		$(this).removeClass("compiled-hover");
	
	});
	
	//setup, grab all our tab objects (all elements with class paneltabs)
	//and grab all our panels (all elements with class panel)
	//$(".SombrillaMast").pngFix();
	//$(document).pngFix(); 
	//@example $(function(){
	$('div#title').pngFix();
	$('div#topBarContainer').pngFix();

	$tabs = $(".tabs");
	$panels = $(".panel");
	var tabs = $(".tab");
	var hoverTimeout = 300;
	var slideDelay = 6000;
	
	$(".tab").eq(0).toggleClass("selected");
	var cycleContainer = $(".panels").cycle({
	fx: 'fade',
	timeout: slideDelay,
	before: onAfter,
	pager: '.panelLink'
	});
	
	function onAfter(e) {
	//console.log(this);
	//alert($(this).position);
	var panelPos = $(this).attr("index");
	//alert(panelPos);
	$(".tab").removeClass("selected");
	$(".tab").find(".article_descript").css("color", "#aaaaaa");
	$(".tab").find(".feature_number").css("color", "#aaaaaa");
	
	$(".tab").eq(panelPos).toggleClass("selected");
	$(".tab").eq(panelPos).find(".article_descript").css("color", "#222222");
	$(".tab").eq(panelPos).find(".feature_number").css("color", "#222222");
	}
	
	//hover magic goes here
	//our timer variable for setInterval
	var hoverIntent = null;
	//get all the anchor elements in our tabs
	$tabs.find(".tab").hover(function () {
	//get our currently selected hover
	var divel = this;
	var el = $(this).find(".panelLink").get(0);
	//if the user stays over this hover for 500ms, change the panel
	//to the appropriate panel image by hiding every panel but the
	//one selected (filter(el.hash))
	hoverIntent = setTimeout(function () {
	//cycleContainer.cycle('stop');
	$tabs.find(".tab").removeClass("selected").filter(divel.hash).addClass("selected");
	$tabs.find(".tab").find(".article_descript").css("color", "#aaaaaa");
	$tabs.find(".tab").find(".feature_number").css("color", "#aaaaaa");
	
	$(divel).toggleClass("selected");
	$(divel).find(".article_descript").css("color", "#222222");
	$(divel).find(".feature_number").css("color", "#222222");
	
	var desiredSlide = parseInt($(divel).attr("index"));
	cycleContainer.cycle('pause');
	cycleContainer.cycle(desiredSlide);
	}, hoverTimeout);
	}, function () {
	//on hover out, stop counting to 500ms
	clearTimeout(hoverIntent);
	//restart our rotation
	$(".panels").cycle('resume');
	}).click(function () {
	return false;
	});
	
	//click magic goes here
	$tabs.find(".tab").click(function () {
	//look for the embedded articleLink anchor tag
	//on click, set the window to the new url
	var urlToFollow = $(this).find(".articleLink").attr("href");
	window.location = urlToFollow;
	event.preventDefault();
	});


	
	$(".toc_hover, .toc_hover2, .toc_hover3").hover(function () {
		//do this on hover
		$(this).toggleClass("toc_hover_selected");
		}, function() {
		//do this on hover out
		$(this).removeClass("toc_hover_selected");
	
	});
	
	//click magic goes here
	$(".toc_hover, .toc_hover2, .toc_hover3").click(function () {
	var urlToFollow = $(this).find(".articleLink").attr("href");
	window.location = urlToFollow;
	event.preventDefault();
	});
	
	
	
	$(".archive").hover(function () {
		//do this on hover
		$(this).toggleClass("archive_hover");
		}, function() {
		//do this on hover out
		$(this).removeClass("archive_hover");
	
	});

	
	
	
	//$("#formWriteBack").validate(
	
	//{ submitHandler: function(form) { $("#formWriteBack").submit(); } }); 
	
	
	$("#bullseye").validate();
	
	
	$('#feedback-dialog').dialog({
	  height: 'auto',
	  width: '460px',
	  modal: true,
	  autoOpen: false,
	  resizable: false,
	  buttons: {	
	   "cancel": function() { 
		$(this).dialog("close"); 
	   } 
	  }
	 });
	
	 $('#fdbk_tab').click(function(){
	  $('#feedback-dialog').dialog('open');
	   return false;
	  });
	 
	 
	 
	 
	 $('#xtra-romo-dialog').dialog({
	  height: 'auto',
	  width: '600px',
	  modal: true,
	  autoOpen: false,
	  resizable: false,
	  buttons: {
	   
	   "close": function() { 
		$(this).dialog("close"); 
	   } 
	  }
	 });
	
	 $('#romo_xtra').click(function(){
	  $('#xtra-romo-dialog').dialog('open');
	   return false;
	  });
	 
	 
	 $('#xtra-carter-dialog').dialog({
	  height: 'auto',
	  width: '500px',
	  modal: true,
	  autoOpen: false,
	  resizable: false,
	  buttons: {
	  
	   "close": function() { 
		$(this).dialog("close"); 
	   } 
	  }
	 });
	
	 $('#carter_xtra').click(function(){
	  $('#xtra-carter-dialog').dialog('open');
	   return false;
	  });
 
});

//-->

