$(document).ready(function() {

gPageTitle = $("title").html();
 $("object").live("mouseenter mouseleave mousedown mouseup",function(){
      document.title = gPageTitle;
 }); 

// Harvest login:

$('#harvestlogin').submit(function(){
		doLogin();
		return false;
	});

function doLogin()
	{	
		var username = $('#usernameTextBox').val();
		var password = $('#passwordTextBox').val();
	
		if (username == '' || username == 'username') { alert('Please enter a valid username'); return false; }
		if (password == '') { alert('Please enter a valid password'); return false; }
	
		var url = 'http://ws.harvestmedia.net/login.aspx';
		url += '?username=' + username;
		url += '&password=' + do_md5(password);
		url += '&acctid=' + $('#login_acctid').val();
		url += '&loginurl=http://www.boostmusic.com/invalid.php';
		//url += '&loginurl=' + this.location.href.replace(/\//g, '%2F');
		url += '&dt=' + new Date().getTime();
		//iframe[0].contentWindow.location.href = url;
		//alert(url);
		var player = window.open(url, 'boostmusic', 'height=773, width=980, resizable=no, toolbar=no, titlebar=no, scrollbars=yes, location=no, menubar=no');
		//alert(player);
		if (player)
		{
			player.focus();
		} else {
			//alert('f');	
		}

		return false;
	}

// Carousel: 

$("#carouselleft").CloudCarousel({			
			xPos: 128,
			yPos: 32,
			buttonLeft: $("#left-but"),
			buttonRight: $("#right-but"),
			mouseWheel:true,
			bringToFront:false});
	
$.ajax({
			type:'POST',
			url:'getFirstCarouselAlbum.php',
			success:function(data){
				//alert('DATA: '+data);
				$('#carouselright').html(data);
			}
  	    });

var wrapperHeight = $('#wrapper').height();
$('#wrapperleft').height(wrapperHeight);
$('#wrapperright').height(wrapperHeight);

$('.cloudcarousel').hover(function(){
	$(this).css('cursor','pointer');},
	function(){$(this).css('cursor','auto');});

$('.cloudcarousel').click(function(){
	var id = $(this).attr('id');
	$.ajax({
			type:'POST',
			url:'getCarouselAlbum.php',
			data:{'id':id},
			success:function(data){
				//alert('DATA: '+data);
				$('#carouselright').html(data);
			}
  	    });
});

$('#newsletterform').submit(function(){
	var email = $('#newsletteremail').val();
	$.ajax({
			type:'POST',
			url:'notifyNewsletterSubmit.php',
			data:{'email':email},
			success:function(data){
				alert('Thank you - you have been added to the mailing list.');
				$('#newsletteremail').val('');
			}
  	    });
	return false;
});

});


