/*
********************************
**	(c)2009 R3 WEBMOTION	  **
**	contact: info@r3.com.br	  **
********************************
*/

// CONFIG

jQuery.fn.extend({
	changeImg: function(){
		if($(this)){
			$(this).not(":only-child").each(function(){
				$(this).animate({ opacity: 1 },5000).fadeOut(1000,function(){
					if($(this).is(":last-child")){
						$(this).removeClass("view");
						$(this).parent().children().filter(":first-child").addClass("view").fadeIn(1000).changeImg();
					} else {
						$(this).removeClass("view").next().addClass("view").fadeIn(1000).changeImg();
					}
				});
			});
		}
	}
});

$(document).ready(function(){
	
	baseurl = '';
	dombase = 'http://'+$(document).attr("domain");
	urlraw = $(document).attr('URL').replace(dombase+baseurl,'')

	urlrw = urlraw.split('/');
	
	/*$("div#prehome").each(function(){
		console.log($(document).height() + " - " + $(window).height());
		$("html").css("height","100%");
		$("body").css("height","100%");
		$("div#central").css("minHeight",$(window).innerHeight() + "px");
		//if($(window).height() > $(document).height()){
			//$(document).height($(window).height());
			//$("body").height($(window).height());
			//$("div#central").height($(window).height());
		//}
	});*/
	//$("div#central").innerHeight($(window).height());
	
	$('a').click(function(){ $(this).blur(); });
	
	$('div#nav ul li a[href^=/'+urlrw[1]+'/'+urlrw[2]+']').addClass('selectednav');
	$('div#subnav ul li a[href^=/'+urlrw[1]+'/'+urlrw[2]+'/'+urlrw[3]+']').addClass('selectedsubnav');
	$('div#langbox p a[href^=/'+urlrw[1]+'/home]').addClass('selectedlang'+urlrw[1]);
	
	$("#imgrotateprehome ul li:not(.view)").hide();
	$("#imgrotateprehome ul li.view").changeImg();
	
	$("#imgrotatehome ul li:not(.view)").hide();
	$("#imgrotatehome ul li.view").changeImg();
	
	$.superbox.settings = {
		boxId: "superbox", // Id attribute of the "superbox" element
		boxClasses: "", // Class of the "superbox" element
		overlayOpacity: .3, // Background opaqueness
		boxWidth: "750", // Default width of the box
		boxHeight: "400", // Default height of the box
		loadTxt: "Carregando...", // Loading text
		closeTxt: "Fechar", // "Close" button text
		prevTxt: "&laquo; Anterior &nbsp;", // "Previous" button text
		nextTxt: "&nbsp; Pr&oacute;ximo &raquo;" // "Next" button text
	};
	
	$.superbox();
	
});
