var myBgs=new Array();
myBgs[0]="TEMP-Image_1_1.jpg";
myBgs[1]="TEMP-Image_1_2.jpg";
myBgs[2]="TEMP-Image_1_3.jpg";

$(document).ready(function(){
	$(".c_box").hover(
		function () {
			$(".c_box").stop().animate( { opacity: "0.35" }, { queue: false, duration: 500 });
			$(this).stop().css("opacity","1");
			
			var myhref = $(this).find("a.release").attr("href");
			if(myhref!=undefined){
				$("body").css("cursor","pointer");
			}
			
		},
		function () {
			$(".c_box").stop().animate( { opacity: "1" }, { queue: false, duration: 550 });
			$("body").css("cursor","default");
		}
	);
	
	$(".c_box").click(function(){
			var myhref = $(this).find("a.release").attr("href");
			if(myhref!=undefined){
				window.location = myhref;
			}					   
	});
	
	//$("#bgimage").css("opacity","0").animate( { opacity: "1" }, { queue: false, duration: 5000 });
	
	$("#bgimage").css("opacity","0");
	
	var currIndex = 0;
	
	function rotateMe(){
		$("#bgimage").css("opacity","0").css("background-image","url("+myBgs[currIndex]+")").animate( { opacity: "1" }, { queue: false, duration: 4000 });
		currIndex++;
		if(currIndex >= myBgs.length){
			currIndex = 0;
		}
		setTimeout(fadeMe, 14000);
	}
	
	function fadeMe(){
		$("#bgimage").animate( { opacity: "0" }, { queue: false, duration: 4000 });
		setTimeout(rotateMe, 5500);
	}
	
	//setTimeout(fadeMe, 7000);
	
	if($("#icon-fb").css('backgroundPositionY')){
		//alert("y supported");
		
		$("#icon-fb, #icon-sc, #icon-lk, #icon-ms, #icon-yt, #icon-tw").css( {backgroundPositionY: "-40px"} ).css( {backgroundPositionX: "0px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPositionY : '0px'}, {duration : 200});
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPositionY : '-40px'}, {duration : 100})
		});
	
	} else {
		//alert("not supported!");
		
		$("#icon-fb, #icon-sc, #icon-lk, #icon-ms, #icon-yt, #icon-tw").css( {backgroundPosition: "0 -40px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition : '0 0'}, { queue: false, duration : 200 });
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition : '0 -40px'}, { queue: false, duration : 100 })
		});
	}
	
	
	
	
	
	var trackString = "[ { artist: 'UFO!', title: 'Some Track', index: '1' }, { artist: 'UFO!', title: 'Some Other Track', index: '2' } ]";
	var tracks = eval(trackString);
	//alert(tracks[0].title +' and ' + tracks[1].title);




	$("#email").focus(function(){
		var emailval = $(this).val();
		if(emailval == "your email"){
			$(this).val("");
		}
	});
	
	$("#email").blur(function(){
		var emailval = $(this).val();
		if(emailval == ""){
			$(this).val("your email");
		}
	});
	
	
	$("#email").mouseover(function(){
		$(this).css("background","#e8e9ea");
	});

	$("#email").mouseout(function(){
		$(this).css("background","#fff");
	});


	
	//$("#mail-overlay").hide();
	
	$("#mail-overlay a").live("click", function(){
      $("#mail-overlay").hide();
	  return false;
    });
	
	$("#sendlink").click(function(){
		var emailval = $("#email").val();
		if(emailval == "your email" || emailval == ""){
			$("#mail-overlay").html("<p>please enter an email address<br /><a href='#'>close this</a></p>").show();
		} else {
			$.post("/srwp/wp-content/plugins/sanguine-subscribers/php/sanguine-subscribers-ajax.php", { action: "add", email: emailval },
			  function(data){
				$("#mail-overlay").html("<p>"+ data +"</p><p><a href='#'>close</a></p>").show();
			  });
		}
		return false;
	});
	
	$("#unlink").click(function(){
		var emailval = $("#email").val();
		if(emailval == "your email" || emailval == ""){
			$("#mail-overlay").html("<p>please enter an email address<br /><a href='#'>close this</a></p>").show();
		} else {
			$.post("/srwp/wp-content/plugins/sanguine-subscribers/php/sanguine-subscribers-ajax.php", { action: "rmv", email: emailval },
			  function(data){
				$("#mail-overlay").html("<p>"+ data +"</p><p><a href='#'>close</a></p>").show();
			  });
		}
		return false;
	});
	
	
});