/* javascript */

var SITEBASE = {
	init: function() {		
		SITEBASE.bases.handlers.init();		
		SITEBASE.frontSelector.init();
		SITEBASE.contactForm.init();
	},
	bases: {
		handlers: {
			init: function() {				
				SITEBASE.bases.handlers.hoverHandlers();
			},
			hoverHandlers: function() {				
				jQuery("a").hover(function () {jQuery(this).toggleClass("hover");});
			}
		}
	},
	frontSelector: {
		init: function() {
			SITEBASE.frontSelector.handlers();
		},
		handlers: function() {
			jQuery(".frontSelector .arrowContainer div").mouseover(SITEBASE.frontSelector.events.onMouseover);
			jQuery(".frontSelector .arrowContainer div").click(SITEBASE.frontSelector.events.onClick);
		},
		events: {
			onMouseover: function() {
				var currentClass = jQuery(this).find("span").attr("class");
				jQuery(this).parent().find("div").removeClass("hover");
				jQuery(this).addClass("hover");
				jQuery(this).parent().parent().find("div.textContainer div").removeClass("active").parent().find("div[class*='" + currentClass + "']").addClass("active");
			},
			onClick: function() {
				var linkUrl = jQuery(this).find("span").attr('link');				
				if (String(linkUrl) != '') {
					document.location.href = linkUrl;
				}
			}
		}
	},
	contactForm: {
		init: function() {
		   $("div.contactComment a").bind("click", function() {
				$("#commentBox").slideToggle("fast");return false;
		   });
		   
		   if ($("#commentBox textarea").val() != "") {
			$("#commentBox").show();
		   }
		   
		   $("div.contactOrder input").bind("click", function() {
			$(this).prev().toggleClass('selected', $(this).attr("checked"));
		   });
		   
		   $("div.mContactForm div.contactInfo input").bind("focus", function() {
			$(this).parent().addClass("currentInfo");
		   });
		   
		   $("div.mContactForm div.contactInfo input").bind("blur", function() {
			$(this).parent().removeClass("currentInfo");
		   });
			  
		   // Set already selected
		   $.each($("div.contactOrder input"), function() {
			$(this).prev().toggleClass('selected', $(this).attr("checked"));
		   });
		   
		   jQuery("div.contactOrder div.prodTeam div.selectBoxes select").bind("change", function() {
			if (jQuery(this).val() == "-1") {
				jQuery(this).parent().find("div.ProdutPackages").hide();
			} else {
				jQuery(this).parent().find("div.ProdutPackages").show();
			}			
		   });
		}
	}
};


jQuery(function($) {
	SITEBASE.init();
});
