// ROUND CORNERS
DD_roundies.addRule(".rounded3px", "3px", true);
DD_roundies.addRule(".rounded4px", "4px", true);
DD_roundies.addRule(".rounded5px", "5px", true);

//SUBMIT FORMS
$(document).ready(function() { 
	$(".submit-btn").click(function() { 
		$(this).parent().submit();
	});
});

$(document).ready(function() { 
	$(".submit-container span").click(function() { 
		$(this).parents().eq(1).submit();
	});
});

//TOGGLE CLASS FOR SEARCH FIELD
$(document).ready(function() { 
	$("#q").bind("focus", function() { 
		$("#q").removeClass("home-search");
	});
	$("#q").bind("blur", function() { 
		if ($("#q").val() == '') {
			$("#q").addClass("home-search");
		}
	});
});

//SEE ALSO MENU
$(document).ready(function() {
	$("#see-also dl dt").click(function() {
		$(this).nextUntil("dt").slideToggle("normal");
		
		if ($("#see-also dl dt.current")) {
			$("#see-also dl dt.current").removeClass("current");
		}
		
		$(this).addClass("current");
		
	});
});

//BTN BACK
$(document).ready(function() {
	$("#btn-back img").click(function() {
		history.go(-1);
	});
});

//PRODUCTS SLIDESHOW
$(document).ready(function() {
	
	var numItems = $("#slideshow-content ul li").length; //numero de itens na lista
	var visibleWidth = 278; //largura da area visivel
	var singleItem = 132; //largura de item
	var itemMargin = 7; // espaçamento entre os itens
	
	//Atribui uma largura à lista de fotos, se for ímpar, adiciona mais a de um item
	$("#slideshow-content ul").css({"width":numItems*((singleItem/2)+itemMargin)+((numItems % 2 == 0)?0:singleItem)+"px"});
	
	$("#slideshow-navigation li").click(function() {
		
		$("#slideshow-content ul").animate({ "left":"-"+visibleWidth*$(this).index()+"px" });
		$(this).parent().find("li.slideshow-bullet-selected").removeClass("slideshow-bullet-selected");
		$(this).addClass("slideshow-bullet-selected"); 
		
	});
	
});

//MULTIMEDIA
$(document).ready(function() {
	
	$("#multimedia-content ul li").first().show();
	$("#multimedia-tabs ul li:eq(1)").addClass("nofocus");
	
	$("#multimedia-tabs ul li").click(function() {
		
		if ($(this).attr("id") == "multimedia-video-tab") {
			$("#multimedia-plus-btn").hide();
		} else {
			$("#multimedia-plus-btn").show();
		}
		
		$("#multimedia-tabs ul li").addClass("nofocus");
		$(this).removeClass("nofocus");
		$("#multimedia-content ul li:visible").hide();
		$("#multimedia-content ul li:eq("+$(this).index()+")").show();
		
	});
});

//SHOW FLASH ANIMATION
function showFlash(src, larg, alt, wmode){
	var flash = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ larg +'" height="'+ alt +'">';
	flash += '<param name="movie" value="'+ src +'" />';
	flash += '<param name="allowScriptAccess" value="sameDomain" />';
	flash += '<param name="menu" value="false" />';	
	flash += '<param name="wmode" value="'+ wmode +'" />';	
	flash += '<embed src="'+ src +'" pluginspage="http://www.macromedia.com/go/getflashplayer" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" width="'+ larg +'" height="'+ alt +'" menu = "false" wmode = "'+ wmode +'"></embed>';
	flash += '</object>';	
	
	document.write(flash);
}



//HIGHLIGHTS
$(document).ready(function() {

	var numItems = $("#highlights-list-container ul li").length;
	 
	$("#highlights-list-container ul li:eq(0)").fadeIn();
	
	$(".btn-arrow-right").click(function() {
		
		var next = $("#highlights-list-container ul li:visible").index()+1;
		
		if (next > numItems-1) {
			next = 0;
		}
		
		$("#highlights-list-container ul li:visible").fadeOut("fast", function() {
			$("#highlights-list-container ul li:eq("+next+")").fadeIn();
		});
		
	});
	
	$(".btn-arrow-left").click(function() {
		
		var prev = $("#highlights-list-container ul li:visible").index()-1;
		
		if (prev < 0) {
			prev = numItems-1;
		}
		
		$("#highlights-list-container ul li:visible").fadeOut("fast", function() {
			$("#highlights-list-container ul li:eq("+prev+")").fadeIn();
		});
	});
});

