String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}



// =======================================
// set the following variables
// =======================================

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000

// Duration of crossfade (seconds)
var crossFadeDuration = 5

// Specify the image files
var Pic = new Array() // don't touch this
// to add more images, just continue
// the pattern, adding to the array below
Pic[0] = '../images/foto_topo1.jpg'
Pic[1] = '../images/foto_topo2.jpg'
Pic[2] = '../images/foto_topo3.jpg'
Pic[3] = '../images/foto_topo4.jpg'
Pic[4] = '../images/foto_topo5.jpg'
Pic[5] = '../images/foto_topo6.jpg'
Pic[6] = '../images/foto_topo7.jpg'
Pic[7] = '../images/foto_topo8.jpg'
Pic[8] = '../images/foto_topo9.jpg'

// =======================================
// do not edit anything below this line
// =======================================

var t
var j = 0
var p = Pic.length

var preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = Pic[i]
}

function runSlideShow()
{
   if (document.all){
      document.images.SlideShow.style.filter="revealTrans(duration=2, transition=12)"
      document.images.SlideShow.style.filter="revealTrans(duration=crossFadeDuration, transition=12)"
      document.images.SlideShow.filters.revealTrans.Apply()      
   }
   document.images.SlideShow.src = preLoad[j].src
   if (document.all){
      document.images.SlideShow.filters.revealTrans.Play()
   }
   j = j + 1
   if (j > (p-1)) j=0
   t = setTimeout('runSlideShow()', slideShowSpeed)

}



function VerificaEmail(obj) 
{
	var validChars, err01,err02, err03, err04, fieldValue, fieldLength;
	var cont = 0, cont2 = 0;
	var Limpar = false;
	
	validChars  = "abcdefghijklmnopqrstuvwxyz"; 
	validChars += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
	validChars += "0123456789.@_-";
	fieldValue  = obj.value; 
	fieldLength = obj.value.length; 
	minLength   = 8; 
	maxLength   = 255; 

	err01   = "Foi encontrado um caracter inválido."; 
	err02   = "Por favor introduza pelo menos " + minLength + " caracteres."; 
	err03   = "Por favor introduza menos que " + maxLength + " caracteres."; 
 
	if ( fieldLength > 0)
	{
		if ( fieldLength < minLength ) 
		{ 
			alert( err02 ); 
			Limpar = true;
		}
		else if (( fieldLength > maxLength ) && ( maxLength > 0 )) 
		{ 
			alert( err03 ); 
			Limpar = true;
		}
		else if (( fieldValue.charAt( 0 ) == "@" ) || ( fieldValue.charAt( fieldLength - 1 ) == "@" )) 
		{
			alert("O Email não é válido !!!"); 
			Limpar = true;
		}
		else 
		{ 
			for( var i=0; i< fieldLength; i++ ) 
			{ 
				if ( validChars.indexOf( fieldValue.charAt( i )) == -1 ) 
				{ 
				    alert( err01 ); 
				    Limpar = true;
				    break; 
				}
				if (fieldValue.charAt( i ) == "@")
					cont++;
				if (fieldValue.charAt( i ) == ".")
					cont2++;
		    } 
			    
		    if (cont2 == 0 )
			{
				alert("O Email não é válido !!!"); 
				Limpar = true;
			}
			else if ( (cont == 0) || (cont > 1) )
		    {
				alert("O Email não é válido !!!"); 
				Limpar = true;		
			}
		} 
    } 
    if(Limpar) obj.focus(); 
}


function VerificaEmailUK(obj) 
{
	var validChars, err01,err02, err03, err04, fieldValue, fieldLength;
	var cont = 0, cont2 = 0;
	var Limpar = false;
	
	validChars  = "abcdefghijklmnopqrstuvwxyz"; 
	validChars += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
	validChars += "0123456789.@_-";
	fieldValue  = obj.value; 
	fieldLength = obj.value.length; 
	minLength   = 8; 
	maxLength   = 255; 

	err01   = "One invalid caracter was found."; 
	err02   = "Please introduce at least " + minLength + " caracters."; 
	err03   = "Please introduce less than " + maxLength + " caracters."; 
 
	if ( fieldLength > 0)
	{
		if ( fieldLength < minLength ) 
		{ 
			alert( err02 ); 
			Limpar = true;
		}
		else if (( fieldLength > maxLength ) && ( maxLength > 0 )) 
		{ 
			alert( err03 ); 
			Limpar = true;
		}
		else if (( fieldValue.charAt( 0 ) == "@" ) || ( fieldValue.charAt( fieldLength - 1 ) == "@" )) 
		{
			alert("The Email is not valid !!!"); 
			Limpar = true;
		}
		else 
		{ 
			for( var i=0; i< fieldLength; i++ ) 
			{ 
				if ( validChars.indexOf( fieldValue.charAt( i )) == -1 ) 
				{ 
				    alert( err01 ); 
				    Limpar = true;
				    break; 
				}
				if (fieldValue.charAt( i ) == "@")
					cont++;
				if (fieldValue.charAt( i ) == ".")
					cont2++;
		    } 
			    
		    if (cont2 == 0 )
			{
				alert("The Email is not valid !!!"); 
				Limpar = true;
			}
			else if ( (cont == 0) || (cont > 1) )
		    {
				alert("The Email is not valid !!!"); 
				Limpar = true;		
			}
		} 
    } 
    if(Limpar) obj.focus(); 
}



var bTranState = 0;
function fnToggle()
{
oTransContainer.filters[0].enabled = true;
oTransContainer.filters[0].Apply();
if (bTranState=='0') 
{ 
	bTranState = 1;
}
else 
{  
	bTranState = 0;
}
oTransContainer.filters[0].Play();
}


function Mostrar(i)
{
	var l;
	if(document.all("modalidade").style.visibility == "visible")
	{
		document.all("modalidade").style.visibility = "hidden";
		
	}	
	else
	{
		document.all("modalidade").style.visibility = "visible";
		document.all("contexto").innerHTML = i;
	}	
}


function Esconder(i)
{
	var l;
	if(document.all("modalidade").style.visibility == "visible")
	{
		document.all("modalidade").style.visibility = "hidden";
		
	}	
	else
	{
		document.all("modalidade").style.visibility = "v";
	}	
}

 function AbrirFotoG(RegID)
	{
		window.open("FotoG.asp?FID=" + RegID,"","width=200px,height=200px,top=0,left=0");
	}
	
function OpenJanela(pagina)
{
	window.open(pagina,"Galeria","width=600, height=400, left=300, right=0, scrollbars=1,resizable=yes");
}	

function OpenOptions(i)
{
	var l;
	if(document.all(i).style.display == "block")
		document.all(i).style.display = "none";
	else
		document.all(i).style.display = "block";
}

browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);

ns3up = (browserName == "Netscape" && browserVer >= 3);
ie4up = (browserName.indexOf("Microsoft") >= 0 && browserVer >= 4);

function doPic(imgName) 
{
if (ns3up || ie4up) 
{
imgOn = ("../Database/Images/Obras/" + imgName);
document.mainpic.src = imgOn;
slowhigh(mainpic);
}
}

var baseopacity=20

function slowhigh(which2){
imgobj=which2
browserdetect=which2.filters? "ie" : typeof which2.style.MozOpacity=="string"? "mozilla" : ""
instantset(baseopacity)
highlighting=setInterval("gradualfade(imgobj)",200)
}

function slowlow(which2){
cleartimer()
instantset(baseopacity)
}

function instantset(degree){
if (browserdetect=="mozilla")
imgobj.style.MozOpacity=degree/100
else if (browserdetect=="ie")
imgobj.filters.alpha.opacity=degree
}

function cleartimer(){
if (window.highlighting) clearInterval(highlighting)
}

function gradualfade(cur2){
if (browserdetect=="mozilla" && cur2.style.MozOpacity<1)
cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.1, 0.99)
else if (browserdetect=="ie" && cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=5
else if (window.highlighting)
clearInterval(highlighting)
}