// JavaScript Document
function mw_marcos_m_out(marco,def){
	if (def.mo){
		mw_marcos_cambiar(marco,def.img,def.txtcolor);
	}
}
function mw_marcos_m_over(marco,def){
	if (def.mo){
		mw_marcos_cambiar(marco,def.imgmo,def.txtcolormo);
	}
	
}
function mw_marcos_cambiar(marco,imga,txtcolor){
	if (tbls=marco.getElementsByTagName("table")){
		tbl=tbls[0];
		imgindex=0;
		for(rnum=0;rnum<3;rnum++){
			for(cnum=0;cnum<3;cnum++){
				if (imgindex==4){
					tbl.rows[rnum].cells[cnum].style.backgroundImage='url('+imga[imgindex]+')';
					if (txtcolor){
						if (tbl.rows[rnum].cells[cnum].childNodes[0]){
							if (tbl.rows[rnum].cells[cnum].childNodes[0].style){
								tbl.rows[rnum].cells[cnum].childNodes[0].style.color=txtcolor;
							}
						}
						tbl.rows[rnum].cells[cnum].style.color=txtcolor;
					}
				}else{
					mw_marcos_cambiar_img(tbl.rows[rnum].cells[cnum],imga[imgindex]);
				}
				imgindex++;
			}
		}
	}
	
}


function mw_marcos_cambiar_img(td,img){
	if (imgs=td.getElementsByTagName("img")){
		imgs[0].src=img;
	}
	td.style.backgroundImage='url('+img+')';
}
function mw_marcos_definicion(cod){
	this.img=new Array();	
	this.imgmo=new Array();
	this.mo=false;
	this.txtcolor=false;
	this.txtcolormo=false;
	this.cod=cod;
	this.iddivmatriz=false;
	this.nodomatriz=false;
	this.nomelementosaplicar=false;
	this.nodomatrizcargado=false;
	this.loadnodomatriz=function(){
		if(this.nodomatriz=fp_get_element_by_id_siexiste(this.iddivmatriz)){
			this.nodomatrizcargado=true;
		}
	}
	this.aplicarmarcosbyname=function(contenedor){
		if (elementos=contenedor.getElementsByName(this.nomelementosaplicar)){
			for (i=0;i<elementos.length;i++){
				this.aplicarmarco(elementos[i]);
			}
		}
	}
	this.aplicarmarco=function(nodo){
		if (!this.nodomatrizcargado){
			return false;	
		}
		marcocolone=this.nodomatriz.cloneNode(true);
		clone=nodo.cloneNode(true);
		//clone.setAttribute("id","");
		//clone.setAttribute("name","");
		if (tbls=marcocolone.getElementsByTagName("table")){
			tbl=tbls[0];
			tbl.rows[1].cells[1].appendChild(clone);
			nodopadre=nodo.parentNode;
			nodopadre.replaceChild(marcocolone, nodo);
		}
		
	}
}
function mw_marcos_lista(){
	this.marcos=new Array();
	this.tagslist=new Array();
	function add_tag(tname){
		
	}
}
function mw_marcos_lista_tagslist(tname){
	this.tname=tname;
	this.estilos=new Array();
}

function mw_marcos_aplicar_marcos(contenedor,prefmarcosobj){
	/*
	if (elementos=contenedor.getElementsByName('span')){
		alert(elementos.length);
		for (i=0;i<elementos.length;i++){
			if(marcocod=elementos[i].getAttribute('titlex')){
				alert(marcocod);
			}
		}
	}
	*/
	/*
	alert("w");
	if (elementos=contenedor.getElementsByTagName('span')){
		alert(elementos.length);
		for (i=0;i<elementos.length;i++){
			if(marcocod=elementos[i].getAttribute('titlex')){
				alert(marcocod);
			}
		}
	}
	*/
}

function mw_marcos_set_serie(firstselect,msg){
	valorfirst=firstselect.options[firstselect.selectedIndex].value;
	imgindexin=firstselect.selectedIndex;
	if (valorfirst){
		if (valorfirst.length>0){
			if (confirm(msg)){
				imgindex=0;
				if (tbl=mw_dom_get_parent_by_tagname(firstselect,"table")){
					for(rnum=0;rnum<3;rnum++){
						for(cnum=0;cnum<3;cnum++){
							if (imgindex>0){
								sel=tbl.rows[rnum].cells[cnum].childNodes[0];
								sel.selectedIndex=imgindexin+imgindex;
							}
							imgindex++;
						}
					}
				}
			}
		}
	}
	
}
