function createVideo(root,source) {
	var controls=new Array("ImageWindow","controlpanel","statusField","positionField");
	var src=new Array(source,"http://www.xtec.es/videoteca/real/buit.rpm","http://www.xtec.es/videoteca/real/buit.rpm","http://www.xtec.es/videoteca/real/buit.rpm");
	var width=new Array("352","352","262","90");
	var height=new Array("288","25","28","28");
	var i,j;
	var conta;
	var obj,cell;
	creaTable("3","1","tabla1",root);
	obj=document.getElementById("tabla1");
	obj.setAttribute("border","0");
	obj.setAttribute("cellpadding","0");
	obj.setAttribute("cellspacing","0");
	obj.setAttribute("width","352");
	conta=0;
	for(i=0;i<(3-1);i++) {
		for(j=0;j<1;j++) {
			cell=getCell(i,j,obj);
			content=creaElement("embed","embed"+conta,"src",src[conta],"controls",controls[conta],"console","master","width",width[conta],"height",height[conta]);
			if(conta==0) {
				content.setAttribute("autostart","true");
			}
			cell.appendChild(content);
			conta++;
		}
	}
	cell=getCell(2,0,obj);
	creaTable(1,2,"tabla2",cell);
	obj=document.getElementById("tabla2");
	obj.setAttribute("border","0");
	obj.setAttribute("cellpadding","0");
	obj.setAttribute("cellspacing","0");
	obj.setAttribute("width","352");
	
		for(i=0;i<1;i++) {
		for(j=0;j<2;j++) {
			cell=getCell(i,j,obj);
			content=creaElement("embed","embed"+conta,"src",src[conta],"controls",controls[conta],"console","master","width",width[conta],"height",height[conta]);
			cell.appendChild(content);
			conta++;
		}
	}
}
function getCell(fila,col,tabla) {
	var row,cell;
	row=tabla.rows[fila];
	cell=row.cells[col];
	return cell;
}

function creaTable(fila,col,id,root) {
	var i,j;
	table=document.createElement("table");
	table.setAttribute("id",id);
	for(i=0;i<fila;i++) {
		table.insertRow(i);
		for(j=0;j<col;j++) {
			table.rows[i].insertCell(j);
		}
	}
	root.appendChild(table);
}
/**
	Crea un elementoHTML de cualquier tipo soportado(table,h[1-7]p,...)
	@param tipo cadena que indica el elemento a crear
	@param id identificador unico para el elemento
	@return HTMLElement
	
*/
function creaElement(tipo,id) {
	var i;
	obj=document.createElement(tipo);
	obj.setAttribute("id",id);
	for(i=2;i<arguments.length;i++) {
		obj.setAttribute(arguments[i],arguments[++i]);
	}
	return obj;
}
function creaContent(capa,orig) {
	obj=document.getElementById(capa);
	orig=window.opener.document.getElementById(orig)
	index=orig.selectedIndex;
	opcio=orig.options[index];
	url=opcio.value;
	createVideo(obj,url);
	document.title="Nostranau - "+opcio.text;
orig.options[0].selected=1;	
}




