jQuery(function($) {
	function change_header_slide(new_index) {
		$('.pages a').removeClass('active');
		$('.pages a:eq(' + new_index + ')').addClass('active');
		$('.slides-handler > *:visible').fadeOut();
		$('.slides-handler > *:nth-child(' + (new_index + 1) + ')').fadeIn();
	}
	
	$('.pages a').click(function () {
	    var i = $('.pages a').index(this);
	    change_header_slide(i);
	});
	
	// $('.head').mouseover(function () {
	// 	    $(this).toggleClass('expanded-header');
	// 	    $('a.collapse, a.expand').toggleClass('collapse').toggleClass('expand');
	// 	    $(this).parents('.more-top').find('.head').addClass('sub-header');
	// 	
	// 		return false; 
	// 	});
	// 	
	// 	$('.head').mouseout(function () {
	// 	    $(this).toggleClass('expanded-header');
	// 	    $('a.collapse, a.expand').toggleClass('collapse').toggleClass('expand');
	// 	    $(this).parents('.more-top').find('.head').addClass('sub-header');
	// 		return false; 
	// 	});
	
	$("#your_favorites_link").click(function () {
      $("#your_favorites").slideDown("slow");
    });

	var auto_refresh = setInterval(
	function ()
		{
		    var new_index = $('.pages a.active').text();
			var new_index = parseFloat(new_index);
			if (new_index == 4) {
				var new_index = 0
			};	
			$('.pages a').removeClass('active');
			$('.pages a:eq(' + new_index + ')').addClass('active');
			$('.slides-handler > *:visible').fadeOut();
			$('.slides-handler > *:nth-child(' + (new_index + 1) + ')').fadeIn();
		}, 6000); // refresh every 6 seconds

});


// Use the Jquery Input Default plugin to set default values for the appropriate input fields
$(document).ready(function() {
  $(':input[@default]').inputdefault();
});

// Example
// <a href="http://www.espn.com/" onClick="popUp(this.href,'cs',700,500);return false" target="_blank">
var newWin = null;
function popUpp(URL, type, width, height) {
  if (newWin != null && !newWin.closed)
    newWin.close();
  var options="";
  if (type=="nav")
    options="toolbar,resizable,scrollbars,height="+
      height+",width="+width;
  if (type=="cs")
    options="resizable,scrollbars,height="+
      height+",width="+width;
  if (type=="console")
    options="resizable,height="+
      height+",width="+width;
  if (type=="fixed")
    options="scrollbars,height="+
      height+",width="+width;
  if (type=="elastic")
    options="toolbar,menubar,scrollbars,"+
      "resizable,location,height="+
      height+",width="+width;
  newWin = window.open(URL, 'newWin', options);
  newWin.focus();
}

