var curvyCornersVerbose = false;

// Image swap
function initRollOverImages() {
  var image_cache = new Object();
  $("img.rollover").each(function(i) {
    var imgsrc = this.src;
    var dot = this.src.lastIndexOf('.');
    var imgsrc_ovr = this.src.substr(0, dot) + '-ovr' + this.src.substr(dot, 4);
    image_cache[this.src] = new Image();
    image_cache[this.src].src = imgsrc_ovr;
    $(this).hover(
      function() { this.src = imgsrc_ovr; },
      function() { this.src = imgsrc; });
  });
}
$(document).ready(initRollOverImages);


// Link - blank
$(function(){
  $(".blank").click(function(){
    this.target = "_blank";
  });
});


// Link - top
$(function(){
  $(".top").click(function(){
    this.target = "_top";
  });
});

// Button rollover
$(document).ready(function(){
	$('#submitKeywordHeader').hover(
		function(){ // Change the input image's source when we "roll on"
			$(this).attr({ src : '/common/img/btn-header-search-ovr.png'});
		},
	function(){ // Change the input image's source back to the default on "roll off"
		$(this).attr({ src : '/common/img/btn-header-search.png'});             }
	);
});

$(document).ready(function(){
	$('#submitCastTitle, #submitCastTitle2').hover(
		function(){ // Change the input image's source when we "roll on"
			$(this).attr({ src : '/search/img/btn-search-resubmit-ovr.gif'});
		},
	function(){ // Change the input image's source back to the default on "roll off"
		$(this).attr({ src : '/search/img/btn-search-resubmit.gif'});             }
	);
});


$(document).ready(function(){
	$('#submitKeyword').hover(
		function(){ // Change the input image's source when we "roll on"
			$(this).attr({ src : '/search/img/btn-search-submit-ovr.gif'});
		},
	function(){ // Change the input image's source back to the default on "roll off"
		$(this).attr({ src : '/search/img/btn-search-submit.gif'});             }
	);
});

$(document).ready(function(){
	$('#submitMagazine').hover(
		function(){ // Change the input image's source when we "roll on"
			$(this).attr({ src : '/magazine/img/btn-submit-ovr.gif'});
		},
	function(){ // Change the input image's source back to the default on "roll off"
		$(this).attr({ src : '/magazine/img/btn-submit.gif'});             }
	);
});

//Tabbed Content

var TabbedContent = {
	init: function() {	
		$(".tab-item").mouseover(function() {
		
			var background = $(this).parent().find(".moving-bg");
			
			$(background).stop().animate({
				left: $(this).position()['left']
			}, {
				duration: 300
			});
			
			TabbedContent.slideContent($(this));
			
		});
	},
	
	slideContent: function(obj) {
		
		var margin = $(obj).parent().parent().find(".slide-content").width();
		margin = margin * ($(obj).prevAll().size() - 1);
		margin = margin * -1;
		
		$(obj).parent().parent().find(".tabslider").stop().animate({
			marginLeft: margin + "px"
		}, {
			duration: 300
		});
	}
}

$(document).ready(function() {
	TabbedContent.init();
});
