// JavaScript Document

// AJAX INIT STUFF -- START
var xmlhttp=null;


try
{
	xmlhttp = new XMLHttpRequest();
}
catch (error)
{
	try
	{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch (error)
	{
		xmlhttp = null;
	}
}
//  END


function clearInput(input, defaultValue){ //alert(input.value);
	input.style.color = 'black';
	input.style.fontStyle = 'normal';
	input.style.fontWeight = 'normal';
	if(input.value == defaultValue){
		input.value = '';
	}
}

function resetInput(input, defaultValue){ //alert(input.value);
	if(input.value == ''){
		input.value = defaultValue;
		input.style.color = '#999';
		input.style.fontStyle = 'italic';
	}
}

function checkForm(){
	var passedCheck = true;
	var name = document.getElementById('name').value;
	var email = document.getElementById('email').value;
	
	name = jQuery.trim(name);
	email = jQuery.trim(email);
	
	if(name == '' || name == 'Name'){
		document.getElementById('name').style.color = 'red';
		document.getElementById('name').style.fontWeight = 'bold';
		passedCheck = false;
	}else{
		document.getElementById('name').style.color = '#999';
		document.getElementById('name').style.fontWeight = 'normal';
	}
	
	if(email == '' || email == 'Email Address'){
		document.getElementById('email').style.color = 'red';
		document.getElementById('email').style.fontWeight = 'bold';
		passedCheck = false;
	}else{
		document.getElementById('email').style.color = '#999';
		document.getElementById('email').style.fontWeight = 'normal';
	}
	
	return passedCheck; }

function sendform(){
	var formvars = $("#mlform").serialize();
	
	if(checkForm()){
		xmlhttp.open("GET", "ajaxHandler.php?action=mailinglist&" + formvars + "&time=" + new  Date().getTime());
		xmlhttp.onreadystatechange = function(){
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
				var response = xmlhttp.responseText; //alert(response);
				document.getElementById('mlform').innerHTML = '<p style="text-align:center"><br /><br /><em><strong>Thank you for joining our mailing list.</strong></em><br><br><br><br>&nbsp;</p>';
			}
		}
		//setTimeout("contactForm('up')",2500);
		xmlhttp.send(null);
	}
	
	return false; }

function showCD(){
	$('a.2009-cd').click( function (){
		$('#musicplayer').css('display','block');
		$('div.2008-cd').fadeOut('medium', function (){
			$('div.2009-cd').fadeIn('medium');
		});
	});
	
	$('a.2008-cd').click( function (){
		$('#musicplayer').css('display','block');	
		$('div.2009-cd').fadeOut('medium', function (){
			$('div.2008-cd').fadeIn('medium');
		});
	});
}

var player = null;
function playerReady(thePlayer) {
	player = window.document[thePlayer.id];
}


function play(file){
	player.sendEvent('LOAD','/CDs/'+file);
	player.sendEvent("PLAY");
}

$(function(){
	playerReady('player');
	showCD();
	
	$("ul#ticker01").liScroll();
	
	$('#slideshow').cycle({ 
    fx: 'fade', 
    timeout: 6000, 
    delay:  -2000 
	});
}); 