$( function () {
	$('marquee').marquee();
});

function PlayRelatedVideo(video)
{
	if (isInteger(video) || video.substr(0,3) == 'ka:')
	{
		if((window.location+"").indexOf("onntv")> 0)
		{
			// NEW MAVEN VIDEO LINK USING ONN LARGE PLAYER
			window.open('http://www.10tv.com/live/content/video/onn.html?referralObject=' + video, '', 'left=20,top=20,width=1000,height=592,status=0,toolbar=0,resizable=0,scrollbars=0,location=0');
		}
		else
		{	
			// NEW MAVEN VIDEO LINK USING 10TV LARGE PLAYER
			window.open('http://www.10tv.com/live/content/video/10tv.html?referralObject=' + video, '', 'left=20,top=20,width=1000,height=592,status=0,toolbar=0,resizable=0,scrollbars=0,location=0');
		}
	}
	else
	{
		// OLD STYLE PREP VIDEO LINK
		window.open('http://wwwphp.10tv.com/vplayer.php?clip=' + video,'mywindow','width=760,height=520')
	}
}

function isInteger(iString) {
    return (("" + parseInt(iString)) == iString);
}

function ShowRelatedSlideshow(slideshow)
{
	// TEMPORARY FIX FOR CRT ISSUE
	if (slideshow.substring(11,0) == '/sites/10tv')
	{
		slideshow = "/" + slideshow.substring(12,slideshow.length);
	}

	// NORMAL SLIDESHOW REDIRECTS
	if (slideshow.substring(13,0) == '/picturethis/')
	{
		//THIS IS FOR LINKS OFF TO PICTURE THIS SLIDESHOWS
		window.location = 'http://picturethis.10tv.com/' + slideshow.substring(13,slideshow.length);
	}
	else
	{
		if (slideshow.substring(5,0) == '/live')
		{
			//THE URL STARTS WITH LIVE SO IT SHOULD BE CORRECT AS IS
			window.location = slideshow;
		}
		else
		{
			if (slideshow.substring(10,0) == '/contentbe')
			{
				//THIS IS A CONTENTBE LINK
				window.location = '/live' + slideshow;
			}
			else
			{
				//THIS IS AN EPIC QUALIFIED PATH SO ADD /LIVE/CONTENT
				window.location = '/live/content' + slideshow;
			}
		}
	}
}

function openWindow()
{
	var thePath = window.location.pathname;
	var emailURL = "/live/foundation/email_form.jsp?story=" + thePath + "&storytitle=VGhlIENvbHVtYnVzIERpc3BhdGNoIDogMTBUVg==";
	window.open(emailURL,'mywindow','width=800,height=700')
}

function showClosingsAlertBar()
{
  try
  {
  if (getNumberOfSchoolClosings() > 0)
    {
      document.write('<h1 class="alert-bar">Closings and Delays: <a href="/live/content/onnweather/closings.html">' + getNumberOfSchoolClosings() + ' Current Listing(s)</a></h1>');
    }
  }
  catch (Exception)
  {
     // THE SCHOOL CLOSINGS BAR WAS NOT LOADED CORRECTLY, JUST IGNORE
  }
}

/* 10TV WEATHER RELATED PAGES */
function weather_gotoHour(clickedElement)
{
	//HIDE EVERYTHING
	document.getElementById('hr1').style.display = "none";
	document.getElementById('hr2').style.display = "none";
	document.getElementById('hr3').style.display = "none";
	document.getElementById('hr4').style.display = "none";
	document.getElementById('hr5').style.display = "none";
	document.getElementById('hr6').style.display = "none";
	document.getElementById('now').style.display = "none";
	
	var conditionsTitleBar = document.getElementById('current-conditions-title');

	conditionsTitleBar.innerHTML="Conditions at: " + clickedElement.innerHTML;

	//SHOW SELECTED DIV
	var selectedHour = clickedElement.id;
	if (selectedHour == 'navhr1')
	{
		document.getElementById('hr1').style.display = "block";
	}
	if (selectedHour == 'navhr2')
	{
		document.getElementById('hr2').style.display = "block";
	}
	if (selectedHour == 'navhr3')
	{
		document.getElementById('hr3').style.display = "block";
	}
	if (selectedHour == 'navhr4')
	{
		document.getElementById('hr4').style.display = "block";
	}
	if (selectedHour == 'navhr5')
	{
		document.getElementById('hr5').style.display = "block";
	}
	if (selectedHour == 'navhr6')
	{
		document.getElementById('hr6').style.display = "block";
	}

}

function weather_gotoNow()
{
	//HIDE EVERYTHING
	document.getElementById('hr1').style.display = "none";
	document.getElementById('hr2').style.display = "none";
	document.getElementById('hr3').style.display = "none";
	document.getElementById('hr4').style.display = "none";
	document.getElementById('hr5').style.display = "none";
	document.getElementById('hr6').style.display = "none";
	document.getElementById('now').style.display = "block";
	
	var conditionsTitleBar = document.getElementById('current-conditions-title');

	conditionsTitleBar.innerHTML="Current Conditions";
}

                function getToolHook()
                {
                        var a = document.getElementsByTagName("A");
                        //FORCE ONN LINKS BACK TO ONN WRAP
                        for(var i=0;i<a.length;i++)
                        {
                                if (EPIC_siteSection == 'onnbusiness')
                                {
                                        a[i].href = a[i].href.replace("/content/business/","/content/onnbusiness/");
                                }
                                if (EPIC_siteSection == 'onnsports')
                                {
                                        a[i].href = a[i].href.replace("/content/sports/","/content/onnsports/");
                                }
                                if (EPIC_siteSection == 'onnentertainment')
                                {
                                        a[i].href = a[i].href.replace("/content/entertainment/","/content/onnentertainment/");
                                }
                                if (EPIC_siteSection == 'onnhealth')
                                {
                                        a[i].href = a[i].href.replace("/content/health/","/content/onnhealth/");
                                }
                                if (EPIC_siteSection == 'onncontests')
                                {
                                        a[i].href = a[i].href.replace("/content/contests/","/content/onncontests/");
                                }
                                if (EPIC_siteSection == 'onntravel')
                                {
                                        a[i].href = a[i].href.replace("/content/tavel/","/content/onntravel/");
                                }
                        }
                }

function showTab(tabName, className) {
 //HIDE ALL TAB CONTENT
 $('.' + className + '-content').css('display','none');
 //var tabContainers = document.getElementsByClassName(className + '-content');
 //for (var i = 0; i < tabContainers.length; i++) {
 //tabContainers[i].style.display = "none";
 //}

 try {
 //UNSELECT CURRENT TAB
 $('.' + className + '-selected').removeClass().addClass(className);
 //document.getElementsByClassName(className + '-selected')[0].className = className;
 } catch(err) {
 //ASSUME THERE WAS NO SELECTED TAB
 }

 //SELECT NEW TAB
 document.getElementById(tabName + '-tab').className = className + '-selected';

 //DISPLAY SELECTED TAB
 document.getElementById(tabName + '-tab').className = className + '-selected';
 document.getElementById(tabName).style.display = "block";
}