
var IE=false;if(navigator.userAgent.indexOf("MSIE")>=0)IE=true;if(navigator.appVersion.indexOf("MSIE 6.0")>=0){VERSION="6.0";};if(navigator.appVersion.indexOf("MSIE 6.5")>=0){VERSION="6.5";};if(navigator.appVersion.indexOf("MSIE 7.0")>=0){VERSION="7.0";};if(navigator.appVersion.indexOf("MSIE 8.0")>=0){VERSION="8.0";};var Editable=true;var notesTouched=false;var otherLoaded=false;var bF=null;function getXMLHttpRequest(){if(typeof XMLHttpRequest!='undefined')
{return new XMLHttpRequest();}
try{return new ActiveXObject("Msxml2.XMLHTTP");}
catch(e){try{return new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}}return false;}
var http=getXMLHttpRequest();function insertLoadingAjax(ox){var img=new Image();img.src="/noticias/extensions/glimages/ajax-loader.gif";img.style.height="5px";img.style.marginTop="3px";img.style.float="right";ox.parentNode.appendChild(img);return img;}
function removeLoadingAjax(ox){ox.parentNode.removeChild(ox);}
function onLoad(){xxx=getIFrameDocumentAll();if(xxx){xxx.contentEditable="true";xxx.designMode="On";http=getXMLHttpRequest();if(!http){alert('Error: problema con javascript, no se podrá guardar sus notas');}else{inp=xxx.parentNode.getElementsByTagName('INPUT')[0];executer=inp.parentNode;http.open("POST","/noticias/extensions/notes/index.php?action=load",true);http.setRequestHeader("Content-Type","application/x-www-form-urlencoded");http.onreadystatechange=function()
{if(http.readyState==4)
{nts=http.responseXML.getElementsByTagName('usernotes');src="public.gif";if(nts.length>0){if((nts[0].getAttribute('public'))&&(nts[0].getAttribute('public')=="true")){src="publicsel.gif";$e.$(xxx.parentNode.parentNode.getAttribute('id')).notesPublic="true";}
btns=executer.parentNode.getElementsByTagName('IMG');for(var i=0;i<btns.length;i++){if(btns[i].src.indexOf('public')>=0){btns[i].src="/noticias/extensions/glimages/"+src;}}
nts=nts[0].firstChild;nts=(nts)?nts=nts.data:"<span>&nbsp;</span>";if(!IE){if(navigator.userAgent.indexOf('Firefox/2')>=0){nts+="<div class='ff2Warning'><img class='ff3logo'";nts+=" src='/noticias/extensions/glimages/ff3.gif' />";nts+="<img src='/noticias/extensions/glimages/close_on.gif'";nts+=" onclick='this.parentNode.parentNode.removeChild(this.parentNode);' /><br /><span class='frase'>You can look,<br /> but you can't touch!.</span><br />";nts+=" To be able to edit notes, <br />you will need Firefox Version 3 or newer.<br />"
nts+="<a href='http://www.firefox.com'>Please upgrade your browser!</a><br />";nts+="</div>";}}
if((qsParamValue('notes')==wgUserName)||(qsParamValue('notes')=="")){inp.value=wgUserName;}else{inp.value=qsParamValue('notes');}
xxx.innerHTML=nts;xxx.designMode="On";xxx.contentEditable=true;}}}
var data="wikiuser="+escape(wgUserName)+"&title="+escape(wgPageName);if(!((qsParamValue("notes")==wgUserName)||(qsParamValue("notes")==""))){data="wikiuser="+escape(qsParamValue('notes'))+"&title="+escape(wgPageName);}
http.send(data);}}}
function onUnload(event){if(notesTouched)
event.returnValue="You have not saved your notes!";}
function getIFrameDocumentAll(){return document.getElementById('notesEditor');}
function getIFrameWinAll(){return document.getElementById('notesEditor');}
function getIFrameDocument(b){return document.getElementById('notesEditor');}
function retParent(ob,nmclass,nmclass2){var res;res=ob.parentNode;while((res.className)&&(res.className!=nmclass)&&(res.className!=nmclass2)){res=res.parentNode;}
return res;}
function notesToolClick(b){if(b.src.indexOf('bold.gif')>=0){if(navigator.userAgent.indexOf('Firefox/2')<0){makeBold(document);}}else
if(b.src.indexOf('italic.gif')>=0){if(navigator.userAgent.indexOf('Firefox/2')<0){makeItalic(document);}}else
if(b.src.indexOf('synctag.gif')>=0){if(navigator.userAgent.indexOf('Firefox/2')<0){makeSyncTag(getIFrameDocument(b),retParent(b,"mainW","mainWslides"));}}else
if(b.src.indexOf('newnotes.gif')>=0){if(navigator.userAgent.indexOf('Firefox/2')<0){getIFrameDocument(b).innerHTML="";notesTouched=true;}}else
if(b.src.indexOf('save.gif')>=0){if(navigator.userAgent.indexOf('Firefox/2')<0){saveNotes(b,getIFrameDocument(b),true);}}else
if(b.src.indexOf('public.gif')>=0){if(navigator.userAgent.indexOf('Firefox/2')<0){$e.$(b.parentNode.parentNode.parentNode.getAttribute('id')).notesPublic="true";b.src="/noticias/extensions/glimages/publicsel.gif";notesTouched=true;}}else
if(b.src.indexOf('publicsel.gif')>=0){if(navigator.userAgent.indexOf('Firefox/2')<0){$e.$(b.parentNode.parentNode.parentNode.getAttribute('id')).notesPublic="false";b.src="/noticias/extensions/glimages/public.gif";notesTouched=true;}}
return true;}
function makeBold(doku){doku.execCommand('bold',false,null);notesTouched=true;}
function makeItalic(doku){doku.execCommand('italic',false,null);notesTouched=true;}
function onEditLbl(lb){txt=lb.innerHTML;txt=txt.replace(/[^0-9:]/g,'');lb.innerHTML=txt;}
function makeSyncTag(doku,wn){win=doku.parentNode;st=secondsToTime(ply.$(wn.getAttribute('g_playerid')).currentTime);ht='<span contentEditable="false" designMode="Off" class="notesTM" g_playerid="';ht+=wn.getAttribute('g_playerid')+'"><img contentEditable="false" designMode="Off"';ht+=' class="aSync" onclick="notesSyncVideo(this);" onmouseover="notesShowStats(this);" ';ht+=' src="/noticias/extensions/glimages/syncnotes.gif" /><span  contentEditable="true"';ht+=' designMode="On" onblur="onEditLbl(this);" onchange="onEditLbl(this);">';ht+=st+'</span><img  contentEditable="false" designMode="Off" src="/noticias';ht+='/extensions/glimages/decrement.gif" class="backward" onclick="notesIncrement(this);" />';ht+='<img contentEditable="false" designMode="Off" src="/noticias';ht+='/extensions/glimages/increment.gif" onclick="notesIncrement(this);" class="forward" /><img src="/noticias';ht+='/extensions/glimages/extend.gif" class="extendTM" onclick="extend(this);" /></span>';ht=(IE)?ht:ht+"&nbsp;"
insertHTML(doku,ht,false);sps=doku.getElementsByTagName('SPAN');for(var i=0;i<sps.length;i++){if((sps[i].className)&&(sps[i].className=="notesTM")){sps[i].designMode="off";sps[i].contentEditable="false";tmlabel=sps[i].getElementsByTagName('SPAN')[0];tmlabel.designMode='true';tmlabel.contentEditable="true";}}
notesTouched=true;var sel=null;executer=null;if(IE){sel=document.selection.createRange();sel.collapse(false);}else
{sel=document.getSelection();doku.focus();}}
function insertHTML(doku,txt,rep){if(!IE){if(rep)
doku.innerHTML=txt;else
document.execCommand('insertHTML',false,txt);}else{doku.focus();sel=document.selection.createRange();sel.pasteHTML(txt);}
return true;}
function saveNotes(bn,doku,AjxLd){flag=false;if(otherLoaded){if(confirm('Esto reemplazara sus notas!, Desea continuar?')){otherLoaded=false;}else{return false;}}
var img=null;var http2=null;if(AjxLd)img=insertLoadingAjax(bn);else http2=getXMLHttpRequest();btns=bn.parentNode.getElementsByTagName('IMG');publico=false;for(var i=0;i<btns.length;i++){if(btns[i].src.indexOf('publicsel.gif')>=0){publico=true;}}
if(AjxLd){$http=http;}else{$http=http2;}
$http.open("POST","/noticias/extensions/notes/index.php?action=save",true);$http.setRequestHeader("Content-Type","application/x-www-form-urlencoded");$http.onreadystatechange=function()
{if($http.readyState==4)
{if(AjxLd)removeLoadingAjax(img);Xml=$http.responseXML;r=getNodeVal(Xml,'result');if(r=='OK'){r=getNodeVal(Xml,'usermsg');alert(r);notesTouched=false;}else{alert('We have troubles with communication.. try in a few seconds');}
bn.parentNode.getElementsByTagName('INPUT')[0].value=wgUserName;}}
texto=doku.innerHTML;var data="wikiuser="+escape(wgUserName)+"&title="+escape(wgPageName)+"&notesText="+escape(texto);$e.$(bn.parentNode.parentNode.parentNode.getAttribute('id')).notesBuffer=texto;if(publico)
{data=data+"&public=true";}else{data=data+"&public=false";}
$http.send(data);}
function makeXMLHttpRequest(tipo,url,data,funcion){tipo=(tipo>0)?"POST":"GET";http.open(tipo,url,true);http.setRequestHeader("Content-Type","application/x-www-form-urlencoded");http.onreadystatechange=funcion;http.send(data);}
function inputKey(e,obj){key=(window.event)?event.keyCode:e.keyCode;if(obj.value.length>0){switch(key){case 13:{if(obj.getAttribute('opt')=="search")
setChosen(obj,1);else
setChosen(obj,0);}break;case 27:{showList(obj,false);obj.parentNode.childNodes[1].innerHTML="";}break;case 38:{moveSelected("up",obj);}break;case 40:{moveSelected("down",obj);}break;default:{if(key>65){var data="";if(obj.getAttribute('opt')!='search'){if(obj.value.toUpperCase()!="MY NOTES")
data="text="+escape(obj.value)+"&title="+escape(wgPageName);else data="text="+escape(wgUserName)+"&title="+escape(wgPageName);makeXMLHttpRequest(1,"/noticias/extensions/notes/index.php?action=suggest",data,function(){if(http.readyState==4)
{try{fillDropDown(obj,http.responseXML,0);obj.onblur=function(){showList(this,false);};}catch(e){}}});}else{data="text="+escape(obj.value);makeXMLHttpRequest(1,"/noticias/extensions/notes/index.php?action=suggest&op=search",data,function(){if(http.readyState==4)
{try{fillDropDown(obj,http.responseXML,1);obj.onblur=function(){showList(this,false);};}catch(e){}}});}}}break;}}}
function setChosen(obj,opt){inp=obj;var selected=null;if(obj.tagName=="DIV"){selected=obj;obj=obj.parentNode.parentNode.firstChild;}
showList(obj,false);if(!selected)selected=getTextSelect(obj);texto="";valor="";if(selected){obj.value=selected.getAttribute('text');texto=selected.getAttribute('text');valor=selected.getAttribute('value');}else{texto=inp.value;if(texto.toUpperCase()=="MY NOTES")texto=wgUserName;valor=texto;}
if(opt==0){var Ajx=insertLoadingAjax(obj.parentNode);var data="text="+escape(valor)+"&title="+escape(wgPageName);if((!otherLoaded)&&(notesTouched)){if(!confirm('This will destroy the changes, proceed?')){removeLoadingAjax(Ajx);return false;}}
if(valor!=wgUserName)otherLoaded=true;else otherLoaded=false;url="/noticias/extensions/notes/index.php?action=suggest&op=load";if(valor==wgUserName)url=url+"self";makeXMLHttpRequest(1,url,data,function(){if(http.readyState==4)
{Xml=http.responseXML;removeLoadingAjax(Ajx);r=getNodeVal(Xml,'contenido');if(r.length>0){doku=getIFrameDocument(obj.parentNode);doku.innerHTML="";insertHTML(doku,unescape(r),true);notesTouched=false;}}});}}
function showList(obj,op){if(obj.tagName=="INPUT")obj.parentNode.childNodes[1].style.display=(op)?"block":"none";else obj.parentNode.style.display=(op)?"block":"none";}
function getValueSelect(obj){drp=obj.parentNode.childNodes[1];return drp.getAttribute("value");}
function getTextSelect(obj){drp=obj.parentNode.childNodes[1].firstChild;while(drp){if((drp.getAttribute('selected'))&&(drp.getAttribute('selected')=="true")){return drp;}
try{drp=drp.nextSibling;}catch(e){drp=null;}}
return"";}
function moveSelected(op,obj){pg=obj.parentNode.childNodes[1].firstChild;if(pg){bfr=null;nxt=pg.nextSibling;flag=false;if(pg.nextSibling){while(nxt){if((pg.getAttribute('selected'))&&(pg.getAttribute('selected')=="true")){flag=true;switch(op){case"down":{pg.className="notesDropOp";pg.setAttribute("selected","false");nxt.className="notesDropOpSelected";nxt.setAttribute("selected","true");nxt.parentNode.setAttribute('value',nxt.getAttribute("value"));nxt=null;}break;case"up":{if(bfr){pg.className='notesDropOp';pg.setAttribute("selected","false");bfr.className="notesDropOpSelected"
bfr.setAttribute("selected","true");bfr.parentNode.setAttribute('value',bfr.getAttribute("value"));}
nxt=null;}break;}}else{bfr=pg;pg=pg.nextSibling;nxt=pg.nextSibling
if((!nxt)&&(pg.getAttribute("selected"))&&(pg.getAttribute("selected")=="true")&&(op=="up")){if(bfr){pg.className="notesDropOp";pg.setAttribute("selected","false");bfr.className="notesDropOpSelected";bfr.setAttribute("selected","true");bfr.parentNode.setAttribute('value',bfr.getAttribute("value"));}}}}}else{pg.className="notesDropOpSelected";pg.setAttribute("selected","true");pg.parentNode.setAttribute('value',pg.getAttribute("value"));}}}
function fillDropDown(obj,Xml,opt){list=obj.parentNode.childNodes[1];list.innerHTML="";r=Xml.getElementsByTagName('op');if(r.length>0)showList(obj,true);for(var i=0;i<r.length;i++){nd=createOption(r[i],opt);if(i==0){nd.setAttribute('selected',"true");nd.className="notesDropOpSelected";}
list.appendChild(nd);}}
function createOption(rop,opt){texto=rop.getAttribute('text');valor=rop.getAttribute('value');var res=document.createElement('DIV');res.onclick=function(){this.setAttribute("selected","true");setChosen(this,opt);showList(this,false);inpt.onblur=bF;};res.onmouseover=function(){this.className="notesDropOpSelected";inpt=this.parentNode.parentNode.firstChild;bF=inpt.onblur;inpt.onblur=null;this.onmouseout=function(){this.className="notesDropOp";inpt.onblur=bF;};this.onmouseup=function(){inpt.onblur=bF;};};res.setAttribute('value',valor);res.setAttribute('selected','false');res.setAttribute('text',texto);res.className="notesDropOp";res.innerHTML="<img src='/noticias/extensions/glimages/download.gif' /><span>"+texto+"</span>";return res;}
function resetRows(tbody){for(var i=0;i<tbody.childNodes.length;i++){row=tbody.childNodes[i];row.className=row.getAttribute('beforeclass');imgs=row.getElementsByTagName('IMG');for(var j=0;j<imgs.length;j++){if((imgs[j].getAttribute('beforesrc'))&&(imgs[j].src!=imgs[j].getAttribute('beforesrc'))&&(imgs[j].src!=imgs[j].getAttribute('beforesrc')))
{imgs[j].src=imgs[j].getAttribute('beforesrc');}}}}
function getNodeVal(xml,name){try{r=xml.getElementsByTagName(name);if(r.length>0)return r[0].firstChild.data;else return"";}catch(e){return"";}}
function showNotes(event,img){if(img.src.indexOf('close')>=0){resetRows(img.parentNode.parentNode.parentNode);document.getElementById('notesPreview').style.visibility="hidden";}else{md=img.parentNode;while(md.getAttribute('id')!='bodyContent'){md=md.parentNode;}
tbls=md.getElementsByTagName('TABLE')
for(var i=0;i<tbls.length;i++){resetRows(tbls[i].firstChild);}
img.setAttribute('beforesrc',img.src);img.src='/noticias/extensions/glimages/close_on.gif';if(!http)http=getXMLHttpRequest();row=img.parentNode.parentNode;row.setAttribute('beforeclass',row.className);row.className="selected";var ndv=document.getElementById('notesPreview');ndv.style.visibility="visible";var ajx=new Image();ajx.src="/noticias/extensions/glimages/ajax-loader.gif";ndv.childNodes[1].innerHTML="Loading ...";ndv.childNodes[1].appendChild(ajx);img.parentNode.appendChild(ndv);ajx.style.height="5px";offs=getOffset(ndv.parentNode.parentNode,"bodyContent");ndv.style.top=offs.posy+"px";offs=getOffset(ndv.parentNode,"bodyContent");if(IE)offs.posx-=despX+11;ndv.style.left=offs.posx+ndv.parentNode.offsetWidth+3+"px";ndv.childNodes[0].style.height=(img.parentNode.offsetHeight-2)+"px";var data="text="+escape(img.getAttribute('usuario'))+"&title="+escape(img.getAttribute('handle'));url="/noticias/extensions/notes/index.php?action=suggest&op=loadsearch";if(img.getAttribute('usuario')==wgUserName){url+="self";}
makeXMLHttpRequest(1,url,data,function(){if(http.readyState==4)
{try{ajx.parentNode.removeChild(ajx);xml=http.responseXML;ndv.childNodes[1].innerHTML=unescape(getNodeVal(xml,'contenido'));}catch(e){}}});}}
function getOffset(obj,tope){res=new ClassPoint();while(obj!=null){if(obj){if(typeof(obj.offsetTop)=="number")res.posy+=obj.offsetTop;if(typeof(obj.offsetLeft)=="number")res.posx+=obj.offsetLeft;obj=obj.parentNode;if((obj)&&((obj.id)||((obj.className)))){if((obj.id==tope)||(obj.className==tope)){obj=null;}}}}
return res;}
function hidePreviewNotes(btn){btn.parentNode.style.visibility="hidden";}
function changePublicNotes(btn){if(!http)http=getXMLHttpRequest();hdl=btn.getAttribute('handle');usr=btn.getAttribute('user');if(usr==wgUserName){pub=true;if(btn.src.indexOf('sel')>=0){pub=false;}
btn.src="/noticias/extensions/glimages/sharing.gif";var data;data="usr="+escape(wgUserName)+"&handle="+escape(hdl)+"&value="+escape(pub);makeXMLHttpRequest(1,"/noticias/extensions/notes/index.php?action=makepublic",data,function(){if(http.readyState==4)
{Xml=http.responseXML;r=getNodeVal(Xml,'result');if(r=='OK'){r=getNodeVal(Xml,'usermsg');if(pub)btn.src="/noticias/extensions/glimages/publicsel.gif";else btn.src="/noticias/extensions/glimages/public.gif";btn.setAttribute('beforesrc',btn.src);btn.style.width='';}else{btn.src=btn.getAttribute('beforesrc');btn.style.width='';alert('We have troubles with communication.. try in a few seconds');}}});}else{}}
function deleteNotes(btn){if(!http)http=getXMLHttpRequest();hdl=btn.getAttribute('handle');usr=btn.getAttribute('user');if(usr==wgUserName){btn.src="/noticias/extensions/glimages/ajax-loader.gif";btn.style.width='9px';var data;data="usr="+escape(wgUserName)+"&handle="+escape(hdl);makeXMLHttpRequest(1,"/noticias/extensions/notes/index.php?action=delete",data,function(){if(http.readyState==4)
{Xml=http.responseXML;r=getNodeVal(Xml,'result');if(r=='OK'){r=getNodeVal(Xml,'usermsg');row=btn.parentNode.parentNode;row.parentNode.removeChild(row);}else{btn.src=btn.getAttribute('beforesrc');btn.style.width='';alert('We have troubles with communication.. try in a few seconds');}}});}else{}}
function wrapSort(im){rw=im.parentNode.parentNode;rw=rw.getElementsByTagName('IMG');for(var i=0;i<rw.length;i++){if(rw[i].parentNode.innerHTML!=im.parentNode.innerHTML)
rw[i].src="/noticias/skins/common/images/sort_none.gif";}
nxI=im.nextSibling;while(nxI.tagName!='A')nxI=nxI.nextSibling;nxA=nxI;inThis=false;rw=im.parentNode.parentNode;while((!inThis)&&(rw)){if((rw.className)&&(rw.className=='selected')){inThis=true;}
rw=rw.nextSibling;}
if(inThis){resetRows(im.parentNode.parentNode.parentNode);document.getElementById('notesPreview').style.visibility="hidden";}
nxA.onclick();nxI=nxI.getElementsByTagName('IMG')[0];im.src=nxI.src;}
function showTbl(bn){o=bn.parentNode.parentNode;while(o.tagName!='TABLE')o=o.nextSibling;if(bn.getAttribute('opt')=='hide'){o.style.display='none';bn.setAttribute('opt','show');bn.innerHTML="[show]";}else{o.style.display='block';bn.setAttribute('opt','hide');bn.innerHTML='[hide]';}}
function notesSyncVideo(b){ply.$(b.parentNode.getAttribute('g_playerid')).goTo(b.parentNode.getElementsByTagName('SPAN')[0].innerHTML);if(b.parentNode.getElementsByTagName('SPAN')[1]){globalStop=timeToSeconds(b.parentNode.getElementsByTagName('SPAN')[1].innerHTML);}}
function notesIncrement(b){tmlbl=null;if(b.getAttribute('opt')=='end')
tmlbl=b.parentNode.getElementsByTagName('SPAN')[1];else
tmlbl=b.parentNode.getElementsByTagName('SPAN')[0];time=timeToSeconds(tmlbl.innerHTML);if(b.className=='forward'){time=time+1;}else{time=time-1;if(time<0)time=0;}
tmlbl.innerHTML=secondsToTime(time);}
function extend(im){sp=im.parentNode;nsp=document.createElement('SPAN');nsp.innerHTML='00:00';nsp.onblur=function(){onEditLbl(this);};nsp.contentEditable='true';nsp.designMode='on';nimg1=document.createElement('IMG');nimg1.src=sp.getElementsByTagName('IMG')[1].src;nimg1.className='backward';nimg1.onclick=function(){notesIncrement(this);}
nimg1.setAttribute('opt','end');nimg2=document.createElement('IMG');nimg2.src=sp.getElementsByTagName('IMG')[2].src;nimg2.className='forward';nimg2.onclick=function(){notesIncrement(this);}
nimg2.setAttribute('opt','end');sp.appendChild(nsp);sp.appendChild(nimg1);sp.appendChild(nimg2);im.parentNode.removeChild(im);}
function notesShowStats(b){tb=timeToSeconds(b.nextSibling.innerHTML);if(b.parentNode.getElementsByTagName('SPAN')[1]){te=timeToSeconds(b.parentNode.getElementsByTagName('SPAN')[1].innerHTML);}else{te=ply.$(b.parentNode.getAttribute('g_playerid')).totalTime;}
if(te>tb){ply.$(b.parentNode.getAttribute('g_playerid')).showActive(tb,te);}else{ply.$(b.parentNode.getAttribute('g_playerid')).showActive(tb,tb+1);}
b.onmouseout=function(){ply.$(this.parentNode.getAttribute('g_playerid')).hideActive();};}