function newJukebox(targ, movie, clip, dir, src) {
	var so = new SWFObject("/assets/swf/player.swf", movie, "166", "19", "8", "#FFFFFF");
	so.addVariable("movie", movie);
	so.addVariable("clip", clip);
	so.addVariable("src", "/content/"+dir+"/audio/"+src+".mp3");
	so.addParam("scale", "noscale");
	so.addParam("wmode", "transparent");
	so.addParam("menu", "false");
	so.write(targ);
}
function getFlashMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}
function stopAudio(movie) {
	if (swfs.length > 0) {
		for (i = 0; i < swfs.length; i++) {
			if (movie != swfs[i]) {
				getFlashMovie(swfs[i]).stopAllAudio();
			}
		}
	}
}
function trim(sStringToTrim) {
	//validate input value
	if (typeof(sStringToTrim) != "string") { return sTrimmedString; }

	//trim whitespaces
	var sTrimmedString = sStringToTrim.replace(/^\s*/, "");	//left side
	sTrimmedString = sTrimmedString.replace(/\s*$/, "");	//right side
	
	return sTrimmedString;
}

function submit_short_form() {
	$("#short_form button.get_started").text('sending...');
	$("#short_form input").each(function(){
		if ($(this).val() == $(this).attr('title')) {
			$(this).val('');
		}
	});
	$.ajax({
		type: "POST", 
		url: "/includes/helpers/jquery_short_form.php", 
		data: $("#short_form form").serialize(),
		dataType: "json", 
		success: function (data, textStatus) {
			if (data.errors) {
				$("#short_form button.get_started").text('get started!');
				$("input").removeClass('error');
				var errors = '<br />';
				for (i=0; i<data.errors.length; i++) {
					if (data.errors[i].display.length > 0) {
						$("#"+data.errors[i].input).addClass('error');
						errors = errors + '<p>'+data.errors[i].display+'</p>';
					}
				}
				$("#short_form_alert").html('Please correct errors in red:'+errors);
				if($("#short_form_alert").css('display') == 'none') {
					$("#short_form_alert").slideToggle();
				}
				$("#short_form input").each(function(){
					if ($(this).val() == '') {
						$(this).val($(this).attr('title'));
					}
				});
				return false;
			} else {
				window.location = "/get_started/thanks/";
				return true;
			}
		}
	});
}


function setCookie(c_name, value, expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

$(document).ready(function() {
	// Make Things Clickable
	$(".clickable").click(function(){
		var linkURL = $(this).children("a").attr("href");
		if(!linkURL) linkURL = $(this).children("div").children("a").attr("href");
			window.location.href = linkURL;
			return false;
	});
	
	// Text Counter
	if($("textarea.limit").length>0){
		$("textarea.limit").textlimit('p.counter span',parseFloat($('textarea.limit').attr('rel')));
	};
	
	//Fancybox
	$("a.terms").fancybox({ 
		'hideOnContentClick': false,
		'padding': 20,
		'overlay': true,
		'centerOnScroll': true,
		'frameWidth': 600
	});
	
		// TOGGLER	
	$(".toggler").click(function(){
		if ($('#'+$(this).attr("rel")).css('display')=='none') {
		//$(".toggled").hide();
		$('#'+$(this).attr("rel")).slideToggle("800");
		} else {
			$('#'+$(this).attr("rel")).slideToggle("800");
		}
		return false;
	});
	
	// show / enable Short Form
	window.setTimeout(function() {
		$('#short_form_wrap').slideToggle(500, function(){ 
		
			// show graphic
			$('#short_form_graphic').fadeIn('slow');
			
			// Short form close button
			$('.short_form_close').click(function(){
				$('#short_form_wrap').fadeOut();
				// set cookie to hide short form for 7 days
				setCookie('voice_short_form', 'hide', 7);
				return false;
			});
			
			// Short form input value handler
			$("#short_form input").focus(function(){
				if ($(this).attr('title') == $(this).val()) {
					$(this).val('');
				}
			}).blur(function(){
				if ($(this).val() == '') {
					$(this).val($(this).attr('title'));
				}
			});
			
		});
	}, 6000);
});