﻿function showCodeFunctions(){var codes=getElementsByClass('code','div');var maxHeight=500;for(var i=0;i<codes.length;i++){var height=codes[i].offsetHeight;var width=80;var menu=document.createElement('div');menu.className='codeMenu';if(window.opera)
width-=20;else{menu.innerHTML+='<a href="javascript:void(0);" onclick="return selectAll(\''+codes[i].id+'\');" class="small" title="Select all of this code"><img src="/images/icons/code_select.png" class="blogIcon" style="margin-left:2px;" alt="Select all of this code" /></a>';if(codes[i]!=null){codes[i].ondblclick=function(){selectAll(this.id);}}}
if(height>165){menu.innerHTML+='<a href="javascript:void(0);" onclick="return saveCode(\''+codes[i].id+'\');" class="small" title="Save this code as a text file"><img src="/images/icons/code_save.png" class="blogIcon" style="margin-left:2px;" alt="Save this code as a text file" /></a>';menu.innerHTML+='<a href="javascript:void(0);" onclick="return printElementContents(\''+codes[i].id+'\');" class="small" title="Print this code"><img src="/images/icons/printer.png" class="blogIcon" style="margin-left:2px;" alt="Print this code" /></a>';if(height<maxHeight)
width-=20;else{menu.innerHTML+='<a href="javascript:void(0);" onclick="return toggleVerticalScroll(\''+codes[i].id+'\', '+maxHeight+');" class="small" title="Toggle vertical scrolling"><img src="/images/icons/code_scroll.png" class="blogIcon" style="margin-left:2px;" alt="Toggle Vertical Scrolling" /></a>';toggleVerticalScroll(codes[i].id,maxHeight);}
menu.style.display='block';menu.style.width=width+'px';codes[i].parentNode.insertBefore(menu,codes[i]);menu=null;}
height=null;}
codes=null;}
function saveCode(elemId){var elem=document.getElementById(elemId);var hid=document.getElementById('hidCode');var frm=document.forms.frmSave;if(elem==null||hid==null||frm==null){alert('Error');}
else{var str=(document.all)?elem.innerText:elem.textContent;hid.value=str;frm.submit();}
elem,hid,frm=null;return false;}
function toggleVerticalScroll(elemId,amt){var elem=document.getElementById(elemId);if(elem!=null){if(elem.style.maxHeight!=amt+'px'){if(elem.offsetHeight>amt){elem.style.maxHeight=amt+'px';elem.style.overflowY='scroll';}}
else{elem.style.maxHeight='9999px';elem.style.overflowY='hidden';}}
elem=null;return false;}
function selectAll(objId){var range;deselectAll();if(document.selection){range=document.body.createTextRange();range.moveToElementText(document.getElementById(objId));range.select();}
else{if(window.getSelection||document.getSelection){range=document.createRange();range.selectNode(document.getElementById(objId));window.getSelection().addRange(range);}}
range=null;return false;}
function deselectAll(){if(document.selection){document.selection.empty();}
else{if(window.getSelection){window.getSelection().removeAllRanges();}}}
function printElementContents(elemId){var elem=document.getElementById(elemId);var htmlStart='<html><head><style type="text\/css">body { font-family:Courier New; monotype; font-size:1.0em; }<\/style><\/head><body>'
var htmlEnd='<\/body><\/html>'
var theWin=window.open('','');if(elem!=null){self.focus();theWin.document.open();theWin.document.write(htmlStart+elem.innerHTML+htmlEnd);theWin.document.close();theWin.print();theWin.close();}
elem,htmlStart,htmlEnd,theWin=null;return false;}
addLoadEvent(showCodeFunctions);