//TRANSIÇÃO DE IMAGENS
function roll(img_name, img_src) {
   document[img_name].src = img_src;
}

//RELÓGIO
function UR_Start() 
{
	UR_Nu = new Date;
	UR_Indhold = showFilled(UR_Nu.getHours()) + "<strong>:</strong>" + showFilled(UR_Nu.getMinutes());
	document.getElementById("ur").innerHTML = UR_Indhold;
	setTimeout("UR_Start()",1000);
}
function showFilled(Value) 
{
	return (Value > 9) ? "" + Value : "0" + Value;
}

//POSTAR PÁGINA
function post(pagina,form){
    with(document.getElementById(form)){
        method = 'POST';
        action = pagina;
        submit();
    }
    return;
}

//POPUP
function PopupCenter(pageURL, title,w,h) {
	var left = (screen.width/2)-(w/2);
	var top = (screen.height/2)-(h/2);
	var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, 	copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}

//MASCARAS
function redireciona(caminho) {
	document.location = caminho;
}

function mascara(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}

function dta(v){
    v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
    v=v.replace(/(\d{2})(\d)/,"$1/$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
    v=v.replace(/(\d{2})(\d)/,"$1/$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
    return v
}

function soNumeros(v){
    return v.replace(/\D/g,"")
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function FormataMascara(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 leech(v){
	v=v.replace(/o/gi,"0")
	v=v.replace(/i/gi,"1")
	v=v.replace(/z/gi,"2")
	v=v.replace(/e/gi,"3")
	v=v.replace(/a/gi,"4")
	v=v.replace(/s/gi,"5")
	v=v.replace(/t/gi,"7")
	return v
}

function Formatadata(Campo, teclapres){
	var tecla = teclapres.keyCode;
	var vr = new String(Campo.value);
	vr = vr.replace("/", "");
	vr = vr.replace("/", "");
	vr = vr.replace("/", "");
	tam = vr.length + 1;
	if (tecla != 8 && tecla != 8){
		if (tam > 0 && tam < 2)
		Campo.value = vr.substr(0, 2) ;
		if (tam > 2 && tam < 4)
		Campo.value = vr.substr(0, 2) + '/' + vr.substr(2, 2);
		if (tam > 4 && tam < 7)
		Campo.value = vr.substr(0, 2) + '/' + vr.substr(2, 2) + '/' + vr.substr(4, 7);
	}
}

function telefone(v){
    v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
    v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")    //Coloca hífen entre o quarto e o quinto dígitos
    return v
}

//DEIXA VALOR DO CAMPO MAIUSCULO
function converteUpper(campo) {
    campo.value = campo.value.toUpperCase();
}

// ABRIR PÁGINA EM DIV (JQUERY.JS)
function displayOnDiv(pagina) {
	$("#content").load(pagina); 

};

function displayOnDivId(div, pagina) {
	$("#"+div).load(pagina); 
};  
