
var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
var ie  = (typeof window.ActiveXObject != 'undefined');

function validaForm(frm, method, exec_func, func){
	var objForm = document.forms[frm];
	var objElemento = '';
	var msg = '';
	var post = '';
	var focus = '';
	
	for(i = 0; i < objForm.length; i++){
		objElemento = objForm.elements[i];
		if(objElemento.disabled == false && objElemento.type != "submit" && objElemento.tagName != "FIELDSET"){
			//alert(objElemento.tagName);

			if(objElemento.type == "radio"){
				if(objElemento.checked == true)
					post += objElemento.name +'|;|'+ objElemento.value+'|;|';
			}else if(objElemento.type == "checkbox" && objElemento.title != '' && objElemento.checked == false){
				//if(objElemento.checked == true) {
					//post += objElemento.name +'|;|'+ objElemento.value+'|;|';
				//} else {
					msg += objElemento.title+"\n";
				//}
			}else if((objElemento.type == "textarea" || objElemento.type == "select-one") && (objElemento.title != 'undefined' || objElemento.title != '') && (objElemento.value == objElemento.title || objElemento.value == "")){
				msg += objElemento.title+"\n";
				if(focus == "")
					focus = objElemento;
			}else{
				if(objElemento.alt != "" && (objElemento.value == objElemento.alt || objElemento.value == "")){
					msg += objElemento.alt+"\n";
					if(focus == "")
						focus = objElemento;
				}else if(objElemento.alt == "E-mail" || objElemento.name == "email"){
					var vetEmail = objElemento.value.split(';');
					var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
					for(k = 0; k < vetEmail.length; k++){
						if(!filter.test(vetEmail[k]))
							msg = "E-mail invalido, " + vetEmail[k] +"\n"+msg;
					}
					if(msg == "")
						post += objElemento.name +'|;|'+ objElemento.value+'|;|'; 
					else
						focus = objElemento;		
				}else {
					post += objElemento.name +'|;|'+ objElemento.value+'|;|'; 
				}
			}
		}

	}

	if(msg == "" && (method == "" || method == "submit"))
		objForm.submit();
	else if(msg == "" && method == "ajax")
		eval(exec_func(post,func));
	else if(msg != ""){
		try{
			msgHtml = msg.replace(/\n/g, '<br />');
			openAlert("<div id='pendencias'>Preencha o(s) campo(s):<br />"+msgHtml+"</div>");
		}catch(e){
			alert("Preencha o(s) campo(s):\n"+msg);
		}
		focus.focus();
	}
}

function onlyNumber(tecla){
	if(window.event)
		keynum = tecla.keyCode
	else
		keynum = tecla.which
	
	if(keynum == 0 || keynum == 8){
	
	}else{
		if(keynum < 48 || keynum > 57)
			return false;
	}
}

function over(img, local){
	document.getElementById(local).src = img;
}

function mascaraCampo(e,src,mask) {
	if(window.event) { 
		_TXT = e.keyCode; 
	} else if (e.which) { 
		_TXT = e.which; 
	}

	if(_TXT > 47 && _TXT < 58) { 
		var i = src.value.length; 
		var saida = mask.substring(0,1); 
		var texto = mask.substring(i);
		if (texto.substring(0,1) != saida) { 
			 src.value += texto.substring(0,1); 
		}
		return true; 
	} else { 
		if (_TXT != 8) { 
			return false; 
		} else { 
			return true; 
		}
	}
}

function validarCPF(cpf) {
    
   if(cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" ||
	  cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" ||
	  cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" ||
	  cpf == "88888888888" || cpf == "99999999999"){
	  return false;
   }

   soma = 0;
   for(i = 0; i < 9; i++)
   	 soma += parseInt(cpf.charAt(i)) * (10 - i);
   resto = 11 - (soma % 11);
   if(resto == 10 || resto == 11)
	 resto = 0;
   if(resto != parseInt(cpf.charAt(9))){
	 return false;
   }
   soma = 0;
   for(i = 0; i < 10; i ++)
	 soma += parseInt(cpf.charAt(i)) * (11 - i);
   resto = 11 - (soma % 11);
   if(resto == 10 || resto == 11)
	 resto = 0;
   if(resto != parseInt(cpf.charAt(10))){
 	 return false;
   }
   return true;
}

function numerico(obj, e){

	var ch;
	var valido = false;
	var arrPermitido = Array(9, 13, 16, 17, 18, 19, 20, 27, 32, 33, 34, 35, 36, 48, 44, 45, 46, 49, 50, 51, 52, 53, 54, 55, 56, 57, 91, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 145);
	var size = obj.value.length;

	try { ch = e.keyCode; } catch (e) { ch = e.which; }

	for ( var i = 0; i < arrPermitido.length; i++ ) {
		if ( ch == arrPermitido[i] ) {
			valido = true;
			break;
		}
	}

	if ( valido == false ) {
		obj.value = obj.value.substr(0,size-1);
	}

}

function redirect(track, url){
	tracker(track);
	setTimeout("goUrl('"+url+"')",1000);
}


function goUrl(url){
	window.location = url;
}

function tracker(name) {
	var pageTracker = _gat._getTracker("UA-82394-47");
	pageTracker._initData();
	if (!name)
		pageTracker._trackPageview();
	else
		pageTracker._trackPageview(name);
}

function faleConosco() {
	tracker('/site/home/rodape/fale_conosco/acesso');
	open('http://www.rexona.com.br/site/content/contato/contato_popup.php?origem=DANCE','','width=475,height=435')
}

function Meta () {
	tracker("/site/mypage/play_video");
	document.getElementById("Meta").src = SITE + "site/content/mypage/play_video_meta.html";
}
