function toggle_audio(str)
{
	if (str == "muted")
	{
		$(".mute").addClass('mute_toggle');
	}
	else if (str == "unmuted")
	{
		$(".mute").removeClass('mute_toggle');
	}
}

function openLink(url)
{
	$.address.value(url);
	$.scrollTo("#top");
}

function video_link_click(video)
{
	var new_title;
	
	if (video == "THE TRAILER")
	{
		new_title = "The Trailer - The Burning Question";
	}
	else if (video == "A NEED FOR CHANGE")
	{
		new_title = "A Need for Change - The Burning Question"
	}
	else if (video == "THE QUESTION REVEALED")
	{
		new_title = "The Question Revealed - The Burning Question"
	}
	else if (video == "A NEW WAY")
	{
		new_title = "A New Way - The Burning Question";
	}
	else if (video == "THE PAYOFF")
	{
		new_title = "The Payoff - The Burning Question";
	}
	
	$('#actual_content').html("");
	$('#content_overlay').fadeOut();
	$.address.value("/");
	$.address.title(new_title);
	
	obj = swfobject.getObjectById("Application");
	if (obj) {
		obj.play();
	}
}

function tooltip_hover_over()
{
	$("#what_is_tooltip").show();
	$(".tip_toggle").toggleClass("tip_on");
}

function tooltip_hover_out()
{
	$("#what_is_tooltip").hide();
	$(".tip_toggle").toggleClass("tip_on");
}

$(document).ready(function() {
	
	$(".script").click(function() {
		window.open($(this).attr("href"), "newWin", "status = 1, height = 500, width = 675, scrollbars = 1, resizeable = 1");
		return false;
	});
		
	// $("#header ul li.tip_hover").mouseover(function() {
	// 	$("#what_is_tooltip").show();
	// 	$(".tip_toggle").toggleClass("tip_on");
	// });
	// 
	// $("#header ul li.tip_hover").mouseout(function() {
	// 	$("#what_is_tooltip").hide();
	// 	$(".tip_toggle").toggleClass("tip_on");
	// });
	
	var config = {
		over: tooltip_hover_over,
		timeout: 5,
		out: tooltip_hover_out
	};
	
	$("#header ul li.tip_hover").hoverIntent(config);
	
	$("#what_is_tooltip p a").click(function() {
		obj = swfobject.getObjectById("Application");
		if (obj) {
			obj.pause();
		}
		$("#what_is_tooltip").hide();
		$.address.value($(this).attr('href'));
		$.address.title("Explore Marketing with Meaning - The Burning Question");
		$.get('/pages/marketing-with-meaning.page.php', function(data) {
			$('#actual_content').html(data);
			$('#content_overlay').fadeIn();
		});
		return false;
	});
	
	$(".contact").click(function() {
		var content = $("#contact_form").length;
		if (!content) {
			obj = swfobject.getObjectById("Application");
			if (obj) {
				obj.pause();
			}
			$.address.value($(this).attr('href'));
			$.address.title("Contact Us - The Burning Question");
			$.get('/pages/contact-us.page.php', function(data) {
				$('#actual_content').html(data);
				$('#content_overlay').fadeIn();
			});
		}		
		return false;
	});
	
	$("body").delegate("#submit", "mouseover", function(){
		$(this).attr("src", "/img/contact/btn_send_over.jpg");
	});
	
	$("body").delegate("#submit", "mouseout", function(){
		$(this).attr("src", "/img/contact/btn_send_off.jpg");
	});
	
	$("body").delegate(".overlay_link", "click", function(){
		obj = swfobject.getObjectById("Application");
		if (obj) {
			obj.pause();
		}
		var href = $(this).attr('href');
		$.address.value($(this).attr('href'));
		$.get('/pages'+$(this).attr('href')+'.page.php', function(data) {
			$('#actual_content').html(data);
			$('#content_overlay').fadeIn();
		});		
		return false;
	});
	
	$("body").delegate("#overlay_close a, .close_thanks, #back_to_home", "click", function(){
		$('#actual_content').html("");
		$('#content_overlay').fadeOut();
		$.address.value("/");
		$.address.title("The Burning Question");
		obj = swfobject.getObjectById("Application");
		if (obj) {
			obj.play();
		}
		
		return false;
	});
	
	$(".mute").click(function() {
		obj = swfobject.getObjectById("Application");
		if ($(".mute").hasClass('mute_toggle'))
		{
			if (obj) {
				obj.unmute();
				$(".mute").removeClass('mute_toggle');
			}
		}
		else
		{
			if (obj) {
				obj.mute();
				$(".mute").addClass('mute_toggle');
			}
		}
	});
	
	$("body").delegate(".show_form_again", "click", function(){
	
		$("input, textarea").each(function() {
			$(this).val('');
		});
	
		$("#form_toggle").toggle();
		$("#thanks_toggle").toggle();
		
		return false;
	});
	
	$.address.change(function(event) {
		var url_to_share = "http://"+window.location.hostname+event.value;		
		
		if (event.value != "")
		{
			if (event.value == "/") {
				obj = swfobject.getObjectById("Application");
				if (obj) {
					obj.play();
				}
			} else {
				obj = swfobject.getObjectById("Application");
				if (obj) {
					obj.pause();
				}
			}
			
			$.get('/pages'+event.value+'.page.php', function(data) {
				$('#actual_content').html(data);
				$('#content_overlay').fadeIn();
				
				// change page title based on url
				if (event.value == "/") {
					$.address.title("The Burning Question");
				} else if (event.value == "/meet-jim-stengel-and-bob-gilbreath") {
					$.address.title("Meet Jim Stengel and Bob Gilbreath - The Burning Question");
					// add custom scrollbars to bio sections
					$(".bio_main").jScrollPane();
				} else if (event.value == "/marketing-with-meaning") {
					$.address.title("Explore Marketing with Meaning - The Burning Question");
				} else if (event.value == "/possible-worldwide") {
					$.address.title("Evolve with Possible Worldwide - The Burning Question");
				} else if (event.value == "/contact-us") {
					$.address.title("Contact Us - The Burning Question");
				}
			});
		}
    });
});

