﻿
//NEWS TICKER
function startTicker() 
{ 
  // Define run time values 
  theCurrentStory     = -1; 
  theCurrentLength    = 0; 
  // Locate base objects 
  if (document.getElementById) {	 
          theAnchorObject     = document.getElementById("tickerAnchor"); 
          runTheTicker();   	 
       } 
  else { 
          document.write("<style>.ticki{display:none;}.ticko{border:0px; padding:0px;}</style>"); 
          return true; 
  } 
} 
// Ticker main run loop 
function runTheTicker() 
{ 
  var myTimeout;   
  // Go for the next story data block 
  if(theCurrentLength == 0) 
  { 
      theCurrentStory++; 
      theCurrentStory      = theCurrentStory % theItemCount; 
      theStorySummary      = theSummaries[theCurrentStory].replace(/&quot;/g,'"'); 
      theTargetLink        = theSiteLinks[theCurrentStory]; 
      theAnchorObject.href = theTargetLink; 
      theAnchorObject.target = theSiteTargets[theCurrentStory]; 
      thePrefix 	     = "<span class='tickls'>" + theLeadString + "</span>"; 
  } 
  // Stuff the current ticker text into the anchor 
  theAnchorObject.innerHTML = thePrefix +  
  theStorySummary.substring(0,theCurrentLength) + whatSideBar(); 
  // Modify the length for the substring and define the timer 
  if(theCurrentLength != theStorySummary.length) 
  { 
      theCurrentLength++; 
      myTimeout = theCharacterTimeout; 
  } 
  else 
  { 
      theCurrentLength = 0; 
      myTimeout = theStoryTimeout; 
  } 
  // Call up the next cycle of the ticker 
  setTimeout("runTheTicker()", myTimeout); 
} 
// SideBar generator 
function whatSideBar() 
{ 
  if(theCurrentLength == theStorySummary.length) 
  { 
      return theSideBarNone; 
  } 
  if((theCurrentLength % 2) == 1) 
  { 
      return theSideBarOne; 
  } 
  else 
  { 
      return theSideBarTwo;
   } 
}
//END NEWS TICKER


//jQuery


// Top Stories
$(document).ready(function() {
    $('#firstTab').attr('class', 'on');
    $('#firstForm').show();
    $('#secondForm').hide();
    $('#thirdForm').hide();

    $('#firstTab').click(function() {
        $('#secondForm').hide();
        $('#firstForm').show();
        $('#thirdForm').hide();
        $('#firstTab').attr('class', 'on');
        $('#secondTab').removeClass('on');
        $('#thirdTab').removeClass('on');
    });
    $('#secondTab').click(function() {
        $('#firstForm').hide();
        $('#secondForm').show();
        $('#thirdForm').hide();
        $('#secondTab').attr('class', 'on');
        $('#firstTab').removeClass('on');
        $('#thirdTab').removeClass('on');
    });
    $('#thirdTab').click(function() {
        $('#firstForm').hide();
        $('#secondForm').hide();
        $('#thirdForm').show();
        $('#thirdTab').attr('class', 'on');
        $('#firstTab').removeClass('on');
        $('#secondTab').removeClass('on');
    });
});
function fnOpen(obj) {
    document.getElementById('idHide' + obj).style.display = "block";
    document.getElementById('idShow' + obj).style.display = "none";
}
function fnClose(obj) {
    document.getElementById('idShow' + obj).style.display = "block";
    document.getElementById('idHide' + obj).style.display = "none";
}


$(document).ready(function () {
    //search enter fix
    var $btn = $('.form_submit');
    var $form = $btn.parents('#search');

    $form.keypress(function (e) {
        if (e.which == 13 && e.target.type != 'textarea') {
            if ($btn[0].type == 'submit')
                $btn[0].click();
            else
                eval($btn[0].href);
            return false;
        }
    });

    //print left
    $("#print").attr("href", "javascript:void( 0 )").click(function () {
        $("#cont_left").jqprint();
        return (false);
    });
        
});

//latest news 

var showLimit = 3;
var showMoreText = "Show more";
var showHideText = "Hide";

$(document).ready(function(){
	var totDiv = $('#mainTabDiv > div').size();
	var totP = $('#tabbedID p').length;
	$('#tabbedID').find('p').slice(showLimit,totP).hide();
	
	$('#tabButtonID a').click(function(){
		$('#tabbedID').find('p').slice(showLimit,totP).toggle(750);
		
		if($(this).html() == showMoreText)
		{
			$(this).html(showHideText);
			$(this).removeClass('showmore_btn');
			$(this).addClass('showmore_btnHide');
		}
		else
		{
			$(this).html(showMoreText);
			$(this).removeClass('showmore_btnHide');
			$(this).addClass('showmore_btn');
		}
	});
	
	$('#tabTitleID li').eq(1).click(function(){
		$(this).children('a').addClass('most_shared_active');
		$('#tabTitleID li').eq(0).children('a').removeClass('most_shared_active');
		$('#tabTitleID li').eq(2).children('a').removeClass('most_shared_active');
		
		for(var i=1; i<(totDiv-1) ; i++)
		{
			if(i == 2)
			{
				$('#mainTabDiv > div').eq(i).addClass('storiestxtarea');
				$('#mainTabDiv > div').eq(i).attr('id','tabbedID');
				$('#mainTabDiv > div').eq(i).show();
				$('#tabbedID').find('p').slice(showLimit,totP).hide();
				continue;
			}
			$('#mainTabDiv > div').eq(i).removeClass('storiestxtarea');
			$('#mainTabDiv > div').eq(i).attr('id','');
			$('#mainTabDiv > div').eq(i).hide();
		}
		
		$('#tabButtonID a').html(showMoreText);
		$('#tabButtonID a').removeClass('showmore_btnHide');
		$('#tabButtonID a').addClass('showmore_btn');
	});
	$('#tabTitleID li').eq(2).click(function(){
		$(this).children('a').addClass('most_shared_active');
		$('#tabTitleID li').eq(0).children('a').removeClass('most_shared_active');
		$('#tabTitleID li').eq(1).children('a').removeClass('most_shared_active');
		
		for(var i=1; i<(totDiv-1) ; i++)
		{
			if(i == 3)
			{
				$('#mainTabDiv > div').eq(i).addClass('storiestxtarea');
				$('#mainTabDiv > div').eq(i).attr('id','tabbedID');
				$('#mainTabDiv > div').eq(i).show();
				$('#tabbedID').find('p').slice(showLimit,totP).hide();
				continue;
			}
			$('#mainTabDiv > div').eq(i).removeClass('storiestxtarea');
			$('#mainTabDiv > div').eq(i).attr('id','');
			$('#mainTabDiv > div').eq(i).hide();
		}
		
		$('#tabButtonID a').html(showMoreText);
		$('#tabButtonID a').removeClass('showmore_btnHide');
		$('#tabButtonID a').addClass('showmore_btn');
	});
	$('#tabTitleID li').eq(0).click(function(){
		$(this).children('a').addClass('most_shared_active');
		$('#tabTitleID li').eq(1).children('a').removeClass('most_shared_active');
		$('#tabTitleID li').eq(2).children('a').removeClass('most_shared_active');
		
		for(var i=1; i<(totDiv-1) ; i++)
		{
			if(i == 1)
			{
				$('#mainTabDiv > div').eq(i).addClass('storiestxtarea');
				$('#mainTabDiv > div').eq(i).attr('id','tabbedID');
				$('#mainTabDiv > div').eq(i).show();
				$('#tabbedID').find('p').slice(showLimit,totP).hide();
				continue;
			}
			$('#mainTabDiv > div').eq(i).removeClass('storiestxtarea');
			$('#mainTabDiv > div').eq(i).attr('id','');
			$('#mainTabDiv > div').eq(i).hide();
		}
		
		$('#tabButtonID a').html(showMoreText);
		$('#tabButtonID a').removeClass('showmore_btnHide');
		$('#tabButtonID a').addClass('showmore_btn');
	});
});


