$(document).ready(function(){
	$("div.itemCopy").hide();
	
	$("div.itemLink").each(function(x){
		this.id = "link"+x;
		this.onclick = function(){
			checkItem(x);
		};
	});
	$("div.itemCopy").each(function(x){
		this.id = "copy"+x;
	});
	
	$("div.itemLink").mouseover(function(){
		$(this).addClass("over");
	});
	$("div.itemLink").mouseout(function(){
		$(this).removeClass("over");
	});
	
	
$(document).ready(function(){
	horiz.init();
});
	
/***************************************/
/* TEASER POP UPS */
/***************************************/
	
	$("div.teaserTrigger").hover(
		function() {
			$(this).siblings(".teaserPop").animate( {
				top:		"46px"
      		}, 100 );
      		
      		$(this).siblings(".teaserPop").children("h4").addClass("current");
         },
		 
		 function() {
			$(this).siblings(".teaserPop").animate( {
				top:		"99px"
      		}, 100 );
      		
      		$(this).siblings(".teaserPop").children("h4").removeClass("current");
         }).click(function(){
         	window.location = $(this).siblings(".teaserPop").children("h4").children("a").attr("href");
         }).css("cursor", "pointer");

/***************************************/
/* /TEASER POP UPS */
/***************************************/

});



function checkItem(wItem) {
	var current=null;
	var links = $("div.itemLink");
	for(var x=0; x<links.length; x++){
		if(links[x].className.indexOf("current") != -1) {
			current = x;
		}
	}
	
	if((current == null) || (current == wItem)) {
		toggleItem(wItem);
	} else {
		hideItem(current, wItem);
	}
}



function showItem(wItem) {
	$("#copy"+wItem).slideDown(200);
	$("#link"+wItem).addClass("current");
}
function hideItem(wItem, wNextItem) {
	$("#copy"+wItem).slideUp(200, function() {showItem(wNextItem);});
	$("#link"+wItem).removeClass("current");
}
function toggleItem(wItem) {
	$("#copy"+wItem).slideToggle(200);
	$("#link"+wItem).toggleClass("current");
}




