// JavaScript Document

fontDefault = 12;

function fontSize(alink){// #center #innerCenter p

	/*	var pharagrafs=document.getElementsByTagName("p");

		for(i=0;i<pharagrafs.length;i++){

			pharagrafs.item(i).setAttribute("style","font-size:"+num+"px");

		}*/
		if(alink == "plus"){
			if(fontDefault < 14){
				fontDefault++;
			}
		} else if(alink == "minus"){
			if(fontDefault > 9){
				fontDefault--;
			}
		}
		document.getElementById("innerCenter").style.fontSize = fontDefault+"px";
		childs = document.getElementById("innerCenter").childNodes;
		for (i=0;i<=childs.length;i++){
			childs[i].style.fontSize = fontDefault+"px";
		}
}

function explode(inputstring, separators, includeEmpties) {

	inputstring = new String(inputstring);

	separators = new String(separators);

	

	if(separators == "undefined") {

		separators = " :;";

	}

	

	fixedExplode = new Array(1);

	currentElement = "";

	count = 0;

	

	for(x=0; x < inputstring.length; x++) {

		char = inputstring.charAt(x);

		if(separators.indexOf(char) != -1) {

			if ( ( (includeEmpties <= 0) || (includeEmpties == false)) && (currentElement == "")) {

			

			}	else {

				fixedExplode[count] = currentElement;

				count++;

				currentElement = "";

			}

		}	else {

			currentElement += char;		

		}

	}

	if (( ! (includeEmpties <= 0) && (includeEmpties != false)) || (currentElement != "")) {

		fixedExplode[count] = currentElement;

	}

	return fixedExplode;

}





//Inicio Efeito Alpha Image (IE only)

function clean(anImage, anLabel, anTxt){

		interval = setInterval("makeclean('"+anImage+"','"+anLabel+"','"+anTxt+"')",10);

}

varTop = 730;

varTop2 = 731;

maxTop = 764;

function foggy(anImage, anLabel, anTxt){

		document.getElementById(anTxt).style.visibility = "hidden";

		document.getElementById(anTxt).style.overflow = "hidden";

		clearInterval(interval);

		document.getElementById(anImage).filters.alpha.opacity = 10;

		document.getElementById(anLabel).filters.alpha.opacity = 25;

		document.getElementById(anLabel).style.top = varTop;

		varTop2 = varTop+1;

}

function makeclean(anImage, anLabel, anTxt){

		document.getElementById(anTxt).style.visibility = "visible";

		document.getElementById(anTxt).style.overflow = "visible";

	if (varTop2 < maxTop){

		document.getElementById(anImage).filters.alpha.opacity += 5;

		document.getElementById(anLabel).filters.alpha.opacity += 10;

		document.getElementById(anLabel).style.top = varTop2;

		varTop2++;

	} else if (window.interval)	{

		clearInterval(interval);

	}

}

//Fim Efeito Alpha Image



//Início função Foamata Campo

function txtBoxFormat(objForm, strField, sMask, evtKeyPress) {

	var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

	

	nav = explode(navigator.appName, " ");

	if((x[0] == "Microsoft") || (x[0] == "microsoft")) {

		nTecla = evtKeyPress.keyCode; // Internet Explorer

	} else if((x[0] == "Netscape") || (x[0] == "netscape")) {

		nTecla = evtKeyPress.which; // Nestcape

	}

	

	sValue = objForm[strField].value;

	

	// Limpa todos os caracteres de formatação que

	// já estiverem no campo.

	sValue = sValue.toString().replace( "-", "" );

	sValue = sValue.toString().replace( "-", "" );

	sValue = sValue.toString().replace( ".", "" );

	sValue = sValue.toString().replace( ".", "" );

	sValue = sValue.toString().replace( "/", "" );

	sValue = sValue.toString().replace( "/", "" );

	sValue = sValue.toString().replace( "(", "" );

	sValue = sValue.toString().replace( "(", "" );

	sValue = sValue.toString().replace( ")", "" );

	sValue = sValue.toString().replace( ")", "" );

	sValue = sValue.toString().replace( ":", "" );

	sValue = sValue.toString().replace( " ", "" );

	sValue = sValue.toString().replace( " ", "" );

	fldLen = sValue.length;

	mskLen = sMask.length;

	

	i = 0;

	nCount = 0;

	sCod = "";

	mskLen = fldLen;

	

	while (i <= mskLen) {

		bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))

		bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " ") || (sMask.charAt(i) == ":"))

		

		if (bolMask) {

			sCod += sMask.charAt(i);

			mskLen++;

		}	else {

			sCod += sValue.charAt(nCount);

			nCount++;

		}

		i++;

	}

	

	objForm[strField].value = sCod;

	

	if (nTecla != 8) { // backspace

		if (sMask.charAt(i-1) == "9") { // apenas números...

			return ((nTecla > 47) && (nTecla < 58)); // números de 0 a 9

		} else { // qualquer caracter...

			return true;

		}

	}	else {

		return true;

	}

} //Final da função para formatar valores em campos

function flash(arquivo, largura, altura){

	document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,29,0' width='" + largura + "' height='" + altura + "'>");

	document.write("	<param name='movie' value='" + arquivo + "'>");

	document.write("	<param name='quality' value='high'>");

	document.write("	<param name='wmode' value='transparent'>");

	document.write("	<embed src='" + arquivo + "' wmode='transparent' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + largura + "' height='" + altura + "'></embed>");

	document.write("</object>");

}


//document.getElementById("pessoa").focus();
function isEmail(string) {
return (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1);
}
function formatTelefone(element, evt)
{
var separador = '-'; 
//var sValue = element.value.toString().replace( "-", "" );
var sValue = element.value;
	sValue = cleanString(sValue, /[!-/:-@[-`{-~]/);
	sValue = cleanString(sValue, /[a-z]/);
	sValue = cleanString(sValue, /[A-Z]/);
	sValue = cleanString(sValue, ' ');
	//sValue = cleanString(sValue, /[0-9]/);

var sLength = sValue.length < 14 ? sValue.length : 14;
var sCode = "";
var i = 0;
var nTecla = getEvent(evt);

if ((nTecla >= 48 && nTecla <= 57) || nTecla == null)
{
	sCode = '(';
	while (i < sLength) 
	{
		sCode += sValue.charAt(i);
		i++;
		switch (i)
		{
			case 2:
				sCode += ') ';
				break;
			case 5:
				if (sLength <= 8)
				{
					sCode += '-';
				}
				break;
			case 6:
				if (sLength >= 9)
				{
					sCode += '-';
				}
				break;
		}
	}
	element.value = sCode;
} else
{
	if (nTecla == 8)
		return true;
	else
		return false;
}
}
function getEvent(evt)
{
if (evt == null)
{
	return null; // executa ao sair do campo, onBlur
} else if (evt.which)
{
	return evt.which; // FF
} else 
{
	return evt.keyCode; // Opera e IE
}
}
function cleanString(value, pattern)
{
var total = value.length;
var i;

for (i = 0; i <= total; i++)
{
	value = value.toString().replace(pattern, "");
}

return value;
}
function validaForm(){
	       var f = document.forms[0];
               if(f.pessoa.value.length < 2){
                    alert("Por favor, digite o seu nome.");
                    f.pessoa.focus();
                    return false;
               }
               if(f.telefone.value.length < 12){
                    alert("Por favor, digite o seu telefone.");
                    f.telefone.focus();
                    return false;
               }
               if(f.mailpessoa.value.length > 5){
                    if(!isEmail(f.mailpessoa.value)){
                        alert("Email não válido.");
                        f.mailpessoa.focus();
                        return false; 
                    }
               } else {
                    alert("Por favor, digite o seu e-mail.");
                    f.mailpessoa.focus();
                    return false;
               }
               if(f.mesp.value.length < 3){
                    alert("Por favor, Informe o mês da reserva.");
                    f.mesp.focus();
                    return false;
               }
               if(f.anop.value.length < 4){
                    alert("Por favor, digite o ano da reserva.");
                    f.anop.focus();
                    return false;
               }
               f.submit();
	}
