/*
 Joel Espinosa Longi
 joel.espinosa@amite.mx
 j.longi@gmail.com
 LGPL - http://www.gnu.org/licenses/lgpl.html
 2014-08-05
*/
var prometeoJS=function(d){d.PrometeoApp=function(a){this.applet=a;this.parentContainer=a.parentNode;this.parentContainer.style.margin="0px";this.width=parseFloat(a.getAttribute("width"));this.height=parseFloat(a.getAttribute("height"));this.children=a.getElementsByTagName("param");this.container=document.createElement("div");this.parentContainer.appendChild(this.container);this.container.width=this.width;this.container.height=this.height;this.container.setAttribute("style","position: relative; top: 0px; left: 0px; overflow: hidden; width: "+
this.width+"px; height: "+this.height+"px; background: rgba(255,255,255,0);");a=this.children;this.childrenIframes=[];for(var c,b,e=0,k=a.length;e<k;e++)c=a[e],"E"==c.name.charAt(0)&&"_"==c.name.charAt(1)&&(c=this.split(c.value),b=document.createElement("iframe"),b.setAttribute("src",c.source),b.setAttribute("id",c.nombre),b.setAttribute("marginheight",0),b.setAttribute("marginwidth",0),b.setAttribute("frameborder",0),b.setAttribute("scrolling","no"),b.setAttribute("style","position: absolute; left: "+
c.pos.split(",")[0]+"px; top: "+c.pos.split(",")[1]+"px; width: "+this.width+"px; height: "+this.height+"px;"),this.container.appendChild(b),this.childrenIframes.push(b),d.targetNames.push({name:c.nombre,iframe:b,type:c.tipo}));window.parent.postMessage({type:"reportSize",href:window.location.href,width:this.width,height:this.height},"*")};d.PrometeoApp.prototype.split=function(a){if("string"!=typeof a)return[];a=(a||"").replace(/\\'/g,"\u2019");for(var c=[],b=0,e=0,d=!1,f=0,h=!1;b<a.length;){" "!=
a.charAt(b)||d||b++;" "==a.charAt(b)||d||(d=!0,f=b);"="!=a.charAt(b)||"'"!=a.charAt(b+1)||h||(h=!0,c[e]=[a.substring(f,b)],f=b+2,b+=2);h&&"'"==a.charAt(b)&&(d=h=!1,c[e].push(a.substring(f,b)),e++);if("="==a.charAt(b)&&"'"!=a.charAt(b+1)&&!h){c[e]=[a.substring(f,b)];f=b+1;b++;var d=a.substring(b).indexOf("="),g;-1==d?g=a.length:(d+=b,g=a.substring(b,d).lastIndexOf(" "),g=-1==g?a.length:g+b);c[e].push(a.substring(f,g));e++;d=!1;b=g}b++}a={};e=0;for(b=c.length;e<b;e++)a[c[e][0]]=c[e][1];return a};return d}(prometeoJS||
{}),prometeoJS=function(d){d.apps=[];d.targetNames=[];d.getPrometeoApps=function(){return d.apps};(function(){var a=document.getElementById("StylePrometeoApps");a&&a.parentNode.removeChild(a);a=document.createElement("style");a.id="StylePrometeoApps";a.type="text/css";a.setAttribute("rel","stylesheet");a.innerHTML="applet.prometeoJS {display:none;} applet {display:none;}";document.head.appendChild(a)})();d.receiveMessage=function(a){a=a.data;var c;if(a)if("changeTarget"===a.type){for(var b=0,e=d.targetNames.length;b<
e;b++)if(c=d.targetNames[b],c.name===a.name){c.iframe.src=a.value;return}window.parent!=window&&window.parent.postMessage({type:"changeTarget",name:a.name,value:a.value},"*")}else if("reportSize"===a.type)for(b=0,e=d.targetNames.length;b<e;b++)c=d.targetNames[b],c.iframe.src===a.href&&(c.iframe.style.width=a.width+"px",c.iframe.style.height=a.height+"px")};window.addEventListener("load",function(a){a=document.getElementsByTagName("*");for(var c=[],b=0,e=a.length;b<e;b++)"PrometeoAppContainer"==a[b].className&&
c.push(a[b]);b=0;for(e=c.length;b<e;b++)c[b].parentNode.removeChild(c[b]);c=document.getElementsByTagName("applet");a=[];for(var e=0,k=c.length;e<k;e++)b=c[e],b.getAttribute("code").match("Prometeo")&&a.push(b);c=0;for(b=a.length;c<b;c++)d.apps.push(new d.PrometeoApp(a[c])),a[c].className="prometeoJS";document.getElementById("StylePrometeoApps").innerHTML="applet.prometeoJS {display:none;}"});window.addEventListener("message",d.receiveMessage);return d}(prometeoJS||{});
