// JavaScript Document
function Clear(elem) {
    elem.value = '';
}


function confirmaExclusao(){

	
    links = document.getElementsByTagName('a');
	
    for (i=0; i<links.length; i++) {

        if(links[i].className == 'btnExcluir'){
            var anchor = links[i];
            links[i].onclick = function() {
				
                if (window.confirm ("Certeza que deseja excluir o registro? ")) {
                //window.location.href = this.getAttribute('href');
                    
                } else {
                    this.setAttribute('href', 'javascript:void(0)');
                }
            }
        }
    }
}
// Final confirmaExclusao


//http://www.codigofonte.com.br/codigo/js-dhtml/browser/invocar-a-tela-print-preview-no-ie/imprimir
//Imprimir pagina compativel com Firefox e IE
function visualizarImpressao(){
    var Navegador = '<object id="Navegador1" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
    document.body.insertAdjacentHTML('beforeEnd', Navegador);
    Navegador1.ExecWB(7, 1);
    Navegador1.outerHTML = "";
}



/* 
 * Alerta sobre a exclusao da foto principal
 * author: João Gustavo
 */
function excluirFotoPrincipal() {
	
    div = document.getElementsByTagName('div');
	
    for ( i=0; i<div.length; i++ ) {
		
        strClass = div[i].className;
		
        arrClass = strClass.split(" ");
		
        for ( j=0; j<arrClass.length; j++ ) {
			
            if (arrClass[j] == 'fotoPrincipal') {
				
                links = div[i].getElementsByTagName('a');
				
                for ( j=0; j<links.length; j++ ) {
                    if( links[j].className == 'btnExcluirFoto') {
						
                        links[j].onclick = function() {
				
                            if (window.confirm ("Excluindo a foto principal, não tera foto no corpo do texto. Certeza que deseja excluir?"))
                            {
                            //window.location.href = this.getAttribute('href');
                            }
                            else
                            {
                                this.setAttribute('href', 'javascript:void(0)');
                            }
							
                        }
						
                    } //endif
                } //endfor
				
				
            } //endif
			
        } //endfor
		
    } // endfor
	
}

addEvent (window, "load", confirmaExclusao);
addEvent (window, "load", excluirFotoPrincipal);

function selecionar(id , para ){
	
	
    window.location.href=  para+document.getElementById(id).value;
	
}




function editarLegenda(id){

    var style = document.getElementById(id).style.display;
	
    if( style == "none") {
        document.getElementById(id).style.display ="block";
		
    }else{
        document.getElementById(id).style.display ="none";
	
    }
}	


//usada no formulario de compra tem a mesa funcao do submit
//usada para submit em botao tipo link
function enviar(form_name){			
    form = document.getElementById(form_name);
    //alert(form.comNome.value);
    form.submit();
/*document.cform.submit();*/
}

function lightbox(src) {

    var a_false = document.createElement("A");
    a_false.rel = "lightbox";
    a_false.href = src;
    myLightbox.start(a_false);
    a_false = null;

}

function SetFocus() {
    document.getElementById("login").focus();
}

/**
 * usado para setar um campo checkbox passando o seu id
 */
function set_campo(id) {
    document.getElementById(id).checked = true;
}

function set_campos_check(id) {
    if(document.getElementById(id).checked == false){
        document.getElementById('dcTurnoM_'+id).checked = false;
        document.getElementById('dcTurnoT_'+id).checked = false;
        document.getElementById('dcTurnoN_'+id).checked = false;
        document.getElementById('dcCoordenador_'+id).checked = false;
    }

}


