function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}
function mainmenu(){
	$(" #nav ul.horisontalNav ").css({display: "none"}); // Opera Fix
	$(" #nav li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(200);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
	});
}
function clearSearch()
{
	document.getElementById('searchWord').value = '';
}

function addSearchTxt()
{
	var srchFld = document.getElementById('searchWord').value;
	var srchFor = document.getElementById('searchFor').value;
	if (srchFld == '')
	{
		if (srchFor == 'recipe'){
			document.getElementById('searchWord').value = 'search for recipe';
		}else{
			document.getElementById('searchWord').value = 'search for show';
		}
	}
}
function clearEatOut()
{
	document.getElementById('SuburbPostcode').value = '';
}

function addEatOut()
{
	var srchFld = document.getElementById('SuburbPostcode').value;
	if (srchFld == '')
	{
		document.getElementById('SuburbPostcode').value = 'Suburb or Postcode';
	}
}

function clearNLName()
{
	document.getElementById('Name').value = '';
}

function addNLName()
{
	var srchFld = document.getElementById('Name').value;
	if (srchFld == '')
	{
		document.getElementById('Name').value = 'Name';
	}
}
function clearNLEmail()
{
	document.getElementById('Email').value = '';
}

function addNLEmail()
{
	var srchFld = document.getElementById('Email').value;
	if (srchFld == '')
	{
		document.getElementById('Email').value = 'Email';
	}
}


function showNow()
{
	$("#tabs-1").show();
	$("#tabs-2").hide();
	$("#tabs-3").hide();
	$("img#ShowNow").attr("src","/images/site/buttons/nowActive-BTN.gif"); 
	$("img#ShowNext").attr("src","/images/site/buttons/nextInActive-BTN.gif"); 
	$("img#ShowSoon").attr("src","/images/site/buttons/soonInActive-BTN.gif"); 
}
function showNext()
{
	$("#tabs-1").hide();
	$("#tabs-2").show();
	$("#tabs-3").hide();
	$("img#ShowNow").attr("src","/images/site/buttons/nowInActive-BTN.gif"); 
	$("img#ShowNext").attr("src","/images/site/buttons/nextActive-BTN.gif"); 
	$("img#ShowSoon").attr("src","/images/site/buttons/soonInActive-BTN.gif"); 
}
function showSoon()
{
	$("#tabs-1").hide();
	$("#tabs-2").hide();
	$("#tabs-3").show();
	$("img#ShowNow").attr("src","/images/site/buttons/nowInActive-BTN.gif"); 
	$("img#ShowNext").attr("src","/images/site/buttons/nextInActive-BTN.gif"); 
	$("img#ShowSoon").attr("src","/images/site/buttons/soonActive-BTN.gif"); 
} 
function showSearchRecipes()
{
	$("li#recipeItem").addClass("uRhere");
	$("a#recipeLink").addClass("uRhere");
	$("li#showItem").removeClass("uRhere");
	$("a#showLink").removeClass("uRhere");
	$("#searchFor").val("recipe");
	$("#searchWord").val("search for recipe");
}
function showSearchShows()
{
	$("li#recipeItem").removeClass("uRhere");
	$("a#recipeLink").removeClass("uRhere");
	$("li#showItem").addClass("uRhere");
	$("a#showLink").addClass("uRhere");
	$("#searchFor").val("show");
	$("#searchWord").val("search for show");
}

var whatsOnTimer;
var currentShow = 1;

function whatsOnOnClick(showid)
{
	currentShow = showid;
	clearInterval(whatsOnTimer);
	switchShow(currentShow);
	whatsOnTimer = setInterval("getShowId()", 10000);
}

function getShowId()
{
	currentShow++;										
	if (currentShow > 3)	currentShow = 1;
	switchShow(currentShow);
}
function switchShow(showid)
{
	switch (showid)
	{
		case 1: showNow(); break;
		case 2: showNext(); break;
		case 3: showSoon(); break;
	}
}


var topStoryTimer;
var currentStory = 1;

function topStoryOnClick(storyid)
{
	currentStory = storyid;
	clearInterval(topStoryTimer);
	switchStory(currentStory);
	topStoryTimer = setInterval("getStoryId()", 10000);
}

function getStoryId()
{
	currentStory++;										
	if (currentStory > 6)	currentStory = 1;
	switchStory(currentStory);
}
function switchStory(storyid)
{
	$("ul.topStoryHeaders").children(".topStoryURhere").addClass("topStoryLink");
	$("ul.topStoryHeaders").children(".topStoryURhere").removeClass("topStoryURhere");
	$("li#storyHeader"+storyid).removeClass("topStoryLink");
	$("li#storyHeader"+storyid).addClass("topStoryURhere");
	$("div.picHolder > img").hide();
	$("#topStoryImage"+storyid).show();
	$("div.topStoryDescription > p").hide();
	$("#topStoryDesc"+storyid).show();
}

$(document).ready(function(){
	topStoryTimer = setInterval("getStoryId()", 10000);
	whatsOnTimer = setInterval("getShowId()", 10000);
	correctPNG();
	mainmenu();
	showSearchRecipes();
});
