/* === jQuery Functions === */

$(document).ready(function(){
	
	styledSelect();
	initCarousel();
	initSideMenu();
	ie6Fixes();
	
	
	function styledSelect(){
		
		$('#chooseCountry, #identity').sSelect();
		$('#header .newList li:first-child').hide();
		$('#header .newList li:nth-child(2)').addClass('top pngfix');
		$('#header .newList li:last-child').addClass('btm pngfix');
		
	}
	
	function initCarousel(){
		$('#carousel').carousel({ pagination: true, animSpeed: 500, autoSlide: true, autoSlideInterval: 6000, delayAutoSlide: 3000 });
	}
	
	function initSideMenu(){
		
		if($('#side-menu a.toggle').hasClass('selected')){
			$('#side-menu a.selected').parent().children('ul').slideDown('slow');
		}
		
		$('#side-menu a.toggle').click(function(){
			
			if($(this).hasClass('selected')){
				$(this).removeClass('selected');
			} else {
				$('#side-menu a.toggle').removeClass('selected');
				$(this).addClass('selected');
			}
			
			$(this).parent().children('ul').slideToggle('slow');
			return false;
				
		});
		
	}
	
	function ie6Fixes(){
		
		if ($.browser.msie && $.browser.version == 6){
			
			$('#header #mainMenu li:first-child, #team-list li:first-child').addClass('first-child');
			
			$('#header .newList li:nth-child(2)').mouseover(function(){
				$(this).addClass('ietop pngfix');
			}).mouseout(function(){
				$(this).removeClass('ietop pngfix');
			});
			
			$('#header .newList li:last-child').mouseover(function(){
				$(this).addClass('iebtm pngfix');
			}).mouseout(function(){
				$(this).removeClass('iebtm pngfix');
			});
			
		}
	}
	
});


/* === Remove outline in IE === */

function addEvent(obj, evType, fn){ 
	if (obj.addEventListener){ 
		obj.addEventListener(evType, fn, true); 
		return true; 
	}else if (obj.attachEvent){ 
		var r = obj.attachEvent("on"+evType, fn); 
		return r; 
	}else{ 
		return false; 
	} 
}

function hideFocusBorders(){
var theahrefs = document.getElementsByTagName("a");
	if (!theahrefs){return;}
		for(var x=0;x!=theahrefs.length;x++){
		theahrefs[x].onfocus = function stopLinkFocus(){this.hideFocus=true;};
	}
}

addEvent(window, 'load', hideFocusBorders);
