$(document).ready(function() {
	function getInternetExplorerVersion()
	{
		var rv = -1; // Return value assumes failure.
		if (navigator.appName == 'Microsoft Internet Explorer')
		{
		var ua = navigator.userAgent;
		var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null)
			rv = parseFloat( RegExp.$1 );
		}
		return rv;
	}
	var ver = getInternetExplorerVersion();

	$('#c_featured').hide().fadeIn('slow');
	start_interval();
	var featured_count = parseInt($('#featured_count').attr('alt'));
	if (ver >= 7.0 || navigator.appName != 'Microsoft Internet Explorer')
	{
		$('#follow_us').show();
	}
	$('.fl').live('mouseover', function() {
		$(this).css('text-decoration', 'underline');
	});
	$('.fl').live('mouseout', function() {
		$(this).css('text-decoration', 'none');
	});
	$('.nav1_main').mouseenter(function() {
		$('.navbar1_drop').hide();
		if (ver > 7.0 || navigator.appName != 'Microsoft Internet Explorer')
		{
			$(this).children(this).show();
		}
		else
		{
			$(this).children(this).show();
		}
	})
	$('.navbar1_drop').mouseleave(function() {
		if (ver > 7.0 || navigator.appName != 'Microsoft Internet Explorer')
		{
			$(this).hide();
		}
		else
		{
			$(this).hide();
		}
	});
	$('.choose_box').mouseenter(function() {
		if (!$(this).hasClass('choose_box-over'))
		{
			$(this).addClass('choose_box-live');
		}
		$(this).removeClass('choose_box-main').addClass('choose_box-over');
	}).mouseleave(function() {
		if ($(this).hasClass('choose_box-live'))
		{
			$(this).removeClass('choose_box-over').addClass('choose_box-main');
		}
	});
	$('.choose_box').click(function() {
		if ($('#startlive').data('on') == 1)
		{
			stop_interval();
		}
		if ($('#c_featured').data('old_id'))
		{
			var old_id = $('#c_featured').data('old_id');
		}
		else
		{
			var old_id = 1;
		}
		$('.choose_box-over').removeClass('choose_box-over').addClass('choose_box-main');
		$(this).removeClass('choose_box-main').addClass('choose_box-over').removeClass('choose_box-live');
		var id = $(this).attr('alt');
		$('#c_featured').data('old_id', id);
		$('#feat_' + old_id).fadeOut('medium', function() {
			$('#feat_' + id).fadeIn('medium');
		});
	});
	function update_feed()
	{
		if ($('#c_featured').data('old_id'))
		{
			var old_id = $('#c_featured').data('old_id');
		}
		else
		{
			var old_id = 1;
		}
		if (old_id == featured_count)
		{
			var id = 1;
		}
		else
		{
			var id = parseInt(old_id) + 1;
		}
		$('.choose_box-over').removeClass('choose_box-over').addClass('choose_box-main');
		$('#cb_' + id).removeClass('choose_box-main').addClass('choose_box-over').removeClass('choose_box-live');
		$('#c_featured').data('old_id', id);
		$('#feat_' + old_id).fadeOut('medium', function() {
			$('#feat_' + id).fadeIn('medium');
		});
	}
	function stop_interval()
	{
		clearInterval(live_loader);
		$('#stoplive').fadeOut('fast', function() {
			$('#startlive').fadeIn('fast');
		});
		$('#startlive').data('on', 0);
	}
	function start_interval()
	{
		live_loader = setInterval(update_feed, featured_stay_time);
		$('#startlive').fadeOut('fast', function() {
			$('#stoplive').fadeIn('fast');
		});
		$('#startlive').data('on', 1);
	}
	var live_loader;

	$('#stoplive').click(function() {
		stop_interval();
		$(this).data('active', 1);
		$('#startlive').data('active', 0);
	});
	$('#startlive').click(function() {
		start_interval();
		$(this).data('active', 1);
		$('#stoplive').data('active', 0);
	});
	if ($('#s').val() != 'Type your search here')
	{
		$('#s').css('color', '#444444').css('font-style', 'normal');
	}
	$('#s').focus(function() {
		if ($(this).val() == 'Type your search here')
		{
			$(this).val('').css('color', '#444444').css('font-style', 'normal');
		}
	});
	$('#s').blur(function() {
		if ($(this).val() == 'Type your search here' || $(this).val() == '')
		{
			$(this).val('Type your search here').css('color', '#aaa').css('font-style', 'italic');
		}
	});
});
