/* Netscape ou IE */

/**/
function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

/***********************************************
* Highlight Table Cells Script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Specify highlight behavior. "TD" to highlight table cells, "TR" to highlight the entire row:
var highlightbehavior="TR"

var ns6=document.getElementById&&!document.all
var ie=document.all

function changeto(e,highlightcolor){
source=ie? event.srcElement : e.target
if (source.tagName=="TABLE")
return
while(source.tagName!=highlightbehavior && source.tagName!="HTML")
source=ns6? source.parentNode : source.parentElement
if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
source.style.backgroundColor=highlightcolor
}

function contains_ns6(master, slave) { //check if slave is contained by master
while (slave.parentNode)
if ((slave = slave.parentNode) == master)
return true;
return false;
}

function changeback(e,originalcolor){
if (ie&&(event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")||source.tagName=="TABLE")
return
else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id=="ignore"))
return
if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source)
source.style.backgroundColor=originalcolor
}

function ViewCrossReference (selSelectObject)
{
   if (selSelectObject.options[selSelectObject.selectedIndex].value != "")
   { 
     location.href=selSelectObject.options[selSelectObject.selectedIndex].value
   }
}

function checkMaxInput(form,field,nchar) {
	var maxLen = nchar; // max number of characters allowed in the textbox
	if (field.value.length > maxLen) // if too long.... trim it!
		field.value = field.value.substring(0, maxLen);
	else // otherwise, update 'characters left' counter
		form.remLen.value = maxLen - field.value.length;
}

function validarForm_003(frm) {
	if (frm.Nome.value.length < 2) {
		alert("Verificar Nome (mínimo 2 caracteres).");
		frm.Nome.focus();
		return false;
	}
	if (frm.UtilizadorEmail.value.indexOf("@") == -1 || frm.UtilizadorEmail.value.indexOf(".") == -1) {
		alert("E-Mail incompleto.");
		frm.UtilizadorEmail.focus()
		return false;
	}
	return true;
}

function validarForm_004(frm) {
	if (frm.Nome.value.length < 2) {
		frm.erro.value = "Verificar Nome (mínimo 2 caracteres).";
		frm.Nome.focus();
		return false;
	}
	if (frm.morada.value.length < 3) {
		frm.erro.value = "Verificar Morada.";
		frm.morada.focus();
		return false;
	}
	if (frm.localidade.value.length < 3) {
		frm.erro.value = "Verificar Localidade.";
		frm.localidade.focus();
		return false;
	}
	if (frm.cpostal.value.length < 4) {
		frm.erro.value = "Verificar Código Postal.";
		frm.cpostal.focus();
		return false;
	}
	if (frm.pais.value.length < 4) {
		frm.erro.value = "Verificar País.";
		frm.pais.focus();
		return false;
	}
	return true;
}

function validarForm_005(frm) {

	if (frm.email.value.indexOf("@") == -1 || frm.email.value.indexOf(".") == -1) {
		alert ("E-Mail incompleto.");
		frm.email.focus()
		return false;
	}
	return true;
}

//SHOW HIDE DIVS//
/*
Highlight Image Script- 
© Dynamic Drive (www.dynamicdrive.com)
For full source code, installation instructions,
100's more DHTML scripts, and Terms Of
Use, visit dynamicdrive.com
*/

function makevisible(cur,which){
if (which==0)
	cur.filters.alpha.opacity=75
else
	cur.filters.alpha.opacity=100
}


/* Show / Hide */
if (parseInt(navigator.appVersion) > 3) {
	if (navigator.appName == "Netscape") {
		layerVar="document.layers";
		styleVar="";
	}else{
		layerVar="document.all";
		styleVar=".style";
	}
}

function skf_ShowHideLayer(TheLayer,TheAttrib) {
	if (parseInt(navigator.appVersion) > 3) {
		eval(layerVar + '["' + TheLayer + '"]' + styleVar + '.display = "' + TheAttrib + '"');
	}
}

function hideAll(){
//	skf_ShowHideLayer('layer1','none');
//	skf_ShowHideLayer('layer1a','none');
//	skf_ShowHideLayer('layer2','none');
//	skf_ShowHideLayer('layer2a','none');
//	skf_ShowHideLayer('layer3','none');
//	skf_ShowHideLayer('layer3a','none');
//	skf_ShowHideLayer('layer5','none');
//	skf_ShowHideLayer('layer5a','none');
//	skf_ShowHideLayer('layer6','none');
//	skf_ShowHideLayer('layer6a','none');
//	skf_ShowHideLayer('layer7','none');
//	skf_ShowHideLayer('layer7a','none');
//	skf_ShowHideLayer('layer8','none');
//	skf_ShowHideLayer('layer8a','none');
	hideallids();
}

//here you place the ids of every element you want.
var ids=new Array('layer1','layer2','layer3','layer4','layer5','layer6','layer7','layer8','layer9','layer10');

function switchid(id){	
	hideallids();
	showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

//function toggle(target)
//{
   //obj=(document.all) ? document.all[target] : document.getElementById(target);
   //obj.style.display=(obj.style.display=='none') ? 'inline' : 'none';
//}

// toggle visibility 

function toggle(targetId){ 

  if (document.getElementById){ 
        target = document.getElementById( targetId ); 
           if (target.style.display == "none"){ 
              target.style.display = ""; 
           } else { 
              target.style.display = "none"; 
           } 
     } 
} 
//FIM - SHOW HIDE DIVS//


function mypopup(file,w,h){
	mywindow = window.open (file,'mywindow','location=1,status=1,scrollbars=1,width='+w+',height='+h);
	mywindow.moveTo(0,0);
} 