var isExplorer = (navigator.appName.search("Explorer") > 0) ;

function c() {
//	if (arguments.length>3)	{
//		if (!arguments[3].activo)	return
//	}
	if (arguments.length>4)	{
		document.f.directo.value= arguments[4];
	}
	nivel = arguments[0] ; document.f.nivel.value=nivel ;
	valor = arguments[1] ;
	inm   = arguments[2] ;
//alert("Nivel:"+nivel+", Valor:"+valor+", Inm:"+inm);

	switch(document.f.nivel.value) {
		case "0":
			if (inm>0) document.f.tinm.value=inm;
			else if(inm == -1) document.f.tinm.value=0;
//			else if(inm == -2) document.f.loc.value=0;
			document.f.prov.value = 0 ;     
			document.f.action = '/es/maps.php' ;
			if (isExplorer)
				event.returnValue = false ;
			document.f.submit() ; 
			break ;
		case "1": 
			if (inm>0) document.f.tinm.value=inm ;
			else if(inm == -1) document.f.tinm.value=0;
//			else if(inm == -2) document.f.loc.value=0;
			document.f.prov.value = valor ; 
			document.f.action = '/es/maps.php' ; 
			if (isExplorer)
				event.returnValue = false ;
			document.f.submit() ; 
			break ;
		case "2":  
			if (inm!=0) document.f.tinm.value=inm ;
			if (valor==0){
				document.f.loc.value = arrayJLocalidades.toString();
                    document.f.com.value = arrayJComarcas.toString();
			}else{
                    if(arguments[5])
                         document.f.com.value = valor ;
                    else
                         document.f.loc.value = valor ;
               }                
			document.f.action = '/es/newbrowser.php'
			if (isExplorer)
				event.returnValue = false ;
			document.f.submit() ;
			break ;
	}
	return ;
}

function cs(seccion,nivel,provincia) {document.f.sec.value=seccion; document.f.nivel.value=nivel; document.f.prov.value = provincia ; document.f.action = '/es/maps.php'; document.f.submit() }
function mi(item) {	item.className="m10o" }
function mo(item) {	 item.className="m10"  }
function mid(item) { item.className="m10do" }
function mod(item) { item.className="m10d"  }

function mol(item,loc) { if (in_array(loc,arrayJLocalidades)) { item.src='/imas/c2.gif'; } else { item.src='/imas/c1.gif'} }
function mil(item,loc) { if (in_array(loc,arrayJLocalidades)) { item.src='/imas/c4.gif'; } else { item.src='/imas/c3.gif'} }
function cl(item,loc)  { if (in_array(loc,arrayJLocalidades)) { item.src='/imas/c1.gif'; arrayJLocalidades = delArray(loc,arrayJLocalidades); } else { item.src='/imas/c2.gif'; arrayJLocalidades.push(loc);} }

function moc(item,com) { if (in_array(com,arrayJComarcas)) { item.src='/imas/c2.gif'; } else { item.src='/imas/c1.gif'} }
function mic(item,com) { if (in_array(com,arrayJComarcas)) { item.src='/imas/c4.gif'; } else { item.src='/imas/c3.gif'} }
function cc(item,com)  { if (in_array(com,arrayJComarcas))    { item.src='/imas/c1.gif'; arrayJComarcas = delArray(com,arrayJComarcas); } else { item.src='/imas/c2.gif'; arrayJComarcas.push(com);} }

function mii(item,cod) { if (document.f.tinm.value & cod) { item.src='/imas/c4.gif' } else { item.src='/imas/c3.gif' } }
function moi(item,cod) { if (document.f.tinm.value & cod) { item.src='/imas/c2.gif' } else { item.src='/imas/c1.gif' } }
function ci(item,cod)  { if (document.f.tinm.value & cod) { item.src='/imas/c1.gif'; document.f.tinm.value=(document.f.tinm.value & (~cod)); } else { item.src='/imas/c2.gif'; document.f.tinm.value=(document.f.tinm.value | cod);  } }

function ct(cod) {
	var tipos = new Array () ;
	var union = new Array () ;
	var ind, acum ;
	tipos[0] = new Array(1,2,4,8,16,32,64,128,32768) ;
	tipos[1] = new Array(256,512,1024,2048) ;
	tipos[2] = new Array(4096,8192,16384) ;
	tipos[3] = new Array(131072,262144,524288,1048576) ;

	acum = 0 ;
	for (ind=0;ind<tipos[cod].length ; ind++) {
		if (!(elemento = document.getElementById('inm_check_'+tipos[cod][ind])))
			continue;
		if (elemento.activo) acum = acum | tipos[cod][ind];
	}

	if (document.f.tinm.value == acum) {  //Están seleccionados todos
		for (ind=0;ind<tipos[cod].length ; ind++) {
			if (!(elemento = document.getElementById('inm_check_'+tipos[cod][ind])))
				continue;
			if (elemento.activo) elemento.onclick();
		}
	}
	else {
		for (ind=0;ind<tipos[cod].length ; ind++) {
			if (!(elemento = document.getElementById('inm_check_'+tipos[cod][ind])))
				continue;
			if (!(document.f.tinm.value & tipos[cod][ind]))
				if (elemento.activo) elemento.onclick();
		}
	}
}

function ctl() {
	var ind ;

	if (arrayJLocalidades.length==tloc.length)	{
		for(ind=0; ind < tloc.length; ind++) {
			elemento = document.getElementById('loc_check_'+tloc[ind]) ;
			elemento.onclick() ;
		}
	}
	else {
		for(ind=0; ind < tloc.length; ind++) {
			elemento = document.getElementById('loc_check_'+tloc[ind]) ;
			if (!in_array(arrayJLocalidades[ind],tloc) && elemento.activo)
				elemento.onclick() ;
		}
	}
}