function getFormValues(form)
{
    var str='';
	var elem = new Array();
	var lista = new Array();
	var atts = new Array();
    for(var i=0;i< form.elements.length;i++)
	{
		elem = form.elements[i].name.split("___");
		if(elem.length>1)
		{
			//lista = elem[1].split("_");
			if(form.elements[i].value==0)
			{
				alert('Tots els camps amb asterisc(*) s\u00f3n obligatoris.');
				return false;
			}
		}
		/////revisamos que se cumplan lo requisitos de los atributos del campo
		//correo electrónico
		atts = form.elements[i].name.split("@");
		if(atts.length > 1)
		{
			//alert(form.elements[i].value+" revisamos");
			if(!validateMail(form.elements[i].value))
			{
				return false;
			}
		}
		//fin correo electrónico
    }
	form.submit();
   // alert("submit");
}

function setClassByObj(obj,newClass)
{
	obj.className = newClass;
}
function setClassById(id,newClass)
{
	document.getElementById(id).className = newClass;	
}
function setMenu(index,prefix,totalIndex,outClass,overClass)
{
	for(var i=0;i<totalIndex;i++)
	{
		setClassById(prefix+i,outClass);
	}
	setClassById(prefix+index,overClass);
}
function deactivateMenu(prefix,totalIndex,outClass)
{
	for(var i=0;i<totalIndex;i++)
	{
		setClassById(prefix+i,outClass);
	}	
}
function setIframeHeight()
{
	//find the height of the internal page
  	var the_height=parent.document.getElementById('content').contentWindow.document.body.scrollHeight;

  	//change the height of the iframe
  	//parent.document.getElementById('content').height=the_height;
	
	//if(document.body.scrollHeight>648)
	if(the_height>648)
	{
		//alert("Se cambia la altura a "+the_height);
     	parent.document.getElementById('content').height = the_height;
	}
	else
	{
	 	parent.document.getElementById('content').height = 648;
	}
}
function setComboBoxValue(new_value,combo_box,form)
{
	//document.form.combo_box.value = new_value;
	document.getElementById(combo_box).value = new_value;
}

//////AJAX//////
if (window.XMLHttpRequest) {
    xmlHttp = new XMLHttpRequest();
} else if (window.ActiveXObject) {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
var contenedor = "";
var action = 0;

function mostrarContenido(pag,cont)
{
	contenedor = cont;
	//document.getElementById(contenedor).innerHTML='Carregant...'
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 
	var url= pag;
	url=url+"?sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged ;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function mostrarContenidoVars(pag,cont,ac)
{
	contenedor = cont;
	action = ac;
	//document.getElementById(contenedor).innerHTML='Carregant...';
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 
	var url= pag;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(contenedor).innerHTML=xmlHttp.responseText;
		if(action>0)
		{
			if(action==1)
			{
				setMenu(2,'sm',5,'subMenuT cursor-hand','selec2 cursor-hand');
			}
			if(action==2)
			{
				setMenu(0,'sm',3,'subMenuT cursor-hand','selec2 cursor-hand');
			}
			if(action==3)
			{
				setMenu(0,'admin_m',11,'menu-link-color td-paddin-10 cursor-hand texto-mediano','menu-link-color td-paddin-10 cursor-hand texto-mediano');
			}
			if(action==4)
			{
				setMenu(3,'sm',6,'subMenuT cursor-hand','selec2 cursor-hand');
			}
			if(action==5)
			{
				setMenu(3,'sm',4,'subMenuT cursor-hand','selec2 cursor-hand');
			}
			if(action==6)
			{
				setMenu(1,'sm',4,'subMenuT cursor-hand','selec2 cursor-hand')
			}
			
			action = 0;
		}
	} 
} 

function GetXmlHttpObject()
{ 
	var objXMLHttp=null;
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHttp;
}
