function vinculo(texto, dir, destino, clase, alt) {
	salida = "<a href='" + dir + "' class='" + clase + "' target='" + destino;
	if (alt && alt.length)
		salida += "' alt='" + alt + "' title='" + alt;
	salida += "'>";
	salida += texto + "</a>";
	return salida;
}

function imagen(source, titulo) {
	salida = "<img src='" + source + "' title='" + titulo + "'></img>";
	return salida;
}

function celdaBlanco(ancho) {
	salida = "<td width='"+ancho+"' height='"+alturaCelda+"'>";
	return salida;
}

function celda() { return "<td valign='top'>"; }

function renglonBlanco() { return "<tr><td>&nbsp;</td></tr>"; }

function delChilds(elem) {
	while (elem.length > 1) tabla.removeChild(elem[1]);
}

function objById(id) { return document.getElementById(id);}

/*
function getFrameDoc(frameID) {
//Returns document object inside the iframe with id frameID
    var oIframe = document.getElementById(frameID);
    var oDoc;

    if (oIframe.contentWindow || oIframe.contentDocument)
    {
    	oDoc = (oIframe.contentWindow || oIframe.contentDocument);
    	if (oDoc.document) oDoc = oDoc.document;
    	return oDoc;
	}
	else {
		for (i = 0; i < document.frames.length; i++) {
			if (document.frames[i].id == frameID)
				return document.frames[i].document;
		}
	}
}
*/
var vent;
function getFrameDoc(frameID) {
	var IFrameObj = document.getElementById(frameID);
	var IFrameDoc;
	if (IFrameObj.contentDocument) {
		//NS6, Moz?
		IFrameDoc = IFrameObj.contentDocument; 
	}
	else if (IFrameObj.contentWindow) {
		//IE5.5, IE6
		IFrameDoc = IFrameObj.contentWindow.document;
	}
	else if (IFrameObj.document) {
		//IE5
		//Little dirty trick
		if (typeof vent == 'undefined' || vent == "") {
			vent = window.open('','vent',"width=1,height=1");
			focus();
			IFrameDoc = vent.document;
			}
		else
			IFrameDoc =  vent.document;
	}
	else
		return false;

	return IFrameDoc;
}

function copyURLContent(url, dest, bodyID) {
//Loads an url on the auxiliar IFRAME and waits for the url to load
	//auxIframe('ifr');
	ifrDoc = getFrameDoc('ifr');
	if (ifrDoc) {
		ifrDoc.location.href = url;
		waitURLContent('ifr', dest, bodyID);
	}
}

function waitURLContent(ifrID, dest, bodyID) {
//Waits until target document loads with body's ID equal to param
	ifrDoc = getFrameDoc(ifrID);
	
	if (typeof ifrDoc.body != 'undefined' && ifrDoc.body.innerHTML && ifrDoc.body.id == bodyID) {
		objById(dest).innerHTML = ifrDoc.body.innerHTML;
		if (typeof vent != 'undefined') { vent.close(); vent = "";} //IE5
	}
	else
		setTimeout("waitURLContent('"+ifrID+"','"+dest+"','"+bodyID+"')",70);
}

function auxIframe(id) {
//If it doesn't yet exists, creates an invisible iframe with specified ID
	if (!objById(id))
		document.body.innerHTML += ifrString = "<iframe src='' id='"+id+"' name='ifr' width='0' height='0' frameborder='0'></iframe>";
}
