function verificaCanal(){
	if (document.formulario.idCanal.selectedIndex == 0){
		alert('Indique o Canal desta notícia!');
		return false;
		
	}else{
	 	document.formulario.submit();
	}
}


function confirma(registo,url){

	if(confirm('Tem a certeza que deseja remover o registo "' + registo + '" ? '))
	{
		self.location = url;
	}
}

function mudaClasse(obj,srv){ 
	obj.className = srv; 
} 


function mostraDiv(camada){
	if (camada.style.display == 'none')
		{camada.style.display = ''}
}


function escondeDiv(camada){
	if (camada.style.display == '')
		{camada.style.display = 'none'}
}


function trocaDiv(camada){
	
	obj = document.getElementById(camada)
	
	if (obj.style.display == 'none')
		{obj.style.display = ''}
	else
		{obj.style.display = 'none'}
}


function troca(camada)
{
	if (camada.style.visibility == "hidden")
		{camada.style.visibility = "visible"}
	else
		{camada.style.visibility = "hidden"}
}


function mostra(camada)
{
	if (camada.style.visibility == "hidden")
		{camada.style.visibility = "visible"}
	else
		{return false}
}


function esconde(camada)
{
	if (camada.style.visibility == "visible")
		{camada.style.visibility = "hidden"}
	else
		{return false}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}



function load(formName) {
  var list = document[formName].list;
  var str = list.options[list.selectedIndex].value;
  if (str != "") location.href = str;
}


function Maiusculas()
{
 	var cidade=document.form.CIDADE.value;
 	cid=cidade.toUpperCase();
 	document.form.CIDADE.value=cid;
}


function MM_displayStatusMsg(msgStr) //v1.0
{
  status=msgStr;
  document.MM_returnValue = true;
}




function MM_openBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}


function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}


function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' dever ser um endereço de email válido.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' deve ser um Número.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' deve ser um Número entre '+min+' e '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' é de preenchimento obrigatório.\n'; }
  } if (errors) alert('Ocorreram os seguintes erros:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function YY_checkform() { //v4.65
//copyright (c)1998,2002 Yaromat.com
  var args = YY_checkform.arguments; var myDot=true; var myV=''; var myErr='';var addErr=false;var myReq;
  for (var i=1; i<args.length;i=i+4){
    if (args[i+1].charAt(0)=='#'){myReq=true; args[i+1]=args[i+1].substring(1);}else{myReq=false}
    var myObj = MM_findObj(args[i].replace(/\[\d+\]/ig,""));
    myV=myObj.value;
    if (myObj.type=='text'||myObj.type=='password'||myObj.type=='hidden'){
      if (myReq&&myObj.value.length==0){addErr=true}
      if ((myV.length>0)&&(args[i+2]==1)){ //fromto
        var myMa=args[i+1].split('_');if(isNaN(parseInt(myV))||myV<myMa[0]/1||myV > myMa[1]/1){addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==2)){
          var rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-z]{2,4}$");if(!rx.test(myV))addErr=true;
      } else if ((myV.length>0)&&(args[i+2]==3)){ // date
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);
        if(myAt){
          var myD=(myAt[myMa[1]])?myAt[myMa[1]]:1; var myM=myAt[myMa[2]]-1; var myY=myAt[myMa[3]];
          var myDate=new Date(myY,myM,myD);
          if(myDate.getFullYear()!=myY||myDate.getDate()!=myD||myDate.getMonth()!=myM){addErr=true};
        }else{addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==4)){ // time
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);if(!myAt){addErr=true}
      } else if (myV.length>0&&args[i+2]==5){ // check this 2
            var myObj1 = MM_findObj(args[i+1].replace(/\[\d+\]/ig,""));
            if(myObj1.length)myObj1=myObj1[args[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!myObj1.checked){addErr=true}
      } else if (myV.length>0&&args[i+2]==6){ // the same
            var myObj1 = MM_findObj(args[i+1]);
            if(myV!=myObj1.value){addErr=true}
      }
    } else
    if (!myObj.type&&myObj.length>0&&myObj[0].type=='radio'){
          var myTest = args[i].match(/(.*)\[(\d+)\].*/i);
          var myObj1=(myObj.length>1)?myObj[myTest[2]]:myObj;
      if (args[i+2]==1&&myObj1&&myObj1.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
      if (args[i+2]==2){
        var myDot=false;
        for(var j=0;j<myObj.length;j++){myDot=myDot||myObj[j].checked}
        if(!myDot){myErr+='* ' +args[i+3]+'\n'}
      }
    } else if (myObj.type=='checkbox'){
      if(args[i+2]==1&&myObj.checked==false){addErr=true}
      if(args[i+2]==2&&myObj.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
    } else if (myObj.type=='select-one'||myObj.type=='select-multiple'){
      if(args[i+2]==1&&myObj.selectedIndex/1==0){addErr=true}
    }else if (myObj.type=='textarea'){
      if(myV.length<args[i+1]){addErr=true}
    }
    if (addErr){myErr+='* '+args[i+3]+'\n'; addErr=false}
  }
  if (myErr!=''){alert('A informação está incompleta ou contém erros. Por favor corriga-os.\t\t\t\t\t\n\n'+myErr)}
  document.MM_returnValue = (myErr=='');
}


function redimensiona(){

	var isNav, isIE, nVer = parseInt(navigator.appVersion.charAt(0));
	
	if (nVer >= 4) {
		isNav = (navigator.appName == "Netscape") ? 1 : 0;
		isIE = (navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;
	}
	// netscape 4.x
	if ((isNav) && (nVer < 5)) {
		var w = document.layers[0].document.images[0].width;
		var h = document.layers[0].document.images[0].height;
		window.innerWidth = w;
		window.innerHeight = h;
		window.moveTo((screen.availWidth - window.outerWidth) / 2, (screen.availHeight - window.outerHeight) / 2);
		return;
	}
	// netscape 6.x
	if (isNav) {
		var w = document.images[0].width + 2;
		var h = document.images[0].height + 133;
		w = w - window.innerWidth;
		h = h - window.innerHeight;
		window.resizeBy(w, h);
		window.moveTo((screen.availWidth - window.outerWidth) / 2, (screen.availHeight - window.outerHeight) / 2);
   		return;
   }
	// i.e.
	if (isIE) {
		var w = document.images[0].width + 26;
		var h = document.images[0].height + 140;
		if (w > screen.availWidth) w = screen.availWidth;
		if (h > screen.availHeight) h = screen.availHeight;
		window.resizeTo(w, h);
		window.moveTo((screen.availWidth - w) / 2, (screen.availHeight - h) / 2);
   }
}