google_ad_client = "pub-0625475070077439";
google_ad_slot = "1180154240";
google_ad_width = 728;
google_ad_height = 90;


$(document).ready(function()
	{
	$('#btn_Go').click(function()
		{
		if (checkSearchForm(MSG_WHAT,MSG_WHERE))
			searchSubmit();
		});
	
	
	initiate_fields(MSG_WHAT,MSG_WHERE);
	var o = $('#search')[0];
	if(o.setSelectionRange) // DOM
		{ setTimeout(function(){ o.value = MSG_WHAT; o.setSelectionRange(0,0); }, 4); }
	else if(o.createTextRange) // IE
		{
		o.value = MSG_WHAT;
		var r = o.createTextRange();
		r.moveStart('character', 0);
		r.collapse();
		r.select();
		}
	

	$("#catTabs").html('<ul><li style="width:130px;"><a id="popularCLink" href="/inc/homeTabHeadings.php?src=popular"><span>Popular headings</span></a></li><li style="width:130px;"><a id="allCLink" href="/inc/homeTabHeadings.php?src=all"><span>A-Z (all headings)</span></a></li></ul>');

	var tabWidth = 0;
	$("#catTabs").tabs({
		fx: { opacity: 'toggle', duration: 100 },
		select: function(e, ui) { tabWidth = $(ui.tab).css("width"); },
		spinner: function() { return '<div style="width:'+ tabWidth +'; height:15px; text-align:center;"><img border="0" src="/img/icons/ajax-loader-fb.gif"></div>'; }
		});

	
	$("#catDropLink").click(function()
		{
		if ($("#catDrop").css('display')=='none')
			{
			$("#catDrop").show("fast");
			$("#homeMid").css('top','553px');
			$(".subSearchInner").css('height','933px');
			}
		else
			{
			$("#catDrop").hide("fast");
			$("#homeMid").css('top','320px');
			$(".subSearchInner").css('height','700px');
			}
		});	
	
	$("#popularCLink").click(function()
		{
		if ($("#ui-tabs-9").attr('class'))
			{
			if ($("#ui-tabs-9").attr('class').indexOf("ui-tabs-hide")!='-1')
				$("#catDropWait").show();
			}
		});
	
	$("#allCLink").click(function()
		{
		if ($("#ui-tabs-20").attr('class'))
			{
			if ($("#ui-tabs-20").attr('class').indexOf("ui-tabs-hide")!='-1')
				$("#catDropWait").show();
			}
		});

	$("#catDropClose").click(function()
		{
		$("#catDrop").hide("fast");
		$("#homeMid").css('top','320px');
		$(".subSearchInner").css('height','700px');
		});
	
	
	if (!$.browser.msie)
		{
		$('#blooDood').flash(
			{ src: 'Bloo_Dude_All.swf', width: 128, height: 180, wmode: 'transparent' },
			{ version: 9, expressInstall: true }
			);
		}
	
	$("#iphoneLink").click(function()
		{
		pageTracker._trackPageview('/iphone/home_page-iphone_link'); // log the click with Google
		});
	
	$("#coolLink").click(function()
		{
		pageTracker._trackPageview('/iphone/home_page-coolStuff_link'); // log the click with Google
		});
	
	
	$(".homeBanner a").click(function()
		{
		var trackVar = $(this).attr('rel');
		pageTracker._trackPageview(trackVar); // log the click with Google
		});


	var $weather = $('<div id="weatherFC" title="Your Temperature Forecast (Celcius)"></div>')
		.dialog({
			autoOpen: false,
			modal: true,
			resizable: false,
			height: 190,
			width: 370
		});

	$('#weatherLnk').click(function(evt)
		{
		evt.preventDefault();
		var yw_today = $("#yw_forecast_today").val().split('|');
		var yw_tomoz = $("#yw_forecast_tomoz").val().split('|');

		var yw_html = '<h3 style="text-align:center; margin-bottom:7px;">Two Day Report</h3>';
		yw_html += '<img style="display:inline; float:left; padding-right:10px;" src="http://l.yimg.com/a/i/us/we/52/' + yw_today[4] + '.gif" /><p style="margin:0; height:52px; padding-top:10px;">Today (' + yw_today[0] + ')<br/><strong>' + yw_today[1] + '. High: ' + yw_today[2] + ', Low: ' + yw_today[3] + '</strong></p>';
		yw_html += '<img style="display:inline; float:left; padding-right:10px;" src="http://l.yimg.com/a/i/us/we/52/' + yw_tomoz[4] + '.gif" /><p style="margin:0; height:52px; padding-top:10px;">Tomorrow (' + yw_tomoz[0] + ')<br/><strong>' + yw_tomoz[1] + '. High: ' + yw_tomoz[2] + ', Low: ' + yw_tomoz[3] + '</strong></p>';

		$weather.dialog('open');
		$("#weatherFC").html(yw_html);

		$.ajax({
			type: "POST",
			url: "/inc/log_general.php",
			data: "log_type=7&src=weather-forecast_link"
			});
		});


	//$(".popularList").load('/inc/homePopularHeadings.php?mode=AJAH');

	var $homeVideo = $('<div id="videoTarget"></div>')
		.dialog({
			autoOpen: false,
			modal: true,
			resizable: false,
			width: 515,
			height: 450
		});

	$("#homeVideo").click(function()
		{
		$homeVideo.dialog('open');
		$("#ui-dialog-title-videoTarget").text('bloo Tutorial - Perth, WA');
		$("#videoTarget").html('<div style="position:absolute; top:45px; left:15px;  border:1px solid #eee; -moz-border-radius:5px; -webkit-border-radius:5px; padding:3px; background-color:#F2F2F2; height:397px; width:480px;"><embed height="397" width="480" type="application/x-shockwave-flash" allowfullscreen="true" src="http://www.youtube.com/v/NNftXy_xoaU?fs=1&hd=1&showinfo=0"></div>');
		});


	$('#radioTarget')
		.dialog({
			autoOpen: false,
			modal: true,
			resizable: false,
			width: 365,
			height: 55
		});

	$('#homeRadio').live('click', function()
		{
		$('#radioTarget').dialog('open');

		// log the click...
		$.ajax({
			   type: "POST",
			   url: "/inc/log_general.php",
			   data: "log_type=1&co_id=001&src=home"
			});

		$("#ui-dialog-title-radioTarget").text("bloo's award winning radio jingle!");
		$('#waspTarget1').show();
		});

	wasp("1", "000000", "340", "23", "/media/plugs/radio_ad.mp3", "", "/media/plugs/waspResults.xml" );

	});
