﻿var edButtons=new Array();var edLinks=new Array();var edOpenTags=new Array();function edButton(id,display,tagStart,tagEnd,access,open){this.id=id;this.display=display;this.tagStart=tagStart;this.tagEnd=tagEnd;this.access=access;this.open=open}edButtons.push(new edButton("ed_bold","Negrita","<strong>","</strong>","b"));edButtons.push(new edButton("ed_italic","Cursiva","<em>","</em>","i"));edButtons.push(new edButton("ed_link","Link","","</a>","a"));edButtons.push(new edButton("ed_img","Imagen","","","m",-1));var extendedStart=edButtons.length;function edLink(display,URL,newWin){this.display=display;this.URL=URL;if(!newWin){newWin=0}this.newWin=newWin}function edShowButton(which,button,i){if(button.access){var accesskey=' accesskey = "'+button.access+'"'}else{var accesskey=""}switch(button.id){case"ed_img":document.write('<input type="button" id="'+button.id+"_"+which+'" '+accesskey+' class="ed_button" onclick="edInsertImage(\''+which+'\');" value="'+button.display+'" />');break;case"ed_link":document.write('<input type="button" id="'+button.id+"_"+which+'" '+accesskey+' class="ed_button" onclick="edInsertLink(\''+which+"', "+i+');" value="'+button.display+'" />');break;default:document.write('<input type="button" id="'+button.id+"_"+which+'" '+accesskey+' class="ed_button" onclick="edInsertTag(\''+which+"', "+i+');" value="'+button.display+'"  />');break}}function edAddTag(which,button){if(edButtons[button].tagEnd!=""){edOpenTags[which][edOpenTags[which].length]=button;document.getElementById(edButtons[button].id+"_"+which).value="/"+document.getElementById(edButtons[button].id+"_"+which).value}}function edRemoveTag(which,button){for(i=0;i<edOpenTags[which].length;i++){if(edOpenTags[which][i]==button){edOpenTags[which].splice(i,1);document.getElementById(edButtons[button].id+"_"+which).value=document.getElementById(edButtons[button].id+"_"+which).value.replace("/","")}}}function edCheckOpenTags(which,button){var tag=0;for(i=0;i<edOpenTags[which].length;i++){if(edOpenTags[which][i]==button){tag++}}if(tag>0){return true}else{return false}}function edCloseAllTags(which){var count=edOpenTags[which].length;for(o=0;o<count;o++){edInsertTag(which,edOpenTags[which][edOpenTags[which].length-1])}}function edQuickLink(i,thisSelect){if(i>-1){var newWin="";if(edLinks[i].newWin==1){newWin=' target="_blank"'}var tempStr='<a href="'+edLinks[i].URL+'"'+newWin+">"+edLinks[i].display+"</a>";thisSelect.selectedIndex=0;edInsertContent(edCanvas,tempStr)}else{thisSelect.selectedIndex=0}}function edToolbar(which){document.write('<div id="ed_toolbar_'+which+'"><span>');for(i=0;i<extendedStart;i++){edShowButton(which,edButtons[i],i)}if(edShowExtraCookie()){document.write('<input type="button" id="ed_close_'+which+'" class="ed_button" onclick="edCloseAllTags(\''+which+'\');" value="Cerrar Tags" /></span><br />')}else{document.write('<input type="button" id="ed_close_'+which+'" class="ed_button" onclick="edCloseAllTags(\''+which+'\');" value="Cerrar Tags" /></span><br />')}for(i=extendedStart;i<edButtons.length;i++){edShowButton(which,edButtons[i],i)}document.write("</span>");document.write("</div>");edOpenTags[which]=new Array()}function edInsertTag(which,i){myField=document.getElementById(which);if(document.selection){myField.focus();sel=document.selection.createRange();if(sel.text.length>0){sel.text=edButtons[i].tagStart+sel.text+edButtons[i].tagEnd}else{if(!edCheckOpenTags(which,i)||edButtons[i].tagEnd==""){sel.text=edButtons[i].tagStart;edAddTag(which,i)}else{sel.text=edButtons[i].tagEnd;edRemoveTag(which,i)}}myField.focus()}else{if(myField.selectionStart||myField.selectionStart=="0"){var startPos=myField.selectionStart;var endPos=myField.selectionEnd;var cursorPos=endPos;var scrollTop=myField.scrollTop;if(startPos!=endPos){myField.value=myField.value.substring(0,startPos)+edButtons[i].tagStart+myField.value.substring(startPos,endPos)+edButtons[i].tagEnd+myField.value.substring(endPos,myField.value.length);cursorPos+=edButtons[i].tagStart.length+edButtons[i].tagEnd.length}else{if(!edCheckOpenTags(which,i)||edButtons[i].tagEnd==""){myField.value=myField.value.substring(0,startPos)+edButtons[i].tagStart+myField.value.substring(endPos,myField.value.length);edAddTag(which,i);cursorPos=startPos+edButtons[i].tagStart.length}else{myField.value=myField.value.substring(0,startPos)+edButtons[i].tagEnd+myField.value.substring(endPos,myField.value.length);edRemoveTag(which,i);cursorPos=startPos+edButtons[i].tagEnd.length}}myField.focus();myField.selectionStart=cursorPos;myField.selectionEnd=cursorPos;myField.scrollTop=scrollTop}else{if(!edCheckOpenTags(which,i)||edButtons[i].tagEnd==""){myField.value+=edButtons[i].tagStart;edAddTag(which,i)}else{myField.value+=edButtons[i].tagEnd;edRemoveTag(which,i)}myField.focus()}}}function edInsertContent(which,myValue){myField=document.getElementById(which);if(document.selection){myField.focus();sel=document.selection.createRange();sel.text=myValue;myField.focus()}else{if(myField.selectionStart||myField.selectionStart=="0"){var startPos=myField.selectionStart;var endPos=myField.selectionEnd;var scrollTop=myField.scrollTop;myField.value=myField.value.substring(0,startPos)+myValue+myField.value.substring(endPos,myField.value.length);myField.focus();myField.selectionStart=startPos+myValue.length;myField.selectionEnd=startPos+myValue.length;myField.scrollTop=scrollTop}else{myField.value+=myValue;myField.focus()}}}function edInsertLink(which,i,defaultValue){myField=document.getElementById(which);if(!defaultValue){defaultValue="http://"}if(!edCheckOpenTags(which,i)){var URL=prompt("Ingresa la URL",defaultValue);if(URL){edButtons[i].tagStart='<a href="'+URL+'">';edInsertTag(which,i)}}else{edInsertTag(which,i)}}function edInsertExtLink(which,i,defaultValue){myField=document.getElementById(which);if(!defaultValue){defaultValue="http://"}if(!edCheckOpenTags(which,i)){var URL=prompt("Ingresa la URL",defaultValue);if(URL){edButtons[i].tagStart='<a href="'+URL+'" rel="externo">';edInsertTag(which,i)}}else{edInsertTag(which,i)}}function edInsertImage(which){myField=document.getElementById(which);var myValue=prompt("Ingresa la URL de la imagen","http://");if(myValue){myValue='<img src="'+myValue+'" alt="'+prompt("Ingresa una descripci&oacute;n (opcional)","")+'" />';edInsertContent(which,myValue)}}function edSetCookie(name,value,expires,path,domain){document.cookie=name+"="+escape(value)+((expires)?"; expires="+expires.toGMTString():"")+((path)?"; path="+path:"")+((domain)?"; domain="+domain:"")}function edShowExtraCookie(){var cookies=document.cookie.split(";");for(var i=0;i<cookies.length;i++){var cookieData=cookies[i];while(cookieData.charAt(0)==" "){cookieData=cookieData.substring(1,cookieData.length)}if(cookieData.indexOf("js_quicktags_extra")==0){if(cookieData.substring(19,cookieData.length)=="show"){return true}else{return false}}}return false};
