var isIE=d.all?true:false,isDOM=d.getElementById?true:false,isNS4=d.layers?true:false,INUBE_html_editor_mode_current="editor";function styleDiv(c,h){if(isDOM){if(h=="s"){$(c).style.display=""}if(h=="h"){$(c).style.display="none"}}else{if(isIE){if(h=="s"){eval("document.all."+c+".style.display='';")}if(h=="h"){eval("document.all."+c+".style.display='none';")}}else{if(isNS4){if(h=="s"){eval("document.layers['"+c+"'].display='';")}if(h=="h"){eval("document.layers['"+c+"'].display='none';")}}}}}function INUBE_html_editor_initiate(){if(d.getElementById&&d.designMode&&!browser_isSafari&&!browser_isKonqueror){INUBE_html_editor_isEditable=true}}function INUBE_html_editor_display(c,a,b,e){if(INUBE_html_editor_isEditable){d.writeln('<iframe id="he_f_'+c+'" name="he_f_'+c+'" width="'+b+'px" height="'+e+'px" frameborder="0" style="border:1px solid #888;"></iframe>');$("he_h_"+c).value=a.html;INUBE_html_editor_designer(c,a.html)}else{d.writeln('<textarea id="'+c+'_mode_html_value" style="border:1px solid #888;width:'+b+"px;height:"+e+'px">'+a+"</textarea>")}}function INUBE_html_editor_designer(b,a){he_content='<html id="he_f_'+b+'"><head><style>body {background:#fff;margin:5px;} img {padding:1px;border:1px solid #888;margin:0 3px 3px 0;}</style></head><body>'+a+"</body></html>";he_edit=$("he_f_"+b).contentWindow.document;he_edit.write(he_content);he_edit.designMode="On";if(browser_isMozilla){$("he_f_"+b).contentDocument.designMode="on"}}function INUBE_html_editor_command(b,g,a){he_field=$("he_f_"+b).contentWindow;try{he_field.focus();he_field.document.execCommand(g,false,a);he_field.focus()}catch(c){}}function INUBE_html_editor_update(a){if(INUBE_html_editor_mode_current=="editor"){if(INUBE_html_editor_isEditable){_editor_value=$("he_f_"+a).contentWindow.document.body.innerHTML}else{_editor_value=$(a+"_mode_html_value").value}}else{_editor_value=$(a+"_mode_html_value").value}$("he_h_"+a).value=_editor_value}function INUBE_html_editor_submit(a,c,b){INUBE_html_editor_update(a);form=$("blog-post");form.action="/account/blog/"+b+"/do/";form.target="";form.submit()}function putCode(a){form=$("blog-post");form.entry_text.value=form.entry_text.value+a;form.entry_text.focus()}function insertCode(a,e,c){editor=$("entry_text_mode_html_value");if(e){var j=prompt(e,"")}if(j!=null&&j!=""&&c){var g=prompt(c,"")}switch(a){case"strong":var h="<strong>"+j+"</strong>";break;case"em":var h="<em>"+j+"</em>";break;case"u":var h="<u>"+j+"</u>";break;case"img":var h='<img src="'+j+'" border="0" />';break;case"a":var h='<a href="'+j+'">'+g+"</a>";break}if((h!=null&&h!="")&&(j!=null&&j!="")){if(c){if(g!=null&&g!=""){var b=true}}else{var b=true}}if(b){mode_buffer=INUBE_html_editor_mode_current;INUBE_html_editor_mode_html("entry_text");editor.value=editor.value+h+" <br />";if(mode_buffer!="html"){INUBE_html_editor_mode_editor("entry_text")}}}function INUBE_html_editor_mode_editor(a){if(INUBE_html_editor_mode_current!="editor"){$("he_h_"+a).value=$(a+"_mode_html_value").value;styleDiv(a+"_mode_html","h");styleDiv(a+"_mode_editor","s");$("he_f_"+a).contentWindow.document.body.innerHTML=$("he_h_"+a).value;$("blog-he-tab-html").style.background="#666";$("blog-he-tab-editor").style.background="#222";INUBE_html_editor_mode_current="editor"}}function INUBE_html_editor_mode_html(a){if(INUBE_html_editor_mode_current!="html"){INUBE_html_editor_update(a);styleDiv(a+"_mode_editor","h");styleDiv(a+"_mode_html","s");$(a+"_mode_html_value").value=$("he_h_"+a).value;$("blog-he-tab-html").style.background="#222";$("blog-he-tab-editor").style.background="#666";INUBE_html_editor_mode_current="html"}}function advancedOptions(a){styleDiv("advancedOptions",a);aoTitle=$("advancedOptionsTitle");if(a=="s"){aoTitleStatus="off";aoTitleDo="h"}else{aoTitleStatus="on";aoTitleDo="s"}aoTitle.innerHTML="<a href=\"javascript:advancedOptions('"+aoTitleDo+'\');" style="color:#868B6B;"><img src="http://images.inube.com/s/ao-'+aoTitleStatus+'.png" border="0"> '+aoTitleText+"</a>"}function miwe(){form=$("blog-post");if(form.entry_miwe.checked){form.entry_comments["0"].checked=true;form.entry_comments["0"].disabled=true;form.entry_comments["1"].disabled=true;styleDiv("miweCategory","s")}else{form.entry_comments["0"].checked=true;form.entry_comments["0"].disabled=false;form.entry_comments["1"].disabled=false;styleDiv("miweCategory","h")}}function form_select_add_option(a,c,b){optn=d.createElement("OPTION");optn.text=c;optn.value=b;a.options.add(optn)}function form_select_remove_options(a){for(i=a.options.length-1;i>=0;i--){a.remove(i)}}function miweCategoryChild(){form=$("blog-post");form_select_remove_options(form.entry_miwe_category_child);parentSelected=form.entry_miwe_category_parent.selectedIndex;parentSelectedValue=form.entry_miwe_category_parent[parentSelected].value;for(i=0;i<miweCategoriesName[parentSelectedValue].length;i++){form_select_add_option(form.entry_miwe_category_child,miweCategoriesName[parentSelectedValue][i],miweCategoriesId[parentSelectedValue][i])}form.entry_miwe_category_child.disabled=false}function firewall(a){jj=$("firewall");if(a>0){if(typeof(upload_server)=="undefined"){jj.innerHTML="";f=$("upload-form");fs=f.action;fs=fs.split(":8010");f.action=fs[0]+fs[1]}}else{jj.innerHTML='<script type="text/javascript" src="http://upload.inube.com:8010/server.js"><\/script>';setTimeout("firewall(1)",3000)}}function upload(a,c,b){if(b=="photo"){extensions="jpg|gif|png|jpeg";_extension=new RegExp("^.+.("+extensions+")$","i");if(_extension.test(a.value)){allow_upload=true}else{allow_upload=false;alert("Extension not allowed")}}else{allow_upload=true}if(allow_upload){$("upload-form").submit();$("upload").innerHTML=progress(500,1,0);setTimeout("upload_status('"+c+"','"+b+"')",1000)}}function upload_status(b,a){yapi({method:"upload.status",data:(a=="photo")?{upload_type:a,upload_id:b}:{upload_type:a,upload_id:b,directory:t.directory},success:function(c){$("upload").innerHTML=progress(500,1,c.percent);if(c.percent<100){setTimeout("upload_status('"+b+"','"+a+"')",1000)}else{w.location=(a=="photo")?"/account/photos/add/"+c.id+"/":y.href}}})}function progress(b,a,c){var g=b/100,e=(a>1)?g*(c-(c%a)):g*c;return'<div style="width:'+b+"px;height:30px;border:1px solid #888;background:url('http://cdn.yeacon.com/inube/img/ic/pb/b_r.png');\"><div style=\"width:"+e+"px;height:30px;background:url('http://cdn.yeacon.com/inube/img/ic/pb/b_l.png');\"></div><div style=\"position:relative;top:-30px;width:"+b+'px;height:30px;text-align:center;font-weight:700;font-size:18px;line-height:30px;color:#fff;">'+c+'%</div><div style="clear:both;"></div></div>'}function photo_avatar(a){yapi({method:"photos.avatar",data:{photo:a},success:function(b){if(_avatar_id){$("photo_"+_avatar_id).style.background="#f0f0f0"}$("photo_"+a).style.background="#d1116e";_avatar_id=a}})}function photo_delete(a){if(confirm(_confirm_PHOTO_PHOTO_DELETE)){yapi({method:"photos.delete",data:{photo:a},success:function(b){$("photo_contextmenu_"+a).innerHTML="";s=$("photo_"+a).style;s.background="#fff";s.border="1px dashed #ff0000";s.filter="alpha(opacity:20)";s.KHTMLOpacity="0.20";s.MozOpacity="0.20";s.opacity="0.20"}})}}function photo_contextmenu(a){$("photo_contextmenu_"+a).style.display="block";return false};
