/** 
 * Vectra Scripts
 *  
 * @category  JavaScript
 * @name      scrips.js
 * @author    Lucas Mendonça <lucasnix@gmail.com>
 * @license   http://creativecommons.org/licenses/by-sa/3.0/br/ Creative Commons Attribution-Share Alike 3.0 Unported
 * @version   1.0
 * @since     06-10-2010
 * @updated   08-10-2010
 */
var BASEURL = '';
$(document).ready( function(){

	/*
	* Body Class
	*
	* Adiciona classes ao <body> respectivas ao sistema operacional, browser e versão do browser.
	* Ex.: Se vc estiver no Windows usando Firefox 3: <body class="windows firefox firefox3">
	*
	* @author 	Gabriel Izaias <gabriel.izaias@gmail.com.br>
	* @updated	03-17-2010 <mm-dd-yyyy>
	* @version	1.2
	*/
	var nav = navigator.userAgent.toLowerCase();
	a =  /(chrome)(?:.*chrome)?[ \/]([\w.]+)/.exec(nav) || /(safari)(?:.*version)?[ \/]([\w.]+)/.exec(nav) || /(opera)(?:.*version)?[ \/]([\w.]+)/.exec(nav) || /(ie) ([\w.]+)/.exec(nav) || !/compatible/.test(nav) && /(firefox)(?:.*firefox)?[ \/]([\w.]+)/.exec(nav) || [];
	if ( nav.indexOf('macintosh') != -1 ){ os = 'macintosh';}  else if ( nav.indexOf('windows') != -1 ){ os = 'windows'; } else if ( nav.indexOf('linux') != -1 ){ os = 'linux'; }
	var	browser = { name: a[1] || "", version: a[2] || "0", os: os }
	$("body").addClass( browser.name + ' ' + browser.name+parseInt(browser.version) + ' ' + browser.os );
	/* Fim Body Class */

						   
	$(".defaultValue").focus(function(){
				val = this.value;
				this.value = "";
	}).blur(function(){
			if( this.value == "" ){
			this.value = val;
			}
	});
	
	$(".defaultValue").focus(function(){
									  this.value = "";
	});
	
	$(".menu").bind('mouseover', function(){
								
						id = this.getAttribute('title');
						//alert(id);
						$("#"+id).addClass('selectedMenu');
	 }).mouseleave(function(){
						$("#"+id).removeClass('selectedMenu');		 
	});
	
	//validacao do cadastro
    $('#formFaleConosco').submit(function(){
        var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);

           if(($("#email").val()=='') || $("#email").val()=='Seu e-mail'){
			   $("#email").focus();
                alert('O campo e-mail não deve ser deixado em branco.');
                return false;
            }
            if(!er.test($('#email').attr('value'))){
				$("#email").focus();
				alert('E-mail em formato inválido. Por favor, preencha esse campo corretamente.');
                return false;
			}
			if(($("#mensagem").val()=='') || $("#mensagem").val()=='Escreva o que deseja'){
				$("#mensagem").focus();
                alert('O campo e-mail não deve ser deixado em branco.');
                return false;
            }
         
        return true;
		
    });
	
	$('#formNewsletter').submit(function(){
        var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);

           if(($("#emailNews").val()=='') || $("#emailNews").val()=='Seu e-mail'){
			   $("#emailNews").focus();
                alert('O campo e-mail não deve ser deixado em branco.');
                return false;
            }
            if(!er.test($('#emailNews').attr('value'))){
				$("#emailNews").focus();
				alert('E-mail em formato inválido. Por favor, preencha esse campo corretamente.');
                return false;
			}
         
        return true;
		
    });
	

});

function showContato(){
	$("#boxFaleConosco").show('fast');
}

function hideContato(){
	$("#boxFaleConosco").hide('fast');
}
