var url = new String();
var action = new Number();
var ready = new Boolean();
var wait = new Number();
var hash = new String();
ready = false; action = 0; wait = 0; expireAt = 30; hash = ""; 

function setReadyExternalInterface() {	ready = true; }

function doAction() {
	url = "";	
	wait = 0;
	action = 0;
	if( hash != "" ) {	
        if( hash.indexOf("#") == 0 ) { hash = hash.substr(1); }			
		if( hash.indexOf("url=") != -1 ) { url = hash.substring(4).replace(/\|/gi,"/"); callAction(); } 
		else if( hash.indexOf("do=") != -1 ) { url = hash.substring(3); action = 40; callAction(); } 
		else if( hash.indexOf("popup=") != -1 ) { showPopup(hash.substring(6)); }
		else if( hash.indexOf("click=") != -1 ) { url = hash.substring(6); callClickOption(); } 
		else if( hash.indexOf("book") != -1 ) { url = "kit/book.aspx:swf"; callAction(); } 
		else if( hash.indexOf("bio") != -1 ) { url = "showMy()"; action = 40; callAction(); }
		else if( hash.indexOf("cv") != -1 ) { showPopup("download/cv.pdf,980,640"); }
	}	

}
function showPopup( inf ) {
	opt =  inf.replace(/\|/gi,"/").split(','); //url, width, heigth
	if( opt.length == 3 ) {	if( opt[0].indexOf("http") == -1 ) { popup({_height:opt[2],_width:opt[1],_url:opt[0]});	} }
	delete opt;	
}
function blogComment(to) {
    if( ready ) { flashObject.writeComment("@blog", to); } 
	else { alert("No hay conexion con el objeto Flash.");	}
}
function callAction() {	
	if( ready ) { flashObject.findAction(action, url); } 
	else if ( wait < expireAt ) { wait++; setTimeout("callAction()", 1000);	}
	else { alert("No hay conexion con el objeto Flash."); }
}
function callClickOption() {	
	if( ready ) { var opt = url.split(','); flashObject.clickOption(Number(opt[0]), Number(opt[1]), Number(opt[2])); delete opt; } 
	else if ( wait < expireAt ) { wait++; setTimeout("callClickOption()", 1000); } 
	else { alert("No hay conexion con el objeto Flash."); }
}
function openImage(id, group, p ) {
    var n = p.split("x"); var w = Number(n[0]); var h = Number(n[1]); var ext = (w!=480||h!=800)?".png":".jpg";
    popup({_url:"download/" + group + "." + p + ext, _name:"ID"+id, _width:w+40, _height:h+40});
    delete n, w, h, ext;
}
function updateURI( page ) {
	var hash = document.location.hash;
	page = "#url=" + page.replace(/\//gi,"|");
	if(page != hash ) { document.location.hash = page; }
}
function locationHashChanged() {
    if( document.location.hash != hash ) {
		hash = document.location.hash;
		if (hash != "" ) { doAction(); }
		else { /*vamos a ejecutar un close de la ventana de informacion o mejor un closeAll() */ }
    }
}
function onLoad() {
	window.flashObject = (navigator.appName.indexOf("Microsoft")!=-1) ? window["neltic"] : window.document["neltic"];
    hash = document.location.hash;        
	doAction();
    if ("onhashchange" in window) { window.onhashchange = locationHashChanged; }
}
function onUnload() { delete url, interval, ready, wait, hash; }

