
if(typeof Effect=='undefined')
throw("controls.js requires including script.aculo.us' effects.js library");var Autocompleter={}
Autocompleter.Base=Class.create({baseInitialize:function(element,update,options){element=$(element)
this.element=element;this.update=$(update);this.hasFocus=false;this.changed=false;this.active=false;this.index=0;this.entryCount=0;this.oldElementValue=this.element.value;if(this.setOptions)
this.setOptions(options);else
this.options=options||{};this.options.paramName=this.options.paramName||this.element.name;this.options.tokens=this.options.tokens||[];this.options.frequency=this.options.frequency||0.4;this.options.minChars=this.options.minChars||1;this.options.onShow=this.options.onShow||function(element,update){if(!update.style.position||update.style.position=='absolute'){update.style.position='absolute';Position.clone(element,update,{setHeight:false,offsetTop:element.offsetHeight});}
Effect.Appear(update,{duration:0.15});};this.options.onHide=this.options.onHide||function(element,update){new Effect.Fade(update,{duration:0.15})};if(typeof(this.options.tokens)=='string')
this.options.tokens=new Array(this.options.tokens);if(!this.options.tokens.include('\n'))
this.options.tokens.push('\n');this.observer=null;this.element.setAttribute('autocomplete','off');Element.hide(this.update);Event.observe(this.element,'blur',this.onBlur.bindAsEventListener(this));Event.observe(this.element,'keydown',this.onKeyPress.bindAsEventListener(this));},show:function(){if(Element.getStyle(this.update,'display')=='none')this.options.onShow(this.element,this.update);if(!this.iefix&&(Prototype.Browser.IE)&&(Element.getStyle(this.update,'position')=='absolute')){new Insertion.After(this.update,'<iframe id="'+this.update.id+'_iefix" '+'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" '+'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');this.iefix=$(this.update.id+'_iefix');}
if(this.iefix)setTimeout(this.fixIEOverlapping.bind(this),50);},fixIEOverlapping:function(){Position.clone(this.update,this.iefix,{setTop:(!this.update.style.height)});this.iefix.style.zIndex=1;this.update.style.zIndex=2;Element.show(this.iefix);},hide:function(){this.stopIndicator();if(Element.getStyle(this.update,'display')!='none')this.options.onHide(this.element,this.update);if(this.iefix)Element.hide(this.iefix);},startIndicator:function(){if(this.options.indicator)Element.show(this.options.indicator);},stopIndicator:function(){if(this.options.indicator)Element.hide(this.options.indicator);},onKeyPress:function(event){if(this.active)
switch(event.keyCode){case Event.KEY_TAB:case Event.KEY_RETURN:this.selectEntry();Event.stop(event);case Event.KEY_ESC:this.hide();this.active=false;Event.stop(event);return;case Event.KEY_LEFT:case Event.KEY_RIGHT:return;case Event.KEY_UP:this.markPrevious();this.render();Event.stop(event);return;case Event.KEY_DOWN:this.markNext();this.render();Event.stop(event);return;}
else
if(event.keyCode==Event.KEY_TAB||event.keyCode==Event.KEY_RETURN||(Prototype.Browser.WebKit>0&&event.keyCode==0))return;this.changed=true;this.hasFocus=true;if(this.observer)clearTimeout(this.observer);this.observer=setTimeout(this.onObserverEvent.bind(this),this.options.frequency*1000);},activate:function(){this.changed=false;this.hasFocus=true;this.getUpdatedChoices();},onHover:function(event){var element=Event.findElement(event,'LI');if(this.index!=element.autocompleteIndex)
{this.index=element.autocompleteIndex;this.render();}
Event.stop(event);},onClick:function(event){var element=Event.findElement(event,'LI');this.index=element.autocompleteIndex;this.selectEntry();this.hide();},onBlur:function(event){setTimeout(this.hide.bind(this),250);this.hasFocus=false;this.active=false;},render:function(){if(this.entryCount>0){for(var i=0;i<this.entryCount;i++)
this.index==i?Element.addClassName(this.getEntry(i),"selected"):Element.removeClassName(this.getEntry(i),"selected");if(this.hasFocus){this.show();this.active=true;}}else{this.active=false;this.hide();}},markPrevious:function(){if(this.index>0)this.index--
else this.index=this.entryCount-1;this.getEntry(this.index).scrollIntoView(true);},markNext:function(){if(this.index<this.entryCount-1)this.index++
else this.index=0;this.getEntry(this.index).scrollIntoView(false);},getEntry:function(index){return this.update.firstChild.childNodes[index];},getCurrentEntry:function(){return this.getEntry(this.index);},selectEntry:function(){this.active=false;this.updateElement(this.getCurrentEntry());},updateElement:function(selectedElement){if(this.options.updateElement){this.options.updateElement(selectedElement);return;}
var value='';if(this.options.select){var nodes=$(selectedElement).select('.'+this.options.select)||[];if(nodes.length>0)value=Element.collectTextNodes(nodes[0],this.options.select);}else
value=Element.collectTextNodesIgnoreClass(selectedElement,'informal');var bounds=this.getTokenBounds();if(bounds[0]!=-1){var newValue=this.element.value.substr(0,bounds[0]);var whitespace=this.element.value.substr(bounds[0]).match(/^\s+/);if(whitespace)
newValue+=whitespace[0];this.element.value=newValue+value+this.element.value.substr(bounds[1]);}else{this.element.value=value;}
this.oldElementValue=this.element.value;this.element.focus();if(this.options.afterUpdateElement)
this.options.afterUpdateElement(this.element,selectedElement);},updateChoices:function(choices){if(!this.changed&&this.hasFocus){this.update.innerHTML=choices;Element.cleanWhitespace(this.update);Element.cleanWhitespace(this.update.down());if(this.update.firstChild&&this.update.down().childNodes){this.entryCount=this.update.down().childNodes.length;for(var i=0;i<this.entryCount;i++){var entry=this.getEntry(i);entry.autocompleteIndex=i;this.addObservers(entry);}}else{this.entryCount=0;}
this.stopIndicator();this.index=0;if(this.entryCount==1&&this.options.autoSelect){this.selectEntry();this.hide();}else{this.render();}}},addObservers:function(element){Event.observe(element,"mouseover",this.onHover.bindAsEventListener(this));Event.observe(element,"click",this.onClick.bindAsEventListener(this));},onObserverEvent:function(){this.changed=false;this.tokenBounds=null;if(this.getToken().length>=this.options.minChars){this.getUpdatedChoices();}else{this.active=false;this.hide();}
this.oldElementValue=this.element.value;},getToken:function(){var bounds=this.getTokenBounds();return this.element.value.substring(bounds[0],bounds[1]).strip();},getTokenBounds:function(){if(null!=this.tokenBounds)return this.tokenBounds;var value=this.element.value;if(value.strip().empty())return[-1,0];var diff=arguments.callee.getFirstDifferencePos(value,this.oldElementValue);var offset=(diff==this.oldElementValue.length?1:0);var prevTokenPos=-1,nextTokenPos=value.length;var tp;for(var index=0,l=this.options.tokens.length;index<l;++index){tp=value.lastIndexOf(this.options.tokens[index],diff+offset-1);if(tp>prevTokenPos)prevTokenPos=tp;tp=value.indexOf(this.options.tokens[index],diff+offset);if(-1!=tp&&tp<nextTokenPos)nextTokenPos=tp;}
return(this.tokenBounds=[prevTokenPos+1,nextTokenPos]);}});Autocompleter.Base.prototype.getTokenBounds.getFirstDifferencePos=function(newS,oldS){var boundary=Math.min(newS.length,oldS.length);for(var index=0;index<boundary;++index)
if(newS[index]!=oldS[index])
return index;return boundary;};Ajax.Autocompleter=Class.create(Autocompleter.Base,{initialize:function(element,update,url,options){this.baseInitialize(element,update,options);this.options.asynchronous=true;this.options.onComplete=this.onComplete.bind(this);this.options.defaultParams=this.options.parameters||null;this.url=url;},getUpdatedChoices:function(){this.startIndicator();var entry=encodeURIComponent(this.options.paramName)+'='+
encodeURIComponent(this.getToken());this.options.parameters=this.options.callback?this.options.callback(this.element,entry):entry;if(this.options.defaultParams)
this.options.parameters+='&'+this.options.defaultParams;new Ajax.Request(this.url,this.options);},onComplete:function(request){this.updateChoices(request.responseText);}});Autocompleter.Local=Class.create(Autocompleter.Base,{initialize:function(element,update,array,options){this.baseInitialize(element,update,options);this.options.array=array;},getUpdatedChoices:function(){this.updateChoices(this.options.selector(this));},setOptions:function(options){this.options=Object.extend({choices:10,partialSearch:true,partialChars:2,ignoreCase:true,fullSearch:false,selector:function(instance){var ret=[];var partial=[];var entry=instance.getToken();var count=0;for(var i=0;i<instance.options.array.length&&ret.length<instance.options.choices;i++){var elem=instance.options.array[i];var foundPos=instance.options.ignoreCase?elem.toLowerCase().indexOf(entry.toLowerCase()):elem.indexOf(entry);while(foundPos!=-1){if(foundPos==0&&elem.length!=entry.length){ret.push("<li><strong>"+elem.substr(0,entry.length)+"</strong>"+
elem.substr(entry.length)+"</li>");break;}else if(entry.length>=instance.options.partialChars&&instance.options.partialSearch&&foundPos!=-1){if(instance.options.fullSearch||/\s/.test(elem.substr(foundPos-1,1))){partial.push("<li>"+elem.substr(0,foundPos)+"<strong>"+
elem.substr(foundPos,entry.length)+"</strong>"+elem.substr(foundPos+entry.length)+"</li>");break;}}
foundPos=instance.options.ignoreCase?elem.toLowerCase().indexOf(entry.toLowerCase(),foundPos+1):elem.indexOf(entry,foundPos+1);}}
if(partial.length)
ret=ret.concat(partial.slice(0,instance.options.choices-ret.length))
return"<ul>"+ret.join('')+"</ul>";}},options||{});}});Field.scrollFreeActivate=function(field){setTimeout(function(){Field.activate(field);},1);}
Ajax.InPlaceEditor=Class.create({initialize:function(element,url,options){this.url=url;this.element=element=$(element);this.prepareOptions();this._controls={};arguments.callee.dealWithDeprecatedOptions(options);Object.extend(this.options,options||{});if(!this.options.formId&&this.element.id){this.options.formId=this.element.id+'-inplaceeditor';if($(this.options.formId))
this.options.formId='';}
if(this.options.externalControl)
this.options.externalControl=$(this.options.externalControl);if(!this.options.externalControl)
this.options.externalControlOnly=false;this._originalBackground=this.element.getStyle('background-color')||'transparent';this.element.title=this.options.clickToEditText;this._boundCancelHandler=this.handleFormCancellation.bind(this);this._boundComplete=(this.options.onComplete||Prototype.emptyFunction).bind(this);this._boundFailureHandler=this.handleAJAXFailure.bind(this);this._boundSubmitHandler=this.handleFormSubmission.bind(this);this._boundWrapperHandler=this.wrapUp.bind(this);this.registerListeners();},checkForEscapeOrReturn:function(e){if(!this._editing||e.ctrlKey||e.altKey||e.shiftKey)return;if(Event.KEY_ESC==e.keyCode)
this.handleFormCancellation(e);else if(Event.KEY_RETURN==e.keyCode)
this.handleFormSubmission(e);},createControl:function(mode,handler,extraClasses){var control=this.options[mode+'Control'];var text=this.options[mode+'Text'];if('button'==control){var btn=document.createElement('input');btn.type='submit';btn.value=text;btn.className='editor_'+mode+'_button';if('cancel'==mode)
btn.onclick=this._boundCancelHandler;this._form.appendChild(btn);this._controls[mode]=btn;}else if('link'==control){var link=document.createElement('a');link.href='#';link.appendChild(document.createTextNode(text));link.onclick='cancel'==mode?this._boundCancelHandler:this._boundSubmitHandler;link.className='editor_'+mode+'_link';if(extraClasses)
link.className+=' '+extraClasses;this._form.appendChild(link);this._controls[mode]=link;}},createEditField:function(){var text=(this.options.loadTextURL?this.options.loadingText:this.getText());var fld;if(1>=this.options.rows&&!/\r|\n/.test(this.getText())){fld=document.createElement('input');fld.type='text';var size=this.options.size||this.options.cols||0;if(0<size)fld.size=size;}else{fld=document.createElement('textarea');fld.rows=(1>=this.options.rows?this.options.autoRows:this.options.rows);fld.cols=this.options.cols||40;}
fld.name=this.options.paramName;fld.value=text;fld.className='editor_field';if(this.options.submitOnBlur)
fld.onblur=this._boundSubmitHandler;this._controls.editor=fld;if(this.options.loadTextURL)
this.loadExternalText();this._form.appendChild(this._controls.editor);},createForm:function(){var ipe=this;function addText(mode,condition){var text=ipe.options['text'+mode+'Controls'];if(!text||condition===false)return;ipe._form.appendChild(document.createTextNode(text));};this._form=$(document.createElement('form'));this._form.id=this.options.formId;this._form.addClassName(this.options.formClassName);this._form.onsubmit=this._boundSubmitHandler;this.createEditField();if('textarea'==this._controls.editor.tagName.toLowerCase())
this._form.appendChild(document.createElement('br'));if(this.options.onFormCustomization)
this.options.onFormCustomization(this,this._form);addText('Before',this.options.okControl||this.options.cancelControl);this.createControl('ok',this._boundSubmitHandler);addText('Between',this.options.okControl&&this.options.cancelControl);this.createControl('cancel',this._boundCancelHandler,'editor_cancel');addText('After',this.options.okControl||this.options.cancelControl);},destroy:function(){if(this._oldInnerHTML)
this.element.innerHTML=this._oldInnerHTML;this.leaveEditMode();this.unregisterListeners();},enterEditMode:function(e){if(this._saving||this._editing)return;this._editing=true;this.triggerCallback('onEnterEditMode');if(this.options.externalControl)
this.options.externalControl.hide();this.element.hide();this.createForm();this.element.parentNode.insertBefore(this._form,this.element);if(!this.options.loadTextURL)
this.postProcessEditField();if(e)Event.stop(e);},enterHover:function(e){if(this.options.hoverClassName)
this.element.addClassName(this.options.hoverClassName);if(this._saving)return;this.triggerCallback('onEnterHover');},getText:function(){return this.element.innerHTML;},handleAJAXFailure:function(transport){this.triggerCallback('onFailure',transport);if(this._oldInnerHTML){this.element.innerHTML=this._oldInnerHTML;this._oldInnerHTML=null;}},handleFormCancellation:function(e){this.wrapUp();if(e)Event.stop(e);},handleFormSubmission:function(e){var form=this._form;var value=$F(this._controls.editor);this.prepareSubmission();var params=this.options.callback(form,value)||'';if(Object.isString(params))
params=params.toQueryParams();params.editorId=this.element.id;if(this.options.htmlResponse){var options=Object.extend({evalScripts:true},this.options.ajaxOptions);Object.extend(options,{parameters:params,onComplete:this._boundWrapperHandler,onFailure:this._boundFailureHandler});new Ajax.Updater({success:this.element},this.url,options);}else{var options=Object.extend({method:'get'},this.options.ajaxOptions);Object.extend(options,{parameters:params,onComplete:this._boundWrapperHandler,onFailure:this._boundFailureHandler});new Ajax.Request(this.url,options);}
if(e)Event.stop(e);},leaveEditMode:function(){this.element.removeClassName(this.options.savingClassName);this.removeForm();this.leaveHover();this.element.style.backgroundColor=this._originalBackground;this.element.show();if(this.options.externalControl)
this.options.externalControl.show();this._saving=false;this._editing=false;this._oldInnerHTML=null;this.triggerCallback('onLeaveEditMode');},leaveHover:function(e){if(this.options.hoverClassName)
this.element.removeClassName(this.options.hoverClassName);if(this._saving)return;this.triggerCallback('onLeaveHover');},loadExternalText:function(){this._form.addClassName(this.options.loadingClassName);this._controls.editor.disabled=true;var options=Object.extend({method:'get'},this.options.ajaxOptions);Object.extend(options,{parameters:'editorId='+encodeURIComponent(this.element.id),onComplete:Prototype.emptyFunction,onSuccess:function(transport){this._form.removeClassName(this.options.loadingClassName);var text=transport.responseText;if(this.options.stripLoadedTextTags)
text=text.stripTags();this._controls.editor.value=text;this._controls.editor.disabled=false;this.postProcessEditField();}.bind(this),onFailure:this._boundFailureHandler});new Ajax.Request(this.options.loadTextURL,options);},postProcessEditField:function(){var fpc=this.options.fieldPostCreation;if(fpc)
$(this._controls.editor)['focus'==fpc?'focus':'activate']();},prepareOptions:function(){this.options=Object.clone(Ajax.InPlaceEditor.DefaultOptions);Object.extend(this.options,Ajax.InPlaceEditor.DefaultCallbacks);[this._extraDefaultOptions].flatten().compact().each(function(defs){Object.extend(this.options,defs);}.bind(this));},prepareSubmission:function(){this._saving=true;this.removeForm();this.leaveHover();this.showSaving();},registerListeners:function(){this._listeners={};var listener;$H(Ajax.InPlaceEditor.Listeners).each(function(pair){listener=this[pair.value].bind(this);this._listeners[pair.key]=listener;if(!this.options.externalControlOnly)
this.element.observe(pair.key,listener);if(this.options.externalControl)
this.options.externalControl.observe(pair.key,listener);}.bind(this));},removeForm:function(){if(!this._form)return;this._form.remove();this._form=null;this._controls={};},showSaving:function(){this._oldInnerHTML=this.element.innerHTML;this.element.innerHTML=this.options.savingText;this.element.addClassName(this.options.savingClassName);this.element.style.backgroundColor=this._originalBackground;this.element.show();},triggerCallback:function(cbName,arg){if('function'==typeof this.options[cbName]){this.options[cbName](this,arg);}},unregisterListeners:function(){$H(this._listeners).each(function(pair){if(!this.options.externalControlOnly)
this.element.stopObserving(pair.key,pair.value);if(this.options.externalControl)
this.options.externalControl.stopObserving(pair.key,pair.value);}.bind(this));},wrapUp:function(transport){this.leaveEditMode();this._boundComplete(transport,this.element);}});Object.extend(Ajax.InPlaceEditor.prototype,{dispose:Ajax.InPlaceEditor.prototype.destroy});Ajax.InPlaceCollectionEditor=Class.create(Ajax.InPlaceEditor,{initialize:function($super,element,url,options){this._extraDefaultOptions=Ajax.InPlaceCollectionEditor.DefaultOptions;$super(element,url,options);},createEditField:function(){var list=document.createElement('select');list.name=this.options.paramName;list.size=1;this._controls.editor=list;this._collection=this.options.collection||[];if(this.options.loadCollectionURL)
this.loadCollection();else
this.checkForExternalText();this._form.appendChild(this._controls.editor);},loadCollection:function(){this._form.addClassName(this.options.loadingClassName);this.showLoadingText(this.options.loadingCollectionText);var options=Object.extend({method:'get'},this.options.ajaxOptions);Object.extend(options,{parameters:'editorId='+encodeURIComponent(this.element.id),onComplete:Prototype.emptyFunction,onSuccess:function(transport){var js=transport.responseText.strip();if(!/^\[.*\]$/.test(js))
throw'Server returned an invalid collection representation.';this._collection=eval(js);this.checkForExternalText();}.bind(this),onFailure:this.onFailure});new Ajax.Request(this.options.loadCollectionURL,options);},showLoadingText:function(text){this._controls.editor.disabled=true;var tempOption=this._controls.editor.firstChild;if(!tempOption){tempOption=document.createElement('option');tempOption.value='';this._controls.editor.appendChild(tempOption);tempOption.selected=true;}
tempOption.update((text||'').stripScripts().stripTags());},checkForExternalText:function(){this._text=this.getText();if(this.options.loadTextURL)
this.loadExternalText();else
this.buildOptionList();},loadExternalText:function(){this.showLoadingText(this.options.loadingText);var options=Object.extend({method:'get'},this.options.ajaxOptions);Object.extend(options,{parameters:'editorId='+encodeURIComponent(this.element.id),onComplete:Prototype.emptyFunction,onSuccess:function(transport){this._text=transport.responseText.strip();this.buildOptionList();}.bind(this),onFailure:this.onFailure});new Ajax.Request(this.options.loadTextURL,options);},buildOptionList:function(){this._form.removeClassName(this.options.loadingClassName);this._collection=this._collection.map(function(entry){return 2===entry.length?entry:[entry,entry].flatten();});var marker=('value'in this.options)?this.options.value:this._text;var textFound=this._collection.any(function(entry){return entry[0]==marker;}.bind(this));this._controls.editor.update('');var option;this._collection.each(function(entry,index){option=document.createElement('option');option.value=entry[0];option.selected=textFound?entry[0]==marker:0==index;option.appendChild(document.createTextNode(entry[1]));this._controls.editor.appendChild(option);}.bind(this));this._controls.editor.disabled=false;Field.scrollFreeActivate(this._controls.editor);}});Ajax.InPlaceEditor.prototype.initialize.dealWithDeprecatedOptions=function(options){if(!options)return;function fallback(name,expr){if(name in options||expr===undefined)return;options[name]=expr;};fallback('cancelControl',(options.cancelLink?'link':(options.cancelButton?'button':options.cancelLink==options.cancelButton==false?false:undefined)));fallback('okControl',(options.okLink?'link':(options.okButton?'button':options.okLink==options.okButton==false?false:undefined)));fallback('highlightColor',options.highlightcolor);fallback('highlightEndColor',options.highlightendcolor);};Object.extend(Ajax.InPlaceEditor,{DefaultOptions:{ajaxOptions:{},autoRows:3,cancelControl:'link',cancelText:'cancel',clickToEditText:'Click to edit',externalControl:null,externalControlOnly:false,fieldPostCreation:'activate',formClassName:'inplaceeditor-form',formId:null,highlightColor:'#ffff99',highlightEndColor:'#ffffff',hoverClassName:'',htmlResponse:true,loadingClassName:'inplaceeditor-loading',loadingText:'Loading...',okControl:'button',okText:'ok',paramName:'value',rows:1,savingClassName:'inplaceeditor-saving',savingText:'Saving...',size:0,stripLoadedTextTags:false,submitOnBlur:false,textAfterControls:'',textBeforeControls:'',textBetweenControls:''},DefaultCallbacks:{callback:function(form){return Form.serialize(form);},onComplete:function(transport,element){new Effect.Highlight(element,{startcolor:this.options.highlightColor,keepBackgroundImage:true});},onEnterEditMode:null,onEnterHover:function(ipe){ipe.element.style.backgroundColor=ipe.options.highlightColor;if(ipe._effect)
ipe._effect.cancel();},onFailure:function(transport,ipe){alert('Error communication with the server: '+transport.responseText.stripTags());},onFormCustomization:null,onLeaveEditMode:null,onLeaveHover:function(ipe){ipe._effect=new Effect.Highlight(ipe.element,{startcolor:ipe.options.highlightColor,endcolor:ipe.options.highlightEndColor,restorecolor:ipe._originalBackground,keepBackgroundImage:true});}},Listeners:{click:'enterEditMode',keydown:'checkForEscapeOrReturn',mouseover:'enterHover',mouseout:'leaveHover'}});Ajax.InPlaceCollectionEditor.DefaultOptions={loadingCollectionText:'Loading options...'};Form.Element.DelayedObserver=Class.create({initialize:function(element,delay,callback){this.delay=delay||0.5;this.element=$(element);this.callback=callback;this.timer=null;this.lastValue=$F(this.element);Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this));},delayedListener:function(event){if(this.lastValue==$F(this.element))return;if(this.timer)clearTimeout(this.timer);this.timer=setTimeout(this.onTimerEvent.bind(this),this.delay*1000);this.lastValue=$F(this.element);},onTimerEvent:function(){this.timer=null;this.callback(this.element,$F(this.element));}});var Window=Class.create();Window.keepMultiModalWindow=false;Window.hasEffectLib=(typeof Effect!='undefined');Window.resizeEffectDuration=0.4;Window.prototype={initialize:function(){var id;var optionIndex=0;if(arguments.length>0){if(typeof arguments[0]=="string"){id=arguments[0];optionIndex=1;}
else
id=arguments[0]?arguments[0].id:null;}
if(!id)
id="window_"+new Date().getTime();if($(id))
alert("Window "+id+" is already registered in the DOM! Make sure you use setDestroyOnClose() or destroyOnClose: true in the constructor");this.options=Object.extend({className:"dialog",blurClassName:null,minWidth:100,minHeight:20,resizable:true,closable:true,minimizable:true,maximizable:true,draggable:true,userData:null,showEffect:(Window.hasEffectLib?Effect.Appear:Element.show),hideEffect:(Window.hasEffectLib?Effect.Fade:Element.hide),showEffectOptions:{},hideEffectOptions:{},effectOptions:null,parent:document.body,title:"&nbsp;",url:null,onload:Prototype.emptyFunction,width:200,height:300,opacity:1,recenterAuto:true,wiredDrag:false,closeCallback:null,destroyOnClose:false,gridX:1,gridY:1},arguments[optionIndex]||{});if(this.options.blurClassName)
this.options.focusClassName=this.options.className;if(typeof this.options.top=="undefined"&&typeof this.options.bottom=="undefined")
this.options.top=this._round(Math.random()*500,this.options.gridY);if(typeof this.options.left=="undefined"&&typeof this.options.right=="undefined")
this.options.left=this._round(Math.random()*500,this.options.gridX);if(this.options.effectOptions){Object.extend(this.options.hideEffectOptions,this.options.effectOptions);Object.extend(this.options.showEffectOptions,this.options.effectOptions);if(this.options.showEffect==Element.Appear)
this.options.showEffectOptions.to=this.options.opacity;}
if(Window.hasEffectLib){if(this.options.showEffect==Effect.Appear)
this.options.showEffectOptions.to=this.options.opacity;if(this.options.hideEffect==Effect.Fade)
this.options.hideEffectOptions.from=this.options.opacity;}
if(this.options.hideEffect==Element.hide)
this.options.hideEffect=function(){Element.hide(this.element);if(this.options.destroyOnClose)this.destroy();}.bind(this)
if(this.options.parent!=document.body)
this.options.parent=$(this.options.parent);this.element=this._createWindow(id);this.element.win=this;this.eventMouseDown=this._initDrag.bindAsEventListener(this);this.eventMouseUp=this._endDrag.bindAsEventListener(this);this.eventMouseMove=this._updateDrag.bindAsEventListener(this);this.eventOnLoad=this._getWindowBorderSize.bindAsEventListener(this);this.eventMouseDownContent=this.toFront.bindAsEventListener(this);this.eventResize=this._recenter.bindAsEventListener(this);this.topbar=$(this.element.id+"_top");this.bottombar=$(this.element.id+"_bottom");this.content=$(this.element.id+"_content");Event.observe(this.topbar,"mousedown",this.eventMouseDown);Event.observe(this.bottombar,"mousedown",this.eventMouseDown);Event.observe(this.content,"mousedown",this.eventMouseDownContent);Event.observe(window,"load",this.eventOnLoad);Event.observe(window,"resize",this.eventResize);Event.observe(window,"scroll",this.eventResize);Event.observe(this.options.parent,"scroll",this.eventResize);if(this.options.draggable){var that=this;[this.topbar,this.topbar.up().previous(),this.topbar.up().next()].each(function(element){element.observe("mousedown",that.eventMouseDown);element.addClassName("top_draggable");});[this.bottombar.up(),this.bottombar.up().previous(),this.bottombar.up().next()].each(function(element){element.observe("mousedown",that.eventMouseDown);element.addClassName("bottom_draggable");});}
if(this.options.resizable){this.sizer=$(this.element.id+"_sizer");Event.observe(this.sizer,"mousedown",this.eventMouseDown);}
this.useLeft=null;this.useTop=null;if(typeof this.options.left!="undefined"){this.element.setStyle({left:parseFloat(this.options.left)+'px'});this.useLeft=true;}
else{this.element.setStyle({right:parseFloat(this.options.right)+'px'});this.useLeft=false;}
if(typeof this.options.top!="undefined"){this.element.setStyle({top:parseFloat(this.options.top)+'px'});this.useTop=true;}
else{this.element.setStyle({bottom:parseFloat(this.options.bottom)+'px'});this.useTop=false;}
this.storedLocation=null;this.setOpacity(this.options.opacity);if(this.options.zIndex)
this.setZIndex(this.options.zIndex)
if(this.options.destroyOnClose)
this.setDestroyOnClose(true);this._getWindowBorderSize();this.width=this.options.width;this.height=this.options.height;this.visible=false;this.constraint=false;this.constraintPad={top:0,left:0,bottom:0,right:0};if(this.width&&this.height)
this.setSize(this.options.width,this.options.height);this.setTitle(this.options.title)
Windows.register(this);},destroy:function(){this._notify("onDestroy");Event.stopObserving(this.topbar,"mousedown",this.eventMouseDown);Event.stopObserving(this.bottombar,"mousedown",this.eventMouseDown);Event.stopObserving(this.content,"mousedown",this.eventMouseDownContent);Event.stopObserving(window,"load",this.eventOnLoad);Event.stopObserving(window,"resize",this.eventResize);Event.stopObserving(window,"scroll",this.eventResize);Event.stopObserving(this.content,"load",this.options.onload);if(this._oldParent){var content=this.getContent();var originalContent=null;for(var i=0;i<content.childNodes.length;i++){originalContent=content.childNodes[i];if(originalContent.nodeType==1)
break;originalContent=null;}
if(originalContent)
this._oldParent.appendChild(originalContent);this._oldParent=null;}
if(this.sizer)
Event.stopObserving(this.sizer,"mousedown",this.eventMouseDown);if(this.options.url)
this.content.src=null
if(this.iefix)
Element.remove(this.iefix);Element.remove(this.element);Windows.unregister(this);},setCloseCallback:function(callback){this.options.closeCallback=callback;},getContent:function(){return this.content;},setContent:function(id,autoresize,autoposition){var element=$(id);if(null==element)throw"Unable to find element '"+id+"' in DOM";this._oldParent=element.parentNode;var d=null;var p=null;if(autoresize)
d=Element.getDimensions(element);if(autoposition)
p=Position.cumulativeOffset(element);var content=this.getContent();this.setHTMLContent("");content=this.getContent();content.appendChild(element);element.show();if(autoresize)
this.setSize(d.width,d.height);if(autoposition)
this.setLocation(p[1]-this.heightN,p[0]-this.widthW);},setHTMLContent:function(html){if(this.options.url){this.content.src=null;this.options.url=null;var content="<div id=\""+this.getId()+"_content\" class=\""+this.options.className+"_content\"> </div>";$(this.getId()+"_table_content").innerHTML=content;this.content=$(this.element.id+"_content");}
this.getContent().innerHTML=html;},setAjaxContent:function(url,options,showCentered,showModal){this.showFunction=showCentered?"showCenter":"show";this.showModal=showModal||false;options=options||{};this.setHTMLContent("");this.onComplete=options.onComplete;if(!this._onCompleteHandler)
this._onCompleteHandler=this._setAjaxContent.bind(this);options.onComplete=this._onCompleteHandler;new Ajax.Request(url,options);options.onComplete=this.onComplete;},_setAjaxContent:function(originalRequest){Element.update(this.getContent(),originalRequest.responseText);if(this.onComplete)
this.onComplete(originalRequest);this.onComplete=null;this[this.showFunction](this.showModal)},setURL:function(url){if(this.options.url)
this.content.src=null;this.options.url=url;var content="<iframe frameborder='0' name='"+this.getId()+"_content'  id='"+this.getId()+"_content' src='"+url+"' width='"+this.width+"' height='"+this.height+"'> </iframe>";$(this.getId()+"_table_content").innerHTML=content;this.content=$(this.element.id+"_content");},getURL:function(){return this.options.url?this.options.url:null;},refresh:function(){if(this.options.url)
$(this.element.getAttribute('id')+'_content').src=this.options.url;},setCookie:function(name,expires,path,domain,secure){name=name||this.element.id;this.cookie=[name,expires,path,domain,secure];var value=WindowUtilities.getCookie(name)
if(value){var values=value.split(',');var x=values[0].split(':');var y=values[1].split(':');var w=parseFloat(values[2]),h=parseFloat(values[3]);var mini=values[4];var maxi=values[5];this.setSize(w,h);if(mini=="true")
this.doMinimize=true;else if(maxi=="true")
this.doMaximize=true;this.useLeft=x[0]=="l";this.useTop=y[0]=="t";this.element.setStyle(this.useLeft?{left:x[1]}:{right:x[1]});this.element.setStyle(this.useTop?{top:y[1]}:{bottom:y[1]});}},getId:function(){return this.element.id;},setDestroyOnClose:function(){this.options.destroyOnClose=true;},setConstraint:function(bool,padding){this.constraint=bool;this.constraintPad=Object.extend(this.constraintPad,padding||{});if(this.useTop&&this.useLeft)
this.setLocation(parseFloat(this.element.style.top),parseFloat(this.element.style.left));},_initDrag:function(event){if(Event.element(event)==this.sizer&&this.isMinimized())
return;if(Event.element(event)!=this.sizer&&this.isMaximized())
return;if(Prototype.Browser.IE&&this.heightN==0)
this._getWindowBorderSize();this.pointer=[this._round(Event.pointerX(event),this.options.gridX),this._round(Event.pointerY(event),this.options.gridY)];if(this.options.wiredDrag)
this.currentDrag=this._createWiredElement();else
this.currentDrag=this.element;if(Event.element(event)==this.sizer){this.doResize=true;this.widthOrg=this.width;this.heightOrg=this.height;this.bottomOrg=parseFloat(this.element.getStyle('bottom'));this.rightOrg=parseFloat(this.element.getStyle('right'));this._notify("onStartResize");}
else{this.doResize=false;var closeButton=$(this.getId()+'_close');if(closeButton&&Position.within(closeButton,this.pointer[0],this.pointer[1])){this.currentDrag=null;return;}
this.toFront();if(!this.options.draggable)
return;this._notify("onStartMove");}
Event.observe(document,"mouseup",this.eventMouseUp,false);Event.observe(document,"mousemove",this.eventMouseMove,false);WindowUtilities.disableScreen('__invisible__','__invisible__',this.overlayOpacity);document.body.ondrag=function(){return false;};document.body.onselectstart=function(){return false;};this.currentDrag.show();Event.stop(event);},_round:function(val,round){return round==1?val:val=Math.floor(val/round)*round;},_updateDrag:function(event){var pointer=[this._round(Event.pointerX(event),this.options.gridX),this._round(Event.pointerY(event),this.options.gridY)];var dx=pointer[0]-this.pointer[0];var dy=pointer[1]-this.pointer[1];if(this.doResize){var w=this.widthOrg+dx;var h=this.heightOrg+dy;dx=this.width-this.widthOrg
dy=this.height-this.heightOrg
if(this.useLeft)
w=this._updateWidthConstraint(w)
else
this.currentDrag.setStyle({right:(this.rightOrg-dx)+'px'});if(this.useTop)
h=this._updateHeightConstraint(h)
else
this.currentDrag.setStyle({bottom:(this.bottomOrg-dy)+'px'});this.setSize(w,h);this._notify("onResize");}
else{this.pointer=pointer;if(this.useLeft){var left=parseFloat(this.currentDrag.getStyle('left'))+dx;var newLeft=this._updateLeftConstraint(left);this.pointer[0]+=newLeft-left;this.currentDrag.setStyle({left:newLeft+'px'});}
else
this.currentDrag.setStyle({right:parseFloat(this.currentDrag.getStyle('right'))-dx+'px'});if(this.useTop){var top=parseFloat(this.currentDrag.getStyle('top'))+dy;var newTop=this._updateTopConstraint(top);this.pointer[1]+=newTop-top;this.currentDrag.setStyle({top:newTop+'px'});}
else
this.currentDrag.setStyle({bottom:parseFloat(this.currentDrag.getStyle('bottom'))-dy+'px'});this._notify("onMove");}
if(this.iefix)
this._fixIEOverlapping();this._removeStoreLocation();Event.stop(event);},_endDrag:function(event){WindowUtilities.enableScreen('__invisible__');if(this.doResize)
this._notify("onEndResize");else
this._notify("onEndMove");Event.stopObserving(document,"mouseup",this.eventMouseUp,false);Event.stopObserving(document,"mousemove",this.eventMouseMove,false);Event.stop(event);this._hideWiredElement();this._saveCookie()
document.body.ondrag=null;document.body.onselectstart=null;},_updateLeftConstraint:function(left){if(this.constraint&&this.useLeft&&this.useTop){var width=this.options.parent==document.body?WindowUtilities.getPageSize().windowWidth:this.options.parent.getDimensions().width;if(left<this.constraintPad.left)
left=this.constraintPad.left;if(left+this.width+this.widthE+this.widthW>width-this.constraintPad.right)
left=width-this.constraintPad.right-this.width-this.widthE-this.widthW;}
return left;},_updateTopConstraint:function(top){if(this.constraint&&this.useLeft&&this.useTop){var height=this.options.parent==document.body?WindowUtilities.getPageSize().windowHeight:this.options.parent.getDimensions().height;var h=this.height+this.heightN+this.heightS;if(top<this.constraintPad.top)
top=this.constraintPad.top;if(top+h>height-this.constraintPad.bottom)
top=height-this.constraintPad.bottom-h;}
return top;},_updateWidthConstraint:function(w){if(this.constraint&&this.useLeft&&this.useTop){var width=this.options.parent==document.body?WindowUtilities.getPageSize().windowWidth:this.options.parent.getDimensions().width;var left=parseFloat(this.element.getStyle("left"));if(left+w+this.widthE+this.widthW>width-this.constraintPad.right)
w=width-this.constraintPad.right-left-this.widthE-this.widthW;}
return w;},_updateHeightConstraint:function(h){if(this.constraint&&this.useLeft&&this.useTop){var height=this.options.parent==document.body?WindowUtilities.getPageSize().windowHeight:this.options.parent.getDimensions().height;var top=parseFloat(this.element.getStyle("top"));if(top+h+this.heightN+this.heightS>height-this.constraintPad.bottom)
h=height-this.constraintPad.bottom-top-this.heightN-this.heightS;}
return h;},_createWindow:function(id){var className=this.options.className;var win=document.createElement("div");win.setAttribute('id',id);win.className="dialog";var content;if(this.options.url)
content="<iframe frameborder=\"0\" name=\""+id+"_content\"  id=\""+id+"_content\" src=\""+this.options.url+"\"> </iframe>";else
content="<div id=\""+id+"_content\" class=\""+className+"_content\"> </div>";var closeDiv=this.options.closable?"<div class='"+className+"_close' id='"+id+"_close' onclick='Windows.close(\""+id+"\", event)'> </div>":"";var minDiv=this.options.minimizable?"<div class='"+className+"_minimize' id='"+id+"_minimize' onclick='Windows.minimize(\""+id+"\", event)'> </div>":"";var maxDiv=this.options.maximizable?"<div class='"+className+"_maximize' id='"+id+"_maximize' onclick='Windows.maximize(\""+id+"\", event)'> </div>":"";var seAttributes=this.options.resizable?"class='"+className+"_sizer' id='"+id+"_sizer'":"class='"+className+"_se'";var blank="../themes/default/blank.gif";win.innerHTML=closeDiv+minDiv+maxDiv+"\
      <table id='"+id+"_row1' class=\"top table_window\">\
        <tr>\
          <td class='"+className+"_nw'></td>\
          <td class='"+className+"_n'><div id='"+id+"_top' class='"+className+"_title title_window'>"+this.options.title+"</div></td>\
          <td class='"+className+"_ne'></td>\
        </tr>\
      </table>\
      <table id='"+id+"_row2' class=\"mid table_window\">\
        <tr>\
          <td class='"+className+"_w'></td>\
            <td id='"+id+"_table_content' class='"+className+"_content' valign='top'>"+content+"</td>\
          <td class='"+className+"_e'></td>\
        </tr>\
      </table>\
        <table id='"+id+"_row3' class=\"bot table_window\">\
        <tr>\
          <td class='"+className+"_sw'></td>\
            <td class='"+className+"_s'><div id='"+id+"_bottom' class='status_bar'><span style='float:left; width:1px; height:1px'></span></div></td>\
            <td "+seAttributes+"></td>\
        </tr>\
      </table>\
    ";Element.hide(win);this.options.parent.insertBefore(win,this.options.parent.firstChild);Event.observe($(id+"_content"),"load",this.options.onload);return win;},changeClassName:function(newClassName){var className=this.options.className;var id=this.getId();$A(["_close","_minimize","_maximize","_sizer","_content"]).each(function(value){this._toggleClassName($(id+value),className+value,newClassName+value)}.bind(this));this._toggleClassName($(id+"_top"),className+"_title",newClassName+"_title");$$("#"+id+" td").each(function(td){td.className=td.className.sub(className,newClassName);});this.options.className=newClassName;},_toggleClassName:function(element,oldClassName,newClassName){if(element){element.removeClassName(oldClassName);element.addClassName(newClassName);}},setLocation:function(top,left){top=this._updateTopConstraint(top);left=this._updateLeftConstraint(left);var e=this.currentDrag||this.element;e.setStyle({top:top+'px'});e.setStyle({left:left+'px'});this.useLeft=true;this.useTop=true;},getLocation:function(){var location={};if(this.useTop)
location=Object.extend(location,{top:this.element.getStyle("top")});else
location=Object.extend(location,{bottom:this.element.getStyle("bottom")});if(this.useLeft)
location=Object.extend(location,{left:this.element.getStyle("left")});else
location=Object.extend(location,{right:this.element.getStyle("right")});return location;},getSize:function(){return{width:this.width,height:this.height};},setSize:function(width,height,useEffect){width=parseFloat(width);height=parseFloat(height);if(!this.minimized&&width<this.options.minWidth)
width=this.options.minWidth;if(!this.minimized&&height<this.options.minHeight)
height=this.options.minHeight;if(this.options.maxHeight&&height>this.options.maxHeight)
height=this.options.maxHeight;if(this.options.maxWidth&&width>this.options.maxWidth)
width=this.options.maxWidth;if(this.useTop&&this.useLeft&&Window.hasEffectLib&&Effect.ResizeWindow&&useEffect){new Effect.ResizeWindow(this,null,null,width,height,{duration:Window.resizeEffectDuration});}else{this.width=width;this.height=height;var e=this.currentDrag?this.currentDrag:this.element;e.setStyle({width:width+this.widthW+this.widthE+"px"})
e.setStyle({height:height+this.heightN+this.heightS+"px"})
if(!this.currentDrag||this.currentDrag==this.element){var content=$(this.element.id+'_content');content.setStyle({height:height+'px'});content.setStyle({width:width+'px'});}}},updateHeight:function(){this.setSize(this.width,this.content.scrollHeight,true);},updateWidth:function(){this.setSize(this.content.scrollWidth,this.height,true);},toFront:function(){if(this.element.style.zIndex<Windows.maxZIndex)
this.setZIndex(Windows.maxZIndex+1);if(this.iefix)
this._fixIEOverlapping();},getBounds:function(insideOnly){if(!this.width||!this.height||!this.visible)
this.computeBounds();var w=this.width;var h=this.height;if(!insideOnly){w+=this.widthW+this.widthE;h+=this.heightN+this.heightS;}
var bounds=Object.extend(this.getLocation(),{width:w+"px",height:h+"px"});return bounds;},computeBounds:function(){if(!this.width||!this.height){var size=WindowUtilities._computeSize(this.content.innerHTML,this.content.id,this.width,this.height,0,this.options.className)
if(this.height)
this.width=size+5
else
this.height=size+5}
this.setSize(this.width,this.height);if(this.centered)
this._center(this.centerTop,this.centerLeft);},show:function(modal){this.visible=true;if(modal){if(typeof this.overlayOpacity=="undefined"){var that=this;setTimeout(function(){that.show(modal)},10);return;}
Windows.addModalWindow(this);this.modal=true;this.setZIndex(Windows.maxZIndex+1);Windows.unsetOverflow(this);}
else
if(!this.element.style.zIndex)
this.setZIndex(Windows.maxZIndex+1);if(this.oldStyle)
this.getContent().setStyle({overflow:this.oldStyle});this.computeBounds();this._notify("onBeforeShow");if(this.options.showEffect!=Element.show&&this.options.showEffectOptions)
this.options.showEffect(this.element,this.options.showEffectOptions);else
this.options.showEffect(this.element);this._checkIEOverlapping();WindowUtilities.focusedWindow=this
this._notify("onShow");},showCenter:function(modal,top,left){this.centered=true;this.centerTop=top;this.centerLeft=left;this.show(modal);},isVisible:function(){return this.visible;},_center:function(top,left){var windowScroll=WindowUtilities.getWindowScroll(this.options.parent);var pageSize=WindowUtilities.getPageSize(this.options.parent);if(typeof top=="undefined")
top=(pageSize.windowHeight-(this.height+this.heightN+this.heightS))/2;top+=windowScroll.top
if(typeof left=="undefined")
left=(pageSize.windowWidth-(this.width+this.widthW+this.widthE))/2;left+=windowScroll.left
this.setLocation(top,left);this.toFront();},_recenter:function(event){if(this.centered){var pageSize=WindowUtilities.getPageSize(this.options.parent);var windowScroll=WindowUtilities.getWindowScroll(this.options.parent);if(this.pageSize&&this.pageSize.windowWidth==pageSize.windowWidth&&this.pageSize.windowHeight==pageSize.windowHeight&&this.windowScroll.left==windowScroll.left&&this.windowScroll.top==windowScroll.top)
return;this.pageSize=pageSize;this.windowScroll=windowScroll;if($('overlay_modal'))
$('overlay_modal').setStyle({height:(pageSize.pageHeight+'px')});if(this.options.recenterAuto)
this._center(this.centerTop,this.centerLeft);}},hide:function(){this.visible=false;if(this.modal){Windows.removeModalWindow(this);Windows.resetOverflow();}
this.oldStyle=this.getContent().getStyle('overflow')||"auto"
this.getContent().setStyle({overflow:"hidden"});this.options.hideEffect(this.element,this.options.hideEffectOptions);if(this.iefix)
this.iefix.hide();if(!this.doNotNotifyHide)
this._notify("onHide");},close:function(){if(this.visible){if(this.options.closeCallback&&!this.options.closeCallback(this))
return;if(this.options.destroyOnClose){var destroyFunc=this.destroy.bind(this);if(this.options.hideEffectOptions.afterFinish){var func=this.options.hideEffectOptions.afterFinish;this.options.hideEffectOptions.afterFinish=function(){func();destroyFunc()}}
else
this.options.hideEffectOptions.afterFinish=function(){destroyFunc()}}
Windows.updateFocusedWindow();this.doNotNotifyHide=true;this.hide();this.doNotNotifyHide=false;this._notify("onClose");}},minimize:function(){if(this.resizing)
return;var r2=$(this.getId()+"_row2");if(!this.minimized){this.minimized=true;var dh=r2.getDimensions().height;this.r2Height=dh;var h=this.element.getHeight()-dh;if(this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow){new Effect.ResizeWindow(this,null,null,null,this.height-dh,{duration:Window.resizeEffectDuration});}else{this.height-=dh;this.element.setStyle({height:h+"px"});r2.hide();}
if(!this.useTop){var bottom=parseFloat(this.element.getStyle('bottom'));this.element.setStyle({bottom:(bottom+dh)+'px'});}}
else{this.minimized=false;var dh=this.r2Height;this.r2Height=null;if(this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow){new Effect.ResizeWindow(this,null,null,null,this.height+dh,{duration:Window.resizeEffectDuration});}
else{var h=this.element.getHeight()+dh;this.height+=dh;this.element.setStyle({height:h+"px"})
r2.show();}
if(!this.useTop){var bottom=parseFloat(this.element.getStyle('bottom'));this.element.setStyle({bottom:(bottom-dh)+'px'});}
this.toFront();}
this._notify("onMinimize");this._saveCookie()},maximize:function(){if(this.isMinimized()||this.resizing)
return;if(Prototype.Browser.IE&&this.heightN==0)
this._getWindowBorderSize();if(this.storedLocation!=null){this._restoreLocation();if(this.iefix)
this.iefix.hide();}
else{this._storeLocation();Windows.unsetOverflow(this);var windowScroll=WindowUtilities.getWindowScroll(this.options.parent);var pageSize=WindowUtilities.getPageSize(this.options.parent);var left=windowScroll.left;var top=windowScroll.top;if(this.options.parent!=document.body){windowScroll={top:0,left:0,bottom:0,right:0};var dim=this.options.parent.getDimensions();pageSize.windowWidth=dim.width;pageSize.windowHeight=dim.height;top=0;left=0;}
if(this.constraint){pageSize.windowWidth-=Math.max(0,this.constraintPad.left)+Math.max(0,this.constraintPad.right);pageSize.windowHeight-=Math.max(0,this.constraintPad.top)+Math.max(0,this.constraintPad.bottom);left+=Math.max(0,this.constraintPad.left);top+=Math.max(0,this.constraintPad.top);}
var width=pageSize.windowWidth-this.widthW-this.widthE;var height=pageSize.windowHeight-this.heightN-this.heightS;if(this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow){new Effect.ResizeWindow(this,top,left,width,height,{duration:Window.resizeEffectDuration});}
else{this.setSize(width,height);this.element.setStyle(this.useLeft?{left:left}:{right:left});this.element.setStyle(this.useTop?{top:top}:{bottom:top});}
this.toFront();if(this.iefix)
this._fixIEOverlapping();}
this._notify("onMaximize");this._saveCookie()},isMinimized:function(){return this.minimized;},isMaximized:function(){return(this.storedLocation!=null);},setOpacity:function(opacity){if(Element.setOpacity)
Element.setOpacity(this.element,opacity);},setZIndex:function(zindex){this.element.setStyle({zIndex:zindex});Windows.updateZindex(zindex,this);},setTitle:function(newTitle){if(!newTitle||newTitle=="")
newTitle="&nbsp;";Element.update(this.element.id+'_top',newTitle);},getTitle:function(){return $(this.element.id+'_top').innerHTML;},setStatusBar:function(element){var statusBar=$(this.getId()+"_bottom");if(typeof(element)=="object"){if(this.bottombar.firstChild)
this.bottombar.replaceChild(element,this.bottombar.firstChild);else
this.bottombar.appendChild(element);}
else
this.bottombar.innerHTML=element;},_checkIEOverlapping:function(){if(!this.iefix&&(navigator.appVersion.indexOf('MSIE')>0)&&(navigator.userAgent.indexOf('Opera')<0)&&(this.element.getStyle('position')=='absolute')){new Insertion.After(this.element.id,'<iframe id="'+this.element.id+'_iefix" '+'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" '+'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');this.iefix=$(this.element.id+'_iefix');}
if(this.iefix)
setTimeout(this._fixIEOverlapping.bind(this),50);},_fixIEOverlapping:function(){Position.clone(this.element,this.iefix);this.iefix.style.zIndex=this.element.style.zIndex-1;this.iefix.show();},_getWindowBorderSize:function(event){var div=this._createHiddenDiv(this.options.className+"_n")
this.heightN=Element.getDimensions(div).height;div.parentNode.removeChild(div)
var div=this._createHiddenDiv(this.options.className+"_s")
this.heightS=Element.getDimensions(div).height;div.parentNode.removeChild(div)
var div=this._createHiddenDiv(this.options.className+"_e")
this.widthE=Element.getDimensions(div).width;div.parentNode.removeChild(div)
var div=this._createHiddenDiv(this.options.className+"_w")
this.widthW=Element.getDimensions(div).width;div.parentNode.removeChild(div);var div=document.createElement("div");div.className="overlay_"+this.options.className;document.body.appendChild(div);var that=this;setTimeout(function(){that.overlayOpacity=($(div).getStyle("opacity"));div.parentNode.removeChild(div);},10);if(Prototype.Browser.IE){this.heightS=$(this.getId()+"_row3").getDimensions().height;this.heightN=$(this.getId()+"_row1").getDimensions().height;}
if(Prototype.Browser.WebKit&&Prototype.Browser.WebKitVersion<420)
this.setSize(this.width,this.height);if(this.doMaximize)
this.maximize();if(this.doMinimize)
this.minimize();},_createHiddenDiv:function(className){var objBody=document.body;var win=document.createElement("div");win.setAttribute('id',this.element.id+"_tmp");win.className=className;win.style.display='none';win.innerHTML='';objBody.insertBefore(win,objBody.firstChild);return win;},_storeLocation:function(){if(this.storedLocation==null){this.storedLocation={useTop:this.useTop,useLeft:this.useLeft,top:this.element.getStyle('top'),bottom:this.element.getStyle('bottom'),left:this.element.getStyle('left'),right:this.element.getStyle('right'),width:this.width,height:this.height};}},_restoreLocation:function(){if(this.storedLocation!=null){this.useLeft=this.storedLocation.useLeft;this.useTop=this.storedLocation.useTop;if(this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow)
new Effect.ResizeWindow(this,this.storedLocation.top,this.storedLocation.left,this.storedLocation.width,this.storedLocation.height,{duration:Window.resizeEffectDuration});else{this.element.setStyle(this.useLeft?{left:this.storedLocation.left}:{right:this.storedLocation.right});this.element.setStyle(this.useTop?{top:this.storedLocation.top}:{bottom:this.storedLocation.bottom});this.setSize(this.storedLocation.width,this.storedLocation.height);}
Windows.resetOverflow();this._removeStoreLocation();}},_removeStoreLocation:function(){this.storedLocation=null;},_saveCookie:function(){if(this.cookie){var value="";if(this.useLeft)
value+="l:"+(this.storedLocation?this.storedLocation.left:this.element.getStyle('left'))
else
value+="r:"+(this.storedLocation?this.storedLocation.right:this.element.getStyle('right'))
if(this.useTop)
value+=",t:"+(this.storedLocation?this.storedLocation.top:this.element.getStyle('top'))
else
value+=",b:"+(this.storedLocation?this.storedLocation.bottom:this.element.getStyle('bottom'))
value+=","+(this.storedLocation?this.storedLocation.width:this.width);value+=","+(this.storedLocation?this.storedLocation.height:this.height);value+=","+this.isMinimized();value+=","+this.isMaximized();WindowUtilities.setCookie(value,this.cookie)}},_createWiredElement:function(){if(!this.wiredElement){if(Prototype.Browser.IE)
this._getWindowBorderSize();var div=document.createElement("div");div.className="wired_frame "+this.options.className+"_wired_frame";div.style.position='absolute';this.options.parent.insertBefore(div,this.options.parent.firstChild);this.wiredElement=$(div);}
if(this.useLeft)
this.wiredElement.setStyle({left:this.element.getStyle('left')});else
this.wiredElement.setStyle({right:this.element.getStyle('right')});if(this.useTop)
this.wiredElement.setStyle({top:this.element.getStyle('top')});else
this.wiredElement.setStyle({bottom:this.element.getStyle('bottom')});var dim=this.element.getDimensions();this.wiredElement.setStyle({width:dim.width+"px",height:dim.height+"px"});this.wiredElement.setStyle({zIndex:Windows.maxZIndex+30});return this.wiredElement;},_hideWiredElement:function(){if(!this.wiredElement||!this.currentDrag)
return;if(this.currentDrag==this.element)
this.currentDrag=null;else{if(this.useLeft)
this.element.setStyle({left:this.currentDrag.getStyle('left')});else
this.element.setStyle({right:this.currentDrag.getStyle('right')});if(this.useTop)
this.element.setStyle({top:this.currentDrag.getStyle('top')});else
this.element.setStyle({bottom:this.currentDrag.getStyle('bottom')});this.currentDrag.hide();this.currentDrag=null;if(this.doResize)
this.setSize(this.width,this.height);}},_notify:function(eventName){if(this.options[eventName])
this.options[eventName](this);else
Windows.notify(eventName,this);}};var Windows={windows:[],modalWindows:[],observers:[],focusedWindow:null,maxZIndex:0,overlayShowEffectOptions:{duration:0.5},overlayHideEffectOptions:{duration:0.5},addObserver:function(observer){this.removeObserver(observer);this.observers.push(observer);},removeObserver:function(observer){this.observers=this.observers.reject(function(o){return o==observer});},notify:function(eventName,win){this.observers.each(function(o){if(o[eventName])o[eventName](eventName,win);});},getWindow:function(id){return this.windows.detect(function(d){return d.getId()==id});},getFocusedWindow:function(){return this.focusedWindow;},updateFocusedWindow:function(){this.focusedWindow=this.windows.length>=2?this.windows[this.windows.length-2]:null;},register:function(win){this.windows.push(win);},addModalWindow:function(win){if(this.modalWindows.length==0){WindowUtilities.disableScreen(win.options.className,'overlay_modal',win.overlayOpacity,win.getId(),win.options.parent);}
else{if(Window.keepMultiModalWindow){$('overlay_modal').style.zIndex=Windows.maxZIndex+1;Windows.maxZIndex+=1;WindowUtilities._hideSelect(this.modalWindows.last().getId());}
else
this.modalWindows.last().element.hide();WindowUtilities._showSelect(win.getId());}
this.modalWindows.push(win);},removeModalWindow:function(win){this.modalWindows.pop();if(this.modalWindows.length==0)
WindowUtilities.enableScreen();else{if(Window.keepMultiModalWindow){this.modalWindows.last().toFront();WindowUtilities._showSelect(this.modalWindows.last().getId());}
else
this.modalWindows.last().element.show();}},register:function(win){this.windows.push(win);},unregister:function(win){this.windows=this.windows.reject(function(d){return d==win});},closeAll:function(){this.windows.each(function(w){Windows.close(w.getId())});},closeAllModalWindows:function(){WindowUtilities.enableScreen();this.modalWindows.each(function(win){if(win)win.close()});},minimize:function(id,event){var win=this.getWindow(id)
if(win&&win.visible)
win.minimize();Event.stop(event);},maximize:function(id,event){var win=this.getWindow(id)
if(win&&win.visible)
win.maximize();Event.stop(event);},close:function(id,event){var win=this.getWindow(id);if(win)
win.close();if(event)
Event.stop(event);},blur:function(id){var win=this.getWindow(id);if(!win)
return;if(win.options.blurClassName)
win.changeClassName(win.options.blurClassName);if(this.focusedWindow==win)
this.focusedWindow=null;win._notify("onBlur");},focus:function(id){var win=this.getWindow(id);if(!win)
return;if(this.focusedWindow)
this.blur(this.focusedWindow.getId())
if(win.options.focusClassName)
win.changeClassName(win.options.focusClassName);this.focusedWindow=win;win._notify("onFocus");},unsetOverflow:function(except){this.windows.each(function(d){d.oldOverflow=d.getContent().getStyle("overflow")||"auto";d.getContent().setStyle({overflow:"hidden"})});if(except&&except.oldOverflow)
except.getContent().setStyle({overflow:except.oldOverflow});},resetOverflow:function(){this.windows.each(function(d){if(d.oldOverflow)d.getContent().setStyle({overflow:d.oldOverflow})});},updateZindex:function(zindex,win){if(zindex>this.maxZIndex){this.maxZIndex=zindex;if(this.focusedWindow)
this.blur(this.focusedWindow.getId())}
this.focusedWindow=win;if(this.focusedWindow)
this.focus(this.focusedWindow.getId())}};var Dialog={dialogId:null,onCompleteFunc:null,callFunc:null,parameters:null,confirm:function(content,parameters){if(content&&typeof content!="string"){Dialog._runAjaxRequest(content,parameters,Dialog.confirm);return}
content=content||"";parameters=parameters||{};var okLabel=parameters.okLabel?parameters.okLabel:"Ok";var cancelLabel=parameters.cancelLabel?parameters.cancelLabel:"Cancel";parameters=Object.extend(parameters,parameters.windowParameters||{});parameters.windowParameters=parameters.windowParameters||{};parameters.className=parameters.className||"alert";var okButtonClass="class ='"+(parameters.buttonClass?parameters.buttonClass+" ":"")+" ok_button'"
var cancelButtonClass="class ='"+(parameters.buttonClass?parameters.buttonClass+" ":"")+" cancel_button'"
var content="\
      <div class='"+parameters.className+"_message'>"+content+"</div>\
        <div class='"+parameters.className+"_buttons'>\
          <input type='button' value='"+okLabel+"' onclick='Dialog.okCallback()' "+okButtonClass+"/>\
          <input type='button' value='"+cancelLabel+"' onclick='Dialog.cancelCallback()' "+cancelButtonClass+"/>\
        </div>\
    ";return this._openDialog(content,parameters)},alert:function(content,parameters){if(content&&typeof content!="string"){Dialog._runAjaxRequest(content,parameters,Dialog.alert);return}
content=content||"";parameters=parameters||{};var okLabel=parameters.okLabel?parameters.okLabel:"Ok";parameters=Object.extend(parameters,parameters.windowParameters||{});parameters.windowParameters=parameters.windowParameters||{};parameters.className=parameters.className||"alert";var okButtonClass="class ='"+(parameters.buttonClass?parameters.buttonClass+" ":"")+" ok_button'"
var content="\
      <div class='"+parameters.className+"_message'>"+content+"</div>\
        <div class='"+parameters.className+"_buttons'>\
          <input type='button' value='"+okLabel+"' onclick='Dialog.okCallback()' "+okButtonClass+"/>\
        </div>";return this._openDialog(content,parameters)},info:function(content,parameters){if(content&&typeof content!="string"){Dialog._runAjaxRequest(content,parameters,Dialog.info);return}
content=content||"";parameters=parameters||{};parameters=Object.extend(parameters,parameters.windowParameters||{});parameters.windowParameters=parameters.windowParameters||{};parameters.className=parameters.className||"alert";var content="<div id='modal_dialog_message' class='"+parameters.className+"_message'>"+content+"</div>";if(parameters.showProgress)
content+="<div id='modal_dialog_progress' class='"+parameters.className+"_progress'>  </div>";parameters.ok=null;parameters.cancel=null;return this._openDialog(content,parameters)},setInfoMessage:function(message){$('modal_dialog_message').update(message);},closeInfo:function(){Windows.close(this.dialogId);},_openDialog:function(content,parameters){var className=parameters.className;if(!parameters.height&&!parameters.width){parameters.width=WindowUtilities.getPageSize(parameters.options.parent||document.body).pageWidth/2;}
if(parameters.id)
this.dialogId=parameters.id;else{var t=new Date();this.dialogId='modal_dialog_'+t.getTime();parameters.id=this.dialogId;}
if(!parameters.height||!parameters.width){var size=WindowUtilities._computeSize(content,this.dialogId,parameters.width,parameters.height,5,className)
if(parameters.height)
parameters.width=size+5
else
parameters.height=size+5}
parameters.effectOptions=parameters.effectOptions;parameters.resizable=parameters.resizable||false;parameters.minimizable=parameters.minimizable||false;parameters.maximizable=parameters.maximizable||false;parameters.draggable=parameters.draggable||false;parameters.closable=parameters.closable||false;var win=new Window(parameters);win.getContent().innerHTML=content;win.showCenter(true,parameters.top,parameters.left);win.setDestroyOnClose();win.cancelCallback=parameters.onCancel||parameters.cancel;win.okCallback=parameters.onOk||parameters.ok;return win;},_getAjaxContent:function(originalRequest){Dialog.callFunc(originalRequest.responseText,Dialog.parameters)},_runAjaxRequest:function(message,parameters,callFunc){if(message.options==null)
message.options={}
Dialog.onCompleteFunc=message.options.onComplete;Dialog.parameters=parameters;Dialog.callFunc=callFunc;message.options.onComplete=Dialog._getAjaxContent;new Ajax.Request(message.url,message.options);},okCallback:function(){var win=Windows.focusedWindow;if(!win.okCallback||win.okCallback(win)){$$("#"+win.getId()+" input").each(function(element){element.onclick=null;})
win.close();}},cancelCallback:function(){var win=Windows.focusedWindow;$$("#"+win.getId()+" input").each(function(element){element.onclick=null})
win.close();if(win.cancelCallback)
win.cancelCallback(win);}}
if(Prototype.Browser.WebKit){var array=navigator.userAgent.match(new RegExp(/AppleWebKit\/([\d\.\+]*)/));Prototype.Browser.WebKitVersion=parseFloat(array[1]);}
var WindowUtilities={getWindowScroll:function(parent){var T,L,W,H;parent=parent||document.body;if(parent!=document.body){T=parent.scrollTop;L=parent.scrollLeft;W=parent.scrollWidth;H=parent.scrollHeight;}
else{var w=window;with(w.document){if(w.document.documentElement&&documentElement.scrollTop){T=documentElement.scrollTop;L=documentElement.scrollLeft;}else if(w.document.body){T=body.scrollTop;L=body.scrollLeft;}
if(w.innerWidth){W=w.innerWidth;H=w.innerHeight;}else if(w.document.documentElement&&documentElement.clientWidth){W=documentElement.clientWidth;H=documentElement.clientHeight;}else{W=body.offsetWidth;H=body.offsetHeight}}}
return{top:T,left:L,width:W,height:H};},getPageSize:function(parent){parent=parent||document.body;var windowWidth,windowHeight;var pageHeight,pageWidth;if(parent!=document.body){windowWidth=parent.getWidth();windowHeight=parent.getHeight();pageWidth=parent.scrollWidth;pageHeight=parent.scrollHeight;}
else{var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=document.body.scrollWidth;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}
if(self.innerHeight){windowWidth=self.innerWidth;windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}
if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}
if(xScroll<windowWidth){pageWidth=windowWidth;}else{pageWidth=xScroll;}}
return{pageWidth:pageWidth,pageHeight:pageHeight,windowWidth:windowWidth,windowHeight:windowHeight};},disableScreen:function(className,overlayId,overlayOpacity,contentId,parent){WindowUtilities.initLightbox(overlayId,className,function(){this._disableScreen(className,overlayId,overlayOpacity,contentId)}.bind(this),parent||document.body);},_disableScreen:function(className,overlayId,overlayOpacity,contentId){var objOverlay=$(overlayId);var pageSize=WindowUtilities.getPageSize(objOverlay.parentNode);if(contentId&&Prototype.Browser.IE){WindowUtilities._hideSelect();WindowUtilities._showSelect(contentId);}
objOverlay.style.height=(pageSize.pageHeight+'px');objOverlay.style.display='none';if(overlayId=="overlay_modal"&&Window.hasEffectLib&&Windows.overlayShowEffectOptions){objOverlay.overlayOpacity=overlayOpacity;new Effect.Appear(objOverlay,Object.extend({from:0,to:overlayOpacity},Windows.overlayShowEffectOptions));}
else
objOverlay.style.display="block";},enableScreen:function(id){id=id||'overlay_modal';var objOverlay=$(id);if(objOverlay){if(id=="overlay_modal"&&Window.hasEffectLib&&Windows.overlayHideEffectOptions)
new Effect.Fade(objOverlay,Object.extend({from:objOverlay.overlayOpacity,to:0},Windows.overlayHideEffectOptions));else{objOverlay.style.display='none';objOverlay.parentNode.removeChild(objOverlay);}
if(id!="__invisible__")
WindowUtilities._showSelect();}},_hideSelect:function(id){if(Prototype.Browser.IE){id=id==null?"":"#"+id+" ";$$(id+'select').each(function(element){if(!WindowUtilities.isDefined(element.oldVisibility)){element.oldVisibility=element.style.visibility?element.style.visibility:"visible";element.style.visibility="hidden";}});}},_showSelect:function(id){if(Prototype.Browser.IE){id=id==null?"":"#"+id+" ";$$(id+'select').each(function(element){if(WindowUtilities.isDefined(element.oldVisibility)){try{element.style.visibility=element.oldVisibility;}catch(e){element.style.visibility="visible";}
element.oldVisibility=null;}
else{if(element.style.visibility)
element.style.visibility="visible";}});}},isDefined:function(object){return typeof(object)!="undefined"&&object!=null;},initLightbox:function(id,className,doneHandler,parent){if($(id)){Element.setStyle(id,{zIndex:Windows.maxZIndex+1});Windows.maxZIndex++;doneHandler();}
else{var objOverlay=document.createElement("div");objOverlay.setAttribute('id',id);objOverlay.className="overlay_"+className
objOverlay.style.display='none';objOverlay.style.position='absolute';objOverlay.style.top='0';objOverlay.style.left='0';objOverlay.style.zIndex=Windows.maxZIndex+1;Windows.maxZIndex++;objOverlay.style.width='100%';parent.insertBefore(objOverlay,parent.firstChild);if(Prototype.Browser.WebKit&&id=="overlay_modal"){setTimeout(function(){doneHandler()},10);}
else
doneHandler();}},setCookie:function(value,parameters){document.cookie=parameters[0]+"="+escape(value)+
((parameters[1])?"; expires="+parameters[1].toGMTString():"")+
((parameters[2])?"; path="+parameters[2]:"")+
((parameters[3])?"; domain="+parameters[3]:"")+
((parameters[4])?"; secure":"");},getCookie:function(name){var dc=document.cookie;var prefix=name+"=";var begin=dc.indexOf("; "+prefix);if(begin==-1){begin=dc.indexOf(prefix);if(begin!=0)return null;}else{begin+=2;}
var end=document.cookie.indexOf(";",begin);if(end==-1){end=dc.length;}
return unescape(dc.substring(begin+prefix.length,end));},_computeSize:function(content,id,width,height,margin,className){var objBody=document.body;var tmpObj=document.createElement("div");tmpObj.setAttribute('id',id);tmpObj.className=className+"_content";if(height)
tmpObj.style.height=height+"px"
else
tmpObj.style.width=width+"px"
tmpObj.style.position='absolute';tmpObj.style.top='0';tmpObj.style.left='0';tmpObj.style.display='none';tmpObj.innerHTML=content;objBody.insertBefore(tmpObj,objBody.firstChild);var size;if(height)
size=$(tmpObj).getDimensions().width+margin;else
size=$(tmpObj).getDimensions().height+margin;objBody.removeChild(tmpObj);return size;}}
Effect.ResizeWindow=Class.create();Object.extend(Object.extend(Effect.ResizeWindow.prototype,Effect.Base.prototype),{initialize:function(win,top,left,width,height){this.window=win;this.window.resizing=true;var size=win.getSize();this.initWidth=parseFloat(size.width);this.initHeight=parseFloat(size.height);var location=win.getLocation();this.initTop=parseFloat(location.top);this.initLeft=parseFloat(location.left);this.width=width!=null?parseFloat(width):this.initWidth;this.height=height!=null?parseFloat(height):this.initHeight;this.top=top!=null?parseFloat(top):this.initTop;this.left=left!=null?parseFloat(left):this.initLeft;this.dx=this.left-this.initLeft;this.dy=this.top-this.initTop;this.dw=this.width-this.initWidth;this.dh=this.height-this.initHeight;this.r2=$(this.window.getId()+"_row2");this.content=$(this.window.getId()+"_content");this.contentOverflow=this.content.getStyle("overflow")||"auto";this.content.setStyle({overflow:"hidden"});if(this.window.options.wiredDrag){this.window.currentDrag=win._createWiredElement();this.window.currentDrag.show();this.window.element.hide();}
this.start(arguments[5]);},update:function(position){var width=Math.floor(this.initWidth+this.dw*position);var height=Math.floor(this.initHeight+this.dh*position);var top=Math.floor(this.initTop+this.dy*position);var left=Math.floor(this.initLeft+this.dx*position);if(window.ie){if(Math.floor(height)==0)
this.r2.hide();else if(Math.floor(height)>1)
this.r2.show();}
this.r2.setStyle({height:height});this.window.setSize(width,height);this.window.setLocation(top,left);},finish:function(position){if(this.window.options.wiredDrag){this.window._hideWiredElement();this.window.element.show();}
this.window.setSize(this.width,this.height);this.window.setLocation(this.top,this.left);this.r2.setStyle({height:null});this.content.setStyle({overflow:this.contentOverflow});this.window.resizing=false;}});Effect.ModalSlideDown=function(element){var windowScroll=WindowUtilities.getWindowScroll();var height=element.getStyle("height");element.setStyle({top:-(parseFloat(height)-windowScroll.top)+"px"});element.show();return new Effect.Move(element,Object.extend({x:0,y:parseFloat(height)},arguments[1]||{}));};Effect.ModalSlideUp=function(element){var height=element.getStyle("height");return new Effect.Move(element,Object.extend({x:0,y:-parseFloat(height)},arguments[1]||{}));};PopupEffect=Class.create();PopupEffect.prototype={initialize:function(htmlElement){this.html=$(htmlElement);this.options=Object.extend({className:"popup_effect",duration:0.4},arguments[1]||{});},show:function(element,options){var position=Position.cumulativeOffset(this.html);var size=this.html.getDimensions();var bounds=element.win.getBounds();this.window=element.win;if(!this.div){this.div=document.createElement("div");this.div.className=this.options.className;this.div.style.height=size.height+"px";this.div.style.width=size.width+"px";this.div.style.top=position[1]+"px";this.div.style.left=position[0]+"px";this.div.style.position="absolute"
document.body.appendChild(this.div);}
if(this.options.fromOpacity)
this.div.setStyle({opacity:this.options.fromOpacity})
this.div.show();var style="top:"+bounds.top+";left:"+bounds.left+";width:"+bounds.width+";height:"+bounds.height;if(this.options.toOpacity)
style+=";opacity:"+this.options.toOpacity;new Effect.Morph(this.div,{style:style,duration:this.options.duration,afterFinish:this._showWindow.bind(this)});},hide:function(element,options){var position=Position.cumulativeOffset(this.html);var size=this.html.getDimensions();this.window.visible=true;var bounds=this.window.getBounds();this.window.visible=false;this.window.element.hide();this.div.style.height=bounds.height;this.div.style.width=bounds.width;this.div.style.top=bounds.top;this.div.style.left=bounds.left;if(this.options.toOpacity)
this.div.setStyle({opacity:this.options.toOpacity})
this.div.show();var style="top:"+position[1]+"px;left:"+position[0]+"px;width:"+size.width+"px;height:"+size.height+"px";if(this.options.fromOpacity)
style+=";opacity:"+this.options.fromOpacity;new Effect.Morph(this.div,{style:style,duration:this.options.duration,afterFinish:this._hideDiv.bind(this)});},_showWindow:function(){this.div.hide();this.window.element.show();},_hideDiv:function(){this.div.hide();}}
var BrowserDetect={init:function(){this.browser=this.searchString(this.dataBrowser)||"An unknown browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";this.OS=this.searchString(this.dataOS)||"an unknown OS";},searchString:function(data){for(var i=0;i<data.length;i++){var dataString=data[i].string;var dataProp=data[i].prop;this.versionSearchString=data[i].versionSearch||data[i].identity;if(dataString){if(dataString.indexOf(data[i].subString)!=-1)
return data[i].identity;}
else if(dataProp)
return data[i].identity;}},searchVersion:function(dataString){var index=dataString.indexOf(this.versionSearchString);if(index==-1)return;return parseFloat(dataString.substring(index+this.versionSearchString.length+1));},dataBrowser:[{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari"},{prop:window.opera,identity:"Opera"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],dataOS:[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]};BrowserDetect.init();function gotourl(url){document.location.href=url;}
function showThickbox(header,body,footer,box_height,box_width){if(box_width==null)box_width=329;if(box_height==null)box_height=210;var boxid='thickbox';var img='';if(box_width>329){boxid+='_long';img='_l';}
try{var divHTML='<div id="'+boxid+'" class="thickbox" style="height:'+box_height+'px;overflow:hidden">';divHTML+=' <div class="header clear">'+header+'</div>';divHTML+=' <div class="clear"><img src="/img/bg_box_title_line'+img+'.gif" width="'+box_width+'" height="14" border="0" alt="line" /></div>';divHTML+=' <div class="body clear">'+body+'</div>';divHTML+=' <div class="clear"><img src="/img/bg_box_footer_line'+img+'.gif" width="'+box_width+'" height="14" border="0" alt="line" /></div>';divHTML+=' <div class="footer clear">'+footer+'</div>';divHTML+='</div>';Dialog.info(unescape(divHTML),{className:boxid,width:box_width,height:box_height});}catch(err){alert(err);}}
function showThickbox2(header,body,footer,box_height,box_width){if(box_width==null)box_width=329;if(box_height==null)box_height=210;var boxid='thickbox';var img='';if(box_width>329){boxid+='_long';img='_l';}
try{var divHTML='<div id="'+boxid+'" class="thickbox" style="height:'+box_height+'px;overflow:hidden">';divHTML+=' <div class="header clear">'+header+'</div>';divHTML+=' <div class="clear"><img src="/img/bg_box_title_line'+img+'.gif" width="'+box_width+'" height="14" border="0" alt="line" /></div>';divHTML+=' <div class="body clear">'+body+'</div>';divHTML+=' <div class="clear"><img src="/img/bg_box_footer_line'+img+'.gif" width="'+box_width+'" height="14" border="0" alt="line" /></div>';divHTML+=' <div class="footer clear">'+footer+'</div>';divHTML+='</div>';Dialog.info(unescape(divHTML),{className:boxid,width:box_width,height:box_height});}catch(err){alert(err);}}
function setSearchURL(type){form=document.getElementById('searchbox');if(type=='songs'){form.action='/site/search/song';}else if(type=='artists'){form.action='/site/search/artist';}else if(type=='users'){form.action='/users/searchUsers';}}
function gwGoSearch(form){if(form.keyword.value==''){return false;}
var url='';var category=0;if(form.search_type.value=='forums'){url='http://www.guitarworld.com/forums/search.php?terms=all&author=&sc=1&sf=all&sr=posts&sk=t&sd=d&st=0&ch=300&t=0&submit=Search&keywords=';}else if(form.search_type.value=='tabs_artists'){url='/site/search/artist?search_type=artists&keyword=';}else if(form.search_type.value=='tabs_songs'){url='/site/search/song?search_type=songs&keyword=';}else if(form.search_type.value=='tabs_users'){url='/users/searchUsers?keyword=';}else if(form.sitesearch_category.value=='tabs_users'){url='/users/searchUsers?keyword=';}else if(form.search_type.value>0){url='http://www.guitarworld.com/search/node/';category=form.search_type.value;}else{url='http://www.guitarworld.com/search/node/';}
url+=escape(form.keyword.value);if(category>0){url+='%2Bcategory%253A'+category;}
document.location.href=url;return false;}
function validateSearch(){if(document.getElementById('keyword').value==''||document.getElementById('keyword').value=='Search'){alert("Please enter keyword");document.searchbox.keyword.value='';event.returnValue=false;}}
function sprintf(){if(!arguments||arguments.length<1||!RegExp){return;}
var str=arguments[0];var re=/([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/;var a=b=[],numSubstitutions=0,numMatches=0;while(a=re.exec(str)){var leftpart=a[1],pPad=a[2],pJustify=a[3],pMinLength=a[4];var pPrecision=a[5],pType=a[6],rightPart=a[7];numMatches++;if(pType=='%'){subst='%';}else{numSubstitutions++;if(numSubstitutions>=arguments.length){alert('Error! Not enough function arguments ('+(arguments.length-1)+', excluding the string)\nfor the number of substitution parameters in string ('+numSubstitutions+' so far).');}
var param=arguments[numSubstitutions];var pad='';if(pPad&&pPad.substr(0,1)=="'")pad=leftpart.substr(1,1);else if(pPad)pad=pPad;var justifyRight=true;if(pJustify&&pJustify==="-")justifyRight=false;var minLength=-1;if(pMinLength)minLength=parseInt(pMinLength);var precision=-1;if(pPrecision&&pType=='f')precision=parseInt(pPrecision.substring(1));var subst=param;if(pType=='b')subst=parseInt(param).toString(2);else if(pType=='c')subst=String.fromCharCode(parseInt(param));else if(pType=='d')subst=parseInt(param)?parseInt(param):0;else if(pType=='u')subst=Math.abs(param);else if(pType=='f')subst=(precision>-1)?Math.round(parseFloat(param)*Math.pow(10,precision))/Math.pow(10,precision):parseFloat(param);else if(pType=='o')subst=parseInt(param).toString(8);else if(pType=='s')subst=param;else if(pType=='x')subst=(''+parseInt(param).toString(16)).toLowerCase();else if(pType=='X')subst=(''+parseInt(param).toString(16)).toUpperCase();}
str=leftpart+subst+rightPart;}
return str;}
function printf(){var num=arguments.length;var oStr=arguments[0];for(var i=1;i<num;i++){var pattern="\\{"+(i-1)+"\\}";var re=new RegExp(pattern,"g");oStr=oStr.replace(re,arguments[i]);}
return oStr;}
function isValid(pattern,str){return pattern.test(str);}
function isValidEmail(str){var emailexp=/^[A-Za-z_0-9'\.\-]+@[A-Za-z_0-9'\.\-]+(\.\w+)+$/;var vcheck=isValid(emailexp,str);return vcheck;}
var posX=0;var posY=0;document.onmousedown=mouseDown;function mouseDown(ev){ev=ev||window.event;if(ev.pageX||ev.pageY){posX=ev.pageX;posY=ev.pageY;}else{posX=ev.clientX+document.body.scrollLeft-document.body.clientLeft;posY=ev.clientY+document.body.scrollTop-document.body.clientTop;}}
function sendLink(type,id){var width=400;var height=240;var left=posX-375;var top=posY;var win=new Window('emailWin',{title:"",url:'/site/emailForm/',maximizable:false,minimizable:false,draggable:false,resizable:false,screenY:top,screenX:left,top:top,left:left,width:width,height:height,showEffectOptions:{duration:null}});win.setDestroyOnClose();win.show();}
function sendEmail(form){var toEmail=document.getElementById('toEmail').value;var fromEmail=document.getElementById('fromEmail').value;if(!isValidEmail(toEmail)){alert('To E-mail is not a valid e-mail address');return false;}
if(!isValidEmail(fromEmail)){alert('From E-mail is not a valid e-mail address');return false;}
var query=buildQuery(form);var emailForm=$('send_email_msg');form.action+='?'+query;var comm=document.getElementById('comments');var message_html='<center><font color="#252525" >Please wait ...</font></center>';emailForm.update(message_html);emailForm.show();new Ajax.Request(form.action,{method:'get',onSuccess:function(transport){try{var response=transport.responseXML;if(response){var message=response.getElementsByTagName('message')[0].childNodes[0].nodeValue;var message_html='<center><font color="#252525" ><strong>'+message+'</strong></font></center>';emailForm.update(message_html);emailForm.show();setTimeout('Windows.closeAll()',5000);}}catch(err){setTimeout('window.location.href="'+redirect+'"',3000);}},onFailure:function(){alert('321');}});}
function feedback(){var header='<span class="title left">Give us your feedback!</span>';header+='<span class="close"><a href="javascript:void(0)" onclick="Windows.closeAll();return false;"><img '
+' src="/img/button_close.gif" width="17" height="17" border="0" alt="close" /></a></span>';var text='<div id="send_email_msg" style="height:250px;width:100%;display:none"></div>'
text+='<div name="EmailForm" id="EmailForm">'
+'<form action="/site/ajaxSendEmail/feedback" id="sendFeedbackForm" method="post"><table cellpadding="0" border="0" width="300"><tbody>'
+'<input type="hidden" name="data[Site][location]" value="'+document.location.href+'"/>'
+'<input type="hidden" name="data[Site][toemail]" id="toEmail" value="tabsfeedback@guitarworld.com"/>'
+'<tr>'
+'<td style="font-weight:bold;padding-top:10px">From:</td>'
+' <td colspan="2" style="padding-top:10px">'
+'<input style="width:245px;" type="text" '
+'name="data[Site][fromemail]" id="fromEmail" onfocus="if(this.value==\'Your E-mail Address\'){this.value=\'\'}" '
+'onblur="if(this.value==\'\'){this.value=\'Your E-mail Address\'}" value="Your E-mail Address"/></td>'
+'</tr>'
+'<tr><td style="font-weight:bold" width="40">Subject:</td>'
+'<td colspan="2">'
+'<input style="width:245px;" type="text" '
+'name="data[Site][subject]" id="subject" value=""/></td>'
+'</tr>'
+'<tr>'
+'<td style="font-weight:bold;padding-top:10px" colspan="3">Comments:<br />'
+'<textarea style="width:100%;" '
+' rows="3" name="data[Site][comments]" id="comments"></textarea></td></tr>'
+'<tbody></table></form></div>';var footer='';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="Windows.closeAll();return false;">Cancel</a>';footer+='   </div><div class="sort_left"></div>';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="sendEmail(document.getElementById(\'sendFeedbackForm\'));return false;">Send E-mail</a>';footer+='   </div><div class="sort_left"></div>';showThickbox(header,text,footer,285);}
function showEmail(title,id){var header='<span class="title left">E-mail to a Friend</span>';header+='<span class="close"><a href="javascript:void(0)" onclick="Windows.closeAll();return false;"><img '
+' src="/img/button_close.gif" width="17" height="17" border="0" alt="close" /></a></span>';var text='<div id="send_email_msg" style="height:250px;width:100%;display:none"></div>'
text+='<div name="EmailForm" id="EmailForm">'
+'<form action="/site/ajaxSendEmail/sendlink" id="sendEmailForm" method="post"><table cellpadding="0" border="0" width="300"><tbody>'
+'<input type="hidden" name="data[Site][subject]" value="replace this"/>'
+'<input type="hidden" name="data[Site][location]" value="'+escape(document.location.href)+'"/>'
+'<tr><td style="font-weight:bold" width="40">To:</td>'
+'<td colspan="2">'
+'<input style="width:245px;" type="text" '
+'name="data[Site][toemail]" id="toEmail" onfocus=\'if(this.value=="Your Friend&#39;s E-mail Address"){this.value=""}\' '
+'onblur=\'if(this.value==""){this.value="Your Friend&#39;s E-mail Address"}\' value="Your Friend&#39;s E-mail Address"/></td>'
+'</tr>'
+'<tr>'
+'<td style="font-weight:bold;padding-top:10px">From:</td>'
+' <td colspan="2" style="padding-top:10px">'
+'<input style="width:245px;" type="text" '
+'name="data[Site][fromemail]" id="fromEmail" onfocus="if(this.value==\'Your E-mail Address\'){this.value=\'\'}" '
+'onblur="if(this.value==\'\'){this.value=\'Your E-mail Address\'}" value="Your E-mail Address"/></td>'
+'</tr>'
+'<tr>'
+'<td style="font-weight:bold;padding-top:10px" colspan="3">Comments:<br />'
+'<textarea style="width:100%;" '
+' rows="3" name="data[Site][comments]" id="comments"></textarea></td></tr>'
+'<tbody></table></form></div>';var footer='';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="Windows.closeAll();return false;">Cancel</a>';footer+='   </div><div class="sort_left"></div>';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="sendEmail(document.getElementById(\'sendEmailForm\'));return false;">Send E-mail</a>';footer+='   </div><div class="sort_left"></div>';showThickbox(header,text,footer,285);}
function buildQuery(form)
{var query="";for(var i=0;i<form.elements.length;i++)
{var key=form.elements[i].name;var value=escape(getElementValue(form.elements[i]));if(key&&value)
{query+=key+"="+value+"&";}}
return query;}
function getElementValue(formElement)
{if(formElement.length!=null)var type=formElement[0].type;if((typeof(type)=='undefined')||(type==0))var type=formElement.type;switch(type)
{case'undefined':return;case'radio':for(var x=0;x<formElement.length;x++)
if(formElement[x].checked==true)
return formElement[x].value;case'select-multiple':var myArray=new Array();for(var x=0;x<formElement.length;x++)
if(formElement[x].selected==true)
myArray[myArray.length]=formElement[x].value;return myArray;case'checkbox':return formElement.checked;default:return formElement.value;}}
function showNoArtist(type){var header='<span class="title left">Don\'t See the Artist?</span>';header+='<span class="close"><a href="javascript:void(0)" onclick="Windows.closeAll();return false;"><img '
+' src="/img/button_close.gif" width="17" height="17" border="0" alt="close" /></a></span>';var text='<div>Guitar World Tabs is not yet authorized to provide ';if(type=='tab')
text+='tablature';else
text+='videos';text+=' by the artist you requested. Please check back soon.</div>';var footer='';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="Windows.closeAll();return false;">OK</a>';footer+='   </div><div class="sort_left"></div>';showThickbox(header,text,footer,162);}
function showCCSecurityHelp(type){var header='<span class="title left">What is Security Code</span>';header+='<span class="close"><a href="javascript:void(0)" onclick="Windows.closeAll();return false;"><img '
+' src="/img/button_close.gif" width="17" height="17" border="0" alt="close" /></a></span>';var text='<div>In order for your transaction to be accepted and processed, we need to validate your security code. '+'This is for your protection. For American Express, the security code is the 4-digit number printed on the front '+'of your card just above and to the right of your main credit card number. For MasterCard and Visa, flip your card '+'over and look at the signature box. You should see your 16-digit credit card number followed by a special 3-digit code. '+'This 3-digit code is the credit card security code.</div>';var footer='';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="Windows.closeAll();return false;">OK</a>';footer+='   </div><div class="sort_left"></div>';showThickbox(header,text,footer,240,450);}
function showFailSubscriptionHelp(type){var header='<span class="title left">Credit Card Process Failed</span>';header+='<span class="close"><a href="javascript:void(0)" onclick="Windows.closeAll();return false;"><img '
+' src="/img/button_close.gif" width="17" height="17" border="0" alt="close" /></a></span>';var text='<div>We were unable to renew your subscription due to a billing problem. '+'Please review and update your Billing Information to re-subscribe. </div>';var footer='';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="Windows.closeAll();return false;">OK</a>';footer+='   </div><div class="sort_left"></div>';showThickbox(header,text,footer,160);}
function showFailSubscriptionHelp2(type){var header='<span class="title left">Billing Error </span>';header+='<span class="close"><a href="javascript:void(0)" onclick="Windows.closeAll();return false;"><img '
+' src="/img/button_close.gif" width="17" height="17" border="0" alt="close" /></a></span>';var text='<div>Please review and update your Billing Information in order to subscribe.</div>';var footer='';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="Windows.closeAll();return false;">OK</a>';footer+='   </div><div class="sort_left"></div>';showThickbox(header,text,footer,160);}
function showFailSubscriptionHelp3(){var header='<span class="title left">Subscription Disabled</span>';header+='<span class="close"><a href="javascript:void(0)" onclick="Windows.closeAll();return false;"><img '
+' src="/img/button_close.gif" width="17" height="17" border="0" alt="close" /></a></span>';var text='<div>The subscription for this tab has been disabled because we experienced problems processing your credit card. ';text+='Please review and update your Billing Information and then re-subscribe to this premium tab in Manage Your Subscriptions.</div>';var footer='';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="Windows.closeAll();return false;">OK</a>';footer+='   </div><div class="sort_left"></div>';showThickbox(header,text,footer,200);}
function showPremiumTabHelp(type){var header='<span class="title left">Guitar World Premium Tabs:</span>';header+='<span class="close"><a href="javascript:void(0)" onclick="Windows.closeAll();return false;"><img '
+' src="/img/button_close.gif" width="17" height="17" border="0" alt="close" /></a></span>';var text='<div>';text+='<p>Get the gold standard of guitar tablature for only $0.99 per month</p>';text+='<ul>';text+='<li>Preview for Free!</li>';text+='<li>Meticulously transcribed by the Guitar World experts.</li>';text+='<li>Available online only at Guitar World Tabs.</li>';text+='<li>Full screen view; auto-scroll; section marking; auto-play</li>';text+='</ul>';text+='</div>';var footer='';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="Windows.closeAll();return false;">OK</a>';footer+='   </div><div class="sort_left"></div>';showThickbox(header,text,footer,210,400);}
function charLeft(textareaObj,objStr,maxCharsAllowed,showAlert){var countObj=document.getElementById(''+objStr);var temp=document.getElementById('char_'+objStr);if(textareaObj.value.length>maxCharsAllowed){textareaObj.value=textareaObj.value.substring(0,maxCharsAllowed);if(countObj){countObj.innerHTML=maxCharsAllowed-textareaObj.value.length;}
temp.innerHTML='Character';if(showAlert){alert("The maximum number of characters for this field is "+maxCharsAllowed+" ! ");}
return false;}else if(countObj){countObj.innerHTML=maxCharsAllowed-textareaObj.value.length;}
if(countObj.innerHTML=="0"||countObj.innerHTML=="1"){temp.innerHTML='Character';}else{temp.innerHTML='Characters';}}
function checkNewsletterForm(){if(!isValidEmail(document.subscribeForm.elements['Email Address'].value)){document.subscribeForm.elements['Email Address'].style.backgroundColor='#ffe269';alert("Please enter a valid Email Address. (name@host.com)");document.subscribeForm.elements['Email Address'].focus();return false;}}
function getElementPosition(obj,k){var kk=0;if(k=='y'){if(typeof(obj.offsetTop)!=undefined)kk=obj.offsetTop;if(typeof(obj.offsetParent)!=undefined&&(obj.offsetParent!=null))
kk+=getElementPosition(obj.offsetParent,'y');}
else if(k=='x'){if(typeof(obj.offsetLeft)!=undefined)kk=obj.offsetLeft;if(typeof(obj.offsetParent)!=undefined&&(obj.offsetParent!=null))
kk+=getElementPosition(obj.offsetParent,'x');}else{return{x:getElementPosition(obj,'x'),y:getElementPosition(obj,'y')};}
return kk;}
function shredR2Vote(link){var header='<span class="title left">Warning!</span>';header+='<span class="close"><a href="javascript:void(0)" onclick="Windows.closeAll();return false;"><img '
+' src="/img/button_close.gif" width="17" height="17" border="0" alt="close" /></a></span>';var text='<div><p>For the final round of Shred the Web, you can only vote for ONE finalist! Once you cast your vote, you won\'t be able to change it.</p> ';text+='<br /><p>Are you sure you want to cast your vote?</p></div>';var footer='';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="Windows.closeAll();return false;">No, thanks</a>';footer+='   </div><div class="sort_left"></div>';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="setTimeout(\'window.location.href=\\\''+link.href+'\\\'\', 1000);">Yes</a>';footer+='   </div><div class="sort_left"></div>';showThickbox(header,text,footer,200);}
function showLogin(type,redirect,div_type,obj_id,score){var header='<span class="title">Login</span><span class="lpad10"><a href="/gw_user/users/register">Register Now!</a></span>';var divHTML=' <div id="float_login_msg" style="display:none;text-align:center;text-transform:uppercase"></div>';divHTML+=' <div id="float_login_section">';divHTML+='  <form action="#" method="post" id="float_login_form" onsubmit="floatLogin(\''+redirect+'\', \''+type+'\', \''+div_type+'\', '+obj_id+', '+score+');return false;">';divHTML+='  <fieldset>';divHTML+='    <div class="field_left">Username:</div>';divHTML+='    <div class="field_right"><input type="text" style="width:215px" name="data[TabsUser][user_name]"  id="float_login_user_name" size="27" value="" /></div>';divHTML+='    <div class="field_left clear tpad10">Password:</div>';divHTML+='    <div class="field_right tpad10"><input type="password" id="float_login_password" style="width:215px" name="data[TabsUser][password]"  size="27" value="" /></div>';divHTML+='    <div class="field_left clear tpad10">&nbsp;</div>';divHTML+='    <div class="field_right tpad10"><input type="checkbox" name="keep_login" id="keep_login" value="1" />&nbsp;Keep me logged in</div>';divHTML+='    <div class="field_right"><input type="image" src="/img/pixel.gif" width="1" height="1" /></div>';divHTML+='  </fieldset>';divHTML+='  </form>';divHTML+=' </div>';var footer='  <div class="left"><a href="#" onclick="showSendPassword();return false;">Forgot Your Password?</a></div>';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="Windows.closeAll();return false;">Cancel</a>';footer+='   </div><div class="sort_left"></div>';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="floatLogin(\''+redirect+'\', \''+type+'\', \''+div_type+'\', '+obj_id+', '+score+');return false;">Login</a>';footer+='   </div><div class="sort_left"></div>';showThickbox(header,divHTML,footer,195);setTimeout("document.getElementById('float_login_user_name').focus()",2000);}
function floatLogin(redirect,type,div_type,obj_id,score){if(type==null&&!type)type='float';var form=$('float_login_form');var msg='';if(form.elements["data[TabsUser][user_name]"].value.length>3&&form.elements["data[TabsUser][password]"].value.length>=2){attempLogin(form.elements["data[TabsUser][user_name]"].value,form.elements["data[TabsUser][password]"].value,type,redirect,div_type,obj_id,score);}else{msg='Please enter valid username/password to login';showLoginError(type,msg);}}
function floatSecureLogin(type,artistName,songName,TabId,endDate,unitPrice){if(type==null&&!type)type='subscribe';var form=$('float_login_form');var msg='';if(form.elements["data[TabsUser][user_name]"].value.length>3&&form.elements["data[TabsUser][password]"].value.length>=2){attempSecureLogin(form.elements["data[TabsUser][user_name]"].value,form.elements["data[TabsUser][password]"].value,type,escape(artistName),escape(songName),TabId,endDate,unitPrice);}else{msg='Please enter valid username/password to login';showLoginError(type,msg);}}
function userLogin(redirect){var form=$('user_login_form');var msg='';if(form.elements["data[TabsUser][user_name]"].value.length>3&&form.elements["data[TabsUser][password]"].value.length>=2){attempLogin(form.elements["data[TabsUser][user_name]"].value,form.elements["data[TabsUser][password]"].value,'user_login',redirect);}else{msg='Please enter valid username/password to login';showLoginMsg('right',msg);}}
function attempLogin(username,password,login_type,redirect,div_type,obj_id,score){showLoginWait(login_type,'');if(redirect==null||redirect=='null'||redirect==''||redirect=='undefined'||redirect.length<2){var action='window.location.reload();';}else{var action='window.location.href="'+redirect+'";';}
var keep_login=document.getElementById('keep_login').checked;var now=new Date();new Ajax.Request('/gw_user/users/getAjaxLogin/'+escape(username)+'/'+escape(password)+'/'+keep_login+'?'+now.getTime(),{method:'get',onSuccess:function(transport){try{var response=transport.responseXML;if(response){var code=response.getElementsByTagName('code')[0].childNodes[0].nodeValue;var message=response.getElementsByTagName('message')[0].childNodes[0].nodeValue;if(code==200){if(login_type=='rating'&&div_type&&obj_id&&score){submitRating(div_type,obj_id,score,1);}
showLoginWait(login_type,'');setTimeout(action,1000);}else if(code==300){var gotourl=response.getElementsByTagName('gotourl')[0].childNodes[0].nodeValue;var url_action='window.location.href="'+gotourl+'";';showLoginError(login_type,message);setTimeout(url_action,500);}else{showLoginError(login_type,message);}}else{setTimeout(action,1500);}}catch(err){setTimeout(action,1500);}},onFailure:function(){showLoginMsg(login_type,'An error occurred while processing your request. Please contact the Administrator')}});}
function attempSecureLogin(username,password,login_type,artistName,songName,TabId,endDate,unitPrice){showLoginWait(login_type,'');var now=new Date();new Ajax.Request(_https_host+'/gw_user/users/getAjaxSecureLogin/'+escape(username)+'/'+escape(password)+'?'+now.getTime(),{method:'get',onSuccess:function(transport){try{var response=transport.responseXML;if(response){var code=response.getElementsByTagName('code')[0].childNodes[0].nodeValue;var message=response.getElementsByTagName('message')[0].childNodes[0].nodeValue;if(code==200){if(login_type=='cancel_subscription'){showBillUnSubscriptionConfirm(escape(songName),TabId,endDate);}else if(login_type=='re_subscription'){showBillReSubscriptionConfirm(escape(songName),TabId,unitPrice);}else if(login_type=='subscribed_again_all'){showBillAllSubscriptionConfirm();}else{showBillSubscriptionConfirm(escape(artistName),escape(songName),TabId,unitPrice);}}else if(code==201){showAddCreditCardConfirm();}else if(code==300){var gotourl=response.getElementsByTagName('gotourl')[0].childNodes[0].nodeValue;var url_action='window.location.href="'+gotourl+'";';showLoginError(login_type,message);setTimeout(url_action,500);}else{showLoginError(login_type,message);}}else{showLoginError(login_type,'Error occurs while process reponse from server');}}catch(err){showLoginError(login_type,'Error occurs while process reponse from server');}},onFailure:function(){showLoginMsg(login_type,'An error occurred while processing your request. Please contact the Administrator')}});}
function showLoginWait(type,attchment){var message='Logging in...';if(type!='user_login')
message+='<br /><br /><img src="/img/spinner.gif" alt="login_spinner" />';message+=attchment;showLoginMsg(type,message);}
function showLoginError(type,message){if(type=='user_login'){message='<font color=#8000000">'+message+'</font>';}else{message+='<center><div style="margin-top:10px;width:145px">';message+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';message+='    <a href="javascript:void(0)" onclick="Windows.closeAll();return false;">Cancel</a>';message+='   </div><div class="sort_left"></div>';message+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';message+='    <a href="javascript:void(0)" onclick="$(\'float_login_msg\').hide();return false;">Try Again</a>';message+='   </div><div class="sort_left"></div>';message+='<div class="clear"></div></div></center>';}
showLoginMsg(type,message);}
function showLoginMsg(type,message){if(type=='user_login'){$('user_login_msg').innerHTML=message;$('user_login_msg').style.paddingBottom='2px';$('user_login_msg').show();}else{$('float_login_msg').innerHTML=message;$('float_login_msg').show();}}
function showSendPassword(title,id){var header='<span class="title left">Forgot Your Password?</span>';header+='<span class="close"><a href="javascript:void(0)" onclick="Windows.closeAll();return false;"><img '
+' src="/img/button_close.gif" width="17" height="17" border="0" alt="close" /></a></span>';var text='<div id="send_password_msg" style="height:150px;display:none;text-align:center;text-transform:uppercase"></div>'
text+='<div name="EmailForm" id="EmailForm" style="margin-bottom:10px">'
+'<p>Please enter your E-mail address below.</p><br />'
+'<form action="#" method="post" onsubmit="sendPassword(document.getElementById(\'EmailForm\'));return false;"><table '
+' cellpadding="0" border="0" width="300"><tbody>'
+'<tr><td style="font-weight:bold" width="40">E-mail:</td>'
+'<td colspan="2">'
+'<input style="width:245px;" type="text" '
+'name="data[Site][toemail]" id="sendPasswordEmail" onfocus=\'if(this.value=="Your E-mail Address"){this.value=""}\' '
+'onblur=\'if(this.value==""){this.value="Your E-mail Address"}\' value="Your E-mail Address"/></td>'
+'</tr>'
+'<tbody></table></form></div>';var footer='';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="Windows.closeAll();return false;">Cancel</a>';footer+='   </div><div class="sort_left"></div>';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="sendPassword(document.getElementById(\'EmailForm\'));return false;">Send New Password</a>';footer+='   </div><div class="sort_left"></div>';showThickbox(header,text,footer,180);}
function sendPassword(form){var email=document.getElementById('sendPasswordEmail').value;if(!isValidEmail(email)){showPasswordError('Please enter is not a valid email address');return false;}
showPasswordMsg('Please wait...<br /><br /><img src="/img/spinner.gif" alt="login_spinner" />');var now=new Date();var url='/gw_user/users/forgotPassword/'+escape(email)+'?'+now.getTime();new Ajax.Request(url,{method:'get',onSuccess:function(transport){try{var response=transport.responseXML;if(response){var code=response.getElementsByTagName('code')[0].childNodes[0].nodeValue;var message=response.getElementsByTagName('message')[0].childNodes[0].nodeValue;if(code==200){showPasswordMsg(message);setTimeout('Windows.closeAll()',5000);}else{showPasswordError(message);}}else{showPasswordError('Error occurs while trying to process your request.');}}catch(err){setTimeout('window.location.href="'+redirect+'"',1500);}},onFailure:function(){showPasswordError('Error occurs while trying to process your request.');}});}
function showPasswordError(message){message+='<center><div style="margin-top:10px;width:145px">';message+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';message+='    <a href="javascript:void(0)" onclick="Windows.closeAll();return false;">Cancel</a>';message+='   </div><div class="sort_left"></div>';message+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';message+='    <a href="javascript:void(0)" onclick="$(\'send_password_msg\').hide();return false;">Try Again</a>';message+='   </div><div class="sort_left"></div>';message+='<div class="clear"></div></div></center>';showPasswordMsg(message);}
function showPasswordMsg(message){$('send_password_msg').innerHTML=message;$('send_password_msg').show();}
function showLoginPopup(type,redirect,div_type,obj_id,score){window.open('/gw_user/users/popupLogin/'+div_type+'/'+obj_id+'/'+score,'RatingPopupLogin','width=300, height=130, resizable=yes');}
function showSecureLogin(type,artistName,songName,TabId,endDate,unitPrice){var header='<span class="title left">Premium Tab Subscription</span>';header+='<span class="close"><a href="javascript:void(0)" onclick="Windows.closeAll();return false;"><img '
+' src="/img/button_close.gif" width="17" height="17" border="0" alt="close" /></a></span>';if(type=='cancel_subscription'){header+='<span class="left">To cancel your subscription, please log in using the secure server.</span>';}else if(type=='re_subscription'){header+='<span class="left">To renew your subscription, please log in using the secure server.</span>';}else if(type=='subscribed_again_all'){header+='<span class="left">Subscribing to Premium Tabs is Easy</span>';}else{header+='<span class="left">Subscribing to Premium Tabs is Easy</span>';}
var divHTML=' <div id="float_login_msg" style="display:none;text-align:center;text-transform:uppercase"></div>';divHTML+=' <div id="float_login_section">';divHTML+='  <form action="#" method="post" id="float_login_form" onsubmit="floatSecureLogin(\''+type+'\', \''+escape(artistName)+'\', \''+escape(songName)+'\', '+TabId+', \''+endDate+'\', \''+unitPrice+'\');return false;">';divHTML+='  <fieldset>';divHTML+='    <div class="field_left rpad7" style="width:160px;text-align:right">Enter your username:</div>';divHTML+='    <div class="field_right"><input type="text" style="width:215px" name="data[TabsUser][user_name]"  id="float_login_user_name" size="27" value="" /></div>';divHTML+='    <div class="field_left clear tpad10 rpad7" style="width:160px;text-align:right">Password:</div>';divHTML+='    <div class="field_right tpad10"><input type="password" id="float_login_password" style="width:215px" name="data[TabsUser][password]"  size="27" value="" /></div>';divHTML+='    <div class="field_right tpad10"><input type="hidden" name="keep_login" id="keep_login" value="1" /></div>';divHTML+='    <div class="field_right"><input type="image" src="/img/pixel.gif" width="1" height="1" /></div>';divHTML+='  </fieldset>';divHTML+='  </form>';divHTML+=' </div>';var footer='';footer+='   <div class="sort_right"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="Windows.closeAll();return false;">Cancel</a>';footer+='   </div><div class="sort_left"></div>';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="floatSecureLogin(\''+type+'\', \''+escape(artistName)+'\', \''+escape(songName)+'\', '+TabId+', \''+endDate+'\', \''+unitPrice+'\');return false;">Login Using our Secure Server</a>';footer+='   </div><div class="sort_left"></div>';footer+='   <div class="right" style="padding-top: 10px;"><a href="#" onclick="window.location.href=\'/gw_user/users/register\';return false;">Don\'t have an account? Create one now</a>>></div>';footer+='   ';showThickbox2(header,divHTML,footer,200,450);setTimeout("document.getElementById('float_login_user_name').focus()",2000);}
function showAddCreditCardConfirm(TabId){if(readPremiumCookie('premium_tab_user')){var header='<div style="height:40px;">';header+='<span class="title left">Premium Tab Subscription</span>';header+='<span class="close"><a href="javascript:void(0)" onclick="Windows.closeAll();return false;"><img '
+' src="/img/button_close.gif" width="17" height="17" border="0" alt="close" /></a></span>';header+='</div>';var divHTML='<div style="height:45px;">';divHTML+='<span style="padding:0px 5px;"><img src="/img/warning.gif" width="16" height="16" border="0" alt="warning" style="vertical-align: middle;" /></span>';divHTML+='<span style="font-size:13px;">You Do Not Have a Credit Card Associated with Your Account</span><br />';divHTML+='<span style="font-size:10px;padding-left:30px;">To complete this purchase, please add a credit card to your account</span>';divHTML+='</div>';var footer='<div style="padding-top:10px;">';footer+='   <div class="sort_right"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="addCreditCardAccount();return false;">Add a Credit Card to My Account</a>';footer+='   </div><div class="sort_left"></div>';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="Windows.closeAll();return false;">Cancel</a>';footer+='   </div><div class="sort_left"></div>';footer+='</div>';showThickbox2(header,divHTML,footer,200,450);}else{window.location.href='/gw_user/users/sslLogin?refer=/billing/manage&redirect=/billing/register/'+TabId;}}
function showBillSubscriptionConfirm(artistName,songName,TabId,unitPrice){if(readPremiumCookie('premium_tab_user')){var dotsString=getDotsString(artistName,songName);var header='<div style="height:30px;">';var priceStr='';if(unitPrice<1)
priceStr+=(unitPrice*100)+'&cent;';else if(unitPrice>=1)
priceStr+='$'+unitPrice;header+='<span class="title left">Premium Tab Subscription</span>';header+='<span class="close"><a href="javascript:void(0)" onclick="Windows.closeAll();return false;"><img '
+' src="/img/button_close.gif" width="17" height="17" border="0" alt="close" /></a></span>';header+='</div>';var divHTML='<div style="height:45px;">';divHTML+='<span style="font-size:12px;">Please confirm that you\'d like to subscribe to the follow tab:</span><br /><br />';divHTML+='<span style="font-size:12px;"><strong>'+escape(artistName)+' -- '+escape(songName)+'</strong> '+dotsString+' '+priceStr+'/30 days</span>';divHTML+='</div>';var footer='<div style="padding-top:10px;">';footer+='   <div class="sort_right"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="Windows.closeAll();return false;">Cancel</a>';footer+='   </div><div class="sort_left"></div>';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="/billing/subscribe/'+TabId+'">Bill My Account</a>';footer+='   </div><div class="sort_left"></div>';footer+='</div>';showThickbox2(header,divHTML,footer,200,450);}else{showSecureLogin('float_login');}}
function showBillReSubscriptionConfirm(songName,TabId,unitPrice){var dotsString=getDotsString('',escape(songName));var header='<div style="height:30px;">';var priceStr='';if(unitPrice<1)
priceStr+=(unitPrice*100)+'&cent;';else if(unitPrice>=1)
priceStr+='$'+unitPrice;header+='<span class="title left">Manage Your Subscriptions - Renew</span>';header+='<span class="close"><a href="javascript:void(0)" onclick="Windows.closeAll();return false;"><img '
+' src="/img/button_close.gif" width="17" height="17" border="0" alt="close" /></a></span>';header+='</div>';var divHTML='<div style="height:45px;">';divHTML+='<span style="font-size:12px;">Please confirm that you\'d like to renew subscription to the follow tab:</span><br /><br />';divHTML+='<span style="font-size:12px;"><strong>'+escape(songName)+'</strong> '+dotsString+' '+priceStr+'/30 days</span>';divHTML+='</div>';var footer='<div style="padding-top:10px;">';footer+='   <div class="sort_right"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="Windows.closeAll();return false;">Never Mind</a>';footer+='   </div><div class="sort_left"></div>';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="/billing/subscribe/'+TabId+'/manage">Renew Subscription</a>';footer+='   </div><div class="sort_left"></div>';footer+='</div>';showThickbox2(header,divHTML,footer,200,450);}
function showBillAllSubscriptionConfirm(){if(readPremiumCookie('premium_tab_user')){var header='<div style="height:30px;">';header+='<span class="title left">Manage Your Subscriptions - Renew All</span>';header+='<span class="close"><a href="javascript:void(0)" onclick="Windows.closeAll();return false;"><img '
+' src="/img/button_close.gif" width="17" height="17" border="0" alt="close" /></a></span>';header+='</div>';var divHTML='<div style="height:45px;">';divHTML+='<span style="font-size:12px;">Please confirm that you\'d like to renew all expired tab subscriptions.</span>';divHTML+='</div>';var footer='<div style="padding-top:10px;">';footer+='   <div class="sort_right"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="Windows.closeAll();return false;">Never Mind</a>';footer+='   </div><div class="sort_left"></div>';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="/billing/subscribeAllFailed">Renew All Subscriptions</a>';footer+='   </div><div class="sort_left"></div>';footer+='</div>';showThickbox2(header,divHTML,footer,200,450);}else{showSecureLogin('subscribed_again_all');}}
function showBillUnSubscriptionConfirm(songName,tabId,endDate){var header='<div style="height:30px;">';header+='<span class="title left">Manage Your Subscriptions - Cancel</span>';header+='<span class="close"><a href="javascript:void(0)" onclick="Windows.closeAll();return false;"><img '
+' src="/img/button_close.gif" width="17" height="17" border="0" alt="close" /></a></span>';header+='</div>';var divHTML='<div style="height:65px;">';divHTML+='<span style="font-size:13px;">Are you sure you want to cancel your subscription for ';divHTML+='<strong>"'+escape(songName)+'"?</strong></span><br /><br />';divHTML+='<span style="font-size:13px; color: #800000;">Your last date of access will be ';divHTML+=endDate+'</span>';divHTML+='</div>';var footer='<div style="padding-top:10px;">';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="Windows.closeAll();return false;">No Thanks</a>';footer+='   </div><div class="sort_left"></div>';footer+='   <div class="sort_right"></div><div class="sort_center">';footer+='    <a href="/billing/unsubscribe/'+tabId+'">Cancel Subscription</a>';footer+='   </div><div class="sort_left"></div>';footer+='</div>';showThickbox2(header,divHTML,footer,200,450);}
function readPremiumCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;}
function addCreditCardAccount(uid,tid){window.location.href='/billing/register/'+uid+'/'+tid+'?refer='+window.location.href;}
function getDotsString(artistName,songName){var num=0;var str='';num=60-artistName.length-songName.length;for(var i=0;i<num;i++){str+='.';}
return str;}
function subscribeFromPreview(subscribedFnc){subscribedFnc=unescape(subscribedFnc);if(subscribedFnc=='')
setTimeout('alert(\'There is a problem processing you request.\')',100);else if(subscribedFnc=='subscribed()'){setTimeout('alert(\'You subscribed this tab already. Enjoy it!\')',100);setTimeout('window.close()',200);}else{subscribedFnc='window.opener.'+subscribedFnc;setTimeout(subscribedFnc,100);setTimeout('window.close()',200);}}
function reloadCurrentPage(){window.location.reload();}
function ShredTheWebVideoDescription(){var header='<div style="height:30px;">';header+='<span class="title left">What\'s this?</span>';header+='<span class="close"><a href="javascript:void(0)" onclick="Windows.closeAll();return false;"><img '
+' src="/img/button_close.gif" width="17" height="17" border="0" alt="close" /></a></span>';header+='</div>';var divHTML='<div style="height:55px;">';divHTML+='<span style="font-size:13px;">Songs not selected from our database must be original compositions. Cover songs are not allowed.</span>';divHTML+='</div>';var footer='<div>';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="Windows.closeAll();return false;">OK</a>';footer+='   </div><div class="sort_left"></div>';footer+='</div>';showThickbox2(header,divHTML,footer,175);}
function showAbuse(type,obj_id,subtitle){var title='Report Abuse on This';if(type=='user'){title+=' User';}else if(type=='user_comment'){title+=' User Comment';}else if(type=='tab_comment'){title+=' Tab Comment';}else if(type=='video_comment'){title+=' Video Comment';}else if(type=='song_comment'){title+=' Song Comment';}else if(type=='artist_comment'){title+=' Artist Comment';}else if(type=='tab'){title+=' User-Submitted Tab';}else if(type=='video'){title+=' Video';}
var width=200;if((type=='user'||type=='tab'||type=='video')&&subtitle){if(subtitle.length>33){subtitle=subtitle.substring(0,30)+'...';}
title+='<br>from "'+unescape(subtitle.replace(/\+/g,' '))+'"';width=225;}
var url='/simple_comment/abuses/submitAbuseReport/'+type+'/'+obj_id+'/'+escape(title);var header='<span class="title left" style="width:405px">'+title+'</span>';header+='<span class="close"><a href="javascript:void(0)" onclick="Windows.closeAll();return false;"><img '
+' src="/img/button_close.gif" width="17" height="17" border="0" alt="close" /></a></span>';var divHTML=' <div id="complain_msg" style="height:200px;width:100%;display:none"></div>';divHTML+=' <div id="complain_section">';divHTML+='  <form action="#">';divHTML+='  <fieldset>';divHTML+='    <div style="font-weight:bold;">Please leave a short comment:<br />';divHTML+='    <textarea name="comment" style="width:450px;height:60px;" id="simple_comment_complain"></textarea></div>';divHTML+='  </fieldset>';divHTML+='  </form>';divHTML+=' </div>';var footer='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="Windows.closeAll();return false;">Cancel</a>';footer+='   </div><div class="sort_left"></div>';footer+='   <div class="sort_right" style="margin-right:3px"></div><div class="sort_center">';footer+='    <a href="javascript:void(0)" onclick="$(\''+type+obj_id+'\').hide();sendComplain(\''+url+'\');return false;">Submit Report</a>';footer+='   </div><div class="sort_left"></div>';showThickbox(header,divHTML,footer,width,487);}
function sendComplain(url){var now=new Date();var comment=escape($('simple_comment_complain').value);url+='?comment='+comment+'&'+now.getTime();new Ajax.Request(url,{method:'get',onSuccess:function(transport){try{var response=transport.responseText;showComplainMsg(response);setTimeout('Windows.closeAll()',5000);}catch(err){setTimeout('window.location.reload()',1000);}},onFailure:function(){showComplainMsg(login_type,'An error occurred while processing your request. Please contact the Administrator')}});}
function showComplainMsg(msg){$('complain_msg').innerHTML=msg;$('complain_msg').show();}
var transUpValue=1;var transDownValue=0.3;var floatArr=new Array('left','right');function getScrollXY(){var scrOfX=0,scrOfY=0;if(typeof(window.pageYOffset)=='number'){scrOfY=window.pageYOffset;scrOfX=window.pageXOffset;}else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){scrOfY=document.body.scrollTop;scrOfX=document.body.scrollLeft;}else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){scrOfY=document.documentElement.scrollTop;scrOfX=document.documentElement.scrollLeft;}
return{x:scrOfX,y:scrOfY};}
function createMenu(permittedItems){var role=document.createElement('div');role.setAttribute('id','role');role.style.position='absolute';role.style.left=getScrollXY().x+'px';role.style.top=getScrollXY().y+'px';role.style.background='#000000';role.style.visibility='visible';role.style.borderBottom='1px solid #0000FF';role.style.width='100%';role.style.fontWeight='bold';role.style.fontSize='12px';role.onmouseover=mouseOnMenu;role.onmouseout=mouseOutMenu;role.style.filter="alpha(opacity="+(100*transDownValue)+")";role.style.MozOpacity=transDownValue;for(var i=0;i<permittedItems.length;i++)
addMenu(role,permittedItems[i]);document.body.appendChild(role);Event.observe(window,"scroll",setMenuOnTop);}
function createMenu2(permittedItems){var role=document.getElementById('admin_tools');var tbl1=document.createElement('table');tbl1.style.width='100%';var th=document.createElement('thead');var tr=document.createElement('tr');var textObj=document.createTextNode('Admin tools area:');var tdObj=document.createElement('td');tdObj.style.fontWeight='bold';tdObj.appendChild(textObj);tr.appendChild(tdObj);th.appendChild(tr);tbl1.appendChild(th);var tbl2=document.createElement('table');tbl2.style.width='100%';var tbody=document.createElement('tbody');for(var i=0;i<permittedItems.length;i++){if(i%3==0)var r=document.createElement('tr');addMenu(r,permittedItems[i],i%3);if((i+1)%3==0||i+1==permittedItems.length)tbody.appendChild(r);}
tbl2.appendChild(tbody);role.appendChild(tbl1);role.appendChild(tbl2);}
function setMenuOnTop(){document.getElementById("role").style.left=getScrollXY().x+"px";document.getElementById("role").style.top=getScrollXY().y+"px";}
function mouseOnMenu(event){document.getElementById('role').style.filter="alpha(opacity="+(100*transUpValue)+")";document.getElementById('role').style.MozOpacity=transUpValue;}
function mouseOutMenu(){document.getElementById('role').style.filter="alpha(opacity="+(100*transDownValue)+")";document.getElementById('role').style.MozOpacity=transDownValue;}
function addMenu(parentObj,arr,newrow){var linkObj=document.createElement('a');var textObj=document.createTextNode(unescape(arr.text));linkObj.setAttribute('href',arr.url);linkObj.appendChild(textObj);var tdObj=document.createElement('td');if(newrow==0)tdObj.style.width='60px';tdObj.style.fontWeight='bold';tdObj.appendChild(linkObj);parentObj.appendChild(tdObj);parentObj.onreadystatechange=function(){if(/complete|loaded/.test(parentObj.readyState)){alert('JS onreadystate fired');}}
parentObj.onload=function(){alert('JS onload fired');}
return false;}
function addMenu2(parentObj,arr){var textObj=document.createTextNode(unescape(arr.text));var spanObj=document.createElement('span');spanObj.style.fontWeight='bold';spanObj.appendChild(textObj);var linkObj=document.createElement('a');linkObj.setAttribute('href',arr.url);if(arr.sub==1)linkObj.setAttribute('onclick',"return confirm('Are you sure?');");linkObj.appendChild(spanObj);var obj=document.createElement('span');obj.id=arr.name;obj.setAttribute('style','margin: 0 6px 0 6px; float: '+floatArr[arr.sub]);obj.style.styleFloat=floatArr[arr.sub];obj.style.margin='0 6px';obj.appendChild(linkObj);parentObj.appendChild(obj);}
function mouseOnText(menu){menu.target.style.color='#FF00FF';}
function mouseOuttext(menu){menu.target.style.color='#FFFFFF';}
var _FUTUREUS_SIMPLE_RATING_MAX_STARS=5;var _FUTUREUS_SIMPLE_RATING_STARS_SELECTED=new Array();function selectRating(obj_id,num){if(_FUTUREUS_SIMPLE_RATING_STARS_SELECTED[obj_id]>0)return false;var key='futureus_simple_rating_'+obj_id+'_';for(var i=0;i<num;i++){document.getElementById(key+i).src='/img/star_you.png';}
for(var i=num;i<_FUTUREUS_SIMPLE_RATING_MAX_STARS;i++){document.getElementById(key+i).src='/img/star_off.png';}}
function submitRating(type,obj_id,score,userid,popup){_FUTUREUS_SIMPLE_RATING_STARS_SELECTED[obj_id]=score;if(userid==null||userid<=0){if(popup>0)
showLoginPopup('rating',null,type,obj_id,score);else
showLogin('rating',null,type,obj_id,score);return false;}
var now=new Date();new Ajax.Request('/simple_rating/ratings/submitRating/'+type+'/'+obj_id+'/'+score+'?'+now.getTime(),{method:'get',onSuccess:function(transport){try{var response=transport.responseXML;if(response){var userRating=document.getElementById('futureus_simple_rating_text_'+obj_id);if(userRating)userRating.innerHTML='You Voted:';var rating_voted=document.getElementById('futureus_simple_rating_voted_'+obj_id);if(rating_voted){var html="";if(score>0){html='<img src="/img/featured_videos_rate_pos.gif" width="25" height="21" border="0" alt="Thumbs Up" />';}else{html='<img src="/img/featured_videos_rate_neg.gif" width="25" height="21" border="0" alt="Thumbs Down" />';}
rating_voted.innerHTML=html;}
var new_score=response.getElementsByTagName('all_time_rating')[0].childNodes[0].nodeValue;var new_votes=response.getElementsByTagName('total_rated')[0].childNodes[0].nodeValue;setAvgRating(obj_id,Math.floor(parseFloat(new_score)+0.5),parseFloat(new_votes));}else{window.location.reload();}}catch(err){window.location.reload();}},onFailure:function(){window.location.reload();}});}
function setAvgRating(obj_id,num,votes){var rating_img=document.getElementById('futureus_simple_rating_img_'+obj_id);var rating_score=document.getElementById('futureus_simple_rating_score_'+obj_id);var rating_votes=document.getElementById('futureus_simple_rating_votes_'+obj_id);var rating_rate=document.getElementById('futureus_simple_rating_rate_'+obj_id);if(rating_votes)rating_votes.innerHTML=votes;if(rating_rate){var html="";if(num>0){html='<img src="/img/rate_plus.gif" width="15" height="15" border="0" align="left" alt="score: '+num+'" class="rate_sign" />';}else if(num<0){html='<img src="/img/rate_minus.gif" width="15" height="15" border="0" align="left" alt="score: '+num+'" class="rate_sign" />';}else{html='<img src="/img/rate_zero.gif" width="15" height="15" border="0" align="left" alt="score: '+num+'" class="rate_sign" />';}
html+=' '+num;rating_rate.innerHTML=html;}else{if(rating_score)rating_score.innerHTML=num;if(rating_img){if(num>0){rating_img.src="/img/rate_plus.gif";}else if(num<0){rating_img.src="/img/rate_minus.gif";}else{rating_img.src="/img/rate_zero.gif";}}}}