
function dbg(t){$('dbg').show();$('dbg').innerHTML+=t+'<br>';}
function ut(){var foo=new Date;var unixtime_ms=foo.getTime();var unixtime=parseInt(unixtime_ms/1000);return unixtime;}
function hbl(){a=$('weblinks');a.hide();}
if(typeof Effect=='undefined')
throw("lightwindow.js requires including script.aculo.us' effects.js library!");try{document.execCommand("BackgroundImageCache",false,true);}catch(e){}
var lightwindow=Class.create();lightwindow.prototype={element:null,contentToFetch:null,windowActive:false,dataEffects:[],dimensions:{cruft:null,container:null,viewport:{height:null,width:null,offsetTop:null,offsetLeft:null}},pagePosition:{x:0,y:0},pageDimensions:{width:null,height:null},preloadImage:[],preloadedImage:[],galleries:[],resizeTo:{height:null,heightPercent:null,width:null,widthPercent:null,fixedTop:null,fixedLeft:null},scrollbarOffset:18,navigationObservers:{previous:null,next:null},containerChange:{height:0,width:0},activeGallery:false,galleryLocation:{current:0,total:0},initialize:function(options){this.options=Object.extend({resizeSpeed:8,contentOffset:{height:20,width:20},dimensions:{image:{height:250,width:250},page:{height:250,width:250},inline:{height:250,width:250},media:{height:250,width:250},external:{height:250,width:250},titleHeight:25},classNames:{standard:'lightwindow',action:'lightwindow_action'},fileTypes:{page:['asp','aspx','cgi','cfm','htm','html','pl','php4','php3','php','php5','phtml','rhtml','shtml','txt','vbs','rb'],media:['aif','aiff','asf','avi','divx','m1v','m2a','m2v','m3u','mid','midi','mov','moov','movie','mp2','mp3','mpa','mpa','mpe','mpeg','mpg','mpg','mpga','pps','qt','rm','ram','swf','viv','vivo','wav'],image:['bmp','gif','jpg','png','tiff']},mimeTypes:{avi:'video/avi',aif:'audio/aiff',aiff:'audio/aiff',gif:'image/gif',bmp:'image/bmp',jpeg:'image/jpeg',m1v:'video/mpeg',m2a:'audio/mpeg',m2v:'video/mpeg',m3u:'audio/x-mpequrl',mid:'audio/x-midi',midi:'audio/x-midi',mjpg:'video/x-motion-jpeg',moov:'video/quicktime',mov:'video/quicktime',movie:'video/x-sgi-movie',mp2:'audio/mpeg',mp3:'audio/mpeg3',mpa:'audio/mpeg',mpa:'video/mpeg',mpe:'video/mpeg',mpeg:'video/mpeg',mpg:'audio/mpeg',mpg:'video/mpeg',mpga:'audio/mpeg',pdf:'application/pdf',png:'image/png',pps:'application/mspowerpoint',qt:'video/quicktime',ram:'audio/x-pn-realaudio-plugin',rm:'application/vnd.rn-realmedia',swf:'application/x-shockwave-flash',tiff:'image/tiff',viv:'video/vivo',vivo:'video/vivo',wav:'audio/wav',wmv:'application/x-mplayer2'},classids:{mov:'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',swf:'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000',wmv:'clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6'},codebases:{mov:'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0',swf:'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0',wmv:'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715'},viewportPadding:10,EOLASFix:'swf,wmv,fla,flv',overlay:{opacity:0.7,image:'images/lightwindow/black.png',presetImage:'images/lightwindow/black-70.png'},skin:{main:'<div id="lightwindow_container" >'+'<div id="lightwindow_title_bar" >'+'<div id="lightwindow_title_bar_inner" >'+'<span id="lightwindow_title_bar_title"></span>'+'<a id="lightwindow_title_bar_close_link" >close</a>'+'</div>'+'</div>'+'<div id="lightwindow_stage" >'+'<div id="lightwindow_contents" >'+'</div>'+'<div id="lightwindow_navigation" >'+'<a href="#" id="lightwindow_previous" >'+'<span id="lightwindow_previous_title"></span>'+'</a>'+'<a href="#" id="lightwindow_next" >'+'<span id="lightwindow_next_title"></span>'+'</a>'+'<iframe name="lightwindow_navigation_shim" id="lightwindow_navigation_shim" src="javascript:false;" frameBorder="0" scrolling="no"></iframe>'+'</div>'+'<div id="lightwindow_galleries">'+'<div id="lightwindow_galleries_tab_container" >'+'<a href="#" id="lightwindow_galleries_tab" >'+'<span id="lightwindow_galleries_tab_span" class="up" >Galleries</span>'+'</a>'+'</div>'+'<div id="lightwindow_galleries_list" >'+'</div>'+'</div>'+'</div>'+'<div id="lightwindow_data_slide" >'+'<div id="lightwindow_data_slide_inner" >'+'<div id="lightwindow_data_details" >'+'<div id="lightwindow_data_gallery_container" >'+'<span id="lightwindow_data_gallery_current"></span>'+' of '+'<span id="lightwindow_data_gallery_total"></span>'+'</div>'+'<div id="lightwindow_data_author_container" >'+'by <span id="lightwindow_data_author"></span>'+'</div>'+'</div>'+'<div id="lightwindow_data_caption" >'+'</div>'+'</div>'+'</div>'+'</div>',loading:'<div id="lightwindow_loading" >'+'<img src="images/lightwindow/ajax-loading.gif" alt="loading" />'+'<span>Loading or <a href="javascript: myLightWindow.deactivate();">Cancel</a></span>'+'<iframe name="lightwindow_loading_shim" id="lightwindow_loading_shim" src="javascript:false;" frameBorder="0" scrolling="no"></iframe>'+'</div>',iframe:'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'+'<html xmlns="http://www.w3.org/1999/xhtml">'+'<body>'+'{body_replace}'+'</body>'+'</html>',gallery:{top:'<div class="lightwindow_galleries_list">'+'<h1>{gallery_title_replace}</h1>'+'<ul>',middle:'<li>'+'{gallery_link_replace}'+'</li>',bottom:'</ul>'+'</div>'}},formMethod:'get',hideFlash:false,hideGalleryTab:false,showTitleBar:true,animationHandler:false,navigationHandler:false,transitionHandler:false,finalAnimationHandler:false,formHandler:false,galleryAnimationHandler:false,showGalleryCount:true},options||{});this.duration=((11-this.options.resizeSpeed)*0.15);this._setupLinks();this._getScroll();this._getPageDimensions();this._browserDimensions();this._addLightWindowMarkup(false);this._setupDimensions();this.buildGalleryList();},activate:function(e,link){this._clearWindowContents(true);this._addLoadingWindowMarkup();this._setupWindowElements(link);this._getScroll();this._browserDimensions();this._setupDimensions();this._toggleTroubleElements('hidden',false);this._displayLightWindow('block','hidden');this._setStatus(true);this._monitorKeyboard(true);this._prepareIE(true);this._loadWindow();},deactivate:function(){this.windowActive=false;this.activeGallery=false;if(!this.options.hideGalleryTab){this._handleGalleryAnimation(false);}
this.animating=false;this.element=null;this._displayLightWindow('none','visible');this._clearWindowContents(false);var queue=Effect.Queues.get('lightwindowAnimation').each(function(e){e.cancel();});this._prepareIE(false);this._setupDimensions();this._toggleTroubleElements('visible',false);this._monitorKeyboard(false);},createWindow:function(element,attributes){this._processLink($(element));},activateWindow:function(options){this.element=Object.extend({href:null,title:null,author:null,caption:null,rel:null,top:null,left:null,type:null,showImages:null,height:null,width:null,loadingAnimation:null,iframeEmbed:null,form:null},options||{});this.contentToFetch=this.element.href;this.windowType=this.element.type?this.element.type:this._fileType(this.element.href);this._clearWindowContents(true);this._addLoadingWindowMarkup();this._getScroll();this._browserDimensions();this._setupDimensions();this._toggleTroubleElements('hidden',false);this._displayLightWindow('block','hidden');this._setStatus(true);this._monitorKeyboard(true);this._prepareIE(true);this._loadWindow();},submitForm:function(e){if(this.options.formHandler){this.options.formHandler(e);}else{this._defaultFormHandler(e);}},openWindow:function(element){var element=$(element);this.windowActive=true;this._clearWindowContents(true);this._addLoadingWindowMarkup();this._setupWindowElements(element);this._setStatus(true);this._handleTransition();},navigateWindow:function(direction){this._handleNavigation(false);if(direction=='previous'){this.openWindow(this.navigationObservers.previous);}else if(direction=='next'){this.openWindow(this.navigationObservers.next);}},buildGalleryList:function(){var output='';var galleryLink;for(i in this.galleries){if(typeof this.galleries[i]=='object'){output+=(this.options.skin.gallery.top).replace('{gallery_title_replace}',unescape(i));for(j in this.galleries[i]){if(typeof this.galleries[i][j]=='object'){galleryLink='<a href="#" id="lightwindow_gallery_'+i+'_'+j+'" >'+unescape(j)+'</a>';output+=(this.options.skin.gallery.middle).replace('{gallery_link_replace}',galleryLink);}}
output+=this.options.skin.gallery.bottom;}}
new Insertion.Top('lightwindow_galleries_list',output);for(i in this.galleries){if(typeof this.galleries[i]=='object'){for(j in this.galleries[i]){if(typeof this.galleries[i][j]=='object'){Event.observe($('lightwindow_gallery_'+i+'_'+j),'click',this.openWindow.bind(this,this.galleries[i][j][0]),false);$('lightwindow_gallery_'+i+'_'+j).onclick=function(){return false;};}}}}},_setupLinks:function(){var links=$$('.'+this.options.classNames.standard);links.each(function(link){this._processLink(link);}.bind(this));},_processLink:function(link){if((this._fileType(link.getAttribute('href'))=='image'||this._fileType(link.getAttribute('href'))=='media')){if(gallery=this._getGalleryInfo(link.rel)){if(!this.galleries[gallery[0]]){this.galleries[gallery[0]]=new Array();}
if(!this.galleries[gallery[0]][gallery[1]]){this.galleries[gallery[0]][gallery[1]]=new Array();}
this.galleries[gallery[0]][gallery[1]].push(link);}}
var url=link.getAttribute('href');if(url.indexOf('?')>-1){url=url.substring(0,url.indexOf('?'));}
var container=url.substring(url.indexOf('#')+1);if($(container)){$(container).setStyle({display:'none'});}
Event.observe(link,'click',this.activate.bindAsEventListener(this,link),false);link.onclick=function(){return false;};},_setupActions:function(){var links=$$('#lightwindow_container .'+this.options.classNames.action);links.each(function(link){Event.observe(link,'click',this[link.getAttribute('rel')].bindAsEventListener(this,link),false);link.onclick=function(){return false;};}.bind(this));},_addLightWindowMarkup:function(rebuild){var overlay=Element.extend(document.createElement('div'));overlay.setAttribute('id','lightwindow_overlay');if(Prototype.Browser.Gecko){overlay.setStyle({backgroundImage:'url('+this.options.overlay.presetImage+')',backgroundRepeat:'repeat',height:this.pageDimensions.height+'px'});}else{overlay.setStyle({opacity:this.options.overlay.opacity,backgroundImage:'url('+this.options.overlay.image+')',backgroundRepeat:'repeat',height:this.pageDimensions.height+'px'});}
var lw=document.createElement('div');lw.setAttribute('id','lightwindow');lw.innerHTML=this.options.skin.main;var body=document.getElementsByTagName('body')[0];body.appendChild(overlay);body.appendChild(lw);if($('lightwindow_title_bar_close_link')){Event.observe('lightwindow_title_bar_close_link','click',this.deactivate.bindAsEventListener(this));$('lightwindow_title_bar_close_link').onclick=function(){return false;};}
Event.observe($('lightwindow_previous'),'click',this.navigateWindow.bind(this,'previous'),false);$('lightwindow_previous').onclick=function(){return false;};Event.observe($('lightwindow_next'),'click',this.navigateWindow.bind(this,'next'),false);$('lightwindow_next').onclick=function(){return false;};if(!this.options.hideGalleryTab){Event.observe($('lightwindow_galleries_tab'),'click',this._handleGalleryAnimation.bind(this,true),false);$('lightwindow_galleries_tab').onclick=function(){return false;};}
if(Prototype.Browser.IE){Event.observe(document,'mousewheel',this._stopScrolling.bindAsEventListener(this),false);}else{Event.observe(window,'DOMMouseScroll',this._stopScrolling.bindAsEventListener(this),false);}
Event.observe(overlay,'click',this.deactivate.bindAsEventListener(this),false);overlay.onclick=function(){return false;};},_addLoadingWindowMarkup:function(){$('lightwindow_contents').innerHTML+=this.options.skin.loading;},_setupWindowElements:function(link){this.element=link;this.element.title=null?'':link.getAttribute('title');this.element.author=null?'':link.getAttribute('author');this.element.caption=null?'':link.getAttribute('caption');this.element.rel=null?'':link.getAttribute('rel');this.element.params=null?'':link.getAttribute('params');this.contentToFetch=this.element.href;this.windowType=this._getParameter('lightwindow_type')?this._getParameter('lightwindow_type'):this._fileType(this.contentToFetch);},_clearWindowContents:function(contents){if($('lightwindow_iframe')){Element.remove($('lightwindow_iframe'));}
if($('lightwindow_media_primary')){try{$('lightwindow_media_primary').Stop();}catch(e){}
Element.remove($('lightwindow_media_primary'));}
if($('lightwindow_media_secondary')){try{$('lightwindow_media_secondary').Stop();}catch(e){}
Element.remove($('lightwindow_media_secondary'));}
this.activeGallery=false;this._handleNavigation(this.activeGallery);if(contents){$('lightwindow_contents').innerHTML='';$('lightwindow_contents').setStyle({overflow:'hidden'});if(!this.windowActive){$('lightwindow_data_slide_inner').setStyle({display:'none'});$('lightwindow_title_bar_title').innerHTML='';}
$('lightwindow_data_slide').setStyle({height:'auto'});}
this.resizeTo.height=null;this.resizeTo.width=null;},_setStatus:function(status){this.animating=status;if(status){Element.show('lightwindow_loading');}
if(!(/MSIE 6./i.test(navigator.userAgent))){this._fixedWindow(status);}},_fixedWindow:function(status){if(status){if(this.windowActive){this._getScroll();$('lightwindow').setStyle({position:'absolute',top:parseFloat($('lightwindow').getStyle('top'))+this.pagePosition.y+'px',left:parseFloat($('lightwindow').getStyle('left'))+this.pagePosition.x+'px'});}else{$('lightwindow').setStyle({position:'absolute'});}}else{if(this.windowActive){this._getScroll();$('lightwindow').setStyle({position:'fixed',top:parseFloat($('lightwindow').getStyle('top'))-this.pagePosition.y+'px',left:parseFloat($('lightwindow').getStyle('left'))-this.pagePosition.x+'px'});}else{if($('lightwindow_iframe')){this._browserDimensions();}
$('lightwindow').setStyle({position:'fixed',top:(parseFloat(this._getParameter('lightwindow_top'))?parseFloat(this._getParameter('lightwindow_top'))+'px':this.dimensions.viewport.height/2+'px'),left:(parseFloat(this._getParameter('lightwindow_left'))?parseFloat(this._getParameter('lightwindow_left'))+'px':this.dimensions.viewport.width/2+'px')});}}},_prepareIE:function(setup){if(Prototype.Browser.IE){var height,overflowX,overflowY;if(setup){var height='100%';}else{var height='auto';}
var body=document.getElementsByTagName('body')[0];var html=document.getElementsByTagName('html')[0];html.style.height=body.style.height=height;}},_stopScrolling:function(e){if(this.animating){if(e.preventDefault){e.preventDefault();}
e.returnValue=false;}},_getScroll:function(){window.scrollTo(0,0);if(typeof(window.pageYOffset)=='number'){this.pagePosition.x=window.pageXOffset;this.pagePosition.y=window.pageYOffset;}else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){this.pagePosition.x=document.body.scrollLeft;this.pagePosition.y=document.body.scrollTop;}else if(document.documentElement){this.pagePosition.x=document.documentElement.scrollLeft;this.pagePosition.y=document.documentElement.scrollTop;}},_setScroll:function(x,y){document.documentElement.scrollLeft=x;document.documentElement.scrollTop=y;},_toggleTroubleElements:function(visibility,content){if(content){var selects=$('lightwindow_contents').getElementsByTagName('select');}else{var selects=document.getElementsByTagName('select');}
for(var i=0;i<selects.length;i++){selects[i].style.visibility=visibility;}
if(!content){if(this.options.hideFlash){var objects=document.getElementsByTagName('object');for(i=0;i!=objects.length;i++){objects[i].style.visibility=visibility;}
var embeds=document.getElementsByTagName('embed');for(i=0;i!=embeds.length;i++){embeds[i].style.visibility=visibility;}}
var iframes=document.getElementsByTagName('iframe');for(i=0;i!=iframes.length;i++){iframes[i].style.visibility=visibility;}}},_getPageDimensions:function(){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;}
var windowWidth,windowHeight;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){this.pageDimensions.height=windowHeight;}else{this.pageDimensions.height=yScroll;}
if(xScroll<windowWidth){this.pageDimensions.width=windowWidth;}else{this.pageDimensions.width=xScroll;}},_displayLightWindow:function(display,visibility){$('lightwindow_overlay').style.display=$('lightwindow').style.display=$('lightwindow_container').style.display=display;$('lightwindow_overlay').style.visibility=$('lightwindow').style.visibility=$('lightwindow_container').style.visibility=visibility;},_setupDimensions:function(){var originalHeight,originalWidth;switch(this.windowType){case'page':originalHeight=this.options.dimensions.page.height;originalWidth=this.options.dimensions.page.width;break;case'image':originalHeight=this.options.dimensions.image.height;originalWidth=this.options.dimensions.image.width;break;case'media':originalHeight=this.options.dimensions.media.height;originalWidth=this.options.dimensions.media.width;break;case'external':originalHeight=this.options.dimensions.external.height;originalWidth=this.options.dimensions.external.width;break;case'inline':originalHeight=this.options.dimensions.inline.height;originalWidth=this.options.dimensions.inline.width;break;default:originalHeight=this.options.dimensions.page.height;originalWidth=this.options.dimensions.page.width;break;}
var offsetHeight=this._getParameter('lightwindow_top')?parseFloat(this._getParameter('lightwindow_top'))+this.pagePosition.y:this.dimensions.viewport.height/2+this.pagePosition.y;var offsetWidth=this._getParameter('lightwindow_left')?parseFloat(this._getParameter('lightwindow_left'))+this.pagePosition.x:this.dimensions.viewport.width/2+this.pagePosition.x;$('lightwindow').setStyle({top:offsetHeight+'px',left:offsetWidth+'px'});$('lightwindow_container').setStyle({height:originalHeight+'px',width:originalWidth+'px',left:-(originalWidth/2)+'px',top:-(originalHeight/2)+'px'});$('lightwindow_contents').setStyle({height:originalHeight+'px',width:originalWidth+'px'});},_fileType:function(url){var image=new RegExp("[^\.]\.("+this.options.fileTypes.image.join('|')+")\s*$","i");if(image.test(url))return'image';if(url.indexOf('#')>-1&&(document.domain==this._getDomain(url)))return'inline';if(url.indexOf('?')>-1)url=url.substring(0,url.indexOf('?'));var type='unknown';var page=new RegExp("[^\.]\.("+this.options.fileTypes.page.join('|')+")\s*$","i");var media=new RegExp("[^\.]\.("+this.options.fileTypes.media.join('|')+")\s*$","i");if(document.domain!=this._getDomain(url))type='external';if(media.test(url))type='media';if(type=='external'||type=='media')return type;if(page.test(url)||url.substr((url.length-1),url.length)=='/')type='page';return type;},_fileExtension:function(url){if(url.indexOf('?')>-1){url=url.substring(0,url.indexOf('?'));}
var extenstion='';for(var x=(url.length-1);x>-1;x--){if(url.charAt(x)=='.'){return extenstion;}
extenstion=url.charAt(x)+extenstion;}},_monitorKeyboard:function(status){if(status)document.onkeydown=this._eventKeypress.bind(this);else document.onkeydown='';},_eventKeypress:function(e){if(e==null){var keycode=event.keyCode;}else{var keycode=e.which;}
switch(keycode){case 27:this.deactivate();break;case 13:return;default:break;}
if(this.animating){return false;}
switch(String.fromCharCode(keycode).toLowerCase()){case'p':if(this.navigationObservers.previous){this.navigateWindow('previous');}
break;case'n':if(this.navigationObservers.next){this.navigateWindow('next');}
break;default:break;}},_getGalleryInfo:function(rel){if(!rel)return false;if(rel.indexOf('[')>-1){return new Array(escape(rel.substring(0,rel.indexOf('['))),escape(rel.substring(rel.indexOf('[')+1,rel.indexOf(']'))));}else{return false;}},_getDomain:function(url){var leadSlashes=url.indexOf('//');var domainStart=leadSlashes+2;var withoutResource=url.substring(domainStart,url.length);var nextSlash=withoutResource.indexOf('/');var domain=withoutResource.substring(0,nextSlash);if(domain.indexOf(':')>-1){var portColon=domain.indexOf(':');domain=domain.substring(0,portColon);}
return domain;},_getParameter:function(parameter,parameters){if(!this.element)return false;if(parameter=='lightwindow_top'&&this.element.top){return unescape(this.element.top);}else if(parameter=='lightwindow_left'&&this.element.left){return unescape(this.element.left);}else if(parameter=='lightwindow_type'&&this.element.type){return unescape(this.element.type);}else if(parameter=='lightwindow_show_images'&&this.element.showImages){return unescape(this.element.showImages);}else if(parameter=='lightwindow_height'&&this.element.height){return unescape(this.element.height);}else if(parameter=='lightwindow_width'&&this.element.width){return unescape(this.element.width);}else if(parameter=='lightwindow_loading_animation'&&this.element.loadingAnimation){return unescape(this.element.loadingAnimation);}else if(parameter=='lightwindow_iframe_embed'&&this.element.iframeEmbed){return unescape(this.element.iframeEmbed);}else if(parameter=='lightwindow_form'&&this.element.form){return unescape(this.element.form);}else{if(!parameters){if(this.element.params)parameters=this.element.params;else return;}
var value;var parameterArray=parameters.split(',');var compareString=parameter+'=';var compareLength=compareString.length;for(var i=0;i<parameterArray.length;i++){if(parameterArray[i].substr(0,compareLength)==compareString){var currentParameter=parameterArray[i].split('=');value=currentParameter[1];break;}}
if(!value)return false;else return unescape(value);}},_browserDimensions:function(){if(Prototype.Browser.IE){this.dimensions.viewport.height=document.documentElement.clientHeight;this.dimensions.viewport.width=document.documentElement.clientWidth;}else{this.dimensions.viewport.height=window.innerHeight;this.dimensions.viewport.width=document.width||document.body.offsetWidth;}},_getScrollerWidth:function(){var scrollDiv=Element.extend(document.createElement('div'));scrollDiv.setAttribute('id','lightwindow_scroll_div');scrollDiv.setStyle({position:'absolute',top:'-10000px',left:'-10000px',width:'100px',height:'100px',overflow:'hidden'});var contentDiv=Element.extend(document.createElement('div'));contentDiv.setAttribute('id','lightwindow_content_scroll_div');contentDiv.setStyle({width:'100%',height:'200px'});scrollDiv.appendChild(contentDiv);var body=document.getElementsByTagName('body')[0];body.appendChild(scrollDiv);var noScroll=$('lightwindow_content_scroll_div').offsetWidth;scrollDiv.style.overflow='auto';var withScroll=$('lightwindow_content_scroll_div').offsetWidth;Element.remove($('lightwindow_scroll_div'));this.scrollbarOffset=noScroll-withScroll;},_addParamToObject:function(name,value,object,id){var param=document.createElement('param');param.setAttribute('value',value);param.setAttribute('name',name);if(id){param.setAttribute('id',id);}
object.appendChild(param);return object;},_outerHTML:function(object){if(Prototype.Browser.IE){return object.outerHTML;}else{var clone=object.cloneNode(true);var cloneDiv=document.createElement('div');cloneDiv.appendChild(clone);return cloneDiv.innerHTML;}},_convertToMarkup:function(object,closeTag){var markup=this._outerHTML(object).replace('</'+closeTag+'>','');if(Prototype.Browser.IE){for(var i=0;i<object.childNodes.length;i++){markup+=this._outerHTML(object.childNodes[i]);}
markup+='</'+closeTag+'>';}
return markup;},_appendObject:function(object,closeTag,appendTo){if(Prototype.Browser.IE){appendTo.innerHTML+=this._convertToMarkup(object,closeTag);if(this.options.EOLASFix.indexOf(this._fileType(this.element.href))>-1){var objectElements=document.getElementsByTagName('object');for(var i=0;i<objectElements.length;i++){if(objectElements[i].getAttribute("data"))objectElements[i].removeAttribute('data');objectElements[i].outerHTML=objectElements[i].outerHTML;objectElements[i].style.visibility="visible";}}}else{appendTo.appendChild(object);}},_appendIframe:function(scroll){var iframe=document.createElement('iframe');iframe.setAttribute('id','lightwindow_iframe');iframe.setAttribute('name','lightwindow_iframe');iframe.setAttribute('src','about:blank');iframe.setAttribute('height','100%');iframe.setAttribute('width','100%');iframe.setAttribute('frameborder','0');iframe.setAttribute('marginwidth','0');iframe.setAttribute('marginheight','0');iframe.setAttribute('scrolling',scroll);this._appendObject(iframe,'iframe',$('lightwindow_contents'));},_writeToIframe:function(content){var template=this.options.skin.iframe;template=template.replace('{body_replace}',content);if($('lightwindow_iframe').contentWindow){$('lightwindow_iframe').contentWindow.document.open();$('lightwindow_iframe').contentWindow.document.write(template);$('lightwindow_iframe').contentWindow.document.close();}else{$('lightwindow_iframe').contentDocument.open();$('lightwindow_iframe').contentDocument.write(template);$('lightwindow_iframe').contentDocument.close();}},_loadWindow:function(){switch(this.windowType){case'image':var current=0;var images=[];this.checkImage=[];this.resizeTo.height=this.resizeTo.width=0;this.imageCount=this._getParameter('lightwindow_show_images')?parseInt(this._getParameter('lightwindow_show_images')):1;if(gallery=this._getGalleryInfo(this.element.rel)){for(current=0;current<this.galleries[gallery[0]][gallery[1]].length;current++){if(this.contentToFetch.indexOf(this.galleries[gallery[0]][gallery[1]][current].href)>-1){break;}}
if(this.galleries[gallery[0]][gallery[1]][current-this.imageCount]){this.navigationObservers.previous=this.galleries[gallery[0]][gallery[1]][current-this.imageCount];}else{this.navigationObservers.previous=false;}
if(this.galleries[gallery[0]][gallery[1]][current+this.imageCount]){this.navigationObservers.next=this.galleries[gallery[0]][gallery[1]][current+this.imageCount];}else{this.navigationObservers.next=false;}
this.activeGallery=true;}else{this.navigationObservers.previous=false;this.navigationObservers.next=false;this.activeGallery=false;}
for(var i=current;i<(current+this.imageCount);i++){if(gallery&&this.galleries[gallery[0]][gallery[1]][i]){this.contentToFetch=this.galleries[gallery[0]][gallery[1]][i].href;this.galleryLocation={current:(i+1)/this.imageCount,total:(this.galleries[gallery[0]][gallery[1]].length)/this.imageCount};if(!this.galleries[gallery[0]][gallery[1]][i+this.imageCount]){$('lightwindow_next').setStyle({display:'none'});}else{$('lightwindow_next').setStyle({display:'block'});$('lightwindow_next_title').innerHTML=this.galleries[gallery[0]][gallery[1]][i+this.imageCount].title;}
if(!this.galleries[gallery[0]][gallery[1]][i-this.imageCount]){$('lightwindow_previous').setStyle({display:'none'});}else{$('lightwindow_previous').setStyle({display:'block'});$('lightwindow_previous_title').innerHTML=this.galleries[gallery[0]][gallery[1]][i-this.imageCount].title;}}
images[i]=document.createElement('img');images[i].setAttribute('id','lightwindow_image_'+i);images[i].setAttribute('border','0');images[i].setAttribute('src',this.contentToFetch);$('lightwindow_contents').appendChild(images[i]);this.checkImage[i]=new PeriodicalExecuter(function(i){if(!(typeof $('lightwindow_image_'+i).naturalWidth!="undefined"&&$('lightwindow_image_'+i).naturalWidth==0)){this.checkImage[i].stop();var imageHeight=$('lightwindow_image_'+i).getHeight();if(imageHeight>this.resizeTo.height){this.resizeTo.height=imageHeight;}
this.resizeTo.width+=$('lightwindow_image_'+i).getWidth();this.imageCount--;$('lightwindow_image_'+i).setStyle({height:'100%'});if(this.imageCount==0){this._processWindow();}}}.bind(this,i),1);}
break;case'media':var current=0;this.resizeTo.height=this.resizeTo.width=0;if(gallery=this._getGalleryInfo(this.element.rel)){for(current=0;current<this.galleries[gallery[0]][gallery[1]].length;current++){if(this.contentToFetch.indexOf(this.galleries[gallery[0]][gallery[1]][current].href)>-1){break;}}
if(this.galleries[gallery[0]][gallery[1]][current-1]){this.navigationObservers.previous=this.galleries[gallery[0]][gallery[1]][current-1];}else{this.navigationObservers.previous=false;}
if(this.galleries[gallery[0]][gallery[1]][current+1]){this.navigationObservers.next=this.galleries[gallery[0]][gallery[1]][current+1];}else{this.navigationObservers.next=false;}
this.activeGallery=true;}else{this.navigationObservers.previous=false;this.navigationObservers.next=false;this.activeGallery=false;}
if(gallery&&this.galleries[gallery[0]][gallery[1]][current]){this.contentToFetch=this.galleries[gallery[0]][gallery[1]][current].href;this.galleryLocation={current:current+1,total:this.galleries[gallery[0]][gallery[1]].length};if(!this.galleries[gallery[0]][gallery[1]][current+1]){$('lightwindow_next').setStyle({display:'none'});}else{$('lightwindow_next').setStyle({display:'block'});$('lightwindow_next_title').innerHTML=this.galleries[gallery[0]][gallery[1]][current+1].title;}
if(!this.galleries[gallery[0]][gallery[1]][current-1]){$('lightwindow_previous').setStyle({display:'none'});}else{$('lightwindow_previous').setStyle({display:'block'});$('lightwindow_previous_title').innerHTML=this.galleries[gallery[0]][gallery[1]][current-1].title;}}
if(this._getParameter('lightwindow_iframe_embed')){this.resizeTo.height=this.dimensions.viewport.height;this.resizeTo.width=this.dimensions.viewport.width;}else{this.resizeTo.height=this._getParameter('lightwindow_height');this.resizeTo.width=this._getParameter('lightwindow_width');}
this._processWindow();break;case'external':this._appendIframe('auto');this.resizeTo.height=this.dimensions.viewport.height;this.resizeTo.width=this.dimensions.viewport.width;this._processWindow();break;case'page':var newAJAX=new Ajax.Request(this.contentToFetch,{method:'get',parameters:'',onComplete:function(response){$('lightwindow_contents').innerHTML+=response.responseText;this.resizeTo.height=$('lightwindow_contents').scrollHeight+(this.options.contentOffset.height);this.resizeTo.width=$('lightwindow_contents').scrollWidth+(this.options.contentOffset.width);this._processWindow();}.bind(this)});break;case'inline':var content=this.contentToFetch;if(content.indexOf('?')>-1){content=content.substring(0,content.indexOf('?'));}
content=content.substring(content.indexOf('#')+1);new Insertion.Top($('lightwindow_contents'),$(content).innerHTML);this.resizeTo.height=$('lightwindow_contents').scrollHeight+(this.options.contentOffset.height);this.resizeTo.width=$('lightwindow_contents').scrollWidth+(this.options.contentOffset.width);this._toggleTroubleElements('hidden',true);this._processWindow();break;default:throw("Page Type could not be determined, please amend this lightwindow URL "+this.contentToFetch);break;}},_resizeWindowToFit:function(){if(this.resizeTo.height+this.dimensions.cruft.height>this.dimensions.viewport.height){var heightRatio=this.resizeTo.height/this.resizeTo.width;this.resizeTo.height=this.dimensions.viewport.height-this.dimensions.cruft.height-(2*this.options.viewportPadding);if(this.windowType=='image'||(this.windowType=='media'&&!this._getParameter('lightwindow_iframe_embed'))){this.resizeTo.width=this.resizeTo.height/heightRatio;$('lightwindow_data_slide_inner').setStyle({width:this.resizeTo.width+'px'});}}
if(this.resizeTo.width+this.dimensions.cruft.width>this.dimensions.viewport.width){var widthRatio=this.resizeTo.width/this.resizeTo.height;this.resizeTo.width=this.dimensions.viewport.width-2*this.dimensions.cruft.width-(2*this.options.viewportPadding);if(this.windowType=='image'||(this.windowType=='media'&&!this._getParameter('lightwindow_iframe_embed'))){this.resizeTo.height=this.resizeTo.width/widthRatio;$('lightwindow_data_slide_inner').setStyle({height:this.resizeTo.height+'px'});}}},_presetWindowSize:function(){if(this._getParameter('lightwindow_height')){this.resizeTo.height=parseFloat(this._getParameter('lightwindow_height'));}
if(this._getParameter('lightwindow_width')){this.resizeTo.width=parseFloat(this._getParameter('lightwindow_width'));}},_processWindow:function(){this.dimensions.dataEffects=[];if(this.element.caption||this.element.author||(this.activeGallery&&this.options.showGalleryCount)){if(this.element.caption){$('lightwindow_data_caption').innerHTML=this.element.caption;$('lightwindow_data_caption').setStyle({display:'block'});}else{$('lightwindow_data_caption').setStyle({display:'none'});}
if(this.element.author){$('lightwindow_data_author').innerHTML=this.element.author;$('lightwindow_data_author_container').setStyle({display:'block'});}else{$('lightwindow_data_author_container').setStyle({display:'none'});}
if(this.activeGallery&&this.options.showGalleryCount){$('lightwindow_data_gallery_current').innerHTML=this.galleryLocation.current;$('lightwindow_data_gallery_total').innerHTML=this.galleryLocation.total;$('lightwindow_data_gallery_container').setStyle({display:'block'});}else{$('lightwindow_data_gallery_container').setStyle({display:'none'});}
$('lightwindow_data_slide_inner').setStyle({width:this.resizeTo.width+'px',height:'auto',visibility:'visible',display:'block'});$('lightwindow_data_slide').setStyle({height:$('lightwindow_data_slide').getHeight()+'px',width:'1px',overflow:'hidden',display:'block'});}else{$('lightwindow_data_slide').setStyle({display:'none',width:'auto'});$('lightwindow_data_slide_inner').setStyle({display:'none',visibility:'hidden',width:this.resizeTo.width+'px',height:'0px'});}
if(this.element.title!='null'){$('lightwindow_title_bar_title').innerHTML=this.element.title;}else{$('lightwindow_title_bar_title').innerHTML='';}
var originalContainerDimensions={height:$('lightwindow_container').getHeight(),width:$('lightwindow_container').getWidth()};$('lightwindow_container').setStyle({height:'auto',width:$('lightwindow_container').getWidth()+this.options.contentOffset.width-(this.windowActive?this.options.contentOffset.width:0)+'px'});var newContainerDimensions={height:$('lightwindow_container').getHeight(),width:$('lightwindow_container').getWidth()};this.containerChange={height:originalContainerDimensions.height-newContainerDimensions.height,width:originalContainerDimensions.width-newContainerDimensions.width};this.dimensions.container={height:$('lightwindow_container').getHeight(),width:$('lightwindow_container').getWidth()};this.dimensions.cruft={height:this.dimensions.container.height-$('lightwindow_contents').getHeight()+this.options.contentOffset.height,width:this.dimensions.container.width-$('lightwindow_contents').getWidth()+this.options.contentOffset.width};this._presetWindowSize();this._resizeWindowToFit();if(!this.windowActive){$('lightwindow_container').setStyle({left:-(this.dimensions.container.width/2)+'px',top:-(this.dimensions.container.height/2)+'px'});}
$('lightwindow_container').setStyle({height:this.dimensions.container.height+'px',width:this.dimensions.container.width+'px'});this._displayLightWindow('block','visible');this._animateLightWindow();},_animateLightWindow:function(){if(this.options.animationHandler){this.options.animationHandler().bind(this);}else{this._defaultAnimationHandler();}},_handleNavigation:function(display){if(this.options.navigationHandler){this.options.navigationHandler().bind(this,display);}else{this._defaultDisplayNavigation(display);}},_handleTransition:function(){if(this.options.transitionHandler){this.options.transitionHandler().bind(this);}else{this._defaultTransitionHandler();}},_handleFinalWindowAnimation:function(delay){if(this.options.finalAnimationHandler){this.options.finalAnimationHandler().bind(this,delay);}else{this._defaultfinalWindowAnimationHandler(delay);}},_handleGalleryAnimation:function(list){if(this.options.galleryAnimationHandler){this.options.galleryAnimationHandler().bind(this,list);}else{this._defaultGalleryAnimationHandler(list);}},_defaultDisplayNavigation:function(display){if(display){$('lightwindow_navigation').setStyle({display:'block',height:$('lightwindow_contents').getHeight()+'px',width:'100%',marginTop:this.options.dimensions.titleHeight+'px'});}else{$('lightwindow_navigation').setStyle({display:'none',height:'auto',width:'auto'});}},_defaultAnimationHandler:function(){if(this.element.caption||this.element.author||(this.activeGallery&&this.options.showGalleryCount)){$('lightwindow_data_slide').setStyle({display:'none',width:'auto'});this.dimensions.dataEffects.push(new Effect.SlideDown('lightwindow_data_slide',{sync:true}),new Effect.Appear('lightwindow_data_slide',{sync:true,from:0.0,to:1.0}));}
$('lightwindow_title_bar_inner').setStyle({height:'0px',marginTop:this.options.dimensions.titleHeight+'px'});this.dimensions.dataEffects.push(new Effect.Morph('lightwindow_title_bar_inner',{sync:true,style:{height:this.options.dimensions.titleHeight+'px',marginTop:'0px'}}),new Effect.Appear('lightwindow_title_bar_inner',{sync:true,from:0.0,to:1.0}));if(!this.options.hideGalleryTab){this._handleGalleryAnimation(false);if($('lightwindow_galleries_tab_container').getHeight()==0){this.dimensions.dataEffects.push(new Effect.Morph('lightwindow_galleries_tab_container',{sync:true,style:{height:'20px',marginTop:'0px'}}));$('lightwindow_galleries').setStyle({width:'0px'});}}
var resized=false;var ratio=this.dimensions.container.width-$('lightwindow_contents').getWidth()+this.resizeTo.width+this.options.contentOffset.width;if(ratio!=$('lightwindow_container').getWidth()){new Effect.Parallel([new Effect.Scale('lightwindow_contents',100*(this.resizeTo.width/$('lightwindow_contents').getWidth()),{scaleFrom:100*($('lightwindow_contents').getWidth()/($('lightwindow_contents').getWidth()+(this.options.contentOffset.width))),sync:true,scaleY:false,scaleContent:false}),new Effect.Scale('lightwindow_container',100*(ratio/(this.dimensions.container.width)),{sync:true,scaleY:false,scaleFromCenter:true,scaleContent:false})],{duration:this.duration,delay:0.25,queue:{position:'end',scope:'lightwindowAnimation'}});}
ratio=this.dimensions.container.height-$('lightwindow_contents').getHeight()+this.resizeTo.height+this.options.contentOffset.height;if(ratio!=$('lightwindow_container').getHeight()){new Effect.Parallel([new Effect.Scale('lightwindow_contents',100*(this.resizeTo.height/$('lightwindow_contents').getHeight()),{scaleFrom:100*($('lightwindow_contents').getHeight()/($('lightwindow_contents').getHeight()+(this.options.contentOffset.height))),sync:true,scaleX:false,scaleContent:false}),new Effect.Scale('lightwindow_container',100*(ratio/(this.dimensions.container.height)),{sync:true,scaleX:false,scaleFromCenter:true,scaleContent:false})],{duration:this.duration,afterFinish:function(){if(this.dimensions.dataEffects.length>0){if(!this.options.hideGalleryTab){$('lightwindow_galleries').setStyle({width:this.resizeTo.width+'px'});}
new Effect.Parallel(this.dimensions.dataEffects,{duration:this.duration,afterFinish:function(){this._finishWindow();}.bind(this),queue:{position:'end',scope:'lightwindowAnimation'}});}}.bind(this),queue:{position:'end',scope:'lightwindowAnimation'}});resized=true;}
if(!resized&&this.dimensions.dataEffects.length>0){new Effect.Parallel(this.dimensions.dataEffects,{duration:this.duration,beforeStart:function(){if(!this.options.hideGalleryTab){$('lightwindow_galleries').setStyle({width:this.resizeTo.width+'px'});}
if(this.containerChange.height!=0||this.containerChange.width!=0){new Effect.MoveBy('lightwindow_container',this.containerChange.height,this.containerChange.width,{transition:Effect.Transitions.sinoidal});}}.bind(this),afterFinish:function(){this._finishWindow();}.bind(this),queue:{position:'end',scope:'lightwindowAnimation'}});}},_defaultfinalWindowAnimationHandler:function(delay){if(this.windowType=='media'||this._getParameter('lightwindow_loading_animation')){Element.hide('lightwindow_loading');this._handleNavigation(this.activeGallery);this._setStatus(false);}else{Effect.Fade('lightwindow_loading',{duration:0.75,delay:1.0,afterFinish:function(){if(this.windowType!='image'&&this.windowType!='media'&&this.windowType!='external'){$('lightwindow_contents').setStyle({overflow:'auto'});}
this._handleNavigation(this.activeGallery);this._defaultGalleryAnimationHandler();this._setStatus(false);}.bind(this),queue:{position:'end',scope:'lightwindowAnimation'}});}},_defaultGalleryAnimationHandler:function(list){if(this.activeGallery){$('lightwindow_galleries').setStyle({display:'block',marginBottom:$('lightwindow_data_slide').getHeight()+this.options.contentOffset.height/2+'px'});$('lightwindow_navigation').setStyle({height:$('lightwindow_contents').getHeight()-20+'px'});}else{$('lightwindow_galleries').setStyle({display:'none'});$('lightwindow_galleries_tab_container').setStyle({height:'0px',marginTop:'20px'});$('lightwindow_galleries_list').setStyle({height:'0px'});return false;}
if(list){if($('lightwindow_galleries_list').getHeight()==0){var height=$('lightwindow_contents').getHeight()*0.80;$('lightwindow_galleries_tab_span').className='down';}else{var height=0;$('lightwindow_galleries_tab_span').className='up';}
new Effect.Morph('lightwindow_galleries_list',{duration:this.duration,transition:Effect.Transitions.sinoidal,style:{height:height+'px'},beforeStart:function(){$('lightwindow_galleries_list').setStyle({overflow:'hidden'});},afterFinish:function(){$('lightwindow_galleries_list').setStyle({overflow:'auto'});},queue:{position:'end',scope:'lightwindowAnimation'}});}},_defaultTransitionHandler:function(){this.dimensions.dataEffects=[];if($('lightwindow_data_slide').getStyle('display')!='none'){this.dimensions.dataEffects.push(new Effect.SlideUp('lightwindow_data_slide',{sync:true}),new Effect.Fade('lightwindow_data_slide',{sync:true,from:1.0,to:0.0}));}
if(!this.options.hideGalleryTab){if($('lightwindow_galleries').getHeight()!=0&&!this.options.hideGalleryTab){this.dimensions.dataEffects.push(new Effect.Morph('lightwindow_galleries_tab_container',{sync:true,style:{height:'0px',marginTop:'20px'}}));}
if($('lightwindow_galleries_list').getHeight()!=0){$('lightwindow_galleries_tab_span').className='up';this.dimensions.dataEffects.push(new Effect.Morph('lightwindow_galleries_list',{sync:true,style:{height:'0px'},transition:Effect.Transitions.sinoidal,beforeStart:function(){$('lightwindow_galleries_list').setStyle({overflow:'hidden'});},afterFinish:function(){$('lightwindow_galleries_list').setStyle({overflow:'auto'});}}));}}
this.dimensions.dataEffects.push(new Effect.Morph('lightwindow_title_bar_inner',{sync:true,style:{height:'0px',marginTop:this.options.dimensions.titleHeight+'px'}}),new Effect.Fade('lightwindow_title_bar_inner',{sync:true,from:1.0,to:0.0}));new Effect.Parallel(this.dimensions.dataEffects,{duration:this.duration,afterFinish:function(){this._loadWindow();}.bind(this),queue:{position:'end',scope:'lightwindowAnimation'}});},_defaultFormHandler:function(e){var element=Event.element(e).parentNode;var parameterString=Form.serialize(this._getParameter('lightwindow_form',element.getAttribute('params')));if(this.options.formMethod=='post'){var newAJAX=new Ajax.Request(element.href,{method:'post',postBody:parameterString,onComplete:this.openWindow.bind(this,element)});}else if(this.options.formMethod=='get'){var newAJAX=new Ajax.Request(element.href,{method:'get',parameters:parameterString,onComplete:this.openWindow.bind(this,element)});}},_finishWindow:function(){if(this.windowType=='external'){$('lightwindow_iframe').setAttribute('src',this.element.href);this._handleFinalWindowAnimation(1);}else if(this.windowType=='media'){var outerObject=document.createElement('object');outerObject.setAttribute('classid',this.options.classids[this._fileExtension(this.contentToFetch)]);outerObject.setAttribute('codebase',this.options.codebases[this._fileExtension(this.contentToFetch)]);outerObject.setAttribute('id','lightwindow_media_primary');outerObject.setAttribute('name','lightwindow_media_primary');outerObject.setAttribute('width',this.resizeTo.width);outerObject.setAttribute('height',this.resizeTo.height);outerObject=this._addParamToObject('movie',this.contentToFetch,outerObject);outerObject=this._addParamToObject('src',this.contentToFetch,outerObject);outerObject=this._addParamToObject('controller','true',outerObject);outerObject=this._addParamToObject('wmode','transparent',outerObject);outerObject=this._addParamToObject('cache','false',outerObject);outerObject=this._addParamToObject('quality','high',outerObject);if(!Prototype.Browser.IE){var innerObject=document.createElement('object');innerObject.setAttribute('type',this.options.mimeTypes[this._fileExtension(this.contentToFetch)]);innerObject.setAttribute('data',this.contentToFetch);innerObject.setAttribute('id','lightwindow_media_secondary');innerObject.setAttribute('name','lightwindow_media_secondary');innerObject.setAttribute('width',this.resizeTo.width);innerObject.setAttribute('height',this.resizeTo.height);innerObject=this._addParamToObject('controller','true',innerObject);innerObject=this._addParamToObject('wmode','transparent',innerObject);innerObject=this._addParamToObject('cache','false',innerObject);innerObject=this._addParamToObject('quality','high',innerObject);outerObject.appendChild(innerObject);}
if(this._getParameter('lightwindow_iframe_embed')){this._appendIframe('no');this._writeToIframe(this._convertToMarkup(outerObject,'object'));}else{this._appendObject(outerObject,'object',$('lightwindow_contents'));}
this._handleFinalWindowAnimation(0);}else{this._handleFinalWindowAnimation(0);}
this._setupActions();}}
Event.observe(window,'load',lightwindowInit,false);var myLightWindow=null;function lightwindowInit(){myLightWindow=new lightwindow();}
var jscolor={bindAuto:true,bindClass:'color',dir:'/controller/js/jscolor/',bodyElement:document.getElementsByTagName('body')[0],install:function(){jscolor.addEvent(window,'load',jscolor.init)},init:function(){if(jscolor.bindAuto){jscolor.bind()}},getDir:function(){if(!jscolor.dir){var detected=jscolor.detectDir()
jscolor.dir=detected!=false?detected:'jscolor/'}
return jscolor.dir},detectDir:function(){var base=location.href
var e=document.getElementsByTagName('base')
for(var i=0;i<e.length;i++){if(e[i].href)base=e[i].href}
var e=document.getElementsByTagName('script')
for(var i=0;i<e.length;i++){if(e[i].src&&/(^|\/)jscolor\.js([?#].*)?$/i.test(e[i].src)){var src=new jscolor.URI(e[i].src)
var srcAbs=src.toAbsolute(base)
srcAbs.path=srcAbs.path.replace(/[^\/]+$/,'')
delete srcAbs.query
delete srcAbs.fragment
return srcAbs.toString()}}
return false},bind:function(){var matchClass=new RegExp('(^|\\s)('+jscolor.bindClass+')\\s*(\\{[^}]*\\})?','i')
var e=document.getElementsByTagName('input')
for(var i=0;i<e.length;i++){var m
if(e[i].className&&(m=e[i].className.match(matchClass))){var prop={}
if(m[3]){try{eval('prop='+m[3])}catch(eInvalidProp){}}
e[i].color=new jscolor.color(e[i],prop)}}},fetchElement:function(mixed){return typeof(mixed)=='string'?document.getElementById(mixed):mixed},addEvent:function(el,evnt,func){if(el.addEventListener){el.addEventListener(evnt,func,false)}else if(el.attachEvent){el.attachEvent('on'+evnt,func)}},fireEvent:function(el,evnt){if(!el){return false}else if(document.createEventObject){var ev=document.createEventObject()
return el.fireEvent('on'+evnt,ev)}else if(document.createEvent){var ev=document.createEvent('HTMLEvents')
ev.initEvent(evnt,true,true)
return el.dispatchEvent(ev)}else{if(el['on'+evnt]){return el['on'+evnt]()}else{return false}}},getElementPos:function(e){var e1=e,e2=e
var x=0,y=0
if(e1.offsetParent){do{x+=e1.offsetLeft
y+=e1.offsetTop}while(e1=e1.offsetParent)}
while((e2=e2.parentNode)&&e2.nodeName!='BODY'){x-=e2.scrollLeft
y-=e2.scrollTop}
return[x,y]},getElementSize:function(e){return[e.offsetWidth,e.offsetHeight]},getMousePos:function(e){if(!e)var e=window.event
if(typeof e.pageX=='number'){return[e.pageX,e.pageY]}else if(typeof e.clientX=='number'){return[e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,e.clientY+document.body.scrollTop+document.documentElement.scrollTop]}},getViewPos:function(){if(typeof window.pageYOffset=='number'){return[window.pageXOffset,window.pageYOffset]}else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){return[document.body.scrollLeft,document.body.scrollTop]}else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){return[document.documentElement.scrollLeft,document.documentElement.scrollTop]}else{return[0,0]}},getViewSize:function(){if(typeof window.innerWidth=='number'){return[window.innerWidth,window.innerHeight]}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){return[document.body.clientWidth,document.body.clientHeight]}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){return[document.documentElement.clientWidth,document.documentElement.clientHeight]}else{return[0,0]}},URI:function(uri){this.scheme=null
this.authority=null
this.path=''
this.query=null
this.fragment=null
this.parse=function(uri){var m=uri.match(/^(([A-Za-z][0-9A-Za-z+.-]*)(:))?((\/\/)([^\/?#]*))?([^?#]*)((\?)([^#]*))?((#)(.*))?/)
this.scheme=m[3]?m[2]:null
this.authority=m[5]?m[6]:null
this.path=m[7]
this.query=m[9]?m[10]:null
this.fragment=m[12]?m[13]:null
return this}
this.toString=function(){var result=''
if(this.scheme!=null)result=result+this.scheme+':'
if(this.authority!=null)result=result+'//'+this.authority
if(this.path!=null)result=result+this.path
if(this.query!=null)result=result+'?'+this.query
if(this.fragment!=null)result=result+'#'+this.fragment
return result}
this.toAbsolute=function(base){var base=new jscolor.URI(base)
var r=this
var t=new jscolor.URI
if(base.scheme==null)return false
if(r.scheme!=null&&r.scheme.toLowerCase()==base.scheme.toLowerCase()){r.scheme=null}
if(r.scheme!=null){t.scheme=r.scheme
t.authority=r.authority
t.path=removeDotSegments(r.path)
t.query=r.query}else{if(r.authority!=null){t.authority=r.authority
t.path=removeDotSegments(r.path)
t.query=r.query}else{if(r.path==''){t.path=base.path
if(r.query!=null){t.query=r.query}else{t.query=base.query}}else{if(r.path.substr(0,1)=='/'){t.path=removeDotSegments(r.path)}else{if(base.authority!=null&&base.path==''){t.path='/'+r.path}else{t.path=base.path.replace(/[^\/]+$/,'')+r.path}
t.path=removeDotSegments(t.path)}
t.query=r.query}
t.authority=base.authority}
t.scheme=base.scheme}
t.fragment=r.fragment
return t}
function removeDotSegments(path){var out=''
while(path){if(path.substr(0,3)=='../'||path.substr(0,2)=='./'){path=path.replace(/^\.+/,'').substr(1)}else if(path.substr(0,3)=='/./'||path=='/.'){path='/'+path.substr(3)}else if(path.substr(0,4)=='/../'||path=='/..'){path='/'+path.substr(4)
out=out.replace(/\/?[^\/]*$/,'')}else if(path=='.'||path=='..'){path=''}else{var rm=path.match(/^\/?[^\/]*/)[0]
path=path.substr(rm.length)
out=out+rm}}
return out}
if(uri){this.parse(uri)}},color:function(target,prop){this.required=true
this.adjust=true
this.hash=true
this.caps=true
this.valueElement=target
this.styleElement=target
this.hsv=[0,1,0]
this.rgb=[0,0,0]
this.picker=true
this.pickerMode='HSV'
this.pickerFace=10
this.pickerFaceColor='ThreeDFace'
this.pickerBorder=1
this.pickerBorderColor='ThreeDHighlight ThreeDShadow ThreeDShadow ThreeDHighlight'
this.pickerInset=1
this.pickerInsetColor='ThreeDShadow ThreeDHighlight ThreeDHighlight ThreeDShadow'
this.pickerZIndex=10000
for(var p in prop)this[p]=prop[p]
this.importColor=function(){if(valueElement){if(!this.adjust){if(!this.fromString(valueElement.value,leaveValue)){styleElement.style.backgroundColor=styleElement.jscStyle.backgroundColor
styleElement.style.color=styleElement.jscStyle.color
this.exportColor(leaveValue|leaveStyle)}}else if(!this.required&&/^\s*$/.test(valueElement.value)){valueElement.value=''
styleElement.style.backgroundColor=styleElement.jscStyle.backgroundColor
styleElement.style.color=styleElement.jscStyle.color
this.exportColor(leaveValue|leaveStyle)}else if(this.fromString(valueElement.value)){}else{this.exportColor()}}else{this.exportColor()}}
this.exportColor=function(flags){if(!(flags&leaveValue)&&valueElement){var value=this.toString()
if(this.caps)value=value.toUpperCase()
if(this.hash)value='#'+value
valueElement.value=value}
if(!(flags&leaveStyle)&&styleElement){styleElement.style.backgroundColor='#'+this.toString()
styleElement.style.color=0.213*this.rgb[0]+
0.715*this.rgb[1]+
0.072*this.rgb[2]<0.5?'#FFF':'#000'}
if(!(flags&leavePad)&&isPickerOwner()){redrawPad()}
if(!(flags&leaveSld)&&isPickerOwner()){redrawSld()}}
this.fromHSV=function(h,s,v,flags){this.rgb=HSV_RGB(h==null?this.hsv[0]:(this.hsv[0]=h),s==null?this.hsv[1]:(this.hsv[1]=s),v==null?this.hsv[2]:(this.hsv[2]=v))
this.exportColor(flags)}
this.fromRGB=function(r,g,b,flags){var hsv=RGB_HSV(r==null?this.rgb[0]:(this.rgb[0]=r),g==null?this.rgb[1]:(this.rgb[1]=g),b==null?this.rgb[2]:(this.rgb[2]=b))
if(hsv[0]!=null){this.hsv[0]=hsv[0]}
if(hsv[2]!=0){this.hsv[1]=hsv[1]}
this.hsv[2]=hsv[2]
this.exportColor(flags)}
this.fromString=function(hex,flags){var m=hex.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i)
if(!m){return false}else{if(m[1].length==6){this.fromRGB(parseInt(m[1].substr(0,2),16)/255,parseInt(m[1].substr(2,2),16)/255,parseInt(m[1].substr(4,2),16)/255,flags)}else{this.fromRGB(parseInt(m[1].charAt(0)+m[1].charAt(0),16)/255,parseInt(m[1].charAt(1)+m[1].charAt(1),16)/255,parseInt(m[1].charAt(2)+m[1].charAt(2),16)/255,flags)}
return true}}
this.toString=function(){return((0x100|Math.round(this.rgb[0]*255)).toString(16).substr(1)+
(0x100|Math.round(this.rgb[1]*255)).toString(16).substr(1)+
(0x100|Math.round(this.rgb[2]*255)).toString(16).substr(1))}
function RGB_HSV(r,g,b){var n=Math.min(Math.min(r,g),b)
var v=Math.max(Math.max(r,g),b)
var m=v-n
if(m==0)return[null,0,v]
var h=r==n?3+(b-g)/m:(g==n?5+(r-b)/m:1+(g-r)/m)
return[h==6?0:h,m/v,v]}
function HSV_RGB(h,s,v){if(h==null)return[v,v,v]
var i=Math.floor(h)
var f=i%2?h-i:1-(h-i)
var m=v*(1-s)
var n=v*(1-s*f)
switch(i){case 6:case 0:return[v,n,m]
case 1:return[n,v,m]
case 2:return[m,v,n]
case 3:return[m,n,v]
case 4:return[n,m,v]
case 5:return[v,m,n]}}
function hidePicker(){if(isPickerOwner()){removePicker()}}
function showPicker(){if(!isPickerOwner()){var tp=jscolor.getElementPos(target)
var ts=jscolor.getElementSize(target)
var vp=jscolor.getViewPos(target)
var vs=jscolor.getViewSize(target)
var ps=[2*THIS.pickerBorder+4*THIS.pickerInset+2*THIS.pickerFace+widthPad+2*widthArrow+widthSld,2*THIS.pickerBorder+2*THIS.pickerInset+2*THIS.pickerFace+height]
var pp=[-vp[0]+tp[0]+ps[0]>vs[0]?(-vp[0]+tp[0]+ts[0]/2>vs[0]/2&&tp[0]+ts[0]-ps[0]>0?tp[0]+ts[0]-ps[0]:tp[0]):tp[0],-vp[1]+tp[1]+ts[1]+ps[1]>vs[1]?(-vp[1]+tp[1]+ts[1]/2>vs[1]/2&&tp[1]-ps[1]>0?tp[1]-ps[1]:tp[1]+ts[1]):tp[1]+ts[1]]
drawPicker(pp[0],pp[1])}}
function removePicker(){delete jscolor.picker.owner
jscolor.bodyElement.removeChild(jscolor.picker.boxB)}
function drawPicker(x,y){new_box=false;if(!jscolor.picker){new_box=true;jscolor.picker={box:document.createElement('div'),boxB:document.createElement('div'),pad:document.createElement('div'),padB:document.createElement('div'),padM:document.createElement('div'),sld:document.createElement('div'),sldB:document.createElement('div'),sldM:document.createElement('div'),insB:document.createElement('div')}
for(var i=0,segSize=4;i<height;i+=segSize){var seg=document.createElement('div')
seg.style.height=segSize+'px'
seg.style.fontSize='1px'
seg.style.lineHeight='0'
jscolor.picker.sld.appendChild(seg)}
jscolor.picker.sldB.appendChild(jscolor.picker.sld)
jscolor.picker.box.appendChild(jscolor.picker.sldB)
jscolor.picker.box.appendChild(jscolor.picker.sldM)
jscolor.picker.padB.appendChild(jscolor.picker.pad)
jscolor.picker.box.appendChild(jscolor.picker.padB)
jscolor.picker.box.appendChild(jscolor.picker.padM)
jscolor.picker.boxB.appendChild(jscolor.picker.box)
jscolor.picker.boxB.appendChild(jscolor.picker.insB)}
var p=jscolor.picker
posPad=[x+THIS.pickerBorder+THIS.pickerFace+THIS.pickerInset,y+THIS.pickerBorder+THIS.pickerFace+THIS.pickerInset]
posSld=[null,y+THIS.pickerBorder+THIS.pickerFace+THIS.pickerInset]
p.box.onmouseup=p.box.onmouseout=function(){target.focus()}
p.box.onmousedown=function(){abortBlur=true}
p.box.onmousemove=function(e){holdPad&&setPad(e);holdSld&&setSld(e)}
p.padM.onmouseup=p.padM.onmouseout=function(){if(holdPad){holdPad=false;jscolor.fireEvent(valueElement,'change')}}
p.padM.onmousedown=function(e){holdPad=true;setPad(e)}
p.sldM.onmouseup=p.sldM.onmouseout=function(){if(holdSld){holdSld=false;jscolor.fireEvent(valueElement,'change')}}
p.sldM.onmousedown=function(e){holdSld=true;setSld(e)}
p.box.style.width=4*THIS.pickerInset+2*THIS.pickerFace+widthPad+2*widthArrow+widthSld+'px'
p.box.style.height=2*THIS.pickerInset+2*THIS.pickerFace+height+'px'
p.boxB.style.position='absolute'
p.boxB.style.clear='both'
p.boxB.style.left=x+'px'
p.boxB.style.top=y+'px'
p.boxB.style.zIndex=THIS.pickerZIndex
p.boxB.style.border=THIS.pickerBorder+'px solid'
p.boxB.style.borderColor=THIS.pickerBorderColor
p.boxB.style.background=THIS.pickerFaceColor
switch(modeID){case 0:var img='hs.png';break
case 1:var img='hv.png';break}
p.pad.style.width=widthPad+'px'
p.pad.style.height=height+'px'
p.pad.style.background="url('"+jscolor.getDir()+img+"') 0 0 no-repeat"
p.padB.style.position='absolute'
p.padB.style.left=THIS.pickerFace+'px'
p.padB.style.top=THIS.pickerFace+'px'
p.padB.style.border=THIS.pickerInset+'px solid'
p.padB.style.borderColor=THIS.pickerInsetColor
p.padM.style.position='absolute'
p.padM.style.left='0'
p.padM.style.top='0'
p.padM.style.width=THIS.pickerFace+2*THIS.pickerInset+widthPad+widthArrow+'px'
p.padM.style.height=p.box.style.height
p.padM.style.cursor='crosshair'
p.padM.style.background="url('"+jscolor.getDir()+"cross.gif') no-repeat"
p.sld.style.overflow='hidden'
p.sld.style.width=widthSld+'px'
p.sld.style.height=height+'px'
p.sldB.style.position='absolute'
p.sldB.style.right=THIS.pickerFace+'px'
p.sldB.style.top=THIS.pickerFace+'px'
p.sldB.style.border=THIS.pickerInset+'px solid'
p.sldB.style.borderColor=THIS.pickerInsetColor
p.sldM.style.position='absolute'
p.sldM.style.right='0'
p.sldM.style.top='0'
p.sldM.style.width=widthSld+widthArrow+THIS.pickerFace+2*THIS.pickerInset+'px'
p.sldM.style.height=p.box.style.height
p.sldM.style.background="url('"+jscolor.getDir()+"arrow.gif') no-repeat"
try{p.sldM.style.cursor='pointer'}catch(eOldIE){p.sldM.style.cursor='hand'}
if(new_box){p.insB.innerHTML+=""
+"Move the cross on the left to adjust your color range.  Move the slider "
+"on the right to select your color.  Click outside of this grey area to close the "
+"color selector.";p.insB.style.color="#000000";p.insB.style.padding="5px";p.insB.style.width="210px";}
redrawPad()
redrawSld()
jscolor.picker.owner=THIS
jscolor.bodyElement.appendChild(p.boxB)}
function redrawPad(){switch(modeID){case 0:var yComponent=1;break
case 1:var yComponent=2;break}
var x=Math.round((THIS.hsv[0]/6)*(widthPad-1))
var y=Math.round((1-THIS.hsv[yComponent])*(height-1))
jscolor.picker.padM.style.backgroundPosition=(THIS.pickerFace+THIS.pickerInset+x-7)+'px '+
(THIS.pickerFace+THIS.pickerInset+y-7)+'px'
var seg=jscolor.picker.sld.childNodes
switch(modeID){case 0:var rgb=HSV_RGB(THIS.hsv[0],THIS.hsv[1],1)
for(var i=0;i<seg.length;i++){seg[i].style.backgroundColor='rgb('+
(rgb[0]*(1-i/seg.length)*100)+'%,'+
(rgb[1]*(1-i/seg.length)*100)+'%,'+
(rgb[2]*(1-i/seg.length)*100)+'%)'}
break
case 1:var rgb,s,c=[THIS.hsv[2],0,0]
var i=Math.floor(THIS.hsv[0])
var f=i%2?THIS.hsv[0]-i:1-(THIS.hsv[0]-i)
switch(i){case 6:case 0:rgb=[0,1,2];break
case 1:rgb=[1,0,2];break
case 2:rgb=[2,0,1];break
case 3:rgb=[2,1,0];break
case 4:rgb=[1,2,0];break
case 5:rgb=[0,2,1];break}
for(var i=0;i<seg.length;i++){s=1-1/(seg.length-1)*i
c[1]=c[0]*(1-s*f)
c[2]=c[0]*(1-s)
seg[i].style.backgroundColor='rgb('+
(c[rgb[0]]*100)+'%,'+
(c[rgb[1]]*100)+'%,'+
(c[rgb[2]]*100)+'%)'}
break}}
function redrawSld(){switch(modeID){case 0:var yComponent=2;break
case 1:var yComponent=1;break}
var y=Math.round((1-THIS.hsv[yComponent])*(height-1))
jscolor.picker.sldM.style.backgroundPosition='0 '+(THIS.pickerFace+THIS.pickerInset+y-5)+'px'}
function isPickerOwner(){return jscolor.picker&&jscolor.picker.owner==THIS}
function blurTarget(){if(valueElement==target)THIS.importColor()
hidePicker()}
function blurValue(){if(valueElement!=target)THIS.importColor()}
function setPad(e){var posM=jscolor.getMousePos(e)
var x=posM[0]-posPad[0]<=0?0:(posM[0]-posPad[0]>widthPad-1?widthPad-1:posM[0]-posPad[0])
var y=posM[1]-posPad[1]<=0?0:(posM[1]-posPad[1]>height-1?height-1:posM[1]-posPad[1])
switch(modeID){case 0:THIS.fromHSV(x*(6/(widthPad-1)),1-y/(height-1),null,leaveSld);break
case 1:THIS.fromHSV(x*(6/(widthPad-1)),null,1-y/(height-1),leaveSld);break}}
function setSld(e){var posM=jscolor.getMousePos(e)
var y=posM[1]-posSld[1]<=0?0:(posM[1]-posSld[1]>height-1?height-1:posM[1]-posSld[1])
switch(modeID){case 0:THIS.fromHSV(null,null,1-y/(height-1),leavePad);break
case 1:THIS.fromHSV(null,1-y/(height-1),null,leavePad);break}}
var THIS=this
var modeID=this.pickerMode.toLowerCase()=='hvs'?1:0
var abortBlur=false
var
valueElement=jscolor.fetchElement(this.valueElement),styleElement=jscolor.fetchElement(this.styleElement)
var
holdPad=false,holdSld=false
var
posPad,posSld
var
widthSld=16,widthArrow=7,widthPad=181,height=101
var
leaveValue=1<<0,leaveStyle=1<<1,leavePad=1<<2,leaveSld=1<<3
jscolor.addEvent(target,'focus',function(){if(THIS.picker)showPicker()})
jscolor.addEvent(target,'blur',function(){if(!abortBlur){setTimeout(function(){abortBlur||blurTarget();abortBlur=false},0)}else{abortBlur=false}})
if(valueElement){var updateField=function(){THIS.fromString(valueElement.value,leaveValue)}
jscolor.addEvent(valueElement,'keyup',updateField)
jscolor.addEvent(valueElement,'input',updateField)
jscolor.addEvent(valueElement,'blur',blurValue)
valueElement.setAttribute('autocomplete','off')}
if(styleElement){styleElement.jscStyle={backgroundColor:styleElement.style.backgroundColor,color:styleElement.style.color}}
this.importColor()}}
jscolor.install()
function create_xml_doc(t){try{xmlDoc=new ActiveXObject("Microsoft.XMLDOM");xmlDoc.async="false";xmlDoc.loadXML(t);}catch(e){try{parser=new DOMParser();xmlDoc=parser.parseFromString(t,"text/xml");}catch(e){alert_popup(e.message);return;}}
return xmlDoc;}
function get_xml_value(p){return getNodeText(p);}
function getNodeText(xmlNode){if(!xmlNode)return'';if(typeof(xmlNode.textContent)!="undefined")return xmlNode.textContent;return xmlNode.firstChild.nodeValue;}
function loadMap(){if($('contactMapG').src.indexOf('google')<0){u='http://maps.google.com/maps?f=q&hl=en&geocode=&q=2000+Hogback+Rd.+Suite+13.+Ann+Arbor,+MI+48105&sll=37.0625,-95.677068&sspn=54.79724,78.75&ie=UTF8&g=2000+Hogback+Rd.+Suite+13.+Ann+Arbor,+MI+48105&s=AARTsJoIdsXjsQy4esBG7Lxpc5G_LoJg6g&ll=42.26575,-83.677883&spn=0.022231,0.036478&z=14&iwloc=addr&output=embed';$('contactMapG').src=u;}}
function show_contact_tab(tab_id){var all_tabs=$$('.contact_tab');for(i=0;i<all_tabs.length;i++){if(all_tabs[i].visible())
all_tabs[i].hide();}
$(tab_id).appear();if(tab_id=="contact_map_div"){if($('contactMapG').src.indexOf('google')<0){u='http://maps.google.com/maps?f=q&hl=en&geocode=&q=2000+Hogback+Rd.+Suite+13.+Ann+Arbor,+MI+48105&sll=37.0625,-95.677068&sspn=54.79724,78.75&ie=UTF8&g=2000+Hogback+Rd.+Suite+13.+Ann+Arbor,+MI+48105&s=AARTsJoIdsXjsQy4esBG7Lxpc5G_LoJg6g&ll=42.26575,-83.677883&spn=0.022231,0.036478&z=14&iwloc=addr&output=embed';$('contactMapG').src=u;}}}
function contact_swap_items(a,b){if(!$(a).visible()){new Effect.Parallel([new Effect.SlideDown(a)],{duration:1.0});}
if(b&&$(b).visible()){new Effect.Parallel([new Effect.SlideUp(b)],{duration:1.0});}
setTimeout("loadMap()",1250);}
function clear_sale_form(){$('contact_name').value='';$('contact_email').value='';$('contact_description').value='';$('contact_phone').value='';$('contact_company').value='';$('contact_interested').value='';$('contact_referred').value='';}
function sale_form_is_valid(){var contact_fields=$$('div#contact_sale_form_inner .required');var is_valid=true;var emailRe=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/;var phoneRe=/^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/;for(i=0;i<contact_fields.length;i++){if(contact_fields[i].value==""){contact_fields[i].addClassName("invalid");is_valid=false;}else{contact_fields[i].removeClassName("invalid");}}
var email_fields=$$('div#contact_sale_form_inner .email');for(i=0;i<email_fields.length;i++){if(emailRe.test(email_fields[i].value)){email_fields[i].removeClassName("invalid");}else{email_fields[i].addClassName("invalid");is_valid=false;}}
var phone_fields=$$('div#contact_sale_form_inner .phone');for(i=0;i<phone_fields.length;i++){if(phoneRe.test(phone_fields[i].value)){phone_fields[i].removeClassName("invalid");}else{phone_fields[i].addClassName("invalid");is_valid=false;}}
if(is_valid){return true;}else{return false;}}
function send_sale_form(){if(sale_form_is_valid()){show_loader('contact_form_container','contact_sale_form_div','Sending Message...','loader_5.gif');var query='ajax=true';query+="&contact_name="+Base64.encode($('contact_name').value);query+="&contact_email="+Base64.encode($('contact_email').value);query+="&contact_description="+Base64.encode($('contact_description').value);query+="&contact_phone="+Base64.encode($('contact_phone').value);query+="&contact_company="+Base64.encode($('contact_company').value);query+="&contact_interested="+Base64.encode($('contact_interested').value);query+="&contact_referred="+Base64.encode($('contact_referred').value);query+="&contact_current_url="+Base64.encode(window.location.href);query+="&security_code="+Base64.encode($('security_code').value);new Ajax.Request('topics/contact/processor.php',{parameters:query,onSuccess:function(transport){var contact_form_response=transport.headerJSON;if(contact_form_response.code=="Success"){alert(contact_form_response.message);clear_sale_form();}else{alert(contact_form_response.code+": "+contact_form_response.message);}
setTimeout("hide_loader('contact_form_container', 'contact_sale_form_div')",1000);},onFailure:function(transport){alert('There was an error sending your message.');setTimeout("hide_loader('contact_form_container', 'contact_sale_form_div')",1000);}});return false;}else{alert('Please enter the required information into the highlighted fields.');return false;}}
function show_popup_contact_form(otherinfo,image){window.scrollTo(0,0);select_selection=$$('select');for(i=0;i<select_selection.length;i++){if(select_selection[i].id!='contact_reason'){select_selection[i].hide();}}
$('contact_container').appear({duration:1.0});$('contact_current_url').value=window.location.href;$('contact_other_info').value=otherinfo;if(image!=''){$('contact_img_holder').show();$('contact_img_holder').innerHTML="<img alt='"+otherinfo+"' src='"+image+"' />";}else{$('contact_img_holder').show();$('contact_img_holder').innerHTML="<img alt='"+otherinfo+"' src='images/popupContactForm/general_contact.png' />";}
if(otherinfo!=''){$('contact_empty').show();$('contact_empty').innerHTML="Thank you for your interest in "+otherinfo+".";}}
function hide_popup_contact_form(){$('contact_description').value='';$('contact_name').value='';$('contact_email').value='';$('contact_phone').value='';$('contact_other_info').value='';$('contact_empty').innerHTML='&nbsp;';$('contact_img_holder').innerHTML='&nbsp;';$('contact_img_holder').hide();$('contact_container').fade({duration:0.5});select_selection=$$('select');for(i=0;i<select_selection.length;i++){if(select_selection[i].id!='contact_reason'){select_selection[i].show();}}
return false;}
function popup_contact_form_is_valid(){var contact_fields=$$('div#contact_container .required');var is_valid=true;var emailRe=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/;var phoneRe=/^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/;for(i=0;i<contact_fields.length;i++){if(contact_fields[i].value==""){contact_fields[i].addClassName("invalid");is_valid=false;}else{contact_fields[i].removeClassName("invalid");}}
var email_fields=$$('div#contact_container .email');for(i=0;i<email_fields.length;i++){if(emailRe.test(email_fields[i].value)){email_fields[i].removeClassName("invalid");}else{email_fields[i].addClassName("invalid");is_valid=false;}}
var phone_fields=$$('div#contact_container .phone');for(i=0;i<phone_fields.length;i++){if(phoneRe.test(phone_fields[i].value)){phone_fields[i].removeClassName("invalid");}else{phone_fields[i].addClassName("invalid");is_valid=false;}}
if(is_valid){return true;}else{return false;}}
function send_popup_contact_form(){if(popup_contact_form_is_valid()){var query='ajax=true';query+="&contact_name="+Base64.encode($('contact_name').value);query+="&contact_email="+Base64.encode($('contact_email').value);query+="&contact_description="+Base64.encode($('contact_description').value);query+="&contact_phone="+Base64.encode($('contact_phone').value);query+="&contact_current_url="+Base64.encode($('contact_current_url').value);query+="&contact_other_info="+Base64.encode($('contact_other_info').value);new Ajax.Request('modules/popupContactForm/processor.php',{parameters:query,onSuccess:function(transport){var contact_form_response=transport.headerJSON;if(contact_form_response.code=="Success"){alert(contact_form_response.message);hide_popup_contact_form();}else{alert(contact_form_response.code+": "+contact_form_response.message);}},onFailure:function(transport){alert('There was an error sending your message. (0)');}});return false;}else{alert('Please enter the required information into the highlighted fields.');return false;}}
var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(input){var output="";var chr1,chr2,chr3,enc1,enc2,enc3,enc4;var i=0;input=Base64._utf8_encode(input);while(i<input.length){chr1=input.charCodeAt(i++);chr2=input.charCodeAt(i++);chr3=input.charCodeAt(i++);enc1=chr1>>2;enc2=((chr1&3)<<4)|(chr2>>4);enc3=((chr2&15)<<2)|(chr3>>6);enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64;}else if(isNaN(chr3)){enc4=64;}
output=output+
this._keyStr.charAt(enc1)+this._keyStr.charAt(enc2)+
this._keyStr.charAt(enc3)+this._keyStr.charAt(enc4);}
return output;},decode:function(input){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(i<input.length){enc1=this._keyStr.indexOf(input.charAt(i++));enc2=this._keyStr.indexOf(input.charAt(i++));enc3=this._keyStr.indexOf(input.charAt(i++));enc4=this._keyStr.indexOf(input.charAt(i++));chr1=(enc1<<2)|(enc2>>4);chr2=((enc2&15)<<4)|(enc3>>2);chr3=((enc3&3)<<6)|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64){output=output+String.fromCharCode(chr2);}
if(enc4!=64){output=output+String.fromCharCode(chr3);}}
output=Base64._utf8_decode(output);return output;},_utf8_encode:function(string){string=string.replace(/\r\n/g,"\n");var utftext="";for(var n=0;n<string.length;n++){var c=string.charCodeAt(n);if(c<128){utftext+=String.fromCharCode(c);}
else if((c>127)&&(c<2048)){utftext+=String.fromCharCode((c>>6)|192);utftext+=String.fromCharCode((c&63)|128);}
else{utftext+=String.fromCharCode((c>>12)|224);utftext+=String.fromCharCode(((c>>6)&63)|128);utftext+=String.fromCharCode((c&63)|128);}}
return utftext;},_utf8_decode:function(utftext){var string="";var i=0;var c=c1=c2=0;while(i<utftext.length){c=utftext.charCodeAt(i);if(c<128){string+=String.fromCharCode(c);i++;}
else if((c>191)&&(c<224)){c2=utftext.charCodeAt(i+1);string+=String.fromCharCode(((c&31)<<6)|(c2&63));i+=2;}
else{c2=utftext.charCodeAt(i+1);c3=utftext.charCodeAt(i+2);string+=String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63));i+=3;}}
return string;}}
function show_loader(parent_id,content_id,message,img){c=$(parent_id);if($('loader_'+parent_id))
return false;$(content_id).hide();ofs=c.cumulativeOffset();d=document.createElement('div');d.setAttribute('id','loader_'+parent_id);c.appendChild(d);d.className='loader';d.innerHTML="<span>"+message+"</span>";d.style.width=c.getWidth()+'px';d.style.height=c.getHeight()+'px';i=new Image();i.src='images/'+img;d.appendChild(i);i.style.left=Math.floor((c.getWidth()-i.width)/2)+'px';i.style.top=Math.floor((c.getHeight()-i.height)/2)+'px';}
function hide_loader(parent_id,content_id){c=$('loader_'+parent_id);try{c.parentNode.removeChild(c);$(content_id).show();}catch(e){;}}
function perform_login(frm,did,cid){f=function(o){load_box_content(did,cid);return false;}
vars=$(frm).serialize();new Ajax.Request('controller/includes/process_login.php',{postBody:vars+'&did='+did+'&j='+ut(),method:'post',onSuccess:f});}
function perform_logout(did,cid){f=function(o){load_box_content(did,cid);}
new Ajax.Request('controller/includes/process_login.php?logout=yes&did='+did+'&j='+ut(),{method:'get',onSuccess:f});}
function load_box_content(did,cid){f=function(o){xmlDoc=create_xml_doc(o.responseText);page=xmlDoc.getElementsByTagName("nugget");if(page.length){content=get_xml_value(page[0].getElementsByTagName("module")[0]);$(did+'_inner').innerHTML=content;setTimeout("hide_loader('"+did+"_outer', '"+did+"_inner')",1000);}}
$(did+'_inner').innerHTML='&nbsp;';show_loader(did+'_outer',did+'_inner','Loading...','loader_2.gif');new Ajax.Request('modules/sidebar/load_ajax.php',{postBody:'did='+did+'&id='+cid+'&j='+ut(),method:'post',onSuccess:f});}
function swap_module_contact(ptr,s,h){Effect.Shake(ptr,{duration:0.25,distance:3});$(h+'_address').hide();$(h+'_phone').hide();$(s+'_address').show();$(s+'_phone').show();}