/*     
Proyecto: Web Formato Verde
Nombre: formatoverde.js
Descripcion: Funciones para web Formato Verde
Version: 0.1
Autor: IdeiT S.L., <a href="http://www.ideit.es">IdeiT</a>
Autor URI: http://www.ideit.es
*/

function imageHeaderRandom(folder){
	var num = Math.round(Math.random()*12) + 1;
	var imageName = num < 10 ? 'img_0' + num + '.jpg' : 'img_' + num + '.jpg';
	$("div#header_content").css("background", "url('" + folder + imageName + "') no-repeat scroll 0 0 transparent");
}

function productTab(){
	$("div.product_info").hide();
	$("div.product_list a").mouseover(function(){
		var tab = $(this).attr("rel");
		$("div.product_info").hide();
		$("div#"+tab).show();
		$("div.product_list a.selected").removeClass("selected");
		$(this).addClass("selected");
	});
	/* Establecemos seleccionado el primero */
	$("div#tab_1").show();
	$("div.product_list a[rel='tab_1']").addClass("selected");
}

function menuslider(selector){
	var $menu = $(selector).children("ul");
	var $all_lis = $menu.children("li");
	var $all_uls = $all_lis.children("ul");
	$all_uls.hide();
	//show the selected tree
	$all_lis.each(function (i) {
		if($(this).hasClass("selected")){
			$(this).children("ul").show();
		}
	});
	$all_lis.children("a").click(function(event){
		var $current_li = $(this).parent();
		var $current_ul = $current_li.children("ul");
		if($current_ul.length > 0){
			if($current_ul.is(':hidden')){
				$all_uls.slideUp();
				//Show current ul
				$current_ul.slideDown("slow");
				$all_lis.removeClass("selected");
				$current_li.addClass("selected");
			}
			this.blur();
			event.preventDefault();
			return false;
		}
	});
}

function NewsSelector() {
	$('#wrapper_news').hide();
	$('#NewsToggle a').click(function() {
		$('#wrapper_news').toggle();
		return false;
	});
}


