function arreglaCal()
{

}
//EQUIVALENT ARRAY_SEARCH
function getIdx(vector,k){
	for(i=0;i<vector.length;i++){
		if(vector[i]==k) return i
	}
	return false;
}

var _actual=0
function overMenu(id){
	if(_actual!=0){
		document.getElementById("m_"+_actual).style.display="inline";
		document.getElementById("m_"+_actual+"_on").style.display="none";
	}
	
	document.getElementById("m_"+id).style.display="none";
	document.getElementById("m_"+id+"_on").style.display="block";
	_actual=id;
}
function outMenu(id){
	document.getElementById("m_"+id).style.display="inline";
	document.getElementById("m_"+id+"_on").style.display="none";	
}



function cambiaImg(id, src)
{
	MM_findObj(id).src=src;
}


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&&id.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n) ; return x;
}

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_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_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 NewWindow(theURL, hauteur, largeur) 
{
var winl = (screen.width - largeur) / 2;
var wint = (screen.height - hauteur) / 2;
winprops = 'height='+hauteur+',width='+largeur+',top='+wint+',left='+winl+',scrollbars=0'
win = window.open(theURL, "", winprops)
}

function NewWindowScroll(theURL, hauteur, largeur) 
{
var winl = (screen.width - largeur) / 2;
var wint = (screen.height - hauteur) / 2;
winprops = 'height='+hauteur+',width='+largeur+',top='+wint+',left='+winl+',scrollbars=1'
win = window.open(theURL, "", winprops)
}

function NewWindowScrollResize(theURL, hauteur, largeur) 
{
var winl = (screen.width - largeur) / 2;
var wint = (screen.height - hauteur) / 2;
winprops = 'height='+hauteur+',width='+largeur+',top='+wint+',left='+winl+',scrollbars=1,resizable=1'
win = window.open(theURL, "", winprops)
}

/*function activaCapa(num, img, img2)
{
	// Activa capa en la home
	if (num!=capaActiva)
	{
		// Desactiva capa antigua
		imgold=imgold.replace("_on","");
		MM_findObj("id"+capaActiva).src=imgold;
		decreceCapa(151,capaActiva);
		MM_findObj("img"+capaActiva).onmouseout=function() {
			var imgt=this.childNodes[0].src;
			imgt=imgt.replace("_on","");
			this.childNodes[0].src=imgt;

		};
		// Actualiza los datos de la capa antigua
		imgon=img;
		imgold=img2;
		capaActiva=num;
		// Activa la capa nueva
		MM_findObj("id"+num).src=img;
		MM_findObj("img"+num).onmouseout=function() {
			this.childNodes[0].src=img;
		};
		creceCapa(0,num);

	}
}*/



function decreceCapa(tam, num)
{
	if (tam!=0)
	{
		tam-=10;
		if (tam<0) tam=0;
		MM_findObj("capa"+num).style.height=(tam/10)+"em";
		setTimeout("decreceCapa("+tam+","+num+")",5);
	}
}

function creceCapa(tam, num)
{
	if (tam!=151)
	{
		tam+=10;
		if (tam>151) tam=151;
		MM_findObj("capa"+num).style.height=(tam/10)+"em";
		setTimeout("creceCapa("+tam+","+num+")",5);
	}
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
			} while (obj = obj.offsetParent);
		return [curleft,curtop];
	}
}

function iniciaFormularios()
{
	for (var j=0; j<document.forms.length; j++)
	{
		for (var i=0; i<document.forms[j].elements.length; i++)
		{
			var nam=document.forms[j].elements[i].name.substring(0,5);
			if (nam=="fecha")
			{
				var pos=findPos(MM_findObj(document.forms[j].elements[i].name));
				Calendar.setup({
					inputField     :    document.forms[j].elements[i].name,     // id of the input field
					ifFormat       :    "%d/%m/%Y",      // format of the input field
					button         :    "boton_"+document.forms[j].elements[i].name,  // trigger for the calendar (button ID)
					align          :    "Bl",           // alignment (defaults to "Bl")
					singleClick    :    true
				})
			}
		}
	}
	
}



var rsson=false;
var buscadon=false;

function abreCapaBuscador(id)
{
	if (document.getElementById(id).style.display=="" || document.getElementById(id).style.display=="none") document.getElementById(id).style.display="inline";
	else	document.getElementById(id).style.display="none";
}

function switchRSS(rsson1,id)
{
	if (rsson1) 
	{
		despliegaMenu(id);
		
	
		rsson=true;
	} else {
		escondeMenu(id);
		rsson=false;
	}
}

function cambiaImg(img, url)
{
	//MM_findObj(img).style.display='none';
	alert(document.getElementById(img));
	MM_findObj(img).src="http://bcn01/olivia/gestor/grupo/es/imgs/n2_9_on.png";
	//MM_findObj(img).style.display='inline';
	
}
function despliegaMenu(pos)
{
	//setOpacity(MM_findObj("submenu"+pos), 0);
	MM_findObj("submenu"+pos).style.display='inline';	
	//setTimeout("eval('fadingmenu("+pos+",0)')",200);
}

function escondeMenu(pos)
{
	MM_findObj("submenu"+pos).style.display='none';
}


	function open_picture(i){
		var fotogal=MM_findObj("link_"+i);
		Shadowbox.open(fotogal);
	}
	

	
	var obligs=Array()
function setFormInputs(idform){
	var form=document.getElementById(idform)
	
	//Array de Obligatorios (campo oculto del formulario)
	if(typeof form.oblig != "undefined") {
		obligs[idform]=form.oblig.value.split(",")	
	}else{
			obligs[idform]=Array()
	}
	
	
	for(i=0;i<form.length;i++){
		
		var c = form[i]
		if(c.type=="select-one" || c.type=="text" || c.type=="textarea") {
			c.onfocus=function(){
				this.style.borderColor="#ffffff"
				
			}
			c.onblur=function(){
			//Comprueba si es un campo obligatorio o no para ponerlo en rojo en caso de estar vacio
				if(getIdx(obligs[idform],this.name)!==false){
					if(this.value=="") this.style.borderColor="#FF9900"
					else this.style.borderColor="#689B00"
				}else{
					this.style.borderColor="#353535"
				}
			}
		}
	
	}
}


function getIdx(vector,k){
	for(i=0;i<vector.length;i++){
		if(vector[i]==k) return i
	}
	return false;
}



function validar_enviar_js(idform){
	
	form=document.getElementById(idform)
	//alert(idform)
	//Array de Obligatorios (campo oculto del formulario)
	if(typeof form.oblig != "undefined") {
		obligs[idform]=form.oblig.value.split(",")	
	}else{
			obligs[idform]=Array()
	}
	
	var enviar=true
	
	for(var j=0;j<form.length;j++){
		
		var c = form[j]
		if(c.type=="select-one"|| c.type=="text" || c.type=="textarea"){
			
				if(getIdx(obligs[idform],c.name)!==false){
					if(c.value=="") {c.style.borderColor="#FF9900"
					enviar=false}
				}
		}
	}
	
	if(enviar==true)form.submit()

}

function masinfo(id) {
		document.getElementById("resum"+id).style.display='none';
		document.getElementById("mas"+id).style.display='none';
		document.getElementById("menos"+id).style.display='block';
		v="#ampliado"+id;
		$(v).slideDown('slow');
}

function menosinfo(id) {
		v="#ampliado"+id;
		$(v).slideUp('slow');
		document.getElementById("menos"+id).style.display='none';
		document.getElementById("mas"+id).style.display='block';
		v="#resum"+id;
		$(v).slideDown('slow');
}