
function getEl( el ) {
	return document.getElementById( el );
}

function checkForm( form1, strCampos, strTipos, strDefaults, color01, color02 ) 
{
	var arrCampos = strCampos.split(",")
	var arrTipos = strTipos.split(",")
	var arrDefaults = strDefaults.split(",")
	
	var bErro, errors = false;

	for (i=0; i<arrCampos.length; i++)
    {  
		bErro = false;

//		obj = document.getElementById('td'+arrCampos[i]);
		obj = document.getElementById(arrCampos[i]);
		if( obj )
			obj.style.backgroundColor = color01;

		obj2 = document.getElementById(arrCampos[i]+'02')
		if( obj2 )
			obj2.style.backgroundColor = color01;
		
		value = obj.value

		if( arrTipos[i] == "D" )
		{
	 		  var elems = value.split("-");   	// extrai as 3 componentes da data
	 		  result = (elems.length == 3); 	// verifica se são 3 componentes
	 		  if (result) {
			    var today = new Date();
	 			var day   = parseInt(elems[2],10);
	  			var month = parseInt(elems[1],10);
	 			var year  = parseInt(elems[0],10);
				result    = allDigits(elems[2]) && (day > 0) && (day < 32) &&
						    allDigits(elems[1]) && (month > 0) && (month < 13) &&
						    allDigits(elems[0]) && (elems[0].length == 4) && (year <= today.getFullYear());
	 		  }
	 		  if (!result)
				bErro = true;
		}

		if( value == "" || value == arrDefaults[i] )
			bErro = true;
		else if(arrTipos[i] == "P"){
			  var result = false;
			  var password01 = new String(document.getElementById(arrCampos[i]+"02").value);
			  var password02 = new String(value);

			  if (password01.toLowerCase() == password02.toLowerCase())
				  result = true;
			  if(!result)
				  bErro = true;
		}
		else if( arrTipos[i] == "E" ){
			  var result = false;
			  var theStr = new String(value);
			  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theStr))
				  result = true;
			  if(!result)
				bErro = true;
		}

//		alert(arrTipos[i]+" "+obj
		if( bErro ) {
			errors = true
			if( obj )
				obj.style.backgroundColor = color02;
			if( obj2 )
				obj2.style.backgroundColor = color02;
		}
	
	}
	
	if( errors ) {
		alert("Please fill in / verify the marked fields.")
		return false;
	}
	else
		return true;
}



	function setCookie( name, value ) {
		document.cookie = name+"="+value+"; path=/";
	}
	function getCookie( name ) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return "";
	}

	function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	
	function MM_preloadImages() { //v3.0
	  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}
	
	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_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}

	function getElement(name) {
		return document.getElementById(name);
	}
	function openWindow(url, name, width, height) {
		var myLeft = (screen.width  - width) / 2;
		var myTop  = (screen.height - height) / 2;
		window.open(url, name, "height="+height+",width="+width+",left="+myLeft+",top="+myTop+",scrollbars=yes,status=no,toolbar=no,menubar=no,location=no")
	}
	function openWindowNamed(url, name) {
		window.open(url, name, "scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no")
	}
	function openWindowEmpty(name) {
		window.open('', name, "scrollbars=yes,resizable=yes,status=yes,toolbar=no,menubar=no,location=no")
	}
	function openImage(url, name, width, height) {
		var myLeft = (screen.width  - width) / 2;
		var myTop  = (screen.height - height) / 2;
		window.open(url, name, "height="+height+",width="+width+",left="+myLeft+",top="+myTop+",scrollbars=no,status=no,toolbar=no,menubar=no,location=no")
	}
	function changeArte() {
		if (document.images && (preloadFlag == true)) {
			for (var i=0; i<changeArte.arguments.length; i+=2) {
	
				     document[changeArte.arguments[i]].filters.revealTrans.Transition = transValue;
				     document[changeArte.arguments[i]].filters.revealTrans.Apply();
					 document[changeArte.arguments[i]].src = changeArte.arguments[i+1];
				     document[changeArte.arguments[i]].filters.revealTrans.Play()
	
			}
		}
	}
	
/*****************************************************/
/*
Disable right click script II (on images)- By Dynamicdrive.com
For full source, Terms of service, and 100s DTHML scripts
Visit http://www.dynamicdrive.com
*/

var clickmessage="Right click disabled on images!"

function disableclick(e) {
	//alert(e)
	if (document.all) {
		if (event.button==2||event.button==3) {
			if (event.srcElement.tagName=="IMG"){
				//alert(clickmessage);
				event.cancelBubble=true;
				return false;
			}
		}
	}
	else if (document.layers) {
		if (e.which == 3) {
			//alert(clickmessage);
			return false;
		}
	}
	else if (document.getElementById){
		if (e.which==3&&e.target.tagName=="IMG"){
			//alert(clickmessage)
			return false
		}
	}
}

function associateimages(){
	for(i=0;i<document.images.length;i++)
		document.images[i].onmousedown=disableclick;
}

if (document.all)
document.oncontextmenu=disableclick;//new Function("if(event.button==2||event.button==3) {if(event.srcElement.tagName=='IMG'){/*alert(clickmessage);*/return false;}}")
else if (document.getElementById)
document.oncontextmenu=disableclick


//document.oncontextmenu=new Function("return false")
//else if (document.layers)
//associateimages()