
function doMail(user,domain) {
	locationstring = "mailto:" + user + "@" + domain;
	window.location = locationstring;
}

function checkEmail(addy) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(addy)){
		return (true)
	} else {
		return (false)
	}
}

function downloadDP(targ){
	$("#album-"+targ+" .info").slideToggle();
	activeSignup = targ;
}

function getDownload(set){
	// check vars
	var uname = $("#signup-"+set+"-name").val();
	var uemail = $("#signup-"+set+"-email").val();
	var ucity = $("#signup-"+set+"-city").val();
	var ustate = $("#signup-"+set+"-state").val();
	var upass = $("#signup-"+set+"-passcode").val();
	
	var err = "";
	
	// validate
	if (!uname){
		name = "";
	}
	if (!uemail){
		err = "Please provide an email.";
	}
	if (!checkEmail(uemail)){
		err = "Please provide a valid email.";
	}
	if (!ucity){
		err = "Please provide a location.";
	}
	if (!ustate || ustate == "--"){
		err = "Please provide a state.";
	}
	
	
	// okay?
	if (!err){
		// get user to wait
		$("#signup-"+set+" p").css("display","none");
		$("#signup-"+set+" dl").css("display","none");
		$("#status-"+set).html("Checking enrollment....");
		 $.post("_lib/func_cm.php",
       		{name:uname,email:uemail,city:ucity,state:ustate,passcode:upass,theset:set},
      		function(data)
         	{
				if (data == 1){
					$("#status-"+set).html("<h3>Thank You!</h3><p>We have sent an email confirmation to the address you supplied ("+uemail+"). Click the link in that email to verify the validity of your digital existence to be rewarded with high quality digital sounds for repeated playback.</p>");
				} else if (data == 2){
					$("#status-"+set).html("<h3>Enrollment Verified</h3><p>Your enrollment has been verified. Please feel free to download this release by left-clicking <a href=\"http://www.howibecamethebomb.com/email/success.php?x="+uemail+"\" target=\"_blank\">this link</a>.</p>");
				} else if (data == "X"){
					$("#status-"+set).html("<h3>Download Denied.</h3><p>Your advance download credenitials did not match our requirements. Please revisit when the album is officially available.</p>");
				} else {
					$("#status-"+set).html("<p>Sorry but there seems to have been a serious error. Please try again later."+data+"</p>");
				}
        	});

	} else {
		alert(err);
	}

}
function viewAlbum(id){
	// if album being viewed, reset it
	if (activeAlbum){
		$("#album-"+activeAlbum).animate({
			marginTop:0
		}, 800);
		$("#releases"+activeAlbum).removeClass("active");
		$("body").removeClass(albumSEO[activeAlbum-1]);
		if (activeSignup){
			$("#album-"+activeAlbum + " .info").slideToggle();
			activeSignup ="";
		}
	}
	if (activeVideo){
		$(activeVideo).animate({
			height: 0
		}, 400);
	}
	// determine X position of slideContainer
	xDest = ((id-1)*mainWidth)*-1;
	// move container
	$("#slideContainer").animate({ 
        marginLeft: xDest,
		marginTop: 0
      }, 800);
	// make sure releases is proper height
	if (id == 8){
		$("#releases").animate({
			height: largeHeight
		}, 800);
	} else {
		$("#releases").animate({
			height: mainHeight
		}, 800);
	}
	// set bottom nav active class
	$("#releases"+id).addClass("active");
	$("body").addClass(albumSEO[id-1]);
	// set active to new value
	activeAlbum = id;
	
	// swf address
	var newTitle = mainTitle + " - " + $("#releases"+id).attr('title');
	var newAddress = "/"+albumSEO[id-1];
	SWFAddress.setValue(newAddress);
	SWFAddress.setTitle(newTitle);
}
function viewVideo(albumId, videoId){
	$("#album-"+albumId).animate({
		marginTop: 0
	}, 800);
	$("#video-"+albumId+"-"+videoId).css("display","block");
	$("#video-"+albumId+"-"+videoId).animate({
		height: subHeight,
		marginTop: 0
	}, 800);
	$("#releases").animate({
			height: mainHeight
		}, 800);
	
	// hide releases
	$("#releasesList").hide();
	$("#backButton").show();
	activeVideo = "#video-"+albumId+"-"+videoId;
	jsStopAudio();
}
function closeVideo(){
	// show releases
	$("#releasesList").slideDown();
	$("#backButton").slideUp();
	
	$(activeVideo).animate({
			height: 0
		}, 400, function(){ $(activeVideo).hide(); activeVideo=""; });
	
	
	if (activeAlbum == 8){
		$("#releases").animate({
			height: largeHeight
		}, 800);	
		
	}
}