function ahref(link){window.location.href=link;}
function popupWindow(url,width,height){window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width='+width+',height='+height+',screenX=150,screenY=150,top=150,left=150');}
function popupScrolWindow(url,width,height){window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,width='+width+',height='+height+',screenX=150,screenY=150,top=150,left=150');}
function hoverIE(menu){var MENU=document.getElementById(menu);if(LI=getFirstElementWithTagname(MENU,'UL')){LI=LI.firstChild;do{LI.onmouseover=displayMenuDropDown;LI.onmouseout=hideMenuDropDown;LI=LI.nextSibling;}
while(LI);}}
function getFirstElementWithTagname(OBJ,TAG){ELEMENTS=OBJ.getElementsByTagName(TAG);if(ELEMENTS[0])return ELEMENTS[0];else return false;}
function displayMenuDropDown(){this.className='active';if(UL=getFirstElementWithTagname(this,'UL')){UL.style.display="block";}}
function hideMenuDropDown(){this.className=null;if(UL=getFirstElementWithTagname(this,'UL')){UL.style.display="none";}}
function toggleAuto(target){if(typeof(target)=='string')target=document.getElementById(target);if(target.style.display=="none"){if(arguments[1])display=arguments[1];else display="block";target.style.display=display;}else{target.style.display="none";}}
function removeCDATA(text){return text.substring(9,text.length-3);}
function showToolTip(target,options){target=$(target);if(target){if(!target.tooltip)target.tooltip=new ToolTip(target,options);target.tooltip.show();}}
function closeToolTip(target){target=$(target);if(target&&target.tooltip)target.tooltip.hide();}
var ToolTip=Class.create({initialize:function(target,options){this.timeout=false;this.target=target||false;this.options=options||{};this.options.className=this.options.className||'tooltip';this.options.hideOn=this.options.hideOn||'mouseout';this.options.showOn=this.options.showOn||'mouseover';this.options.align=this.options.align||'right bottom';this.options.shift=this.options.shift||'5 5';this.options.content=this.options.content||false;this.options.autoUpdate=this.options.autoUpdate||(this.options.content?false:true);this.options.title=this.options.title||false;this.options.delay=this.options.delay||0.1;this.options.observe=this.options.observe||true;this.setup=false;if(this.options.observe){if(Object.isElement(this.target)){this.observe(this.target);}else if(this.target){Event.observe(window,'load',this.observeSelector.bindAsEventListener(this));}}},dosetup:function(){this.tooltip=new Element('div',{'class':this.options.className,'style':'position:absolute;'}).hide();this.top=new Element('div',{'class':'top'});if(this.options.hideOn=='click'){this.closeButton=new Element('div',{'class':'closeButton'});this.closeButton.observe('click',this.hide.bindAsEventListener(this,this.closeButton));this.top.appendChild(this.closeButton);}
if(this.options.title!=false){this.title=new Element('h6').update(this.options.title);this.top.appendChild(this.title);}
this.tooltip.appendChild(this.top);this.content=new Element('div',{'class':'inner'});if(this.options.content!=false)
this.content.update(this.options.content);this.tooltip.appendChild(this.content);this.bottom=new Element('div',{'class':'bottom'});this.tooltip.appendChild(this.bottom);$$('body')[0].appendChild(this.tooltip);this.setup=true;},observeSelector:function(){var target=$$(this.target);if(target&&this.options.showOn!=false){target.each(function(Element){this.observe(Element)}.bind(this));}},update:function(content){this.content.update(content);},show:function(e){if(!this.setup){this.dosetup();}
if(this.tooltip.visible()){return false;}
if(e&&Object.isElement(e)){this.target=e;}else{e=this.target;}
if(this.options.autoUpdate){if(e.readAttribute('title')){e.ttip=unescape(e.readAttribute('title'));e.removeAttribute('title');e.select('img').each(function(child){child.removeAttribute("alt");child.removeAttribute("title");});}
if(this.myUpdate){this.myUpdate();}else if(e.ttip){this.update(e.ttip);}}
if(this.options.showOn=='click'&&e.readAttribute('href')){e.removeAttribute("href");e.style.cursor="pointer";}
this.locate();this.tooltip.show();},hide:function(){this.tooltip.hide();},mousemove:function(event){this.locate(Event.pointerX(event),Event.pointerY(event));},click:function(event,element){this.show(element);},locate:function(x,y){if(!x||!y){var ep=this.target.positionedOffset();x=ep.left;y=ep.top;}
var td=this.tooltip.getDimensions();var s=this.options.shift.split(' ',2);var sx=s[0];var sy=(s[1])?s[1]:'top';switch(sx){case'left':break;case'center':x-=(td.width/2);break;case'right':x-=td.width;break;default:if(!isNaN(sx)){x+=parseInt(sx);}
break;}
switch(sy){case'top':break;case'middle':y+=(td.height/2);break;case'bottom':y+=td.height;break;default:if(!isNaN(sy)){y+=parseInt(sy);}
break;}
if(this.options.showOn!='mousemove'){var ed=(this.target.getDimensions)?this.target.getDimensions():{width:0,height:0};var a=this.options.align.split(' ',2);var ax=a[0];var ay=(a[1])?a[1]:'bottom';switch(ax){case'left':break;case'center':x+=(ed.width/2);break;case'right':x+=ed.width;break;default:if(!isNaN(ax)){x+=parseInt(ax);}
break;}
switch(ay){case'top':break;case'middle':y+=(ed.height/2);break;case'bottom':y+=ed.height;break;default:if(!isNaN(ay)){y+=parseInt(ay);}
break;}}
this.tooltip.setStyle({left:x+'px'});this.tooltip.setStyle({top:y+'px'});},observe:function(element){if(this.options.showOn=='mouseover'||this.options.showOn=='mousemove')element.observe('mouseover',this.click.bindAsEventListener(this,element));if(this.options.showOn=='mousemove')element.observe('mousemove',this.mousemove.bindAsEventListener(this,element));if(this.options.showOn=='click')element.observe('click',this.click.bindAsEventListener(this,element));else if(this.options.hideOn=='mouseout')element.observe('mouseout',this.hide.bindAsEventListener(this,element));}});var BlockSelect=Class.create({initialize:function(target){if(Object.isElement(target)){this.target=target;this.observe();}else{Event.observe(window,'load',function(){this.target=$(target);this.observe();}.bindAsEventListener(this));}},observe:function(el){if(this.target){this.target.observe('click',this.click.bindAsEventListener(this));}},click:function(event){var el=event.findElement('.block-select');if(el&&!el.hasClassName('selected')){this.removeAllSelected();el.addClassName('selected');el.select('.block-select-item').each(function(item){this.checkItem(item);}.bind(this));}},checkItem:function(item){if(item.nodeName=='INPUT'&&(item.type=='radio'||item.type=='checkbox')){item.checked=true;}else if(item.nodeName=='DIV'){item.show();}},uncheckItem:function(item){if(item.nodeName=='INPUT'&&(item.type=='radio'||item.type=='checkbox')){item.checked=false;}else if(item.nodeName=='DIV'){item.hide();}},removeAllSelected:function(){this.target.select('.block-select').invoke('removeClassName','selected');this.target.select('.block-select-item').each(function(item){this.uncheckItem(item);}.bind(this));}});
