// LISTENERS
$(document).ready(
	function(){
		Site.init();
	}
);

// SITE
var Site = {
	init: function ()
	{
		$('.botao-fotos').toggle(function(){(!(jQuery.browser.msie && parseInt(jQuery.browser.version)==6&&!window["XMLHttpRequest"]))?$(this).parent().next().slideDown():$(this).parent().next().show();},function(){(!(jQuery.browser.msie && parseInt(jQuery.browser.version)==6&&!window["XMLHttpRequest"]))?$(this).parent().next().slideUp():$(this).parent().next().hide();});
		
		$('#faq li dl dt').click(
			function(){
				if(!(jQuery.browser.msie && parseInt(jQuery.browser.version)==6&&!window["XMLHttpRequest"]))
				{
					$('#faq li dl dd').slideUp('fast');
					$(this).next().slideDown('fast');
				} else
				{
					$('#faq li dl dd').hide();
					$(this).next().show();
				}
			}
		);	
	}
};


function Tecla(e)
{
	if (document.all) // Internet Explorer
		var tecla = event.keyCode;
	else if(document.layers) // Nestcape
		var tecla = e.which;
		if (tecla > 47 && tecla < 58) // numeros de 0 a 9
			return true;
		else
			{
				if (tecla != 8) // backspace
					event.keyCode = 0;
					//return false;
				else
					return true;
			}
};




function trim(vString){
    return vString.replace(/^\s+|\s+$/ig, '');
}
 
function clickInText(obj){
    var valorinicial = trim(obj.getAttribute('valorInicial'));
    if ( trim(obj.value) == valorinicial ) {
        obj.value = '';     
    }
}
 
function clickOutText(obj){
    var valorinicial = trim(obj.getAttribute('valorInicial'));
    if ( trim(obj.value) == '' ) {
        obj.value = valorinicial;     
    }
}
 
function clickInPass(obj1, obj2){
    var valorinicial = trim(obj1.getAttribute('valorInicial'));
    if ( trim(obj1.value) == valorinicial ) {
        obj1.style.display = 'none';
        obj2.style.display = 'inline';
        obj2.value = '';
        obj2.focus();
    }
}
 
function clickOutPass(obj1, obj2){
    var valorinicial = trim(obj1.getAttribute('valorInicial'));
    if ( trim(obj2.value) == '' ) {
        obj2.style.display = 'none';
        obj1.value = valorinicial;
        obj1.style.display = 'inline';
    }
}

function somaTudo(){
    Total = 0;
    Total2 = 0;
    soma();
    soma2();
    
    form1.total.value = Total;
    form1.total2.value = Total2;
}

function soma(campo) {
    with(form1){
        if(pergunta1[0].checked)Total++;
        if(pergunta2[0].checked)Total++;
        if(pergunta3[0].checked)Total++;
        if(pergunta4[0].checked)Total++;
        if(pergunta5[0].checked)Total++;
        if(pergunta6[0].checked)Total++;
        if(pergunta7[0].checked)Total++;
        if(pergunta8[0].checked)Total++;
        if(pergunta9[0].checked)Total++;
        if(pergunta10[0].checked)Total++;
        if(pergunta11[0].checked)Total++;
        if(pergunta12[0].checked)Total++;
        if(pergunta13[0].checked)Total++;
        if(pergunta14[0].checked)Total++;
        if(pergunta15[0].checked)Total++;
        if(pergunta16[0].checked)Total++;
        if(pergunta17[0].checked)Total++;
        if(pergunta18[0].checked)Total++;
        if(pergunta19[0].checked)Total++;
        if(pergunta20[0].checked)Total++;
    }
}

function soma2(campo) {
    with(form1){
        if(pergunta1[1].checked)Total2++;
        if(pergunta2[1].checked)Total2++;
        if(pergunta3[1].checked)Total2++;
        if(pergunta4[1].checked)Total2++;
        if(pergunta5[1].checked)Total2++;
        if(pergunta6[1].checked)Total2++;
        if(pergunta7[1].checked)Total2++;
        if(pergunta8[1].checked)Total2++;
        if(pergunta9[1].checked)Total2++;
        if(pergunta10[1].checked)Total2++;
        if(pergunta11[1].checked)Total2++;
        if(pergunta12[1].checked)Total2++;
        if(pergunta13[1].checked)Total2++;
        if(pergunta14[1].checked)Total2++;
        if(pergunta15[1].checked)Total2++;
        if(pergunta16[1].checked)Total2++;
        if(pergunta17[1].checked)Total2++;
        if(pergunta18[1].checked)Total2++;
        if(pergunta19[1].checked)Total2++;
        if(pergunta20[1].checked)Total2++;
    }
}

// PNG transparente no IE6
//<!--[if lt IE 7]>
//function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
//{
//   var arVersion = navigator.appVersion.split("MSIE")
//   var version = parseFloat(arVersion[1])
//   if ((version >= 5.5) && (document.body.filters))
//   {
//      for(var i=0; i<document.images.length; i++)
//      {
//         var img = document.images[i]
//         var imgName = img.src.toUpperCase()
//         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
//         {
//            var imgID = (img.id) ? "id='" + img.id + "' " : ""
//            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
//            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
//            var imgStyle = "display:inline-block;" + img.style.cssText
//            if (img.align == "left") imgStyle = "float:left;" + imgStyle
//            if (img.align == "right") imgStyle = "float:right;" + imgStyle
//            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
//            var strNewHTML = "<span " + imgID + imgClass + imgTitle
//            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
//            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
//            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
//            img.outerHTML = strNewHTML
//            i = i-1
//         }
//      }
//   }   
//}
//window.attachEvent("onload", correctPNG);
//<![endif]-->


// Banner Dhtml Home

function centerBanner() {
	var viewportHeight =(self.innerHeight || (document.documentElement.clientHeight || (document.body.clientHeight || 0))); // Grava a altura do viewport
	var viewportWidth =(self.innerWidth || (document.documentElement.clientWidth || (document.body.clientWidth || 0))); // Grava a largura do viewport
	
	var bannerHeight = $(".bannerDhtml").height(); 
	var bannerWidth = $(".bannerDhtml").width();
	
	var centerTop = Math.floor((viewportHeight/2) - (bannerHeight/2));
	var centerLeft = Math.floor((viewportWidth/2) - (bannerWidth/2));
	
	$(".bannerDhtml").attr('style','left:'+centerLeft+'px; top:'+centerTop+'px; display: block;');
}