//Marca tudos os checkbox dos formulario
//Visit JavaScript Kit (http://javascriptkit.com) for script
//os checks para marcacao deve ter o nome de chkDel
function checkall(pChecked, pChkItems){
	var c
	var colCheck = eval(pChkItems)		 		//eval("document.forms.frmConsulta.chkSelect")

	for (c=0; c < colCheck.length; c++)
		colCheck[c].checked = eval(pChecked) 	//eval("document.forms.frmConsulta.chkAll.checked")
}

function popup(pEndereco, pWidth, pHeight) {
	resp = window.open(pEndereco,'','width=' + pWidth + ',height=' + pHeight + ',directories=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes')
	if (resp != null) {
		resp.location.href = pEndereco
	}
}

function showDialog(pURL, pWidth, pHeight) {
	window.showModelessDialog(pURL, '', 'Resizable:no; DialogHeight:' + pHeight + 'px; DialogWidth:' + pWidth + 'px; Edge:raised; Help:no; Scroll:no; Status:no; Center:yes;');
}

function showCalendario(oDoc, cDate) {
	window.open("inc/datepicker.asp?backf="+oDoc+"&cDate="+cDate,"window", "height=210, width=300, resizeable=no,","");
    //showDialog("./inc/datepicker.asp?backf="+oDoc+"&cDate="+cDate,300,210);
}

//Function to open preview post window
function debugPrint(pTexto) {
	document.cookie = "textarea=" + pTexto
	window.showModelessDialog('admin/editor/poppreview.asp','debugPrint', 'Resizable:no; DialogHeight:480px; DialogWidth:640px; Edge:raised; Help:no; Scroll:no; Status:no; Center:yes;');
}

function trmouseover(src,cor,useclass) {
    if (useclass == true)
        src.className=cor;
    else {
        src.className='';
        src.bgColor=cor;
    }
    src.style.cursor="hand";
}
function trmouseout(src,cor,useclass) {
    if (useclass == true)
        src.className=cor;
    else {
        src.className='';
        src.bgColor=cor;
    }
    src.style.cursor="default";
}

function validaCampos(pForm){
	var x, campo;
    var obrigatorio, caption;

	with (pForm) {
        for (x=0; x < elements.length; x++) {
		    campo = elements[x];
            obrigatorio = (campo.title.substr(0,1) == "*");
            caption = campo.title.substr(2).toUpperCase();

            if (obrigatorio && campo.value == "") {
                alert("O campo " + caption + " deve ser preenchido!");
                campo.focus();
                return false;
			} //end if
		} //end for
	} //end with
    return true;
}

function addFav(url, title){
    if (window.sidebar) window.sidebar.addPanel(title, url,"");
    else if(window.opera && window.print){
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',url);
        mbm.setAttribute('title',title);
        mbm.click();
    }
    else if(document.all){window.external.AddFavorite(url, title);}
}

function goBack(){
  if (parent.history.length > 0){
  	parent.history.back()
  }
}
function goForward(){
  if (parent.history.length > 0){
  	parent.history.forward()
  }
}