
jQuery.fn.extend({getSelection:function(){var input=this.jquery?this[0]:this;var start;var end;var part;if(document.selection){var s=document.selection.createRange();if(s.text){var number=0;part=s.text;if(input.value.match(/\n/g)!=null){number=input.value.match(/\n/g).length;}
var minus=0;var position=0;var minusEnd=0;if(typeof(input.selectionStart)=="number"){start=input.selectionStart;end=input.selectionEnd;if(start==end){return this;}}else{var re=input.createTextRange();var firstRe;var secondRe;var rc=re.duplicate();firstRe=re.text;re.moveToBookmark(s.getBookmark());secondRe=re.text;rc.setEndPoint("EndToStart",re);if(firstRe==secondRe&&firstRe!=s.text){return this;}
start=rc.text.length;end=rc.text.length+s.text.length;}
if(number>0){for(var i=0;i<=number;i++){var w=input.value.indexOf("\n",position);if(w!=-1&&w<start){position=w+1;minus++;minusEnd=minus;}else if(w!=-1&&w>=start&&w<=end){if(w==start+1){minus--;minusEnd--;position=w+1;continue;}
position=w+1;minusEnd++;}else{i=number;}}}
if(s.text.indexOf("\n",0)==1){minusEnd=minusEnd+2;}
start=start-minus;end=end-minusEnd;return{start:start,end:end,text:s.text,length:end-start};}
return false;}else if(typeof(input.selectionStart)=="number"&&input.selectionStart!=input.selectionEnd){start=input.selectionStart;end=input.selectionEnd;part=input.value.substring(input.selectionStart,input.selectionEnd);return{start:start,end:end,text:part,length:end-start};}else{return{start:undefined,end:undefined,text:undefined,length:undefined};}},replaceSelection:function(inputStr){var input=this.jquery?this[0]:this;var start;var end;if(document.selection){var s=document.selection.createRange();if(typeof(input.selectionStart)=="number"){start=input.selectionStart;end=input.selectionEnd;if(start==end){return this;}}
if(typeof(input.selectionStart)!="number"){var re=input.createTextRange();var firstRe;var secondRe;var rc=re.duplicate();firstRe=re.text;re.moveToBookmark(s.getBookmark());secondRe=re.text;rc.setEndPoint("EndToStart",re);if(firstRe==secondRe&&firstRe!=s.text){return this;}}
if(s.text){s.text=inputStr;}
return this;}else if(typeof(input.selectionStart)=="number"&&input.selectionStart!=input.selectionEnd){start=input.selectionStart;end=input.selectionEnd;input.value=input.value.substr(0,start)+inputStr+input.value.substr(end);return this;}
return this;},countCharacters:function(str){var input=this.jquery?this[0]:this;if(input.value.match(/\r/g)!=null){return input.value.length-input.value.match(/\r/g).length;}
return input.value.length;},setMaxLength:function(max,f){this.each(function(){var input=this.jquery?this[0]:this;var type=input.type;var isSelected;var maxCharacters;if(parseInt(max)<0){max=100000000;}
if(type=="text"){input.maxLength=max;}
if(type=="textarea"||type=="text"){input.onkeypress=function(e){var spacesR=input.value.match(/\r/g);maxCharacters=max;if(spacesR!=null){maxCharacters=parseInt(maxCharacters)+spacesR.length;}
var key=e||event;var keyCode=key.keyCode;if(document.selection){isSelected=document.selection.createRange().text.length>0;}else{isSelected=input.selectionStart!=input.selectionEnd;}
if(input.value.length>=maxCharacters&&(keyCode>47||keyCode==32||keyCode==0||keyCode==13)&&!key.ctrlKey&&!key.altKey&&!isSelected){input.value=input.value.substring(0,maxCharacters);if(typeof(f)=="function"){f()};return false;}}
input.onkeyup=function(){var spacesR=input.value.match(/\r/g);var plus=0;var position=0;maxCharacters=max;if(spacesR!=null){for(var i=0;i<=spacesR.length;i++){if(input.value.indexOf("\n",position)<=parseInt(max)){plus++;position=input.value.indexOf("\n",position)+1;}}
maxCharacters=parseInt(max)+plus;}
if(input.value.length>maxCharacters){input.value=input.value.substring(0,maxCharacters);if(typeof(f)=="function"){f()};return this;}}}else{return this;}})
return this;}});


if(jQuery)(function(){$.extend($.fn,{rightClick:function(handler){$(this).each(function(){$(this).mousedown(function(e){var evt=e;$(this).mouseup(function(){$(this).unbind('mouseup');if(evt.button==2){handler.call($(this),evt);return false;}else{return true;}});});$(this)[0].oncontextmenu=function(){return false;}});return $(this);},rightMouseDown:function(handler){$(this).each(function(){$(this).mousedown(function(e){if(e.button==2){handler.call($(this),e);return false;}else{return true;}});$(this)[0].oncontextmenu=function(){return false;}});return $(this);},rightMouseUp:function(handler){$(this).each(function(){$(this).mouseup(function(e){if(e.button==2){handler.call($(this),e);return false;}else{return true;}});$(this)[0].oncontextmenu=function(){return false;}});return $(this);},noContext:function(){$(this).each(function(){$(this)[0].oncontextmenu=function(){return false;}});return $(this);}});})(jQuery);


$(document).ready(function(){$("#ajax_loading").ajaxStart(function(){$(this).css("background-image","url(../style/common/images/ajax-loader.gif)");});$("#ajax_loading").ajaxStop(function(){$(this).css("background-image","none");});jQuery.each(jQuery.browser,function(i){if($.browser.mozilla){$(".post_button").addClass("post_button_ff");}
if($.browser.msie){$(".post_button").addClass("post_button_saf");}
if($.browser.safari){$(".post_button").addClass("post_button_saf");}});$(".admin_group_list").click(function(){var targ=$(this).children("a").attr("href");window.location=targ;});$(".admin_group_list, .admin_group_list_nolink").hover(function(){$(this).animate({backgroundColor:"#F7D3DB"},250);},function(){$(this).animate({backgroundColor:"#E7F3FB"},500);});$(".conf_message").effect("highlight",{},3000);});function killLinks(leave){var llen=leave.length;$("a").each(function(){if(!$(this).attr("href")){return;}
if($(this).attr("href").substr(0,7)=="mailto:"){return;}
if(llen>0){if($(this).attr("href").substr(0,llen)==leave){return;}}
$(this).attr("href","#null").css({"cursor":"not-allowed"}).attr("title","This link has been disabled while the guide is active.");if($(this).parent().hasClass("admin_group_list")){$(this).parent().unbind("click").css({"cursor":"not-allowed"}).attr("title","This link has been disabled while the guide is active.");}});}
function dalert(text){$("#dialog_box").html(text);$("#dialog_box").dialog({autoOpen:false,modal:true,title:'Alert!',buttons:{"Okay":function(){$("#dialog_box").dialog("close").dialog("destroy");}}});$("#dialog_box").dialog("open");}
function setmainheight(){$(".footer").css({"bottom":"0px"});var winheight=$(window).height()-$(document).height();$(".footer").css({"bottom":winheight+"px"});}
function ar(x){var errors=x.match(/\{.*?\}/g);var log=x.match(/\[.*?\]/g);for(e in errors){alert('--'.errors[e]);$(".ajaxlog").append('<span class="error">'+errors[e]+'</span><br />');x=str_replace(errors[e],"",x);}
for(e in log){$(".ajaxlog").append(log[e]+"<br />");x=str_replace(log[e],"",x);}
return x;}
function getUnixTime(){var now=new Date;var the_time=now.getTime();the_time=parseInt(the_time/1000);return the_time;}
function str_replace(search,replace,subject){var f=search,r=replace,s=subject;var ra=r instanceof Array,sa=s instanceof Array,f=[].concat(f),r=[].concat(r),i=(s=[].concat(s)).length;while(j=0,i--){if(s[i]){while(s[i]=(s[i]+'').split(f[j]).join(ra?r[j]||"":r[0]),++j in f){};}};return sa?s:s[0];}
var MAX_DUMP_DEPTH=10;function dumpObj(obj,name,indent,depth){if(depth>MAX_DUMP_DEPTH){return indent+name+": <Maximum Depth Reached>\n";}
if(typeof obj=="object"){var child=null;var output=indent+name+"\n";indent+="\t";for(var item in obj)
{try{child=obj[item];}catch(e){child="<Unable to Evaluate>";}
if(typeof child=="object"){output+=dumpObj(child,item,indent,depth+1);}else{output+=indent+item+": "+child+"\n";}}
return output;}else{return obj;}}
function dumpProps(obj,parent){for(var i in obj){if(parent){var msg=parent+"."+i+"\n"+obj[i];}else{var msg=i+"\n"+obj[i];}
if(!confirm(msg)){return;}
if(typeof obj[i]=="object"){if(parent){dumpProps(obj[i],parent+"."+i);}else{dumpProps(obj[i],i);}}}}
function trim(str,chars){return ltrim(rtrim(str,chars),chars);}
function ltrim(str,chars){chars=chars||"\\s";return str.replace(new RegExp("^["+chars+"]+","g"),"");}
function rtrim(str,chars){chars=chars||"\\s";return str.replace(new RegExp("["+chars+"]+$","g"),"");}


