function trim(texto)
{
	return texto.replace(/^\s*|\s*$/g,"");
}

function isdefined(variable)
{
    return (typeof(window[variable]) == "undefined")?false:true;
}

function move(fbox, tbox) 
{
	var arrFbox = new Array();
	var arrTbox = new Array();
	var arrLookup = new Array();
	var i,sw;
	sw=0;
	for (i = 0; i < tbox.options.length; i++) {
		arrLookup[tbox.options[i].text] = tbox.options[i].value;
		arrTbox[i] = tbox.options[i].text;
	}
	var fLength = 0;
	var tLength = arrTbox.length;
		for(i = 0; i < fbox.options.length; i++) 
		{
			arrLookup[fbox.options[i].text] = fbox.options[i].value;
			if (fbox.options[i].selected && fbox.options[i].value != "") {
				arrTbox[tLength] = fbox.options[i].text;
				tLength++;
			}else {
				arrFbox[fLength] = fbox.options[i].text;
			fLength++;
   			}
		}
	arrFbox.sort();
	arrTbox.sort();
	fbox.length = 0;
	tbox.length = 0;
	var c;
		for(c = 0; c < arrFbox.length; c++) 
		{
			var no = new Option();
			no.value = arrLookup[arrFbox[c]];
			no.text = arrFbox[c];
			fbox[c] = no;
		}
			for(c = 0; c < arrTbox.length; c++) {
				var no = new Option();
				no.value = arrLookup[arrTbox[c]];
				no.text = arrTbox[c];
				tbox[c] = no;
	   		}
}

function valida_campo(campo,mensaje,tipo) 
{
	var string=campo.value;
	var str;
	
	largo=string.length;
	str='';

	for (i=0; i<=largo; i++) {
		if (string.charAt(i)!=' ') {
		str=str+string.charAt(i);
		}
	}

	if (str=='') {
		alert("Por favor, ingrese "+mensaje);
		campo.focus();
		return false;
	}

	// a = alfanumerico, n= numero
	if (tipo=='a')
	{
		if (!isNaN(string))
		{
			alert(mensaje + " debe ser alfanumerico");
			campo.focus();
			return false;
		}
	}
	if (tipo=='n')
	{
		if (isNaN(string))
		{
			alert(mensaje + " debe ser numerico");
			campo.focus();
			return false;
		}
	}
	return true;
}

function validar_email(campo,idioma) 
{
	if (idioma=="SP")
		mensaje_idioma= "no es un e-mail valido";
	else if (idioma=="BR")
		mensaje_idioma= "não é um e-mail valido";
	else if (idioma=="EN")
		mensaje_idioma= "is not a valid e-mail";
	
	var email=campo.value;
	var largo;
	var valido1=0;
	var valido2=0;
	var valido3=1;
	
	largo=email.length;
	
	for (i=1;i<=largo;i++) 
	{
		if (email.charAt(i)=='@') {valido1=1;}
		if (email.charAt(i)=='.') {valido2=valido1;}
		if (email.charAt(i)==' ') {valido3=0;}
	}
	
	if (!(valido1 && valido2 && valido3)) 
	{
		alert("'" + campo.value + "' " + mensaje_idioma);
		campo.focus();
		return false;
	}
	return true;
}

function show_popup(pag,ancho,alto)
{
	xp=(screen.width-ancho)/2;
	yp=(screen.height-alto)/2-30;
	mywin=open(pag+"&popup=1&rand="+Math.random(),"_blank","width="+ancho+",height="+alto+",left="+xp+",top="+yp+",status=no,toolbar=no,menubar=no,scrollbars=yes");	
}


function preLoadImages(){
	
	/*For the preLoading of images to take place, this function must be called in the onLoad handler caller
	in the body tag of the page. Images that are to be swapped must have a capital 'H' on the end and the original
	image should have a capital 'N' on the end*/
	
	
 	imageArray = new Array();
 	
	
	
	/*****************************************************************/
 	
	/*If there are any extra Images that cannot be detected they should be 
	placed in a array called ExtraImages which the following script will detect*/
	
	
	var URLstring = document.location.toString();
	
	n = URLstring.length;
	while(URLstring.charAt(n)!="/"){
		
			n--;}
		
			var preFix = URLstring.slice(0,n);
			
	
	
	
		
	if(typeof(ExtraImages)=="object"){
		eX = new Array();
		
		for(i=0;i<ExtraImages.length;i++){
			extra_image = new Image();
			eX[i] = extra_image;
			
			var extra_string = preFix+ExtraImages[i];
			
			eX[i].src=extra_string;
			
		}}
		
		
	/*****************************************************************/	
		
	
	/*The following script finds all images with 'H' or 'N' as the last letter and preLoads the 
	image with the opposite letter on the end*/
	for(i=0;i<document.images.length;i++){
		
	
		var an_image = new Image();
		imageArray[i]= an_image;
		an_image_string = document.images[i].src;
		
		
		var theString =an_image_string.toString();
		
		var last= theString.lastIndexOf(".");
		
		if (theString.charAt(last-1) == "N"||theString.charAt(last-1) == "n"){
			
			var suffix = theString.slice(last,theString.length);
			var newString = theString.slice(0,last-1)+"H"+suffix;
			imageArray[i].src= newString;
			
			
		}
		
		if (theString.charAt(last-1) == "H"||theString.charAt(last-1) == "h"){
			
			var suffix = theString.slice(last,theString.length);
			var newString = theString.slice(0,last-1)+"N"+suffix;
			imageArray[i].src= newString;
			
			
			
		}
		
		
	}
	hideLayers();
	
}

function imgswap(pic,imageName){
	
	/*This function takes image names that have "N" for normal or "H" for highlighted as the last
	letter in the image name and also a suffix (".gif" etc) must be present also 
	All images must be in a folder named "media" unless otherwise explicitly stated in all references
	to the image within the HTML page.
	If the image rolled over changed a different image than itself on the same page then add the name of 
	the swapped image as the second parameter (imageName) otherwise leave it blank*/
	

	if (pic.indexOf("media")==-1){
			
			pic = "media/"+pic;
			}
			
	var suffix = pic.slice(pic.length-4,pic.length);
	
  	var picstartpos = pic.indexOf("media/");
	var picname = pic.substring(picstartpos+6,pic.length-5);
	
	
	
	if(typeof(imageName)!="undefined"){
		picname=imageName;}
	
  	if(document.all){
  	
  	
  	
			document.all(picname).src=pic;
  	}
  
  
  	if(document.layers){
  
  	var theString = document.images[picname].src;
  	
  	/*This finds the second to last delimiter to obtain the whole image address for Netscape
  	or just gives it the ../name string which appears to work*/
  	
  	
  	if(pic.charAt(0)=="."){
  		
  	document.images[picname].src=pic;}
  	else{
  	var lastPos = (theString.slice(0,theString.lastIndexOf("/")-1).lastIndexOf("/")+1);
 	document.images[picname].src=theString.slice(0,lastPos)+(pic);
 	}
   
  }
}


// page=*.asp or *.html to open
// h,w,t,l = height,width,top,left
// rs = resizable scrollbars
function openpopup(page,pagename,h,w,t,l,rs,sbs) 
{ 
	w = window.open(page, pagename, "height="+h+",width="+w+",top="+t+",left="+l+",resizable="+rs+",scrollbars="+sbs);
	w.focus();
}

function fallopen(s,n,w)
{
	if(document.all){
	
		document.all(s).style.height = n;
		
		document.all(s).style.width = w;
	}
}

function fallclose(s,n)
{
		if(document.all){	
			document.all(s).style.height = n;
		
		}
}

function tester()
{
	alert("!!Empty Link!!");
}

function swapimage(theLayer,theName,thePic,theId)
{
	/*This the second imageswapper in this file and is used only with menus*/
	if(document.all)
	{
		document.all(theName).src=thePic;
	}
	else
	{
		document.layers[theLayer].document.images[theName].src=thePic;
		lastHead = theLayer;
	}
}

function imgappear(st){
	//alert(st);
	if(document.all){
	st.style.visibility = 'visible';
	}
	if(document.layers){
		
		st.visibility ='show';
		}
	}


function imgdisappear(st){
	
	
	if(document.all){
	st.style.visibility = 'hidden';
	}
	if(document.layers){
		st.visibility ='hide';
		}
	}
		
		
		

function darkenLink(t){

		
		t.style.color="black";
		}
	

function lightenLink(t){

		
		t.style.color="666";
		}	
	
	
	
function setTarget(target){
	
	if (document.all){
		//FOR IE
		frames['content'].location = target;
		
	}
	if (document.layers){
		
		//NETSCAPE
		var firstLayer = document.layers['div'];
		
		firstLayer.document.layers['content'].src = target;
		
		}

}


function AppletAlert(error){
	alert(error);}
	

function chooseStyle(){
	//This function is called on loading every page 
	//for the purposes of referencing a style sheet.
	if(document.all){
	
		document.write('<'+'link rel="stylesheet" href="/css/explorer.css" />');
		
			}
		if(document.layers){
			
		document.write('<'+'link rel="stylesheet" href="/css/netscape.css" />');
	}
}


function hideLayers(){
	
	if(document.all){
	if(document.all.div!=null){
	
	
	document.all.div.visibility = 'hidden';}}
}



function showMenu(){
	//alert('show');
	if(document.all){
		
		document.all.clientMenu.style.visibility = 'visible';
		
	}
	
	if(document.layers){
		
	
		if(document.layers.length>1){
			
			if(document.layers[1].name == "div"){
		document.layers.clientMenu.moveAbove(document.layers[1]);
			}
		}
		
		document.layers.clientMenu.visibility = 'show';
		}
	}
	
	
	
function hideMenu(){
	if(document.all){
		
		document.all.clientMenu.style.visibility = 'hidden';
		
	}

	if(document.layers){
		if(document.layers.length>1){
			if(document.layers[1].name == "div"){
	document.layers.clientMenu.moveBelow(document.layers[0]);}}
		document.layers.clientMenu.visibility = 'hide';
		}
	}
	
	
function nextContent(){
	alert('asdf');}
	
	

