/* Copyright 2010 Crushpad */var CP={};Object.extend(CP,{init:function(){},debugCheck:function(){return(CP.Constants.Force.Debug||document.body.className.match(/(^|\s)debug($|\s)/)?true:false);},log:function(){var args=CP.toArray(arguments);if(CP.debugCheck()){if(!CP.Constants.Force.GhettoConsole&&typeof console!='undefined'&&typeof console.log=='function'){console.log.apply(console,args);}else{if(!CP.Globals.console){CP.Globals.console=$(document.createElement('textarea'));CP.Globals.console.writeAttribute('readonly','readonly');CP.Globals.console.writeAttribute('id','console-interface');$(document.body).appendChild(CP.Globals.console);}
CP.Globals.console.setValue(CP.Globals.console.getValue()+args.join('\n')+'\n');}}},toArray:function(iterable){var arrayed=[];for(var i=0;i<iterable.length;i++){arrayed.push(iterable[i]);};return arrayed;},timeAgo:function(s_ago){var rounded=s_ago;var human_ago='';if(rounded<=1)
{human_ago='1 sec ago';return human_ago;}
if(rounded<60)
{human_ago=rounded+' sec ago';return human_ago;}
var m_ago=s_ago/60;rounded=Math.round(m_ago);if(rounded<=1)
{human_ago='1 min ago';return human_ago;}
if(rounded<60)
{human_ago=rounded+' min ago';return human_ago;}
var h_ago=m_ago/60;rounded=Math.round(h_ago);if(rounded<=1)
{human_ago='1 hour ago';return human_ago;}
if(rounded<24)
{human_ago=rounded+' hours ago';return human_ago;}
var d_ago=h_ago/24;rounded=Math.round(d_ago);if(rounded<=1)
{human_ago='1 day ago';return human_ago;}
if(rounded<365)
{human_ago=rounded+' days ago';return human_ago;}
var y_ago=d_ago/365;rounded=Math.round(y_ago);if(rounded<=1)
{human_ago='1 year ago';return human_ago;}
human_ago=rounded+' years ago';return human_ago;},timeToGo:function(delta){var obj={"day":0,"hour":0,"minute":0,"second":0}
if(delta<=0){return obj;}
var days;var hrs;var rem;var mins;days=Math.abs(delta/86400);rem=Math.abs(delta%86400);if(days<1){days=0;};hrs=Math.abs(rem/3600);rem=Math.abs(rem%3600);if(hrs<1){hrs=0;}
mins=rem/60;if(mins<1){mins=0;}
secs=rem%60;obj.day=Math.floor(days);obj.hour=Math.floor(hrs);obj.minute=Math.floor(mins);obj.second=Math.floor(secs);return obj;},openPopup:function(url,height,width){newwindow=window.open(url,'name','height = '+height+',width = '+width);if(window.focus){newwindow.focus()}
return false;},Constants:{Force:{Debug:'0'=='1',GhettoConsole:false},URL:{MagentoBase:'http://store.brixr.com'}},Globals:{console:false}});Event.observe(document,'dom:loaded',CP.init);var CP;if(typeof CP.Buttons=='undefined'){CP.Buttons={};}
Object.extend(CP.Buttons,{init:function(){$$('.button.pop-up').each(function(ele){ele.observe('click',CP.Buttons.popupCallback);});$$('.button.close').each(function(ele){ele.observe('click',CP.Buttons.closeCallback);});},popupCallback:function(event){var anchor=event.findElement('.button').down('a');if(anchor){window.opener.focus();window.opener.location.href=anchor.href;event.stop();};},closeCallback:function(event){event.stop();window.close();}});Event.observe(document,'dom:loaded',CP.Buttons.init);var CP;if(Object.isUndefined(CP.Utility)){CP.Utility={postToWindow:function(url,target,data){var form=$(document.createElement('form'));form.target=target;form.action=url;form.method='post';form.acceptCharset='UTF-8';form.enctype='multipart/form-data';form.hide();$H(data).each(function(pair){var field=document.createElement('input');field.type='hidden';field.name=pair.key;field.value=pair.value;form.appendChild(field);});document.body.appendChild(form);form.submit();FB.yield(form.remove.bind(form));},getViewportDims:function(){var viewportwidth;var viewportheight;if(typeof window.innerWidth!='undefined'){viewportwidth=window.innerWidth,viewportheight=window.innerHeight}else{viewportwidth=document.documentElement.clientWidth,viewportheight=document.documentElement.clientHeight}
return[viewportheight,viewportwidth];},changeDocumentStyles:function(styleobj){var body=$$('body').first();if(!body){return false;}
var html=$$('html').first();if(!html){return false;}
$H(styleobj).each(function(pair){body.style[pair.key]=pair.value;html.style[pair.key]=pair.value;})
return true;},needsIECSS:function(){/*@cc_on
     return true;
   @*/return false;},needsIE6CSS:function(){/*@cc_on
    /*@if ( @_jscript_version <= 5.6 || @_jscript_version == 5.7 )
     return true && !window.XMLHttpRequest;
    @else @*/return false;/*@end
   @*/},needsIE7CSS:function(){/*@cc_on
    /*@if ( @_jscript_version > 5.6 && @_jscript_version < 5.8)
     return true && window.XMLHttpRequest;
    @else @*/return false;/*@end
   @*/},needsIEPNGFilter:function(){/*@cc_on
    /*@if ((@_jscript_version >= 5.5 && @_jscript_version <= 5.6) || @_jscript_version == 5.7)
     return true && !window.XMLHttpRequest;
    @else @*/return false;/*@end
   @*/},version:function(){return'1.0';},currentQueryString:function(){var qs=window.location.search.substr(1);var params={};qs.split('&').each(function(param){var split_params=param.split('=');params[split_params[0]]=split_params[1];});return params;},currentFragment:function(){var hash;if(typeof window.location.hash!='undefined'){hash=window.location.hash;}else{hash=window.location.href;}
var frag_pos=hash.indexOf('#');if(frag_pos==-1){return hash;}
return hash.substr(frag_pos+1);},loadScript:function(url,callback,sentinel){var load_check,script=$(document.createElement('script'));script.charset='utf-8';script.type='text/javascript';script.src=url;document.body.appendChild(script);if(typeof callback=='function'&&typeof sentinel!='undefined'){load_check=setInterval(function(){try{if(typeof window[sentinel]!='undefined'){clearInterval(load_check);callback.defer(script);}}catch(e){CP.log(e);}},50);};},LinkedList:function(){var that=this;var head=null;var num_objects=0;function push(){for(var i=arguments.length-1;i>=0;i--){if(typeof arguments[i]=='undefined'){throw"Pushing undefined value"}
head={o:arguments[i],n:head};num_objects++;};return that;};this.push=push;function pop(){if(!head){throw"Poping empty list";}
var obj=head.o;head=head.n;num_objects--;return obj;};this.pop=pop;function remove(obj){var walk=head;var last=null;while(walk){if(walk.o===obj){if(last===null){head=walk.n;}else{last.n=walk.n;}
delete walk;num_objects--;break;}else{last=walk;walk=walk.n;}}
return that;};this.remove=remove;function reverse(){var tail=null,next,walk=head;while(walk){tail=walk;walk=walk.n;}
walk=head;while(walk&&walk!=tail){next=tail.n;tail.n=walk;walk=walk.n;tail.n.n=next;}
head=tail;return that;};this.reverse=reverse;function empty(){var walk=head,last;while(walk){last=walk;walk=walk.n;last.n=null;delete last;num_objects--;}
head=null;return that;};this.empty=empty;function filter(callback){var walk=head;var last=null;while(walk){if(callback(walk.o)){if(last===null){head=walk.n;delete walk;walk=head;}else{last.n=walk.n;delete walk;walk=last.n;}
num_objects--;}else{last=walk;walk=walk.n;}}
return that;};this.filter=filter;function length(){return num_objects;};this.length=length;function string(){var walk=head;var str='<@LinkedList: ';while(walk){str+=walk.o.toString();walk=walk.n;if(walk){str+=', ';}}
return str+'>';};this.string=string;this.toString=string;function contains(obj){var walk=head;while(walk){if(walk.o===obj){return true;}
walk=walk.n;}
return false;};this.contains=contains;for(var i=arguments.length-1;i>=0;i--){push(arguments[i]);};},EventRegistry:function(){var event_queue_next_id=0;var queues={};function objToId(obj){try{if(typeof obj[CP.Utility.Constants.EventRegistryMagicKey]!='undefined'){return obj[CP.Utility.Constants.EventRegistryMagicKey];}
return false;}catch(e){return false;}};function initQueue(obj){var id=objToId(obj);if(id===false){id=obj[CP.Utility.Constants.EventRegistryMagicKey]=event_queue_next_id++;}
if(!queues[id]){queues[id]={};}
return true;};this.initQueue=initQueue;function addEvent(obj,event,callback,single_shot){var id=objToId(obj);if(id===false||!queues[id]||typeof callback!='function'){return false;}
if(!queues[id][event]){queues[id][event]=new CP.Utility.LinkedList();}
queues[id][event].push({'callback':callback,'single_shot':single_shot==true});return true;};this.addEvent=addEvent;function removeEvent(obj,event,callback){var id=objToId(obj);if(id===false||!queues[id]||typeof callback!='function'){return false;}
if(queues[id][event]){queues[id][event].filter(function(o){return o.callback===callback;});}
return true;};this.removeEvent=removeEvent;function fireEvent(obj,event,synchronous){var id=objToId(obj);if(id===false||!queues[id]){return false;}
if(queues[id][event]){var args=$A(arguments).slice(3);queues[id][event].filter(function(o){if(synchronous){o.callback.apply(o,args);}else{Function.defer.apply(o.callback,args);}
return o.single_shot;});}
return true;};this.fireEvent=fireEvent;function removeEvents(obj,event){var id=objToId(obj);if(id===false||!queues[id]){return false;}
if(queues[id][event]){queues[id][event].empty();}
return true;};this.removeEvents=removeEvents;},EventHandler:function(element,event,callback,one_shot){function callCallback(e){callback(e);if(one_shot){clear();}};function register(){Event.observe(element,event,callCallback);};this.register=register;function clear(){Event.stopObserving(element,event,callCallback);};this.clear=clear;function fire(){callCallback();};this.fire=fire;},Constants:{Debug:true,DebugParam:'__debug',EventRegistryMagicKey:'__EventRegistryId'}};CP.Utility.EventRegistry=new CP.Utility.EventRegistry();(function(){var params=CP.Utility.currentQueryString();if(params[CP.Utility.Constants.DebugParam]=='false'){CP.Utility.Constants.Debug=false;}else if(params[CP.Utility.Constants.DebugParam]=='true'){CP.Utility.Constants.Debug=true;}})();Element.addMethods({removeChildren:function(element){element=$(element);for(var i=element.childNodes.length-1;i>=0;i--){element.removeChild(element.childNodes[i]);};return element;}});Object.extend(String.prototype,{toDOM:function(){var div=$(document.createElement('div'));div.update(this);return div.down();}});};var CP;if(Object.isUndefined(CP.Utility.CarouselManager)){CP.Utility.CarouselManager={carousels:[],init:function(){CP.Utility.EventRegistry.initQueue(this);$$('.carousel').each(CP.Utility.CarouselManager.create);},create:function(root){var carousel=new CP.Utility.CarouselManager.Carousel(root);CP.Utility.CarouselManager.carousels.push(carousel);CP.Utility.EventRegistry.fireEvent(this,'new-carousel',false,carousel);},findById:function(id){for(var i=CP.Utility.CarouselManager.carousels.length-1;i>=0;i--){if(CP.Utility.CarouselManager.carousels[i].getId()==id){return CP.Utility.CarouselManager.carousels[i];};};},Carousel:Class.create({initialize:function(root,options){var that=this;var attributes={offset:0,delta:1,duration:500,'control-location':null};var panes=[];var current_pane=null;var list=root.select('ul').first();function redraw(){var initial_offset=0;for(var i=0;i<current_pane.position;i++){initial_offset+=parseInt(panes[i].element.getStyle('width'));};if((-1*initial_offset)!=parseInt(list.getStyle('left'))){if(typeof Fx!='undefined'){var fx=new Fx.Style(list,'left',{duration:attributes.duration});fx.custom(parseInt(list.getStyle('left')),(-1*initial_offset));}else{list.setStyle({left:(-1*initial_offset)+'px'});};};};function gotoPane(pane_index){if(pane_index>=panes.length||pane_index<0){return;};current_pane=panes[pane_index];redraw();CP.Utility.EventRegistry.fireEvent(that,'goto-pane',false,that);}
this.gotoPane=gotoPane;function currentPane(){return current_pane;};this.currentPane=currentPane;function nextCallback(event){event.stopPropagation();event.preventDefault();next();};function next(){if(current_pane.position+attributes.delta>=panes.length){current_pane=panes[0];}else{current_pane=panes[current_pane.position+attributes.delta];};redraw();CP.Utility.EventRegistry.fireEvent(that,'next-pane',false,that);};this.next=next;function prevCallback(event){event.stopPropagation();event.preventDefault();prev();};function prev(){if(current_pane.position==0){current_pane=panes[panes.length-attributes.delta];}else if(current_pane.position-attributes.delta<0){current_pane=panes[0];}else{current_pane=panes[current_pane.position-attributes.delta];};redraw();CP.Utility.EventRegistry.fireEvent(that,'previous-pane',false,that);};this.prev=prev;this.previous=prev;function getId(){if(root.id!=''){return root.id;};};this.getId=getId;function toString(){var str='<@Carousel panes='+panes.length+' current-pane='+(currentPane().position+1);var id=getId();if(typeof id!='undefined'){str=str+' id='+id;};$H(attributes).each(function(attribute){str=str+' '+attribute.key+'='+attribute.value;});return str+'>';};this.toString=toString;CP.Utility.EventRegistry.initQueue(this);if(root.hasAttribute('carousel-offset')){attributes.offset=root.getAttribute('carousel-offset');};if(root.hasAttribute('carousel-delta')){attributes.delta=root.getAttribute('carousel-delta');};if(root.hasAttribute('carousel-duration')){attributes.duration=root.getAttribute('carousel-duration');};if(root.hasAttribute('carousel-control-location')){attributes['control-location']=root.getAttribute('carousel-control-location');};if(typeof options!='undefined'){if(typeof options.offset!='undefined'){attributes.offset=options.offset;};if(typeof options.delta!='undefined'){attributes.delta=options.delta;};if(typeof options.duration!='undefined'){attributes.duration=options.duration;};if(typeof options['control-location']!='undefined'){attributes['control-location']=options['control-location'];};};attributes.offset=parseInt(attributes.offset);attributes.delta=parseInt(attributes.delta);attributes.duration=parseInt(attributes.duration);var items=root.select('li');for(var i=0;i<items.length;i++){panes.push({width:parseInt(items[i].getStyle('width')),element:items[i],position:i});};if(attributes.delta>panes.length){attributes.delta=panes.length;};var width=0;for(var i=0;i<items.length;i++){panes[i].element.setStyle({position:'absolute',top:'0px',left:width+'px'});width+=parseInt(panes[i].element.getStyle('width'));};if(list.getStyle('left')===null){list.setStyle({left:'0px'});};current_pane=panes[attributes.offset];redraw();root.select('a[rel=next-pane]').each(function(element){Event.observe(element,'click',nextCallback);});root.select('a[rel=previous-pane]').each(function(element){Event.observe(element,'click',prevCallback);});if(attributes['control-location']!=null){$$(attributes['control-location']+' a[rel=next-pane]').each(function(element){Event.observe(element,'click',nextCallback);});$$(attributes['control-location']+' a[rel=previous-pane]').each(function(element){Event.observe(element,'click',prevCallback);});};}})};document.observe('dom:loaded',function(){CP.Utility.CarouselManager.init();});};