var g = {
	
	listenTrigger: 'listenPlayer',
	listenAudioTrigger: 'listenAudio'
};

var gfn = {
	setWidthClass : function() { // tied to php setting vars on load
			if (screen.availHeight > 768) {
				$(document.body).removeClass('w1024').addClass("w1280");
			}
	}
}
// INITIALIZATION ***********************************
jQuery(function($) {

$(document.body).removeClass("jsOff").addClass("jsOn");
gfn.setWidthClass();

$('#contLeft p:first').addClass('first');
if (getBodyId()==='contact') {
		$('noscript').remove();	 
		prepareContactForm();
	}
$('a[href]').each( function() { 
	var t = $(this);
	if (t.parent().hasClass(getBodyId())) { 
		t.removeAttr('href'); 
	}
});
if (document.getElementById(g.listenTrigger)) {
swfobject.embedSWF("alla.swf", "listenPlayer", "100", "40", "8.0.0","expressInstall.swf", {}, {wmode: "transparent"});
}
if (document.getElementById(g.listenAudioTrigger)) {
swfobject.embedSWF("audio/alla1.swf", "listenAudio", "100", "40", "8.0.0","expressInstall.swf", {}, {wmode: "transparent"});
}
});//end init
// FUNCTIONS ***********************************

//GENERAL HELPER FUNCTIONS
function prepareContactForm() {

	if (jQuery.browser.msie) {
		$('#amcf_submitBtn').hover(function() { 
		$(this).toggleClass("over"); },function() {
		$(this).toggleClass("over"); });
		$('input').focus(function() {$(this).addClass('ieFocus')});
		$('input').blur(function() {$(this).removeClass('ieFocus')});
		$('textarea').focus(function() {$(this).addClass('ieFocus')});
		$('textarea').blur(function() {$(this).removeClass('ieFocus')})
	};
		$("#amcf_name, #amcf_note, #amcf_email").focus( function() { 
			if($(this).next().is(':visible')) { $(this).next().hide('slow')}
		});
		var options = { 
		beforeSubmit: validate, 
		success: showResponse 
		};
		$('#am_cf').ajaxForm(options);
};

function validate(formData, jqForm, options) { 
	var form = jqForm[0];
	var err= false;
	if (!form.amcf_name.value) { $("#amcf_nameErr").show(); err = true;}
	if (form.amcf_note.value.length<6) { $("#amcf_noteErr").show(); err = true;}
	if (emailCheck(form.amcf_email.value)) { $("#amcf_emailErr").show(); err = true; }
	if (err) return false;
};

function showResponse()  {
	$('#am_cf').unbind('submit'); $('#amcf_submitBtn').unbind('click');
	$('#am_cf').hide('slow',function() {
		$('div.amcf_response').fadeIn('slow');
	});
};
function emailCheck(value) {
	return !value.match(/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i);
};
function getBodyId() {
		return document.body.getAttribute('id');
	};
