// JavaScript Document

// ASP Time Script
$(".date").load("/time.asp");


//$(".date").load("/time.php");
$(".homeNews:first").fadeIn();

var banns = new Array();
var uri = 0;

var indBann = 0;

banns[1] = ["Home_Banner_Cta-Emp_1.jpg","/empresarial"];
banns[2] = ["Home_Banner_Cta-Emp_2.jpg","/empresarial"];

var banner = Math.floor(Math.random()*2)+1;
$("#bannerLeft").css("background-image","url("+banns[banner][0]+")");
$("#bannerLeft").attr("url",banns[banner][1]);

$("#menuVertical div:eq(0)").addClass("orange");

var menuItems = $(".module").length;

	$(".centralMenu ul").append('<li><div class="prevBanner"></div></li>');
	for(i=0;i< menuItems;i++){
		$(".centralMenu ul").append('<li class="pageCentral">'+(i+1)+'</li>');
	}
	$(".centralMenu ul").append('<li><div class="nextBanner"></div></li>');

var ref="#menuVertical div";

$(".prevBanner").click(function(){
		indBann--;
		if(indBann<0){
			indBann=menuItems-1;
		}
		ids = indBann;
		theme = $("#menuVertical div:eq("+ids+")").attr("theme");
		newsCh(indBann);
		chooseBanner(indBann,theme);
});

$(".nextBanner").click(function(){
		indBann++;
		if(indBann>menuItems-1){
			indBann=0;
		}
		ids = indBann;
		theme = $("#menuVertical div:eq("+ids+")").attr("theme");
		newsCh(indBann);
		chooseBanner(indBann,theme);
});


function chBnn(){
		indBann++;
		if(indBann>menuItems-1){
			indBann=0;
		}
		ids = indBann;
		theme = $("#menuVertical div:eq("+ids+")").attr("theme");
		chooseBanner(indBann,theme);
}

var counter = setInterval("chBnn()",8000);


$(".module").click(function(){
	window.location = $("#menuVertical div:eq("+$(this).index()+")").attr("url") + ".htm";
	indBann = $(this).index();
});

$("#menuVertical div").click(function(){
	var theme = $(this).attr("theme");
	var ids = $(this).index();
	indBann = ids;
	newsCh(indBann);
	chooseBanner(indBann,theme);
});


$("#bannerLeft").click(function(){
	window.location = $(this).attr("url");
});

$(".module:eq(0)").fadeIn(300);

$(".homeButton").click(function(){
		window.location = "/";
});


$(".centralMenu ul li.pageCentral:first").addClass("pageCentral_over");

$(".centralMenu ul li.pageCentral").click(function(){
	var opc = $(this).index()-1;
	indBann = opc;
	var thm = $("#menuVertical div:eq("+opc+")").attr("theme");
	newsCh(indBann);
	chooseBanner(indBann,thm);
});

$(".enterButton").click(function(){
	window.location = getURL();				 
});

function chooseBanner(id,thm){
	
	$("#overBand").removeClass().addClass("overBand_"+thm);
	$("#centralBanner").css("background","no-repeat url(images/banners/central_"+(id+1)+".jpg)");
	
	
	ths=$(ref+":eq("+id+")");
	
	$(ref).removeClass().addClass("menuButton");
	
	$(ref+" span").removeClass();
	
	$(ref).each(function(){
		$("span:eq(0)",this).addClass("title");
		$("span:eq(1)",this).addClass("small");
	});

	ths.addClass(thm);
	
	$("span:eq(0)",ths).addClass("titleSelected");
	$("span:eq(1)",ths).addClass("smallSelected");

	
	
	$(".module").each(function(){
		$(this).fadeOut(0);
	});
	$(".module:eq(" + id + ")").fadeIn(300);
	
	$(".centralMenu ul li.pageCentral_over").removeClass().addClass("pageCentral");
	$(".centralMenu ul li:eq("+(id+1)+")").addClass("pageCentral_over");
	
	/*$(".homeNews").css("display","none");
	$(".homeNews:eq("+id+")").css("display","block");*/
	
	uri= id;
}

function getURL(){
	urb = $("#menuVertical div:eq("+uri+")").attr("url") + ".htm";
	return urb;
}

/*
$(".element").mouseenter(function(){
	$(this).css("color","#BDD634");
});

$(".element").mouseleave(function(){
	$(this).css("color","#4F6F19");
});

$(".element").click(function(){
	window.location = $(this).attr("url");
});
*/

$(".plusButton").click(function(){
	window.location = "testimoniales.htm";//$(this).attr("url")+".htm";
});

function newsCh(idb){
	$(".homeNews").css("display","none");
	$(".homeNews:eq("+indBann+")").css("display","block");
}

/*
$(".element").mouseenter(function(){
$(this).next().fadeOut();
});
*/
