/* 
	© copyright 2006 webuild solutions
	http://www.webuild.pt
	
*/

// trocaCss		/////////////////////////////////////////////////////////
function thumbsFX(alvo,estilo){
	alvo.className = estilo;	
}

function isNumeric(sText) {
	var ValidChars = "0123456789";
	var IsNumber=true;
	var Char;

	if (sText.length == 0) { 
		return false;
	}
	for (i=0; i < sText.length && IsNumber == true; i++) {
		Char = sText.charAt(i);
		if (ValidChars.indexOf(Char) == -1) {
			IsNumber = false;
		}
	} 
	return IsNumber;
}

//open window	/////////////////////////////////////////////////////////
function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

//muda fundo	/////////////////////////////////////////////////////////
function bk(objecto,cor,imagem) {
	if(imagem == "imagemOut"){
		imagem = "url(images/setaAzul.gif)";//mouseOver
		verMenu = "hidden";
	} 
	else if(imagem == 'imagemOver'){
		imagem = "url(images/setaBranca.gif)";//mouseOut
		verMenu = "visible";
	} else {
		imagem = "none";
	}	
	objecto.style.backgroundColor = cor;
	objecto.firstChild.style.backgroundImage = imagem;
}

//fx caixa de pesquisa //////////////////////////////////////////////////
//Versão que deduz a linguagem activa, poderá se fazer uma função que recebe 
//a linguagem como parametro, mas esta funciona sempre.
//fx caixa de pesquisa //////////////////////////////////////////////////
var PESQUISA_PT = "Produto...";
var PESQUISA_ING = "Product...";
var PESQUISA_FR = "Produit...";
var PESQUISA_ES = "Producto...";

var pesquisa_lang = "PT";	//variavel de controlo interna
function pesquisa(x,y,z) {	//Box Pesquisa
	if (x.value==PESQUISA_PT || x.value==PESQUISA_ING || x.value==PESQUISA_ES || x.value==PESQUISA_FR){
		//Desliga e guarda o valor para calcular o liga
		switch (x.value){
			case PESQUISA_PT: 
			pesquisa_lang = "PT";
			break;

			case PESQUISA_ING: 
			pesquisa_lang = "ING";
			break;
			
			case PESQUISA_ES: 
			pesquisa_lang = "ES";
			break;
			
			case PESQUISA_FR: 
			pesquisa_lang = "FR";
			break;
		}		
		x.value="";
	} else {
		if (x.value==""){
			//Liga
			switch (pesquisa_lang){
				case "PT": 
				x.value = PESQUISA_PT;
				break;

				case "ING": 
				x.value = PESQUISA_ING;
				break;

				case "ES": 
				x.value = PESQUISA_ES;
				break;

				case "FR": 
				x.value = PESQUISA_FR;
				break;
			}
		}
	}
	x.style.borderColor = y; //fundo
	x.style.color = z;			//letras
}
//menu slide de entrada /////////////////////////////////////////////////
function MenuSlide(Obj){
	//alert(Obj);//debug target
	var target = document.getElementById(Obj);
	if(target.style.display == "block"){
		target.style.display = "none";
	} else {
		target.style.display = "block";
	}
}


//menu		/////////////////////////////////////////////////////////////
var timerteste = null;//timer desligado 
var timerOn = false;//timer ligado se igual a "true" 
var tempo = 500; 

function StartTimer(Obj){ 
 	
	if (timerOn == false){
		clearTimeout(timerteste); //se o timer estiver ligado faz reset
		
		Obj = new String(Obj);
		newObj = Obj.substring(7,8);
		newObj = new Number(newObj);

		menuoff = "MenuLateralOff('submenu"+ newObj +"')"; //apaga o menu
		timerteste = setTimeout(menuoff, tempo);
	}
}

function StopTimer(){ 
 	if (timerOn != null){
		clearTimeout(timerteste); 
		timerteste = null;
		timerOn = false;}
}

//formulários

function resetButton(){
	document.forms["Form1"].reset();
	window.scrollTo(0,0);
}

//menu lateral	/////////////////////////////////////////////////////////

function MenuLateral(Obj){
	var target = document.getElementById(Obj);
	if(target.style.display == "block"){
		target.style.display = "none";
	} else {
		target.style.display = "block";
	}
}

function cleanMenus(){
	for (var i=1; i< 5; i++){
		var xpto ="submenu" + i;
		if (document.getElementById(xpto).style.display == "block"){
			document.getElementById(xpto).style.display = "none";
		}
	}			
}
function MenuLateralOn(Obj){
	cleanMenus();
	var target = document.getElementById(Obj);
	target.style.display = "block";
}

function MenuLateralOff(Obj){
	var target = document.getElementById(Obj);
	target.style.display = "none";
}
///////////////////////////////////////////////////////////////////////