var sPop=null;var postSubmited=false;var userAgent=navigator.userAgent.toLowerCase();var is_opera=(userAgent.indexOf('opera')!=-1);var is_saf=((userAgent.indexOf('applewebkit')!=-1)||(navigator.vendor=='Apple Computer, Inc.'));var is_webtv=(userAgent.indexOf('webtv')!=-1);var is_ie=((userAgent.indexOf('msie')!=-1)&&(!is_opera)&&(!is_saf)&&(!is_webtv));var is_ie4=((is_ie)&&(userAgent.indexOf('msie 4.')!=-1));var is_moz=((navigator.product=='Gecko')&&(!is_saf));var is_kon=(userAgent.indexOf('konqueror')!=-1);var is_ns=((userAgent.indexOf('compatible')==-1)&&(userAgent.indexOf('mozilla')!=-1)&&(!is_opera)&&(!is_webtv)&&(!is_saf));var is_ns4=((is_ns)&&(parseInt(navigator.appVersion)==4));var is_mac=(userAgent.indexOf('mac')!=-1);var editbox=editwin=editdoc=null;var cursor=-1;var stack=new Array();function ubbcode(cmd,arg){checkFocus();if(in_array(cmd,['quote','code'])){var ret=wrapTags(cmd,false);}else if(cmd.substr(0,6)=='custom'){var ret=customTags(cmd.substr(8),cmd.substr(6,1));}else if(cmd=='createlink'){promptLink('url',lang['enter_link_url'],'http://');}else if(cmd=='unlink'){var sel=getSel();sel=stripSimple('url',sel);sel=stripComplex('url',sel);insertText(sel);}else if(cmd=='email'){promptLink('email',lang['enter_email_link'],'');}else if(cmd=='insertimage'){var img=showPrompt(lang['enter_image_url'],'http://');if(img=verifyPrompt(img)){return applyFormat('insertimage',false,img);}else{return false;}}else{var ret=applyFormat(cmd,false,(isUndefined(arg)?true:arg));}
checkFocus();return ret;}
function getEditorContents(){return editdoc.value;}
function checkFocus(){var obj=editwin;if(!obj.hasfocus){obj.focus();}}
function applyFormat(cmd,dialog,argument){switch(cmd){case'bold':case'italic':case'underline':wrapTags(cmd.substr(0,1),false);break;case'justifyleft':case'justifycenter':case'justifyright':wrapTags('align',cmd.substr(7));break;case'fontname':wrapTags('font',argument);break;case'fontsize':wrapTags('size',argument);break;case'forecolor':wrapTags('color',argument);break;case'createlink':var sel=getSel();if(sel){wrapTags('url',argument);}else{wrapTags('url',argument,argument);}
break;case'insertimage':wrapTags('img',false,argument);break;}}
function wrapTags(tagname,useoption,selection){if(tagname=='code'){applyFormat('removeformat');}
if(isUndefined(selection)){var selection=getSel();if(selection===false){selection='';}else{selection+='';}}
if(useoption===true){var option=showPrompt(construct_phrase(lang['enter_tag_option'],('['+tagname+']')),'');if(option=verifyPrompt(option)){var opentag='['+tagname+'='+option+']';}else{return false;}}else if(useoption!==false){var opentag='['+tagname+'='+useoption+']';}else{var opentag='['+tagname+']';}
var closetag='[/'+tagname+']';var text=opentag+selection+closetag;insertText(text,mb_strlen(opentag),mb_strlen(closetag));return false;}
function showPrompt(dialogtxt,defaultval){return trim(prompt(dialogtxt,defaultval)+'');}
function verifyPrompt(str){if(in_array(str,['http://','null','undefined','false',''])||str==null||str==false){return false;}else{return str;}}
function promptLink(tagname,phrase,iprompt){var value=showPrompt(phrase,iprompt);if((value=verifyPrompt(value))!==false){if(getSel()){applyFormat('unlink');wrapTags(tagname,value);}else{wrapTags(tagname,value,value);}}
return true;}
function customTags(tagname,params){applyFormat('removeformat');if(custombbcodes[tagname].indexOf(']')==-1){custombbcodes[tagname]='['+tagname+'][/'+tagname+']';}
if(params==1){var selection=getSel();if(selection===false){selection='';}else{selection+='';}
var opentag='['+tagname+']';var closetag='[/'+tagname+']';var text=opentag+selection+closetag;selection==''?insertText(custombbcodes[tagname],mb_strlen('['+tagname+']'),mb_strlen('[/'+tagname+']')):insertText(text,mb_strlen(opentag),mb_strlen(closetag));}else{insertText(custombbcodes[tagname],custombbcodes[tagname].indexOf(']')+1,mb_strlen('[/'+tagname+']'));}
return false;}
function getSel(){if(!isUndefined(editdoc.selectionStart)){return editdoc.value.substr(editdoc.selectionStart,editdoc.selectionEnd-editdoc.selectionStart);}else if(document.selection&&document.selection.createRange){return document.selection.createRange().text;}else if(window.getSelection){return window.getSelection()+'';}else{return false;}}
function stripSimple(tag,str,iterations){var opentag='['+tag+']';var closetag='[/'+tag+']';if(isUndefined(iterations)){iterations=-1;}
while((startindex=stripos(str,opentag))!==false&&iterations!=0){iterations--;if((stopindex=stripos(str,closetag))!==false){var text=str.substr(startindex+opentag.length,stopindex-startindex-opentag.length);str=str.substr(0,startindex)+text+str.substr(stopindex+closetag.length);}else{break;}}
return str;}
function stripComplex(tag,str,iterations){var opentag='['+tag+'=';var closetag='[/'+tag+']';if(isUndefined(iterations)){iterations=-1;}
while((startindex=stripos(str,opentag))!==false&&iterations!=0){iterations--;if((stopindex=stripos(str,closetag))!==false){var openend=stripos(str,']',startindex);if(openend!==false&&openend>startindex&&openend<stopindex){var text=str.substr(openend+1,stopindex-openend-1);str=str.substr(0,startindex)+text+str.substr(stopindex+closetag.length);}else{break;}}else{break;}}
return str;}
function insertText(text,movestart,moveend){checkFocus();if(!isUndefined(editdoc.selectionStart)){var opn=editdoc.selectionStart+0;editdoc.value=editdoc.value.substr(0,editdoc.selectionStart)+text+editdoc.value.substr(editdoc.selectionEnd);if(!isUndefined(movestart)){editdoc.selectionStart=opn+movestart;editdoc.selectionEnd=opn+mb_strlen(text)-moveend;}else if(movestart!==false){editdoc.selectionStart=opn;editdoc.selectionEnd=opn+mb_strlen(text);}}else if(document.selection&&document.selection.createRange){var sel=document.selection.createRange();sel.text=text.replace(/\r?\n/g,'\r\n');if(!isUndefined(movestart)){sel.moveStart('character',-mb_strlen(text)+movestart);sel.moveEnd('character',-moveend);}else if(movestart!==false){sel.moveStart('character',-mb_strlen(text));}
sel.select();}else{editdoc.value+=text;}}
function mb_strlen(str){return(is_ie&&str.indexOf('\n')!=-1)?str.replace(/\r?\n/g,'_').length:str.length;}
function stripos(haystack,needle,offset){if(isUndefined(offset)){offset=0;}
var index=haystack.toLowerCase().indexOf(needle.toLowerCase(),offset);return(index==-1?false:index);}
function isUndefined(variable){return typeof variable=='undefined'?true:false;}
function buttonContext(obj,state){if(state=='mouseover'){var mode=obj.state?'down':'hover';if(obj.mode!=mode){obj.mode=mode;obj.className='editor_button'+mode;}}else{var mode=obj.state?'selected':'normal';if(obj.mode!=mode){obj.mode=mode;obj.className=mode=='selected'?'editor_buttonselected':'editor_button'+'normal';}}
if(is_ie&&event){event.cancelBubble=true;}}
function menuContext(obj,state){obj.style.cursor=is_ie?'hand':'pointer';var mode=state=='mouseover'?'hover':'normal';obj.className='editor_button'+mode;var tds=findtags(obj,'td');for(var i=0;i<tds.length;i++){if(tds[i].id==editorid+'_menu'){tds[i].className='editor_menu'+mode;}else if(tds[i].id==editorid+'_colormenu'){tds[i].className='editor_colormenu'+mode;}}}
function colorContext(obj,state){obj.style.cursor=is_ie?'hand':'pointer';var mode=state=='mouseover'?'hover':'normal';obj.className='editor_color'+mode;}
function PB(id){return document.getElementById(id);}
function trim(str){return(str.replace(/(\s+)$/g,'')).replace(/^\s+/g,'');}
function in_array(needle,haystack){if(typeof needle=='string'){for(var i in haystack){if(haystack[i]==needle){return true;}}}
return false;}
function arraypop(a){if(typeof a!='object'||!a.length){return null;}else{var response=a[a.length-1];a.length--;return response;}}
function newEditor(mode,initialtext){editbox=textobj;editwin=textobj;editdoc=textobj;if(!isUndefined(initialtext)){writeEditorContents(initialtext);}
setEditorEvents();}
function writeEditorContents(text){textobj.value=text;setEditorStyle();}
function setEditorEvents(){editwin.onfocus=function(e){this.hasfocus=true;};editwin.onblur=function(e){this.hasfocus=false;};}
function setEditorStyle(){var iframe=textobj.parentNode.getElementsByTagName('iframe')[0];if(iframe){textobj.style.display='';textobj.style.width=iframe.style.width;textobj.style.height=iframe.style.height;iframe.style.display='none';}}
function findtags(parentobj,tag){if(typeof parentobj.getElementsByTagName!='undefined'){return parentobj.getElementsByTagName(tag);}
else if(parentobj.all&&parentobj.all.tags){return parentobj.all.tags(tag);}
else{return null;}}
var menuslidetimer=null;function Popup_Handler(){this.open_steps=2;this.open_fade=false;this.active=false;this.menus=new Array();this.activemenu=null;this.hidden_selects=new Array();this.activate=function(active){this.active=active;}
this.register=function(clickactive,controlkey,noimage){this.menus[controlkey]=new Popup_Menu(clickactive,controlkey,noimage);return this.menus[controlkey];}
this.hide=function(){if(this.activemenu!=null)this.menus[this.activemenu].hide();}}
function Popup_Events(){this.controlobj_show=function(e){doane(e);clearTimeout(this.slidetimer);if(popupmenu.activemenu==null||popupmenu.menus[popupmenu.activemenu].controlkey!=this.id){popupmenu.menus[this.id].show(this,false,popupmenu.menus[this.id].clickactive);}}
this.controlobj_onclick=function(e){doane(e);if(popupmenu.activemenu==null||popupmenu.menus[popupmenu.activemenu].controlkey!=this.id){popupmenu.menus[this.id].show(this,false,popupmenu.menus[this.id].clickactive);}
else{popupmenu.menus[this.id].hide();}}
this.controlobj_onmouseover=function(e){doane(e);popupmenu.menus[this.id].hover(this);}
this.menuoption_onclick_function=function(e){this.ofunc(e);popupmenu.menus[this.controlkey].hide();}
this.menuoption_onclick_link=function(e){popupmenu.menus[this.controlkey].choose(e,this);}
this.menuoption_onmouseover=function(e){this.className='popupmenu_highlight';}
this.menuoption_onmouseout=function(e){this.className='popupmenu_option';}}
popupmenu=new Popup_Handler();popupevents=new Popup_Events();function popupmenu_hide(e){if(e&&e.button&&e.button!=1&&e.type=='click')return true;else popupmenu.hide();}
function Popup_Menu(clickactive,controlkey,noimage){this.controlkey=controlkey;this.clickactive=clickactive;this.menuname=this.controlkey.split('.')[0]+'_menu';if(PB(this.menuname)){this.init_menu(clickactive);}
this.slide_open=(is_opera?false:true);this.open_steps=popupmenu.open_steps;this.init_control=function(noimage){this.controlobj=PB(this.controlkey);this.controlobj.state=false;if(this.controlobj.firstChild&&(this.controlobj.firstChild.tagName=='TEXTAREA'||this.controlobj.firstChild.tagName=='INPUT')){}else{if(!this.clickactive&&!noimage&&!(is_mac&&is_ie)){var img=document.createElement('img');img.src='images/common/jsmenu.gif';img.border=0;img.title='';img.alt='';this.controlobj.appendChild(img);}
this.controlobj.unselectable=true;if(!noimage){this.controlobj.style.cursor=is_ie?'hand':'pointer';}
if(clickactive){this.controlobj.onclick=popupevents.controlobj_onclick;this.controlobj.onmouseover=popupevents.controlobj_onmouseover;}else{this.controlobj.onmouseover=popupevents.controlobj_show;}}}
this.init_control(noimage);this.init_menu=function(){this.menuobj=PB(this.menuname);if(this.menuobj&&!this.menuobj.initialized){this.menuobj.initialized=true;this.menuobj.onclick=ebygum;this.menuobj.style.position='absolute';if(!this.clickactive){this.menuobj.onmouseover=function(){clearTimeout(menuslidetimer);}
this.menuobj.onmouseout=function(){menuslidetimer=setTimeout("menuhide()",500);}}
this.menuobj.style.zIndex=50;if(is_ie&&!is_mac){this.menuobj.style.filter+="progid:DXImageTransform.Microsoft.shadow(direction=135,color=#CCCCCC,strength=2)";}
this.init_menu_contents();}}
this.init_menu_contents=function(){var tds=findtags(this.menuobj,'td');for(var i=0;i<tds.length;i++){if(tds[i].className=='popupmenu_option'||tds[i].className=='editor_colornormal'){if(is_ie&&!is_mac){tds[i].style.filter+="progid:DXImageTransform.Microsoft.Alpha(opacity=85,finishOpacity=100,style=0)";}
tds[i].style.opacity=0.85;if(tds[i].title&&tds[i].title=='nohighlight'){tds[i].title='';}else{tds[i].controlkey=this.controlkey;if(tds[i].className!='editor_colornormal'){tds[i].onmouseover=popupevents.menuoption_onmouseover;tds[i].onmouseout=popupevents.menuoption_onmouseout;}
if(typeof tds[i].onclick=='function'){tds[i].ofunc=tds[i].onclick;tds[i].onclick=popupevents.menuoption_onclick_function;}else{tds[i].onclick=popupevents.menuoption_onclick_link;}
if(!is_saf&&!is_kon){try{links=findtags(tds[i],'a');for(var j=0;j<links.length;j++){if(typeof links[j].onclick=='undefined')links[j].onclick=ebygum;}}
catch(e){}}}}}}
this.show=function(obj,instant){if(!popupmenu.active){return false;}
else if(!this.menuobj){this.init_menu();}
if(!this.menuobj){return false;}
if(popupmenu.activemenu!=null){popupmenu.menus[popupmenu.activemenu].hide();}
popupmenu.activemenu=this.controlkey;this.menuobj.style.display='';if(popupmenu.slide_open){this.menuobj.style.clip='rect(auto, auto, auto, auto)';}
this.pos=this.fetch_offset(obj);this.leftpx=this.pos['left'];this.toppx=this.pos['top']+obj.offsetHeight;if((this.leftpx+this.menuobj.offsetWidth)>=document.body.clientWidth&&(this.leftpx+obj.offsetWidth-this.menuobj.offsetWidth)>0){this.leftpx=this.leftpx+obj.offsetWidth-this.menuobj.offsetWidth;this.direction='right';}else{this.direction='left';}
this.menuobj.style.left=this.leftpx+'px';this.menuobj.style.top=this.toppx+'px';if(!instant&&this.slide_open){this.intervalX=Math.ceil(this.menuobj.offsetWidth/this.open_steps);this.intervalY=Math.ceil(this.menuobj.offsetHeight/this.open_steps);this.slide((this.direction=='left'?0:this.menuobj.offsetWidth),0,0);}else if(this.menuobj.style.clip&&popupmenu.slide_open){this.menuobj.style.clip='rect(auto, auto, auto, auto)';}
this.handle_overlaps(true);if(this.menuobj.scrollHeight>400){this.menuobj.style.height='400px';if(is_ie||is_opera){this.menuobj.style.width=this.menuobj.scrollWidth+18;}
if(is_opera){this.menuobj.style.overflow='scroll';}else{this.menuobj.style.overflowY='scroll';}}}
this.hide=function(e){if(e&&e.button&&e.button!=1){return true;}
this.stop_slide();this.menuobj.style.display='none';this.handle_overlaps(false);popupmenu.activemenu=null;}
this.slidehide=function(){popupmenu.menus[popupmenu.activemenu].hide()}
this.hover=function(obj,clickactive){if(popupmenu.activemenu!=null){if(popupmenu.menus[popupmenu.activemenu].controlkey!=this.id){this.show(obj,true,clickactive);}}}
this.choose=function(e,obj){var links=findtags(obj,'a');if(links[0]){if(is_ie){links[0].click();window.event.cancelBubble=true;}else{if(e.shiftKey){window.open(links[0].href);e.stopPropagation();e.preventDefault();}else{window.location=links[0].href;e.stopPropagation();e.preventDefault();}}
this.hide();}}
this.slide=function(clipX,clipY,opacity){if(this.direction=='left'&&(clipX<this.menuobj.offsetWidth||clipY<this.menuobj.offsetHeight)){if(popupmenu.open_fade&&is_ie){opacity+=10;this.menuobj.filters.item('DXImageTransform.Microsoft.alpha').opacity=opacity;}
clipX+=this.intervalX;clipY+=this.intervalY;this.menuobj.style.clip="rect(auto, "+clipX+"px, "+clipY+"px, auto)";this.slidetimer=setTimeout("popupmenu.menus[popupmenu.activemenu].slide("+clipX+", "+clipY+", "+opacity+");",0);}else if(this.direction=='right'&&(clipX>0||clipY<this.menuobj.offsetHeight)){if(popupmenu.open_fade&&is_ie){opacity+=10;menuobj.filters.item('DXImageTransform.Microsoft.alpha').opacity=opacity;}
clipX-=this.intervalX;clipY+=this.intervalY;this.menuobj.style.clip="rect(auto, "+this.menuobj.offsetWidth+"px, "+clipY+"px, "+clipX+"px)";this.slidetimer=setTimeout("popupmenu.menus[popupmenu.activemenu].slide("+clipX+", "+clipY+", "+opacity+");",0);}else{this.stop_slide();}}
this.stop_slide=function(){clearTimeout(this.slidetimer);this.menuobj.style.clip='rect(auto, auto, auto, auto)';if(popupmenu.open_fade&&is_ie){this.menuobj.filters.item('DXImageTransform.Microsoft.alpha').opacity=100;}}
this.fetch_offset=function(obj){var left_offset=obj.offsetLeft;var top_offset=obj.offsetTop;while((obj=obj.offsetParent)!=null){left_offset+=obj.offsetLeft;top_offset+=obj.offsetTop;}
return{'left':left_offset,'top':top_offset};}
this.overlaps=function(obj,m){var s=new Array();var pos=this.fetch_offset(obj);s['L']=pos['left'];s['T']=pos['top'];s['R']=s['L']+obj.offsetWidth;s['B']=s['T']+obj.offsetHeight;if(s['L']>m['R']||s['R']<m['L']||s['T']>m['B']||s['B']<m['T']){return false;}
return true;}
this.handle_overlaps=function(dohide){if(is_ie){var selects=findtags(document,'select');if(dohide){var menuarea=new Array();menuarea={'L':this.leftpx,'R':this.leftpx+this.menuobj.offsetWidth,'T':this.toppx,'B':this.toppx+this.menuobj.offsetHeight};for(var i=0;i<selects.length;i++){if(this.overlaps(selects[i],menuarea)){var hide=true;var s=selects[i];while(s=s.parentNode){if(s.className=='popupmenu_popup'){hide=false;break;}}
if(hide){selects[i].style.visibility='hidden';arraypush(popupmenu.hidden_selects,i);}}}}else{while(true){var i=arraypop(popupmenu.hidden_selects);if(typeof i=='undefined'||i==null)break;else selects[i].style.visibility='visible';}}}}}
function doane(eventobj){if(!eventobj||is_ie){window.event.returnValue=false;window.event.cancelBubble=true;return window.event;}else{eventobj.stopPropagation();eventobj.preventDefault();return eventobj;}}
function ebygum(eventobj){if(!eventobj||is_ie){window.event.cancelBubble=true;return window.event;}else{if(eventobj.target.type=='submit')eventobj.target.form.submit();eventobj.stopPropagation();return eventobj;}}
function menuregister(clickactive,controlid,noimage,datefield){if(typeof popupmenu=='object'){popupmenu.register(clickactive,controlid,noimage);}}
function menuhide(){if(popupmenu.activemenu!=null){popupmenu.menus[popupmenu.activemenu].slidehide();}}
if(typeof popupmenu=='object'){if(window.attachEvent&&!is_saf){document.attachEvent('onclick',popupmenu_hide);window.attachEvent('onresize',popupmenu_hide);}else if(document.addEventListener&&!is_saf){document.addEventListener('click',popupmenu_hide,false);window.addEventListener('resize',popupmenu_hide,false);}else{window.onclick=popupmenu_hide;window.onresize=popupmenu_hide;}
popupmenu.activate(true);}