search = function(url)
{
    var keyword = $('txtKeyword').value;
    keyword = keyword.replace(/</g, "");
    keyword = keyword.replace(/>/g, "");
    keyword = keyword.replace(/\?/g, "");
    keyword = keyword.replace(/\!/g, "");
    keyword = keyword.replace(/\"/g, "");
    keyword = keyword.replace(/\\/g, "");
    keyword = keyword.replace(/\[/g, "");
    keyword = keyword.replace(/\]/g, "");
    //alert(keyword);
    location.href = url + '/search.aspx?q=' + keyword;
}

// Sets the value for the keyword search textfield on various user events
var keywordSearchInput =
{
	init : function()
	{
		var smartKeyword = $('txtKeyword');
		if (smartKeyword)
		{
			smartKeyword.value = "Find TV Program...";
			
			smartKeyword.observe("click",keywordSearchInput.click);
			smartKeyword.observe("blur",keywordSearchInput.blur);
			
			smartKeyword.value = "Find TV Program...";
		} 
	},
	click : function()
	{
		var smartKeyword = $('txtKeyword');
		if (smartKeyword.value == "Find TV Program...")
		{
		smartKeyword.value = "";
		}
	},
	blur : function()
	{
		var smartKeyword = $('txtKeyword');
		if (smartKeyword.value == "" || smartKeyword.value == " ")
		{
			smartKeyword.value = "Find TV Program...";
		}
	}
};



showMastheadAdvertising = function()
{
	var selectorID = 'masthead-advertising';
	if ($(selectorID)!=null)
	{
		$(selectorID).style.display = "block";
	}
}

showMPUAdvertising01 = function()
{
	var selectorID = 'mpu-advertising-01';
	if ($(selectorID)!=null)
	{
		$(selectorID).style.display = "block";
	}
}

showFooterAdvertising = function()
{
	var selectorID = 'footer-advertising';
	if ($(selectorID)!=null)
	{
		$(selectorID).style.display = "block";
	}
}

// Attach functions to window onload
// ----------------------------------------------
//Event.observe(window,'load',applyViewportClass);

document.observe("dom:loaded",keywordSearchInput.init);

Event.observe(window,'load',showMastheadAdvertising);
Event.observe(window,'load',showMPUAdvertising01);
Event.observe(window,'load',showFooterAdvertising);


