$(document).ready(function(){
	$(".menuTopo").hover(function(){ $(this).addClass("menuTopoOver");}, function(){ $(this).removeClass("menuTopoOver"); });
	$(".subMenuTopo").hover(function(){ $(this).addClass("subMenuTopoOver");}, function(){ $(this).removeClass("subMenuTopoOver"); });
	$(".smProduto").hover(function(){ $(this).addClass("smProdutoOver");}, function(){ $(this).removeClass("smProdutoOver"); });
	$(".listNoticia").hover(function(){ $(this).addClass("listNoticiaOver");}, function(){ $(this).removeClass("listNoticiaOver"); });
	$(".icotopo").hover(function(){
			var imgM = $(this).attr("src"); if(imgM.indexOf("_on") <= 0){ $(this).attr({src: imgM.substr(0,imgM.indexOf(".gif"))+"_on.gif"}); }
		}, function(){
			var imgM = $(this).attr("src"); if(imgM.indexOf("_on") >= 0){ $(this).attr({src: imgM.substr(0,imgM.indexOf("_on.gif"))+".gif"}); }
		});
	$(".icoSeta").hover(function(){
			var imgM = $(this).attr("src"); if(imgM.indexOf("_over") <= 0){ $(this).attr({src: imgM.substr(0,imgM.indexOf(".gif"))+"_over.gif"}); }
		}, function(){
			var imgM = $(this).attr("src"); if(imgM.indexOf("_over") >= 0){ $(this).attr({src: imgM.substr(0,imgM.indexOf("_over.gif"))+".gif"}); }
		});
	$(".thumbHome").hover(function(){ $(this).addClass("thumbHomeOver");}, function(){ $(this).removeClass("thumbHomeOver"); });

	if (document.getElementById("blendimage")) {
	    var capaImg = arCapa[capan];
		$("#blendimage").css("background-image","url("+capaImg+")");
		if (arCapa.length > 1) intloop = setInterval("loopimg(1000)", 4000);
		$("#idThumb" + capan).addClass("thumbHomeOn");
		movethumb = 3;
		thumbsPos();
	}
});

var intloop = null;
function loopimg(nc){
	capan++;
	if(nc < 1000){ clearInterval(intloop); capan = nc; }
	if(capan > totCapa){ capan=0; }
	$("#blenddiv").css("background-image","url("+capaImg+")");
	$("#blenddiv").show();
	capaImg = arCapa[capan];
	textoImg = arCapaTexto[capan];
	if(textoImg.length > 3){ $("#menulat").html(textoImg); }
	$("#blendimage").hide();
	$("#blendimage").css("background-image","url("+capaImg+")");
	$("#blendimage").fadeIn(400);
	for(nx=0;nx<=totCapa;nx++){
		if(nx == capan){
			$("#idThumb"+nx).addClass("thumbHomeOn");
		} else {
			$("#idThumb"+nx).removeClass("thumbHomeOn");
		}
	}
}
var capaImg = "";

function scrollDiv(){ document.location="#contatoDivLk"; }

function goLink(lkclick){
	if(lkclick.indexOf("http") >= 0){
		window.open(lkclick);
	} else if(lkclick.indexOf("../") >= 0){
		parent.location = lkclick;
	} else {
		document.location = "?id="+lkclick;
	}
	var img = null;
	if(lkclick.indexOf("&") >= 0){ lkclickT = lkclick.substr(0,lkclick.indexOf("&")); } else { lkclickT = lkclick; }
}

function ampliarImg(url){
	w = 100;
	h = 100;
	centerX = (screen.height/2)-h/2;
	centerY = (screen.width/2)-w/2;
	window.open('spz_ampliar.asp?'+url,'ampliar','width='+w+',height='+h+',top='+centerX+',left='+centerY+'');
}
var gh=290;

function re(){
	if(document.getElementById("ImgNews")){
		var altura = document.ImgNews.height;
		var largura = document.ImgNews.width;
		if(largura>780){
			document.ImgNews.width=780;
		}
		//else if(altura>330){
		//	document.ImgNews.height=330;
		//}
	}
}

function mudaId(idm, itemMenu){
	var insTipo = "";
	$("#divTipo").html("");
	$("#divMenu").html("");
	$(".menuTopo").removeClass("menuTopoOff");
	var nummenu = 0;
	var tipom = "";
	var insTipoTemp = "";
	for(im in jsMenu){
		if(im == idm){
			for(tm in jsMenu[im]){
				insTipoTemp += "<div class='subMenuTopo' onClick=\"mudaTipo('" + idm + "','" + tm + "', this);\">" + tm + "</div>";
				tipom = tm;
				nummenu++;
			}
		}
	}
	if(nummenu == 1){
		insTipo = "<div class='subMenuTopoOn' onClick=\"mudaTipo('" + idm + "','" + tipom + "', this);\">" + projname + "</div>";
		mudaTipo(idm, tipom, "");
	} else {
		insTipo = insTipoTemp;
	}
	$("#divTipo").html(insTipo);
	$(itemMenu).addClass("menuTopoOff");
}

function mudaTipo(idm, tipom, itemSubMenu){
	var insMenu = "";
	$("#divMenu").html("");
	$(".subMenuTopo").removeClass("subMenuTopoOn");
	for(im in jsMenu){
		if(im == idm){
			for(tm in jsMenu[im]){
				if(tm == tipom){
					for(mm in jsMenu[im][tm]){
						insMenu += "<div class='subMenuTopo' onClick=\"document.location='default.asp?lang=" + lang + "&id=" + idm + "&tipo=" + tm + "&menu=" + mm + "&cod=0';\">" + jsMenu[im][tm][mm] + "</div>";
					}
				}
			}
		}
	}
	$("#divMenu").html(insMenu);
	$(itemSubMenu).addClass("subMenuTopoOn");
}

var movethumb = 0;
var inilt = 3;
function thumbsPos(){
	if(document.getElementById("linhaThumbs")){
		if(movethumb > 0){
			var wt = $("#linhaThumbs").width();
			var wtc = $("#contentThumbs").width();
			var lt = $("#linhaThumbs").css("left");
			lt = parseFloat(lt);
			if(movethumb == 1){
				if(lt < inilt){
					newlt = lt + 2;
					$("#linhaThumbs").css("left", newlt)
				} else {
					$("#icoSetaEsqOff").show();
					clearInterval(intThumb);
					movethumb = 0;
				}
			}
			if(movethumb == 2){
				if(lt > ((wtc - wt) + inilt + 5)){
					newlt = lt - 2;
					$("#linhaThumbs").css("left", newlt)
				} else {
					$("#icoSetaDirOff").show();
					clearInterval(intThumb);
					movethumb = 0;
				}
			}
		}

		if (movethumb > 0) {

		    $("#icoSetaEsqOff").hide();

		    $("#icoSetaDirOff").hide();

		}

		if (movethumb == 3) {

            var wt = $("#linhaThumbs").width();

            var wtc = $("#contentThumbs").width();

            $("#icoSetaEsqOff").show();

            $("#icoSetaDirOff").show();

			if (wt > wtc) {

			    $("#icoSetaDirOff").hide();

			}

			movethumb = 0;

		}
	}
}
var intThumb;
function ativaThumbPos(d){
	if(d > 0){
		if(d == 1){ movethumb = 1; }
		if(d == 2){ movethumb = 2; }
		intThumb = setInterval("thumbsPos()", 15);
	}
	if(d == 0){
		clearInterval(intThumb);
	}
}
ativaThumbPos(1);

atS = 0;
function atNomeNews(dir){
	atS = 1;
	moveNews(""+dir+"");
}
function desatNomeNews(){
	atS = 0;
}



function enviarLoginF(u,s){
	var vid = "login&enviar=ok&usuario=" + document.loginF.usuario.value + "&senha=" + document.loginF.senha.value;
	goLink(vid);
}

function validar_busca(oForm){
	if (oForm.busca.value == ""){
		alert("Preencha o campo!")
		return false;
	} else {
		return true;
	}
}

function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}
function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 20);
	var timer = 0;
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	//make image transparent
	changeOpac(0, imageid);
	//make new image
	document.getElementById(imageid).src = imagefile;
	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function addEvent(elm, evType, fn, useCapture){
	if (elm.addEventListener){
		elm.addEventListener(evType, fn, useCapture);
		return true;
	} else if (elm.attachEvent){
		var r = elm.attachEvent("on"+evType, fn);
		return r;
	}
}
