jQuery(document).ready(function() {
	jQuery('#carousselhotnews').jCarouselLite({
		auto: 3000,
	    speed: 400
	});

	$('.selectcontainer').each(
		function(i) {
			selectContainer = $(this);
			// Add the class for JS Browers
			selectContainer.addClass('skinned-select');
			// Find the select box
			selectContainer.children().before('<div class="select-text">a</div>').each(
				function() {
					$(this).prev().text(this.options[this.selectedIndex].innerHTML)
				}
			);
			// Store the parent object
			var parentTextObj = selectContainer.children().prev();
			// As we click on the options
			selectContainer.children().click(function() {
				// Set the value of the html
				parentTextObj.text(this.options[this.selectedIndex].innerHTML);
			})        
		}
	);
});

sfHover = function() {
	var sfEls = document.getElementById("topmenu").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

if (window.attachEvent) window.attachEvent("onload", sfHover);

function startAnimations()
{
	if ($('.photoSwitcher > ul > li').length > 1)
		setTimeout('switchPhoto()', 2000);
	initHeaderMenu();
}

function switchPhoto()
{
	$('.photoSwitcher').each(function () {
		if ($('ul > li:visible', this).next().length)
		{
			$('ul > li:visible', this).fadeOut(200, function() {$(this).next().fadeIn(210)});
		}
		else
		{
			$('ul > li:visible', this).fadeOut(200, function() {$(this).prevAll(':last').fadeIn(210)});
		}
	});
	setTimeout('switchPhoto()', 2000);
}

function clearInput(element) { if (element.defaultValue == element.value) element.value = ""; }
function resetInput(element) { if (element.value == "") element.value = element.defaultValue; }

function mycarousel_initCallback(carousel)
{
	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
    });
};

function initHeaderMenu()
{
	$('#menuhome > ul > li').hover(
		function () {
			$(' > ul', this).slideDown();
		},
		function () {
			$(' > ul', this).slideUp();
		}
	);
	
	$('#logo').hover(
		function () {
			$(this).stop().animate({'opacity': 0.5});
		},
		function () {
			$(this).stop().animate({'opacity': 1});
		}
	);	
}