var headline_count;
var headline_interval;
var current_headline = 0;
var old_headline = 0;

$(document).ready(function(){
//	Nifty("div#ad_id","big");
//	$(".top_stories").slideNews();
//	jQuery(".top_stories").show();
/*
	var options = {
        headline: "Top Stories"  (String)          |  Each unique slider (id) or set of sliders (class) can receive a headline.
        newsWidth: 285,          (Integer)         |  The demo is 285. Modifying will require a modification to the CSS.
        newsSpeed: "normal"      (String/Integer)  |  "slow","normal","fast", or an integer, with 1 being the fastest animation.
	}
    $(".top_stories").slideNews(options);
*/

	//showAd();

/*// For Vertical Scroller...*/
	headline_count = $("div.headline").size();
	$("div.headline:eq("+current_headline+")").css("top","1px");
 	//headline_interval = setInterval(slideIT,5000); //time in milliseconds
/*
	$('#ekSection').hover(function() {
		clearInterval(headline_interval);
	}, function() {
		headline_interval = setInterval(slideIT,5000); //time in milliseconds
		scrollIT();
	});
*/
/*// Click A alert
	$("a#later").click(function(){
		alert("Thanks for visiting!");
	});
*/
/*// Link to disappear
	$("a#later").click(function(){
		$(this).hide("slow");
		// By returning - it will continue on to the URL
		return false;
	});
*/

	// Scroll back to top of page <body id="pageTop">
	// <a href="#" class="BTT">back to top</a></div>
	//$('.BTT').click(function(){$('#pageTop').ScrollTo(800);return false});

/*// Scroll the entire page down to element named examples
// Button is... <a href="#examples" id="examplesBtn">
	$('#examplesBtn').click(function(){
		$('#examplesTitle').ScrollTo(800);
		if(document.getElementById('examples').style.display == "none"){$('#examples').slideDown(500);$('#toggleBtnExample').html('-')};
			return false;
	});
*/
/*// Add drop shadow to all graphics  add class="dropshadow" to imgs
	$("img.dropshadow").wrap("<div class='wrap1'><div class='wrap2'>" +
     "<div class='wrap3'></div></div></div>");
*/
/*// Slidebox...
	$('#slickbox').hide();
	// shows the slickbox on clicking the noted link 
	$('a#slick-show').click(function() {
		//$('#slickbox').show('slow');
		//$('#slickbox').slideDown('slow');
		$('#slickbox').animate({ height: 'show', opacity: 'show' }, 'slow');
		return false;
	});
  // hides the slickbox on clicking the noted link 
 	$('a#slick-hide').click(function() {
		//$('#slickbox').hide('fast');
		//$('#slickbox').slideUp('fast');
		$('#slickbox').animate({ height: 'hide', opacity: 'hide' }, 'slow');
		return false;
	});
 // toggles the slickbox on clicking the noted link 
	$('a#slick-toggle').click(function() {
		//$('#slickbox').toggle(400);
		$('#slickbox').slideToggle(400);
		return false;
	});
*/

// Call for <div> fader
/*
	$('ID or class of the element containing the fading objects').innerfade({ 
		animationtype: Type of animation 'fade' or 'slide' (Default: 'fade'), 
		speed: Fadingspeed in milliseconds or keywords (slow, normal or fast)(Default: 'normal'), 
		timeout: Time between the fades in milliseconds (Default: '2000'), 
		type: Type of slideshow: 'sequence' or 'random' (Default: 'sequence'), 
		containerheight: Height of the containing element in any css-height-value (Default: 'auto'), 
		runningclass: CSS-Class which the container gets applied (Default: 'innerfade')
	});
*/
// IE...
/*
	$('#news').innerfade({ 
		animationtype: 'slide', 
		speed: 750, 
		timeout: 2000, 
		type: 'random', 
		containerheight: '1em' 
	});
	$('.portfolio').innerfade({
		speed: 'slow', 
		timeout: 9000, 
		type: 'sequence', 
		containerheight: '280px'
	});
	$('.fade').innerfade({ 
		speed: 'slow', 
		timeout: 1000, 
		type: 'sequence', 
		containerheight: '1.5em' 
	});
*/
 });

function slideUP(){
	current_headline = (old_headline + 1) % headline_count;
	$("div.headline:eq(" + old_headline + ")").animate({top: -200},"slow", function() {
		$(this).css('top','205px');
	});
	$("div.headline:eq(" + current_headline + ")").css('top','198px');
	$("div.headline:eq(" + current_headline + ")").show().animate({top: 0},"slow");
	old_headline = current_headline;
}

function slideDN(){
	current_headline = (old_headline - 1) % headline_count;
	if(current_headline<0){current_headline = (headline_count - 1);}
	$("div.headline:eq(" + old_headline + ")").animate({top: 200},"slow", function() {
		$(this).css('top','-205px');
	});
	$("div.headline:eq(" + current_headline + ")").css('top','-198px');
	$("div.headline:eq(" + current_headline + ")").show().animate({top: 1},"slow");
	old_headline = current_headline;
}

function initPage()
{
	var navRoot = document.getElementById("nav");
	if (navRoot){
		var nodes = navRoot.getElementsByTagName("li");
		for (var i=0; i<nodes.length; i++)
		{
			nodes[i].onmouseover = function() {
				this.className += " hover";
			}
			nodes[i].onmouseout = function() {
				this.className = this.className.replace(new RegExp(" hover"),"");
			}
		}
	}
}

function initSaf(){
	if ((navigator.appVersion.indexOf("Safari")) != -1) document.body.className += " safari";
}


if (window.addEventListener){
	window.addEventListener("load", initSaf, false);
}
else if (window.attachEvent && !window.opera){
	window.attachEvent("onload",initPage);
}
