$(document).ready(function(){



	$("#supportli").hover(function(){
		$("#supportdd").slideDown("fast");
		$(this).find("a#support").css("background-position","bottom");
	}, function() {
		$("#supportdd").slideUp("fast");
		$("#support").css("background-position","top");
	});
	
	var artisttoggle = 0;
	var categorytoggle = 1;
	
	$("#artist-list .categories").hide();
	
	$("#artist-list .expandcontract").click(function(){
		if (artisttoggle == 0){
			$(this).css("background-position","top");
			$(this).siblings(".categories").slideDown("fast");				
			artisttoggle = 1;	
		}else{
			$(this).css("background-position","bottom");
			$(this).siblings(".categories").slideUp("fast");	
			artisttoggle = 0;		
		}
		return false;
	});	
	$("#category-list .expandcontract").click(function(){
		if (categorytoggle == 0){
			$(this).css("background-position","top");
			$(this).siblings(".categories").slideDown("fast");	
			categorytoggle = 1;	
		}else{
			$(this).css("background-position","bottom");
			$(this).siblings(".categories").slideUp("fast");	
			categorytoggle = 0;		
		}
		return false;
	});
	$("#artist-list h3 a").click(function(){
		if (artisttoggle == 0){
			$(this).parent("h3").siblings(".expandcontract").css("background-position","top");
			$(this).parent("h3").siblings(".categories").slideDown("fast");		
			$("#category-list .categories").slideUp("fast");
			$("#category-list .expandcontract").css("background-position","bottom");	
			artisttoggle = 1;
			categorytoggle = 0;		
		}
		return false;
	});
	$("#category-list h3 a").click(function(){
		if (categorytoggle == 0){
			$(this).parent("h3").siblings(".expandcontract").css("background-position","top");
			$(this).parent("h3").siblings(".categories").slideDown("fast");		
			$("#artist-list .categories").slideUp("fast");
			$("#artist-list .expandcontract").css("background-position","bottom");	
			artisttoggle = 0;
			categorytoggle = 1;		
		}
		return false;
	});
	
	var bgtoggle = 0;
	$("#loginbtn").click(function(){		
		$("#loginform").slideToggle("fast");
		/*
if (bgtoggle == 1){
			$("#loginbtn").css("background-position","top left");
			bgtoggle = 0;
		}else{
			$("#loginbtn").css("background-position","bottom right");
			bgtoggle = 1;
		}
*/
	});
		
	$("#selectedcountry").click(function(){
		$("#countrychoices").slideToggle("fast");
	});
	
	    $('#slideshow').cycle({
		fx: 'scrollLeft', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		randomizeEffects: false, 
		pager:  '#slide-nav',
		timeout: 6000,
		after: detectnewborn
		/* before: resetnewborn */
	});
	
	function detectnewborn (){
		
		var newbornslide = $("#newbornslide").css("display");
		if ( newbornslide == "block"){
			/* alert($("#newbornslide").css("display")); */
			$("#newbornb").fadeOut("slow");
			var t = setTimeout('$("#newbornb").fadeIn("slow");', 1500);
			var t = setTimeout('$("#newbornb").fadeOut("slow");', 3500);
			var t = setTimeout('$("#newbornb").fadeIn("slow");', 6500);
		}
	};
	/*
function resetnewborn (){
		var t = setTimeout("$('#newbornb').show();",1000);
	}
*/
	
	
	$("#featuredcards li #newcardselection").show("slow");
	$("#featuredcards li a#new").css("background-position","bottom");
	
	$("#featuredcards li a#new").click(function(){
		$("#featuredcards li #mostpopularcardselection").hide("fast");
		$("#featuredcards li #recentusercardselection").hide("fast");
		$("#featuredcards li #newcardselection").show("slow");
		$("#featuredcards li a#mostpopular").css("background-position","top");
		$("#featuredcards li a#recentuser").css("background-position","top");
		$(this).css("background-position","bottom");
		return false;
	});
	$("#featuredcards li a#mostpopular").click(function(){
		$("#featuredcards li #newcardselection").hide("fast")
		$("#featuredcards li #recentusercardselection").hide("fast");
		$("#featuredcards li #mostpopularcardselection").show("slow");
		$("#featuredcards li a#new").css("background-position","top");
		$("#featuredcards li a#recentuser").css("background-position","top");
		$(this).css("background-position","bottom");
		return false;
	});
	$("#featuredcards li a#recentuser").click(function(){
		$("#featuredcards li #newcardselection").hide("fast")
		$("#featuredcards li #mostpopularcardselection").hide("fast");
		$("#featuredcards li #recentusercardselection").show("slow");
		$("#featuredcards li a#new").css("background-position","top");
		$("#featuredcards li a#mostpopular").css("background-position","top");
		$(this).css("background-position","bottom");
		return false;
	});
});

function displaypword(){

	var curpass = document.getElementById("loginpassword").value;
	if( curpass == ""){
		document.getElementById("dummypass").style.display = "";
		document.getElementById("loginpassword").style.display = "none";
		document.getElementById("dummypass").value = "Password";
	}

}

function swappword(){
	document.getElementById("dummypass").style.display = "none";
	document.getElementById("loginpassword").style.display = "";
	document.getElementById("loginpassword").focus();
}

function supplyusernametext(){
var curval = document.getElementById("loginusername").value;
if( curval == ""){
		document.getElementById("loginusername").value = "Username";
	}
}


function resetusernametext(){
	var curval = document.getElementById("loginusername").value;
	if( curval == "Username"){
		document.getElementById("loginusername").value = "";
	}
}
