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(board,html,he_s_w,he_s_h){if(INUBE_html_editor_isEditable){d.writeln('<iframe id="he_f_'+board+'" name="he_f_'+board+'" width="'+he_s_w+'px" height="'+he_s_h+'px" frameborder="0" style="border:1px solid #888;"></iframe>');$('he_h_'+board).value=html.html;INUBE_html_editor_designer(board,html.html);}else{d.writeln('<textarea id="'+board+'_mode_html_value" style="border:1px solid #888;width:'+he_s_w+'px;height:'+he_s_h+'px">'+html+'</textarea>');}}function INUBE_html_editor_designer(board,html){he_content='<html id="he_f_'+board+'"><head><style>body{background:#fff;margin:5px;}img{padding:1px;border:1px solid #888;margin:0 3px 3px 0;}</style></head><body>'+html+'</body></html>';he_edit=$('he_f_'+board).contentWindow.document;he_edit.write(he_content);he_edit.designMode='On';if(browser_isMozilla){$('he_f_'+board).contentDocument.designMode='on';}}function INUBE_html_editor_command(board,command,option){he_field=$('he_f_'+board).contentWindow;try{he_field.focus();he_field.document.execCommand(command,false,option);he_field.focus();}catch(e){}}function INUBE_html_editor_update(board){if(INUBE_html_editor_mode_current=="editor"){if(INUBE_html_editor_isEditable){_editor_value=$('he_f_'+board).contentWindow.document.body.innerHTML;}else{_editor_value=$(board+'_mode_html_value').value;}}else{_editor_value=$(board+'_mode_html_value').value;}$('he_h_'+board).value=_editor_value;}function INUBE_html_editor_submit(board,action,i_submit){INUBE_html_editor_update(board);form=$("blog-post");form.action='/account/blog/'+i_submit+'/do/';form.target='';form.submit();}function putCode(tag){form=$("blog-post");form.entry_text.value=form.entry_text.value+tag;form.entry_text.focus();}function insertCode(tag,question_a,question_b){editor=$("entry_text_mode_html_value");if(question_a){var tag_value_a=prompt(question_a,'');}if(tag_value_a!=null && tag_value_a!='' && question_b){var tag_value_b=prompt(question_b,'');}switch(tag){case 'strong':var tag_html='<strong>'+tag_value_a+'</strong>';break;case 'em':var tag_html='<em>'+tag_value_a+'</em>';break;case 'u':var tag_html='<u>'+tag_value_a+'</u>';break;case 'img':var tag_html='<img src="'+tag_value_a+'" border="0" />';break;case 'a':var tag_html='<a href="'+tag_value_a+'">'+tag_value_b+'</a>';break;}if((tag_html!=null && tag_html!='')&&(tag_value_a!=null && tag_value_a!='')){if(question_b){if(tag_value_b!=null && tag_value_b!=''){var tag_insert=true;}}else{var tag_insert=true;}}if(tag_insert){mode_buffer=INUBE_html_editor_mode_current;INUBE_html_editor_mode_html("entry_text");editor.value=editor.value+tag_html+"<br />";if(mode_buffer !="html"){INUBE_html_editor_mode_editor("entry_text");}}}function INUBE_html_editor_mode_editor(board){if(INUBE_html_editor_mode_current!="editor"){$('he_h_'+board).value=$(board+'_mode_html_value').value;styleDiv(board+'_mode_html','h');styleDiv(board+'_mode_editor','s');$('he_f_'+board).contentWindow.document.body.innerHTML=$('he_h_'+board).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(board){if(INUBE_html_editor_mode_current!="html"){INUBE_html_editor_update(board);styleDiv(board+'_mode_editor','h');styleDiv(board+'_mode_html','s');$(board+'_mode_html_value').value=$('he_h_'+board).value;$('blog-he-tab-html').style.background='#222';$('blog-he-tab-editor').style.background='#666';INUBE_html_editor_mode_current="html";}}function advancedOptions(_status){styleDiv('advancedOptions',_status);aoTitle=$('advancedOptionsTitle');if(_status=='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(select,text,value){optn=d.createElement("OPTION");optn.text=text;optn.value=value;select.options.add(optn);}function form_select_remove_options(select){for(i=select.options.length-1;i>=0;i--){select.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(j){jj=$("firewall");if(j>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(file,id,type){if(type=="photo"){extensions="jpg|gif|png|jpeg";_extension=new RegExp("^.+\.("+extensions+")$","i");if(_extension.test(file.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('"+id+"','"+type+"')",1000);}}function upload_status(id,type){yapi({method:"upload.status",data:(type=="photo")?{upload_type:type,upload_id:id}:{upload_type:type,upload_id:id,directory:t.directory},success:function(r){$("upload").innerHTML=progress(500,1,r["percent"]);if(r["percent"]<100){setTimeout("upload_status('"+id+"','"+type+"')",1000);}else{w.location=(type=="photo")?'/account/photos/add/'+r["id"]+'/':y.href;}}});}function progress(width,precision,percent){var slice=width / 100,slice_width=(precision>1)?slice *(percent-(percent%precision)):slice * percent;return '<div style="width:'+width+'px;height:30px;border:1px solid #888;background:url(\'http://cdn.yeacon.com/inube/img/ic/pb/b_r.png\');"><div style="width:'+slice_width+'px;height:30px;background:url(\'http://cdn.yeacon.com/inube/img/ic/pb/b_l.png\');"></div><div style="position:relative;top:-30px;width:'+width+'px;height:30px;text-align:center;font-weight:700;font-size:18px;line-height:30px;color:#fff;">'+percent+'%</div><div style="clear:both;"></div></div>';}function photo_avatar(_p){yapi({method:"photos.avatar",data:{photo:_p},success:function(r){if(_avatar_id){$("photo_"+_avatar_id).style.background="#f0f0f0";}$("photo_"+_p).style.background="#d1116e";_avatar_id=_p;}});}function photo_delete(_p){if(confirm(_confirm_PHOTO_PHOTO_DELETE)){yapi({method:"photos.delete",data:{photo:_p},success:function(r){$('photo_contextmenu_'+_p).innerHTML='';s=$("photo_"+_p).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(_p){$('photo_contextmenu_'+_p).style.display='block';return false;}