",""]||(!tags.indexOf("",""]||!tags.indexOf("",""]||jQuery.browser.msie&&[1,"div "," "]||[0,"",""];div.innerHTML=wrap[1]+elem+wrap[2];while(wrap[0]--)div=div.lastChild;if(jQuery.browser.msie){var tbody=!tags.indexOf(""&&tags.indexOf("=0;--j)if(jQuery.nodeName(tbody[j],"tbody")&&!tbody[j].childNodes.length)tbody[j].parentNode.removeChild(tbody[j]);if(/^\s/.test(elem))div.insertBefore(context.createTextNode(elem.match(/^\s*/)[0]),div.firstChild);}elem=jQuery.makeArray(div.childNodes);}if(elem.length===0&&(!jQuery.nodeName(elem,"form")&&!jQuery.nodeName(elem,"select")))return;if(elem[0]==undefined||jQuery.nodeName(elem,"form")||elem.options)ret.push(elem);else
ret=jQuery.merge(ret,elem);});return ret;},attr:function(elem,name,value){if(!elem||elem.nodeType==3||elem.nodeType==8)return undefined;var notxml=!jQuery.isXMLDoc(elem),set=value!==undefined,msie=jQuery.browser.msie;name=notxml&&jQuery.props[name]||name;if(elem.tagName){var special=/href|src|style/.test(name);if(name=="selected"&&jQuery.browser.safari)elem.parentNode.selectedIndex;if(name in elem&¬xml&&!special){if(set){if(name=="type"&&jQuery.nodeName(elem,"input")&&elem.parentNode)throw"type property can't be changed";elem[name]=value;}if(jQuery.nodeName(elem,"form")&&elem.getAttributeNode(name))return elem.getAttributeNode(name).nodeValue;return elem[name];}if(msie&¬xml&&name=="style")return jQuery.attr(elem.style,"cssText",value);if(set)elem.setAttribute(name,""+value);var attr=msie&¬xml&&special?elem.getAttribute(name,2):elem.getAttribute(name);return attr===null?undefined:attr;}if(msie&&name=="opacity"){if(set){elem.zoom=1;elem.filter=(elem.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(value)+''=="NaN"?"":"alpha(opacity="+value*100+")");}return elem.filter&&elem.filter.indexOf("opacity=")>=0?(parseFloat(elem.filter.match(/opacity=([^)]*)/)[1])/100)+'':"";}name=name.replace(/-([a-z])/ig,function(all,letter){return letter.toUpperCase();});if(set)elem[name]=value;return elem[name];},trim:function(text){return(text||"").replace(/^\s+|\s+$/g,"");},makeArray:function(array){var ret=[];if(array!=null){var i=array.length;if(i==null||array.split||array.setInterval||array.call)ret[0]=array;else
while(i)ret[--i]=array[i];}return ret;},inArray:function(elem,array){for(var i=0,length=array.length;i*",this).remove();while(this.firstChild)this.removeChild(this.firstChild);}},function(name,fn){jQuery.fn[name]=function(){return this.each(fn,arguments);};});jQuery.each(["Height","Width"],function(i,name){var type=name.toLowerCase();jQuery.fn[type]=function(size){return this[0]==window?jQuery.browser.opera&&document.body["client"+name]||jQuery.browser.safari&&window["inner"+name]||document.compatMode=="CSS1Compat"&&document.documentElement["client"+name]||document.body["client"+name]:this[0]==document?Math.max(Math.max(document.body["scroll"+name],document.documentElement["scroll"+name]),Math.max(document.body["offset"+name],document.documentElement["offset"+name])):size==undefined?(this.length?jQuery.css(this[0],type):null):this.css(type,size.constructor==String?size:size+"px");};});function num(elem,prop){return elem[0]&&parseInt(jQuery.curCSS(elem[0],prop,true),10)||0;}var chars=jQuery.browser.safari&&parseInt(jQuery.browser.version)<417?"(?:[\\w*_-]|\\\\.)":"(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",quickChild=new RegExp("^>\\s*("+chars+"+)"),quickID=new RegExp("^("+chars+"+)(#)("+chars+"+)"),quickClass=new RegExp("^([#.]?)("+chars+"*)");jQuery.extend({expr:{"":function(a,i,m){return m[2]=="*"||jQuery.nodeName(a,m[2]);},"#":function(a,i,m){return a.getAttribute("id")==m[2];},":":{lt:function(a,i,m){return im[3]-0;},nth:function(a,i,m){return m[3]-0==i;},eq:function(a,i,m){return m[3]-0==i;},first:function(a,i){return i==0;},last:function(a,i,m,r){return i==r.length-1;},even:function(a,i){return i%2==0;},odd:function(a,i){return i%2;},"first-child":function(a){return a.parentNode.getElementsByTagName("*")[0]==a;},"last-child":function(a){return jQuery.nth(a.parentNode.lastChild,1,"previousSibling")==a;},"only-child":function(a){return!jQuery.nth(a.parentNode.lastChild,2,"previousSibling");},parent:function(a){return a.firstChild;},empty:function(a){return!a.firstChild;},contains:function(a,i,m){return(a.textContent||a.innerText||jQuery(a).text()||"").indexOf(m[3])>=0;},visible:function(a){return"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden";},hidden:function(a){return"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden";},enabled:function(a){return!a.disabled;},disabled:function(a){return a.disabled;},checked:function(a){return a.checked;},selected:function(a){return a.selected||jQuery.attr(a,"selected");},text:function(a){return"text"==a.type;},radio:function(a){return"radio"==a.type;},checkbox:function(a){return"checkbox"==a.type;},file:function(a){return"file"==a.type;},password:function(a){return"password"==a.type;},submit:function(a){return"submit"==a.type;},image:function(a){return"image"==a.type;},reset:function(a){return"reset"==a.type;},button:function(a){return"button"==a.type||jQuery.nodeName(a,"button");},input:function(a){return/input|select|textarea|button/i.test(a.nodeName);},has:function(a,i,m){return jQuery.find(m[3],a).length;},header:function(a){return/h\d/i.test(a.nodeName);},animated:function(a){return jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length;}}},parse:[/^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,new RegExp("^([:.#]*)("+chars+"+)")],multiFilter:function(expr,elems,not){var old,cur=[];while(expr&&expr!=old){old=expr;var f=jQuery.filter(expr,elems,not);expr=f.t.replace(/^\s*,\s*/,"");cur=not?elems=f.r:jQuery.merge(cur,f.r);}return cur;},find:function(t,context){if(typeof t!="string")return[t];if(context&&context.nodeType!=1&&context.nodeType!=9)return[];context=context||document;var ret=[context],done=[],last,nodeName;while(t&&last!=t){var r=[];last=t;t=jQuery.trim(t);var foundToken=false,re=quickChild,m=re.exec(t);if(m){nodeName=m[1].toUpperCase();for(var i=0;ret[i];i++)for(var c=ret[i].firstChild;c;c=c.nextSibling)if(c.nodeType==1&&(nodeName=="*"||c.nodeName.toUpperCase()==nodeName))r.push(c);ret=r;t=t.replace(re,"");if(t.indexOf(" ")==0)continue;foundToken=true;}else{re=/^([>+~])\s*(\w*)/i;if((m=re.exec(t))!=null){r=[];var merge={};nodeName=m[2].toUpperCase();m=m[1];for(var j=0,rl=ret.length;j=0;if(!not&&pass||not&&!pass)tmp.push(r[i]);}return tmp;},filter:function(t,r,not){var last;while(t&&t!=last){last=t;var p=jQuery.parse,m;for(var i=0;p[i];i++){m=p[i].exec(t);if(m){t=t.substring(m[0].length);m[2]=m[2].replace(/\\/g,"");break;}}if(!m)break;if(m[1]==":"&&m[2]=="not")r=isSimple.test(m[3])?jQuery.filter(m[3],r,true).r:jQuery(r).not(m[3]);else if(m[1]==".")r=jQuery.classFilter(r,m[2],not);else if(m[1]=="["){var tmp=[],type=m[3];for(var i=0,rl=r.length;i=0)^not)tmp.push(a);}r=tmp;}else if(m[1]==":"&&m[2]=="nth-child"){var merge={},tmp=[],test=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(m[3]=="even"&&"2n"||m[3]=="odd"&&"2n+1"||!/\D/.test(m[3])&&"0n+"+m[3]||m[3]),first=(test[1]+(test[2]||1))-0,last=test[3]-0;for(var i=0,rl=r.length;i=0)add=true;if(add^not)tmp.push(node);}r=tmp;}else{var fn=jQuery.expr[m[1]];if(typeof fn=="object")fn=fn[m[2]];if(typeof fn=="string")fn=eval("false||function(a,i){return "+fn+";}");r=jQuery.grep(r,function(elem,i){return fn(elem,i,m,r);},not);}}return{r:r,t:t};},dir:function(elem,dir){var matched=[],cur=elem[dir];while(cur&&cur!=document){if(cur.nodeType==1)matched.push(cur);cur=cur[dir];}return matched;},nth:function(cur,result,dir,elem){result=result||1;var num=0;for(;cur;cur=cur[dir])if(cur.nodeType==1&&++num==result)break;return cur;},sibling:function(n,elem){var r=[];for(;n;n=n.nextSibling){if(n.nodeType==1&&n!=elem)r.push(n);}return r;}});jQuery.event={add:function(elem,types,handler,data){if(elem.nodeType==3||elem.nodeType==8)return;if(jQuery.browser.msie&&elem.setInterval)elem=window;if(!handler.guid)handler.guid=this.guid++;if(data!=undefined){var fn=handler;handler=this.proxy(fn,function(){return fn.apply(this,arguments);});handler.data=data;}var events=jQuery.data(elem,"events")||jQuery.data(elem,"events",{}),handle=jQuery.data(elem,"handle")||jQuery.data(elem,"handle",function(){if(typeof jQuery!="undefined"&&!jQuery.event.triggered)return jQuery.event.handle.apply(arguments.callee.elem,arguments);});handle.elem=elem;jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];handler.type=parts[1];var handlers=events[type];if(!handlers){handlers=events[type]={};if(!jQuery.event.special[type]||jQuery.event.special[type].setup.call(elem)===false){if(elem.addEventListener)elem.addEventListener(type,handle,false);else if(elem.attachEvent)elem.attachEvent("on"+type,handle);}}handlers[handler.guid]=handler;jQuery.event.global[type]=true;});elem=null;},guid:1,global:{},remove:function(elem,types,handler){if(elem.nodeType==3||elem.nodeType==8)return;var events=jQuery.data(elem,"events"),ret,index;if(events){if(types==undefined||(typeof types=="string"&&types.charAt(0)=="."))for(var type in events)this.remove(elem,type+(types||""));else{if(types.type){handler=types.handler;types=types.type;}jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];if(events[type]){if(handler)delete events[type][handler.guid];else
for(handler in events[type])if(!parts[1]||events[type][handler].type==parts[1])delete events[type][handler];for(ret in events[type])break;if(!ret){if(!jQuery.event.special[type]||jQuery.event.special[type].teardown.call(elem)===false){if(elem.removeEventListener)elem.removeEventListener(type,jQuery.data(elem,"handle"),false);else if(elem.detachEvent)elem.detachEvent("on"+type,jQuery.data(elem,"handle"));}ret=null;delete events[type];}}});}for(ret in events)break;if(!ret){var handle=jQuery.data(elem,"handle");if(handle)handle.elem=null;jQuery.removeData(elem,"events");jQuery.removeData(elem,"handle");}}},trigger:function(type,data,elem,donative,extra){data=jQuery.makeArray(data);if(type.indexOf("!")>=0){type=type.slice(0,-1);var exclusive=true;}if(!elem){if(this.global[type])jQuery("*").add([window,document]).trigger(type,data);}else{if(elem.nodeType==3||elem.nodeType==8)return undefined;var val,ret,fn=jQuery.isFunction(elem[type]||null),event=!data[0]||!data[0].preventDefault;if(event){data.unshift({type:type,target:elem,preventDefault:function(){},stopPropagation:function(){},timeStamp:now()});data[0][expando]=true;}data[0].type=type;if(exclusive)data[0].exclusive=true;var handle=jQuery.data(elem,"handle");if(handle)val=handle.apply(elem,data);if((!fn||(jQuery.nodeName(elem,'a')&&type=="click"))&&elem["on"+type]&&elem["on"+type].apply(elem,data)===false)val=false;if(event)data.shift();if(extra&&jQuery.isFunction(extra)){ret=extra.apply(elem,val==null?data:data.concat(val));if(ret!==undefined)val=ret;}if(fn&&donative!==false&&val!==false&&!(jQuery.nodeName(elem,'a')&&type=="click")){this.triggered=true;try{elem[type]();}catch(e){}}this.triggered=false;}return val;},handle:function(event){var val,ret,namespace,all,handlers;event=arguments[0]=jQuery.event.fix(event||window.event);namespace=event.type.split(".");event.type=namespace[0];namespace=namespace[1];all=!namespace&&!event.exclusive;handlers=(jQuery.data(this,"events")||{})[event.type];for(var j in handlers){var handler=handlers[j];if(all||handler.type==namespace){event.handler=handler;event.data=handler.data;ret=handler.apply(this,arguments);if(val!==false)val=ret;if(ret===false){event.preventDefault();event.stopPropagation();}}}return val;},fix:function(event){if(event[expando]==true)return event;var originalEvent=event;event={originalEvent:originalEvent};var props="altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target timeStamp toElement type view wheelDelta which".split(" ");for(var i=props.length;i;i--)event[props[i]]=originalEvent[props[i]];event[expando]=true;event.preventDefault=function(){if(originalEvent.preventDefault)originalEvent.preventDefault();originalEvent.returnValue=false;};event.stopPropagation=function(){if(originalEvent.stopPropagation)originalEvent.stopPropagation();originalEvent.cancelBubble=true;};event.timeStamp=event.timeStamp||now();if(!event.target)event.target=event.srcElement||document;if(event.target.nodeType==3)event.target=event.target.parentNode;if(!event.relatedTarget&&event.fromElement)event.relatedTarget=event.fromElement==event.target?event.toElement:event.fromElement;if(event.pageX==null&&event.clientX!=null){var doc=document.documentElement,body=document.body;event.pageX=event.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc.clientLeft||0);event.pageY=event.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc.clientTop||0);}if(!event.which&&((event.charCode||event.charCode===0)?event.charCode:event.keyCode))event.which=event.charCode||event.keyCode;if(!event.metaKey&&event.ctrlKey)event.metaKey=event.ctrlKey;if(!event.which&&event.button)event.which=(event.button&1?1:(event.button&2?3:(event.button&4?2:0)));return event;},proxy:function(fn,proxy){proxy.guid=fn.guid=fn.guid||proxy.guid||this.guid++;return proxy;},special:{ready:{setup:function(){bindReady();return;},teardown:function(){return;}},mouseenter:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseover",jQuery.event.special.mouseenter.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseover",jQuery.event.special.mouseenter.handler);return true;},handler:function(event){if(withinElement(event,this))return true;event.type="mouseenter";return jQuery.event.handle.apply(this,arguments);}},mouseleave:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseout",jQuery.event.special.mouseleave.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseout",jQuery.event.special.mouseleave.handler);return true;},handler:function(event){if(withinElement(event,this))return true;event.type="mouseleave";return jQuery.event.handle.apply(this,arguments);}}}};jQuery.fn.extend({bind:function(type,data,fn){return type=="unload"?this.one(type,data,fn):this.each(function(){jQuery.event.add(this,type,fn||data,fn&&data);});},one:function(type,data,fn){var one=jQuery.event.proxy(fn||data,function(event){jQuery(this).unbind(event,one);return(fn||data).apply(this,arguments);});return this.each(function(){jQuery.event.add(this,type,one,fn&&data);});},unbind:function(type,fn){return this.each(function(){jQuery.event.remove(this,type,fn);});},trigger:function(type,data,fn){return this.each(function(){jQuery.event.trigger(type,data,this,true,fn);});},triggerHandler:function(type,data,fn){return this[0]&&jQuery.event.trigger(type,data,this[0],false,fn);},toggle:function(fn){var args=arguments,i=1;while(i=0){var selector=url.slice(off,url.length);url=url.slice(0,off);}callback=callback||function(){};var type="GET";if(params)if(jQuery.isFunction(params)){callback=params;params=null;}else{params=jQuery.param(params);type="POST";}var self=this;jQuery.ajax({url:url,type:type,dataType:"html",data:params,complete:function(res,status){if(status=="success"||status=="notmodified")self.html(selector?jQuery("").append(res.responseText.replace(/ ").parent();if(this.container.size()===0)this.container=this.clip.wrap("").parent();b!==""&&this.container.parent()[0].className.indexOf("jcarousel-skin")==-1&&this.container.wrap('');this.buttonPrev=g(".jcarousel-prev",this.container);if(this.buttonPrev.size()===0&&this.options.buttonPrevHTML!==null)this.buttonPrev=g(this.options.buttonPrevHTML).appendTo(this.container);this.buttonPrev.addClass(this.className("jcarousel-prev"));this.buttonNext= g(".jcarousel-next",this.container);if(this.buttonNext.size()===0&&this.options.buttonNextHTML!==null)this.buttonNext=g(this.options.buttonNextHTML).appendTo(this.container);this.buttonNext.addClass(this.className("jcarousel-next"));this.clip.addClass(this.className("jcarousel-clip")).css({position:"relative"});this.list.addClass(this.className("jcarousel-list")).css({overflow:"hidden",position:"relative",top:0,margin:0,padding:0}).css(this.options.rtl?"right":"left",0);this.container.addClass(this.className("jcarousel-container")).css({position:"relative"}); !this.options.vertical&&this.options.rtl&&this.container.addClass("jcarousel-direction-rtl").attr("dir","rtl");var j=this.options.visible!==null?Math.ceil(this.clipping()/this.options.visible):null,b=this.list.children("li"),e=this;if(b.size()>0){var h=0,i=this.options.offset;b.each(function(){e.format(this,i++);h+=e.dimension(this,j)});this.list.css(this.wh,h+100+"px");if(!c||c.size===void 0)this.options.size=b.size()}this.container.css("display","block");this.buttonNext.css("display","block");this.buttonPrev.css("display", "block");this.funcNext=function(){e.next()};this.funcPrev=function(){e.prev()};this.funcResize=function(){e.resizeTimer&&clearTimeout(e.resizeTimer);e.resizeTimer=setTimeout(function(){e.reload()},100)};this.options.initCallback!==null&&this.options.initCallback(this,"init");!m&&g.browser.safari?(this.buttons(!1,!1),g(window).bind("load.jcarousel",function(){e.setup()})):this.setup()};var f=g.jcarousel;f.fn=f.prototype={jcarousel:"0.2.8"};f.fn.extend=f.extend=g.extend;f.fn.extend({setup:function(){this.prevLast= this.prevFirst=this.last=this.first=null;this.animating=!1;this.tail=this.resizeTimer=this.timer=null;this.inTail=!1;if(!this.locked){this.list.css(this.lt,this.pos(this.options.offset)+"px");var a=this.pos(this.options.start,!0);this.prevFirst=this.prevLast=null;this.animate(a,!1);g(window).unbind("resize.jcarousel",this.funcResize).bind("resize.jcarousel",this.funcResize);this.options.setupCallback!==null&&this.options.setupCallback(this)}},reset:function(){this.list.empty();this.list.css(this.lt, "0px");this.list.css(this.wh,"10px");this.options.initCallback!==null&&this.options.initCallback(this,"reset");this.setup()},reload:function(){this.tail!==null&&this.inTail&&this.list.css(this.lt,f.intval(this.list.css(this.lt))+this.tail);this.tail=null;this.inTail=!1;this.options.reloadCallback!==null&&this.options.reloadCallback(this);if(this.options.visible!==null){var a=this,c=Math.ceil(this.clipping()/this.options.visible),b=0,d=0;this.list.children("li").each(function(f){b+=a.dimension(this, c);f+1this.options.size)c=this.options.size;for(var b=a;b<=c;b++){var d=this.get(b);if(!d.length||d.hasClass("jcarousel-item-placeholder"))return!1}return!0}, get:function(a){return g(">.jcarousel-item-"+a,this.list)},add:function(a,c){var b=this.get(a),d=0,p=g(c);if(b.length===0)for(var j,e=f.intval(a),b=this.create(a);;){if(j=this.get(--e),e<=0||j.length){e<=0?this.list.prepend(b):j.after(b);break}}else d=this.dimension(b);p.get(0).nodeName.toUpperCase()=="LI"?(b.replaceWith(p),b=p):b.empty().append(c);this.format(b.removeClass(this.className("jcarousel-item-placeholder")),a);p=this.options.visible!==null?Math.ceil(this.clipping()/this.options.visible): null;d=this.dimension(b,p)-d;a>0&&a=this.first&&a<=this.last)){var b=this.dimension(c);athis.options.size?this.options.size:a);for(var d=this.first>a,g=this.options.wrap!="circular"&&this.first<=1?1:this.first,j=d?this.get(g): this.get(this.last),e=d?g:g-1,h=null,i=0,k=!1,l=0;d?--e>=a:++ethis.options.size)))j=this.get(this.index(e)),j.length&&(h=this.add(e,j.clone(!0)));j=h;l=this.dimension(h);k&&(i+=l);if(this.first!==null&&(this.options.wrap=="circular"||e>=1&&(this.options.size===null||e<= this.options.size)))b=d?b+l:b-l}for(var g=this.clipping(),m=[],o=0,n=0,j=this.get(a-1),e=a;++o;){h=this.get(e);k=!h.length;if(h.length===0){h=this.create(e).addClass(this.className("jcarousel-item-placeholder"));if(j.length===0)this.list.prepend(h);else j[d?"before":"after"](h);if(this.first!==null&&this.options.wrap=="circular"&&this.options.size!==null&&(e<=0||e>this.options.size))j=this.get(this.index(e)),j.length&&(h=this.add(e,j.clone(!0)))}j=h;l=this.dimension(h);if(l===0)throw Error("jCarousel: No width/height set for items. This will cause an infinite loop. Aborting..."); this.options.wrap!="circular"&&this.options.size!==null&&e>this.options.size?m.push(h):k&&(i+=l);n+=l;if(n>=g)break;e++}for(h=0;h0&&(this.list.css(this.wh,this.dimension(this.list)+i+"px"),d&&(b-=i,this.list.css(this.lt,f.intval(this.list.css(this.lt))-i+"px")));i=a+o-1;if(this.options.wrap!="circular"&&this.options.size&&i>this.options.size)i=this.options.size;if(e>i){o=0;e=i;for(n=0;++o;){h=this.get(e--);if(!h.length)break;n+=this.dimension(h);if(n>=g)break}}e=i-o+ 1;this.options.wrap!="circular"&&e<1&&(e=1);if(this.inTail&&d)b+=this.tail,this.inTail=!1;this.tail=null;if(this.options.wrap!="circular"&&i==this.options.size&&i-o+1>=1&&(d=f.intval(this.get(i).css(!this.options.vertical?"marginRight":"marginBottom")),n-d>g))this.tail=n-g-d;if(c&&a===this.options.size&&this.tail)b-=this.tail,this.inTail=!0;for(;a-- >e;)b+=this.dimension(this.get(a));this.prevFirst=this.first;this.prevLast=this.last;this.first=e;this.last=i;return b},animate:function(a,c){if(!this.locked&& !this.animating){this.animating=!0;var b=this,d=function(){b.animating=!1;a===0&&b.list.css(b.lt,0);!b.autoStopped&&(b.options.wrap=="circular"||b.options.wrap=="both"||b.options.wrap=="last"||b.options.size===null||b.last=b.first&&c<=b.last)&&(c<1||c>b.options.size)&&b.remove(c)}; this.notify("onBeforeAnimation");if(!this.options.animation||c===!1)this.list.css(this.lt,a+"px"),d();else{var f=!this.options.vertical?this.options.rtl?{right:a}:{left:a}:{top:a},d={duration:this.options.animation,easing:this.options.easing,complete:d};if(g.isFunction(this.options.animationStepCallback))d.step=this.options.animationStepCallback;this.list.animate(f,d)}}},startAuto:function(a){if(a!==void 0)this.options.auto=a;if(this.options.auto===0)return this.stopAuto();if(this.timer===null){this.autoStopped= !1;var c=this;this.timer=window.setTimeout(function(){c.next()},this.options.auto*1E3)}},stopAuto:function(){this.pauseAuto();this.autoStopped=!0},pauseAuto:function(){if(this.timer!==null)window.clearTimeout(this.timer),this.timer=null},buttons:function(a,c){if(a==null&&(a=!this.locked&&this.options.size!==0&&(this.options.wrap&&this.options.wrap!="first"||this.options.size===null||this.last=this.options.size))a=this.tail!==null&&!this.inTail;if(c==null&&(c=!this.locked&&this.options.size!==0&&(this.options.wrap&&this.options.wrap!="last"||this.first>1),!this.locked&&(!this.options.wrap||this.options.wrap=="last")&&this.options.size!==null&&this.first==1))c=this.tail!==null&&this.inTail;var b=this;this.buttonNext.size()>0?(this.buttonNext.unbind(this.options.buttonNextEvent+".jcarousel",this.funcNext),a&&this.buttonNext.bind(this.options.buttonNextEvent+".jcarousel",this.funcNext), this.buttonNext[a?"removeClass":"addClass"](this.className("jcarousel-next-disabled")).attr("disabled",a?!1:!0),this.options.buttonNextCallback!==null&&this.buttonNext.data("jcarouselstate")!=a&&this.buttonNext.each(function(){b.options.buttonNextCallback(b,this,a)}).data("jcarouselstate",a)):this.options.buttonNextCallback!==null&&this.buttonNextState!=a&&this.options.buttonNextCallback(b,null,a);this.buttonPrev.size()>0?(this.buttonPrev.unbind(this.options.buttonPrevEvent+".jcarousel",this.funcPrev), c&&this.buttonPrev.bind(this.options.buttonPrevEvent+".jcarousel",this.funcPrev),this.buttonPrev[c?"removeClass":"addClass"](this.className("jcarousel-prev-disabled")).attr("disabled",c?!1:!0),this.options.buttonPrevCallback!==null&&this.buttonPrev.data("jcarouselstate")!=c&&this.buttonPrev.each(function(){b.options.buttonPrevCallback(b,this,c)}).data("jcarouselstate",c)):this.options.buttonPrevCallback!==null&&this.buttonPrevState!=c&&this.options.buttonPrevCallback(b,null,c);this.buttonNextState= a;this.buttonPrevState=c},notify:function(a){var c=this.prevFirst===null?"init":this.prevFirst=j&&k<=e)&&a(k)}}},create:function(a){return this.format("",a)},format:function(a,c){for(var a=g(a),b=a.get(0).className.split(" "),d=0;d -1,
WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
Gecko: navigator.userAgent.indexOf('Gecko') > -1 &&
navigator.userAgent.indexOf('KHTML') === -1,
MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
},
BrowserFeatures: {
XPath: !!document.evaluate,
SelectorsAPI: !!document.querySelector,
ElementExtensions: !!window.HTMLElement,
SpecificElementExtensions:
document.createElement('div')['__proto__'] &&
document.createElement('div')['__proto__'] !==
document.createElement('form')['__proto__']
},
ScriptFragment: '
> ...
*/
UI.Carousel = Class.create(UI.Options, {
// Group: Options
options: {
// Property: direction
// Can be horizontal or vertical, horizontal by default
direction : "horizontal",
// Property: previousButton
// Selector of previous button inside carousel element, ".previous_button" by default,
// set it to false to ignore previous button
previousButton : ".previous_button",
// Property: nextButton
// Selector of next button inside carousel element, ".next_button" by default,
// set it to false to ignore next button
nextButton : ".next_button",
// Property: container
// Selector of carousel container inside carousel element, ".container" by default,
container : ".container",
// Property: scrollInc
// Define the maximum number of elements that gonna scroll each time, auto by default
scrollInc : "auto",
// Property: disabledButtonSuffix
// Define the suffix classanme used when a button get disabled, to '_disabled' by default
// Previous button classname will be previous_button_disabled
disabledButtonSuffix : '_disabled',
// Property: overButtonSuffix
// Define the suffix classanme used when a button has a rollover status, '_over' by default
// Previous button classname will be previous_button_over
overButtonSuffix : '_over'
},
/*
Group: Attributes
Property: element
DOM element containing the carousel
Property: id
DOM id of the carousel's element
Property: container
DOM element containing the carousel's elements
Property: elements
Array containing the carousel's elements as DOM elements
Property: previousButton
DOM id of the previous button
Property: nextButton
DOM id of the next button
Property: posAttribute
Define if the positions are from left or top
Property: dimAttribute
Define if the dimensions are horizontal or vertical
Property: elementSize
Size of each element, it's an integer
Property: nbVisible
Number of visible elements, it's a float
Property: animating
Define whether the carousel is in animation or not
*/
/*
Group: Events
List of events fired by a carousel
Notice: Carousel custom events are automatically namespaced in "carousel:" (see Prototype custom events).
Examples:
This example will observe all carousels
> document.observe('carousel:scroll:ended', function(event) {
> alert("Carousel with id " + event.memo.carousel.id + " has just been scrolled");
> });
This example will observe only this carousel
> new UI.Carousel('horizontal_carousel').observe('scroll:ended', function(event) {
> alert("Carousel with id " + event.memo.carousel.id + " has just been scrolled");
> });
Property: previousButton:enabled
Fired when the previous button has just been enabled
Property: previousButton:disabled
Fired when the previous button has just been disabled
Property: nextButton:enabled
Fired when the next button has just been enabled
Property: nextButton:disabled
Fired when the next button has just been disabled
Property: scroll:started
Fired when a scroll has just started
Property: scroll:ended
Fired when a scroll has been done,
memo.shift = number of elements scrolled, it's a float
Property: sizeUpdated
Fired when the carousel size has just been updated.
Tips: memo.carousel.currentSize() = the new carousel size
*/
// Group: Constructor
/*
Method: initialize
Constructor function, should not be called directly
Parameters:
element - DOM element
options - (Hash) list of optional parameters
Returns:
this
*/
initialize: function(element, options) {
this.setOptions(options);
this.element = $(element);
this.id = this.element.id;
this.container = this.element.down(this.options.container).firstDescendant();
this.elements = this.container.childElements();
this.previousButton = this.options.previousButton == false ? null : this.element.down(this.options.previousButton);
this.nextButton = this.options.nextButton == false ? null : this.element.down(this.options.nextButton);
this.posAttribute = (this.options.direction == "horizontal" ? "left" : "top");
this.dimAttribute = (this.options.direction == "horizontal" ? "width" : "height");
this.elementSize = this.computeElementSize();
this.nbVisible = this.currentSize() / this.elementSize;
var scrollInc = this.options.scrollInc;
if (scrollInc == "auto")
scrollInc = Math.floor(this.nbVisible);
[ this.previousButton, this.nextButton ].each(function(button) {
if (!button) return;
var className = (button == this.nextButton ? "next_button" : "previous_button") + this.options.overButtonSuffix;
button.clickHandler = this.scroll.bind(this, (button == this.nextButton ? -1 : 1) * scrollInc * this.elementSize);
button.observe("click", button.clickHandler)
.observe("mouseover", function() {button.addClassName(className)}.bind(this))
.observe("mouseout", function() {button.removeClassName(className)}.bind(this));
}, this);
this.updateButtons();
},
// Group: Destructor
/*
Method: destroy
Cleans up DOM and memory
*/
destroy: function($super) {
[ this.previousButton, this.nextButton ].each(function(button) {
if (!button) return;
button.stopObserving("click", button.clickHandler);
}, this);
this.element.remove();
this.fire('destroyed');
},
// Group: Event handling
/*
Method: fire
Fires a carousel custom event automatically namespaced in "carousel:" (see Prototype custom events).
The memo object contains a "carousel" property referring to the carousel.
Example:
> document.observe('carousel:scroll:ended', function(event) {
> alert("Carousel with id " + event.memo.carousel.id + " has just been scrolled");
> });
Parameters:
eventName - an event name
memo - a memo object
Returns:
fired event
*/
fire: function(eventName, memo) {
memo = memo || { };
memo.carousel = this;
return this.element.fire('carousel:' + eventName, memo);
},
/*
Method: observe
Observe a carousel event with a handler function automatically bound to the carousel
Parameters:
eventName - an event name
handler - a handler function
Returns:
this
*/
observe: function(eventName, handler) {
this.element.observe('carousel:' + eventName, handler.bind(this));
return this;
},
/*
Method: stopObserving
Unregisters a carousel event, it must take the same parameters as this.observe (see Prototype stopObserving).
Parameters:
eventName - an event name
handler - a handler function
Returns:
this
*/
stopObserving: function(eventName, handler) {
this.element.stopObserving('carousel:' + eventName, handler);
return this;
},
// Group: Actions
/*
Method: checkScroll
Check scroll position to avoid unused space at right or bottom
Parameters:
position - position to check
updatePosition - should the container position be updated ? true/false
Returns:
position
*/
checkScroll: function(position, updatePosition) {
if (position > 0)
position = 0;
else {
var limit = this.elements.last().positionedOffset()[this.posAttribute] + this.elementSize;
var carouselSize = this.currentSize();
if (position + limit < carouselSize)
position += carouselSize - (position + limit);
position = Math.min(position, 0);
}
if (updatePosition)
this.container.style[this.posAttribute] = position + "px";
return position;
},
/*
Method: scroll
Scrolls carousel from maximum deltaPixel
Parameters:
deltaPixel - a float
Returns:
this
*/
scroll: function(deltaPixel) {
if (this.animating)
return this;
// Compute new position
var position = this.currentPosition() + deltaPixel;
// Check bounds
position = this.checkScroll(position, false);
// Compute shift to apply
deltaPixel = position - this.currentPosition();
if (deltaPixel != 0) {
this.animating = true;
this.fire("scroll:started");
var that = this;
// Move effects
this.container.morph("opacity:0.5", {duration: 0.2, afterFinish: function() {
that.container.morph(that.posAttribute + ": " + position + "px", {
duration: 0.4,
delay: 0.2,
afterFinish: function() {
that.container.morph("opacity:1", {
duration: 0.2,
afterFinish: function() {
that.animating = false;
that.updateButtons()
.fire("scroll:ended", { shift: deltaPixel / that.currentSize() });
}
});
}
});
}});
}
return this;
},
/*
Method: scrollTo
Scrolls carousel, so that element with specified index is the left-most.
This method is convenient when using carousel in a tabbed navigation.
Clicking on first tab should scroll first container into view, clicking on a fifth - fifth one, etc.
Indexing starts with 0.
Parameters:
Index of an element which will be a left-most visible in the carousel
Returns:
this
*/
scrollTo: function(index) {
if (this.animating || index < 0 || index > this.elements.length || index == this.currentIndex() || isNaN(parseInt(index)))
return this;
return this.scroll((this.currentIndex() - index) * this.elementSize);
},
/*
Method: updateButtons
Update buttons status to enabled or disabled
Them status is defined by classNames and fired as carousel's custom events
Returns:
this
*/
updateButtons: function() {
this.updatePreviousButton();
this.updateNextButton();
return this;
},
updatePreviousButton: function() {
var position = this.currentPosition();
var previousClassName = "previous_button" + this.options.disabledButtonSuffix;
if (this.previousButton.hasClassName(previousClassName) && position != 0) {
this.previousButton.removeClassName(previousClassName);
this.fire('previousButton:enabled');
}
if (!this.previousButton.hasClassName(previousClassName) && position == 0) {
this.previousButton.addClassName(previousClassName);
this.fire('previousButton:disabled');
}
},
updateNextButton: function() {
var lastPosition = this.currentLastPosition();
var size = this.currentSize();
var nextClassName = "next_button" + this.options.disabledButtonSuffix;
if (this.nextButton.hasClassName(nextClassName) && lastPosition != size) {
this.nextButton.removeClassName(nextClassName);
this.fire('nextButton:enabled');
}
if (!this.nextButton.hasClassName(nextClassName) && lastPosition == size) {
this.nextButton.addClassName(nextClassName);
this.fire('nextButton:disabled');
}
},
// Group: Size and Position
/*
Method: computeElementSize
Return elements size in pixel, height or width depends on carousel orientation.
Returns:
an integer value
*/
computeElementSize: function() {
return this.elements.first().getDimensions()[this.dimAttribute];
},
/*
Method: currentIndex
Returns current visible index of a carousel.
For example, a horizontal carousel with image #3 on left will return 3 and with half of image #3 will return 3.5
Don't forget that the first image have an index 0
Returns:
a float value
*/
currentIndex: function() {
return - this.currentPosition() / this.elementSize;
},
/*
Method: currentLastPosition
Returns the current position from the end of the last element. This value is in pixel.
Returns:
an integer value, if no images a present it will return 0
*/
currentLastPosition: function() {
if (this.container.childElements().empty())
return 0;
return this.currentPosition() +
this.elements.last().positionedOffset()[this.posAttribute] +
this.elementSize;
},
/*
Method: currentPosition
Returns the current position in pixel.
Tips: To get the position in elements use currentIndex()
Returns:
an integer value
*/
currentPosition: function() {
return this.container.getNumStyle(this.posAttribute);
},
/*
Method: currentSize
Returns the current size of the carousel in pixel
Returns:
Carousel's size in pixel
*/
currentSize: function() {
return this.container.parentNode.getDimensions()[this.dimAttribute];
},
/*
Method: updateSize
Should be called if carousel size has been changed (usually called with a liquid layout)
Returns:
this
*/
updateSize: function() {
this.nbVisible = this.currentSize() / this.elementSize;
var scrollInc = this.options.scrollInc;
if (scrollInc == "auto")
scrollInc = Math.floor(this.nbVisible);
[ this.previousButton, this.nextButton ].each(function(button) {
if (!button) return;
button.stopObserving("click", button.clickHandler);
button.clickHandler = this.scroll.bind(this, (button == this.nextButton ? -1 : 1) * scrollInc * this.elementSize);
button.observe("click", button.clickHandler);
}, this);
this.checkScroll(this.currentPosition(), true);
this.updateButtons().fire('sizeUpdated');
return this;
}
});
/*
Class: UI.Ajax.Carousel
Gives the AJAX power to carousels. An AJAX carousel :
* Use AJAX to add new elements on the fly
Example:
> new UI.Ajax.Carousel("horizontal_carousel",
> {url: "get-more-elements", elementSize: 250});
*/
UI.Ajax.Carousel = Class.create(UI.Carousel, {
// Group: Options
//
// Notice:
// It also include of all carousel's options
options: {
// Property: elementSize
// Required, it define the size of all elements
elementSize : -1,
// Property: url
// Required, it define the URL used by AJAX carousel to request new elements details
url : null
},
/*
Group: Attributes
Notice:
It also include of all carousel's attributes
Property: elementSize
Size of each elements, it's an integer
Property: endIndex
Index of the last loaded element
Property: hasMore
Flag to define if there's still more elements to load
Property: requestRunning
Define whether a request is processing or not
Property: updateHandler
Callback to update carousel, usually used after request success
Property: url
URL used to request additional elements
*/
/*
Group: Events
List of events fired by an AJAX carousel, it also include of all carousel's custom events
Property: request:started
Fired when the request has just started
Property: request:ended
Fired when the request has succeed
*/
// Group: Constructor
/*
Method: initialize
Constructor function, should not be called directly
Parameters:
element - DOM element
options - (Hash) list of optional parameters
Returns:
this
*/
initialize: function($super, element, options) {
if (!options.url)
throw("url option is required for UI.Ajax.Carousel");
if (!options.elementSize)
throw("elementSize option is required for UI.Ajax.Carousel");
$super(element, options);
this.endIndex = 0;
this.hasMore = true;
// Cache handlers
this.updateHandler = this.update.bind(this);
this.updateAndScrollHandler = function(nbElements, transport, json) {
this.update(transport, json);
this.scroll(nbElements);
}.bind(this);
// Run first ajax request to fill the carousel
this.runRequest.bind(this).defer({parameters: {from: 0, to: Math.ceil(this.nbVisible) - 1}, onSuccess: this.updateHandler});
},
// Group: Actions
/*
Method: runRequest
Request the new elements details
Parameters:
options - (Hash) list of optional parameters
Returns:
this
*/
runRequest: function(options) {
this.requestRunning = true;
new Ajax.Request(this.options.url, Object.extend({method: "GET"}, options));
this.fire("request:started");
return this;
},
/*
Method: scroll
Scrolls carousel from maximum deltaPixel
Parameters:
deltaPixel - a float
Returns:
this
*/
scroll: function($super, deltaPixel) {
if (this.animating || this.requestRunning)
return this;
var nbElements = (-deltaPixel) / this.elementSize;
// Check if there is not enough
if (this.hasMore && nbElements > 0 && this.currentIndex() + this.nbVisible + nbElements - 1 > this.endIndex) {
var from = this.endIndex + 1;
var to = Math.ceil(from + this.nbVisible - 1);
this.runRequest({parameters: {from: from, to: to}, onSuccess: this.updateAndScrollHandler.curry(deltaPixel).bind(this)});
return this;
}
else
$super(deltaPixel);
},
/*
Method: update
Update the carousel
Parameters:
transport - XMLHttpRequest object
json - JSON object
Returns:
this
*/
update: function(transport, json) {
this.requestRunning = false;
this.fire("request:ended");
if (!json)
json = transport.responseJSON;
this.hasMore = json.more;
this.endIndex = Math.max(this.endIndex, json.to);
this.elements = this.container.insert({bottom: json.html}).childElements();
return this.updateButtons();
},
// Group: Size and Position
/*
Method: computeElementSize
Return elements size in pixel
Returns:
an integer value
*/
computeElementSize: function() {
return this.options.elementSize;
},
/*
Method: updateSize
Should be called if carousel size has been changed (usually called with a liquid layout)
Returns:
this
*/
updateSize: function($super) {
var nbVisible = this.nbVisible;
$super();
// If we have enough space for at least a new element
if (Math.floor(this.nbVisible) - Math.floor(nbVisible) >= 1 && this.hasMore) {
if (this.currentIndex() + Math.floor(this.nbVisible) >= this.endIndex) {
var nbNew = Math.floor(this.currentIndex() + Math.floor(this.nbVisible) - this.endIndex);
this.runRequest({parameters: {from: this.endIndex + 1, to: this.endIndex + nbNew}, onSuccess: this.updateHandler});
}
}
return this;
},
updateNextButton: function($super) {
var lastPosition = this.currentLastPosition();
var size = this.currentSize();
var nextClassName = "next_button" + this.options.disabledButtonSuffix;
if (this.nextButton.hasClassName(nextClassName) && lastPosition != size) {
this.nextButton.removeClassName(nextClassName);
this.fire('nextButton:enabled');
}
if (!this.nextButton.hasClassName(nextClassName) && lastPosition == size && !this.hasMore) {
this.nextButton.addClassName(nextClassName);
this.fire('nextButton:disabled');
}
}
});
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Varien
* @package js
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
function popWin(url,win,para) {
var win = window.open(url,win,para);
win.focus();
}
function setLocation(url){
window.location.href = url;
}
function setPLocation(url, setFocus){
if( setFocus ) {
window.opener.focus();
}
window.opener.location.href = url;
}
function setLanguageCode(code, fromCode){
//TODO: javascript cookies have different domain and path than php cookies
var href = window.location.href;
var after = '', dash;
if (dash = href.match(/\#(.*)$/)) {
href = href.replace(/\#(.*)$/, '');
after = dash[0];
}
if (href.match(/[?]/)) {
var re = /([?&]store=)[a-z0-9_]*/;
if (href.match(re)) {
href = href.replace(re, '$1'+code);
} else {
href += '&store='+code;
}
var re = /([?&]from_store=)[a-z0-9_]*/;
if (href.match(re)) {
href = href.replace(re, '');
}
} else {
href += '?store='+code;
}
if (typeof(fromCode) != 'undefined') {
href += '&from_store='+fromCode;
}
href += after;
setLocation(href);
}
/**
* Add classes to specified elements.
* Supported classes are: 'odd', 'even', 'first', 'last'
*
* @param elements - array of elements to be decorated
* [@param decorateParams] - array of classes to be set. If omitted, all available will be used
*/
function decorateGeneric(elements, decorateParams)
{
var allSupportedParams = ['odd', 'even', 'first', 'last'];
var _decorateParams = {};
var total = elements.length;
if (total) {
// determine params called
if (typeof(decorateParams) == 'undefined') {
decorateParams = allSupportedParams;
}
if (!decorateParams.length) {
return;
}
for (var k in allSupportedParams) {
_decorateParams[allSupportedParams[k]] = false;
}
for (var k in decorateParams) {
_decorateParams[decorateParams[k]] = true;
}
// decorate elements
// elements[0].addClassName('first'); // will cause bug in IE (#5587)
if (_decorateParams.first) {
Element.addClassName(elements[0], 'first');
}
if (_decorateParams.last) {
Element.addClassName(elements[total-1], 'last');
}
for (var i = 0; i < total; i++) {
if ((i + 1) % 2 == 0) {
if (_decorateParams.even) {
Element.addClassName(elements[i], 'even');
}
}
else {
if (_decorateParams.odd) {
Element.addClassName(elements[i], 'odd');
}
}
}
}
}
/**
* Decorate table rows and cells, tbody etc
* @see decorateGeneric()
*/
function decorateTable(table, options) {
var table = $(table);
if (table) {
// set default options
var _options = {
'tbody' : false,
'tbody tr' : ['odd', 'even', 'first', 'last'],
'thead tr' : ['first', 'last'],
'tfoot tr' : ['first', 'last'],
'tr td' : ['last']
};
// overload options
if (typeof(options) != 'undefined') {
for (var k in options) {
_options[k] = options[k];
}
}
// decorate
if (_options['tbody']) {
decorateGeneric(table.select('tbody'), _options['tbody']);
}
if (_options['tbody tr']) {
decorateGeneric(table.select('tbody tr'), _options['tbody tr']);
}
if (_options['thead tr']) {
decorateGeneric(table.select('thead tr'), _options['thead tr']);
}
if (_options['tfoot tr']) {
decorateGeneric(table.select('tfoot tr'), _options['tfoot tr']);
}
if (_options['tr td']) {
var allRows = table.select('tr');
if (allRows.length) {
for (var i = 0; i < allRows.length; i++) {
decorateGeneric(allRows[i].getElementsByTagName('TD'), _options['tr td']);
}
}
}
}
}
/**
* Set "odd", "even" and "last" CSS classes for list items
* @see decorateGeneric()
*/
function decorateList(list, nonRecursive) {
if ($(list)) {
if (typeof(nonRecursive) == 'undefined') {
var items = $(list).select('li')
}
else {
var items = $(list).childElements();
}
decorateGeneric(items, ['odd', 'even', 'last']);
}
}
/**
* Set "odd", "even" and "last" CSS classes for list items
* @see decorateGeneric()
*/
function decorateDataList(list) {
list = $(list);
if (list) {
decorateGeneric(list.select('dt'), ['odd', 'even', 'last']);
decorateGeneric(list.select('dd'), ['odd', 'even', 'last']);
}
}
/**
* Parse SID and produces the correct URL
*/
function parseSidUrl(baseUrl, urlExt) {
sidPos = baseUrl.indexOf('/?SID=');
sid = '';
urlExt = (urlExt != undefined) ? urlExt : '';
if(sidPos > -1) {
sid = '?' + baseUrl.substring(sidPos + 2);
baseUrl = baseUrl.substring(0, sidPos + 1);
}
return baseUrl+urlExt+sid;
}
/**
* Formats currency using patern
* format - JSON (pattern, decimal, decimalsDelimeter, groupsDelimeter)
* showPlus - true (always show '+'or '-'),
* false (never show '-' even if number is negative)
* null (show '-' if number is negative)
*/
function formatCurrency(price, format, showPlus){
precision = isNaN(format.precision = Math.abs(format.precision)) ? 2 : format.precision;
requiredPrecision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision;
//precision = (precision > requiredPrecision) ? precision : requiredPrecision;
//for now we don't need this difference so precision is requiredPrecision
precision = requiredPrecision;
integerRequired = isNaN(format.integerRequired = Math.abs(format.integerRequired)) ? 1 : format.integerRequired;
decimalSymbol = format.decimalSymbol == undefined ? "," : format.decimalSymbol;
groupSymbol = format.groupSymbol == undefined ? "." : format.groupSymbol;
groupLength = format.groupLength == undefined ? 3 : format.groupLength;
if (showPlus == undefined || showPlus == true) {
s = price < 0 ? "-" : ( showPlus ? "+" : "");
} else if (showPlus == false) {
s = '';
}
i = parseInt(price = Math.abs(+price || 0).toFixed(precision)) + "";
pad = (i.length < integerRequired) ? (integerRequired - i.length) : 0;
while (pad) { i = '0' + i; pad--; }
j = (j = i.length) > groupLength ? j % groupLength : 0;
re = new RegExp("(\\d{" + groupLength + "})(?=\\d)", "g");
/**
* replace(/-/, 0) is only for fixing Safari bug which appears
* when Math.abs(0).toFixed() executed on "0" number.
* Result is "0.-0" :(
*/
r = (j ? i.substr(0, j) + groupSymbol : "") + i.substr(j).replace(re, "$1" + groupSymbol) + (precision ? decimalSymbol + Math.abs(price - i).toFixed(precision).replace(/-/, 0).slice(2) : "")
if (format.pattern.indexOf('{sign}') == -1) {
pattern = s + format.pattern;
} else {
pattern = format.pattern.replace('{sign}', s);
}
return pattern.replace('%s', r).replace(/^\s\s*/, '').replace(/\s\s*$/, '');
};
function expandDetails(el, childClass) {
if (Element.hasClassName(el,'show-details')) {
$$(childClass).each(function(item){item.hide()});
Element.removeClassName(el,'show-details');
}
else {
$$(childClass).each(function(item){item.show()});
Element.addClassName(el,'show-details');
}
}
// Version 1.0
var isIE = navigator.appVersion.match(/MSIE/) == "MSIE";
if (!window.Varien)
var Varien = new Object();
Varien.showLoading = function(){
Element.show('loading-process');
}
Varien.hideLoading = function(){
Element.hide('loading-process');
}
Varien.GlobalHandlers = {
onCreate: function() {
Varien.showLoading();
},
onComplete: function() {
if(Ajax.activeRequestCount == 0) {
Varien.hideLoading();
}
}
};
Ajax.Responders.register(Varien.GlobalHandlers);
/**
* Quick Search form client model
*/
Varien.searchForm = Class.create();
Varien.searchForm.prototype = {
initialize : function(form, field, emptyText){
this.form = $(form);
this.field = $(field);
this.emptyText = emptyText;
Event.observe(this.form, 'submit', this.submit.bind(this));
Event.observe(this.field, 'focus', this.focus.bind(this));
Event.observe(this.field, 'blur', this.blur.bind(this));
this.blur();
},
submit : function(event){
if (this.field.value == this.emptyText || this.field.value == ''){
Event.stop(event);
return false;
}
return true;
},
focus : function(event){
if(this.field.value==this.emptyText){
this.field.value='';
}
},
blur : function(event){
if(this.field.value==''){
this.field.value=this.emptyText;
}
},
initAutocomplete : function(url, destinationElement){
new Ajax.Autocompleter(
this.field,
destinationElement,
url,
{
paramName: this.field.name,
method: 'get',
minChars: 2,
updateElement: this._selectAutocompleteItem.bind(this),
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});
}
}
);
},
_selectAutocompleteItem : function(element){
if(element.title){
this.field.value = element.title;
}
this.form.submit();
}
}
Varien.Tabs = Class.create();
Varien.Tabs.prototype = {
initialize: function(selector) {
var self=this;
$$(selector+' a').each(this.initTab.bind(this));
},
initTab: function(el) {
el.href = 'javascript:void(0)';
if ($(el.parentNode).hasClassName('active')) {
this.showContent(el);
}
el.observe('click', this.showContent.bind(this, el));
},
showContent: function(a) {
var li = $(a.parentNode), ul = $(li.parentNode);
ul.getElementsBySelector('li', 'ol').each(function(el){
var contents = $(el.id+'_contents');
if (el==li) {
el.addClassName('active');
contents.show();
} else {
el.removeClassName('active');
contents.hide();
}
});
}
}
Varien.DOB = Class.create();
Varien.DOB.prototype = {
initialize: function(selector, required, format) {
var el = $$(selector)[0];
this.day = Element.select($(el), '.dob-day input')[0];
this.month = Element.select($(el), '.dob-month input')[0];
this.year = Element.select($(el), '.dob-year input')[0];
this.dob = Element.select($(el), '.dob-full input')[0];
this.advice = Element.select($(el), '.validation-advice')[0];
this.required = required;
this.format = format;
this.day.validate = this.validate.bind(this);
this.month.validate = this.validate.bind(this);
this.year.validate = this.validate.bind(this);
this.year.setAttribute('autocomplete','off');
this.advice.hide();
},
validate: function() {
var error = false;
if (this.day.value=='' && this.month.value=='' && this.year.value=='') {
if (this.required) {
error = 'This date is a required value.';
} else {
this.dob.value = '';
}
} else if (this.day.value=='' || this.month.value=='' || this.year.value=='') {
error = 'Please enter a valid full date.';
} else {
var date = new Date();
if (this.day.value<1 || this.day.value>31) {
error = 'Please enter a valid day (1-31).';
} else if (this.month.value<1 || this.month.value>12) {
error = 'Please enter a valid month (1-12).';
} else if (this.year.value<1900 || this.year.value>date.getFullYear()) {
error = 'Please enter a valid year (1900-'+date.getFullYear()+').';
} else {
this.dob.value = this.format.replace(/(%m|%b)/i, this.month.value).replace(/(%d|%e)/i, this.day.value).replace(/%y/i, this.year.value);
var testDOB = this.month.value + '/' + this.day.value + '/'+ this.year.value;
var test = new Date(testDOB);
if (isNaN(test)) {
error = 'Please enter a valid date.';
}
}
}
if (error !== false) {
try {
this.advice.innerHTML = Translator.translate(error);
}
catch (e) {
this.advice.innerHTML = error;
}
this.advice.show();
return false;
}
this.advice.hide();
return true;
}
}
Validation.addAllThese([
['validate-custom', ' ', function(v,elm) {
return elm.validate();
}]
]);
function truncateOptions() {
$$('.truncated').each(function(element){
Event.observe(element, 'mouseover', function(){
if (element.down('div.truncated_full_value')) {
element.down('div.truncated_full_value').addClassName('show')
}
});
Event.observe(element, 'mouseout', function(){
if (element.down('div.truncated_full_value')) {
element.down('div.truncated_full_value').removeClassName('show')
}
});
});
}
Event.observe(window, 'load', function(){
truncateOptions();
});
Element.addMethods({
getInnerText: function(element)
{
element = $(element);
if(element.innerText && !Prototype.Browser.Opera) {
return element.innerText
}
return element.innerHTML.stripScripts().unescapeHTML().replace(/[\n\r\s]+/g, ' ').strip();
}
});
if (!("console" in window) || !("firebug" in console))
{
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
window.console = {};
for (var i = 0; i < names.length; ++i)
window.console[names[i]] = function() {}
}
/**
* Executes event handler on the element. Works with event handlers attached by Prototype,
* in a browser-agnostic fashion.
* @param element The element object
* @param event Event name, like 'change'
*
* @example fireEvent($('my-input', 'click'));
*/
function fireEvent(element, event){
if (document.createEventObject){
// dispatch for IE
var evt = document.createEventObject();
return element.fireEvent('on'+event,evt)
}
else{
// dispatch for firefox + others
var evt = document.createEvent("HTMLEvents");
evt.initEvent(event, true, true ); // event type,bubbling,cancelable
return !element.dispatchEvent(evt);
}
}
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Varien
* @package js
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
VarienForm = Class.create();
VarienForm.prototype = {
initialize: function(formId, firstFieldFocus){
this.form = $(formId);
if (!this.form) {
return;
}
this.cache = $A();
this.currLoader = false;
this.currDataIndex = false;
this.validator = new Validation(this.form);
this.elementFocus = this.elementOnFocus.bindAsEventListener(this);
this.elementBlur = this.elementOnBlur.bindAsEventListener(this);
this.childLoader = this.onChangeChildLoad.bindAsEventListener(this);
this.highlightClass = 'highlight';
this.extraChildParams = '';
this.firstFieldFocus= firstFieldFocus || false;
this.bindElements();
if(this.firstFieldFocus){
try{
Form.Element.focus(Form.findFirstElement(this.form))
}
catch(e){}
}
},
submit : function(url){
if(this.validator && this.validator.validate()){
this.form.submit();
}
return false;
},
bindElements:function (){
var elements = Form.getElements(this.form);
for (var row in elements) {
if (elements[row].id) {
Event.observe(elements[row],'focus',this.elementFocus);
Event.observe(elements[row],'blur',this.elementBlur);
}
}
},
elementOnFocus: function(event){
var element = Event.findElement(event, 'fieldset');
if(element){
Element.addClassName(element, this.highlightClass);
}
},
elementOnBlur: function(event){
var element = Event.findElement(event, 'fieldset');
if(element){
Element.removeClassName(element, this.highlightClass);
}
},
setElementsRelation: function(parent, child, dataUrl, first){
if (parent=$(parent)) {
// TODO: array of relation and caching
if (!this.cache[parent.id]){
this.cache[parent.id] = $A();
this.cache[parent.id]['child'] = child;
this.cache[parent.id]['dataUrl'] = dataUrl;
this.cache[parent.id]['data'] = $A();
this.cache[parent.id]['first'] = first || false;
}
Event.observe(parent,'change',this.childLoader);
}
},
onChangeChildLoad: function(event){
element = Event.element(event);
this.elementChildLoad(element);
},
elementChildLoad: function(element, callback){
this.callback = callback || false;
if (element.value) {
this.currLoader = element.id;
this.currDataIndex = element.value;
if (this.cache[element.id]['data'][element.value]) {
this.setDataToChild(this.cache[element.id]['data'][element.value]);
}
else{
new Ajax.Request(this.cache[this.currLoader]['dataUrl'],{
method: 'post',
parameters: {"parent":element.value},
onComplete: this.reloadChildren.bind(this)
});
}
}
},
reloadChildren: function(transport){
var data = eval('(' + transport.responseText + ')');
this.cache[this.currLoader]['data'][this.currDataIndex] = data;
this.setDataToChild(data);
},
setDataToChild: function(data){
if (data.length) {
var child = $(this.cache[this.currLoader]['child']);
if (child){
var html = '';
Element.insert(child, {before: html});
Element.remove(child);
}
}
else{
var child = $(this.cache[this.currLoader]['child']);
if (child){
var html = '';
Element.insert(child, {before: html});
Element.remove(child);
}
}
this.bindElements();
if (this.callback) {
this.callback();
}
}
}
RegionUpdater = Class.create();
RegionUpdater.prototype = {
initialize: function (countryEl, regionTextEl, regionSelectEl, regions, disableAction, zipEl)
{
this.countryEl = $(countryEl);
this.regionTextEl = $(regionTextEl);
this.regionSelectEl = $(regionSelectEl);
this.zipEl = $(zipEl);
this.regions = regions;
this.disableAction = (typeof disableAction=='undefined') ? 'hide' : disableAction;
this.zipOptions = (typeof zipOptions=='undefined') ? false : zipOptions;
if (this.regionSelectEl.options.length<=1) {
this.update();
}
Event.observe(this.countryEl, 'change', this.update.bind(this));
},
update: function()
{
if (this.regions[this.countryEl.value]) {
var i, option, region, def;
if (this.regionTextEl) {
def = this.regionTextEl.value.toLowerCase();
this.regionTextEl.value = '';
}
if (!def) {
def = this.regionSelectEl.getAttribute('defaultValue');
}
this.regionSelectEl.options.length = 1;
for (regionId in this.regions[this.countryEl.value]) {
region = this.regions[this.countryEl.value][regionId];
option = document.createElement('OPTION');
option.value = regionId;
option.text = region.name;
if (this.regionSelectEl.options.add) {
this.regionSelectEl.options.add(option);
} else {
this.regionSelectEl.appendChild(option);
}
if (regionId==def || region.name.toLowerCase()==def || region.code.toLowerCase()==def) {
this.regionSelectEl.value = regionId;
}
}
if (this.disableAction=='hide') {
if (this.regionTextEl) {
this.regionTextEl.style.display = 'none';
}
this.regionSelectEl.style.display = '';
} else if (this.disableAction=='disable') {
if (this.regionTextEl) {
this.regionTextEl.disabled = true;
}
this.regionSelectEl.disabled = false;
}
this.setMarkDisplay(this.regionSelectEl, true);
} else {
if (this.disableAction=='hide') {
if (this.regionTextEl) {
this.regionTextEl.style.display = '';
}
this.regionSelectEl.style.display = 'none';
Validation.reset(this.regionSelectEl);
} else if (this.disableAction=='disable') {
if (this.regionTextEl) {
this.regionTextEl.disabled = false;
}
this.regionSelectEl.disabled = true;
} else if (this.disableAction=='nullify') {
this.regionSelectEl.options.length = 1;
this.regionSelectEl.value = '';
this.regionSelectEl.selectedIndex = 0;
this.lastCountryId = '';
}
this.setMarkDisplay(this.regionSelectEl, false);
}
// Make Zip and its label required/optional
var zipUpdater = new ZipUpdater(this.countryEl.value, this.zipEl);
zipUpdater.update();
},
setMarkDisplay: function(elem, display){
elem = $(elem);
var labelElement = elem.up(0).down('label > span.required') ||
elem.up(1).down('label > span.required') ||
elem.up(0).down('label.required > em') ||
elem.up(1).down('label.required > em');
if(labelElement) {
inputElement = labelElement.up().next('input');
if (display) {
labelElement.show();
if (inputElement) {
inputElement.addClassName('required-entry');
}
} else {
labelElement.hide();
if (inputElement) {
inputElement.removeClassName('required-entry');
}
}
}
}
}
ZipUpdater = Class.create();
ZipUpdater.prototype = {
initialize: function(country, zipElement)
{
this.country = country;
this.zipElement = $(zipElement);
},
update: function()
{
// Country ISO 2-letter codes must be pre-defined
if (typeof optionalZipCountries == 'undefined') {
return false;
}
// Ajax-request and normal content load compatibility
if (this.zipElement != undefined) {
this._setPostcodeOptional();
} else {
Event.observe(window, "load", this._setPostcodeOptional.bind(this));
}
},
_setPostcodeOptional: function()
{
this.zipElement = $(this.zipElement);
if (this.zipElement == undefined) {
return false;
}
// find label
var label = $$('label[for="' + this.zipElement.id + '"]')[0];
if (label != undefined) {
var wildCard = label.down('em') || label.down('span.required');
}
// Make Zip and its label required/optional
if (optionalZipCountries.indexOf(this.country) != -1) {
while (this.zipElement.hasClassName('required-entry')) {
this.zipElement.removeClassName('required-entry');
}
if (wildCard != undefined) {
wildCard.hide();
}
} else {
this.zipElement.addClassName('required-entry');
if (wildCard != undefined) {
wildCard.show();
}
}
}
}
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Varien
* @package js
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
/**
* @classDescription simple Navigation with replacing old handlers
* @param {String} id id of ul element with navigation lists
* @param {Object} settings object with settings
*/
var mainNav = function() {
var main = {
obj_nav : $(arguments[0]) || $("nav"),
settings : {
show_delay : 0,
hide_delay : 0,
_ie6 : /MSIE 6.+Win/.test(navigator.userAgent),
_ie7 : /MSIE 7.+Win/.test(navigator.userAgent)
},
init : function(obj, level) {
obj.lists = obj.childElements();
obj.lists.each(function(el,ind){
main.handlNavElement(el);
if((main.settings._ie6 || main.settings._ie7) && level){
main.ieFixZIndex(el, ind, obj.lists.size());
}
});
if(main.settings._ie6 && !level){
document.execCommand("BackgroundImageCache", false, true);
}
},
handlNavElement : function(list) {
if(list !== undefined){
list.onmouseover = function(){
main.fireNavEvent(this,true);
};
list.onmouseout = function(){
main.fireNavEvent(this,false);
};
if(list.down("ul")){
main.init(list.down("ul"), true);
}
}
},
ieFixZIndex : function(el, i, l) {
if(el.tagName.toString().toLowerCase().indexOf("iframe") == -1){
el.style.zIndex = l - i;
} else {
el.onmouseover = "null";
el.onmouseout = "null";
}
},
fireNavEvent : function(elm,ev) {
if(ev){
elm.addClassName("over");
elm.down("a").addClassName("over");
if (elm.childElements()[1]) {
main.show(elm.childElements()[1]);
}
} else {
elm.removeClassName("over");
elm.down("a").removeClassName("over");
if (elm.childElements()[1]) {
main.hide(elm.childElements()[1]);
}
}
},
show : function (sub_elm) {
if (sub_elm.hide_time_id) {
clearTimeout(sub_elm.hide_time_id);
}
sub_elm.show_time_id = setTimeout(function() {
if (!sub_elm.hasClassName("shown-sub")) {
sub_elm.addClassName("shown-sub");
}
}, main.settings.show_delay);
},
hide : function (sub_elm) {
if (sub_elm.show_time_id) {
clearTimeout(sub_elm.show_time_id);
}
sub_elm.hide_time_id = setTimeout(function(){
if (sub_elm.hasClassName("shown-sub")) {
sub_elm.removeClassName("shown-sub");
}
}, main.settings.hide_delay);
}
};
if (arguments[1]) {
main.settings = Object.extend(main.settings, arguments[1]);
}
if (main.obj_nav) {
main.init(main.obj_nav, false);
}
};
document.observe("dom:loaded", function() {
//run navigation without delays and with default id="#nav"
//mainNav();
//run navigation with delays
mainNav("nav", {"show_delay":"100","hide_delay":"100"});
});
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
* @package js
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
var Translate = Class.create();
Translate.prototype = {
initialize: function(data){
this.data = $H(data);
},
translate : function(){
var args = arguments;
var text = arguments[0];
if(this.data.get(text)){
return this.data.get(text);
}
return text;
},
add : function() {
if (arguments.length > 1) {
this.data.set(arguments[0], arguments[1]);
} else if (typeof arguments[0] =='object') {
$H(arguments[0]).each(function (pair){
this.data.set(pair.key, pair.value);
}.bind(this));
}
}
}
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
* @package js
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
// old school cookie functions grabbed off the web
if (!window.Mage) var Mage = {};
Mage.Cookies = {};
Mage.Cookies.expires = null;
Mage.Cookies.path = '/';
Mage.Cookies.domain = null;
Mage.Cookies.secure = false;
Mage.Cookies.set = function(name, value){
var argv = arguments;
var argc = arguments.length;
var expires = (argc > 2) ? argv[2] : Mage.Cookies.expires;
var path = (argc > 3) ? argv[3] : Mage.Cookies.path;
var domain = (argc > 4) ? argv[4] : Mage.Cookies.domain;
var secure = (argc > 5) ? argv[5] : Mage.Cookies.secure;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
};
Mage.Cookies.get = function(name){
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
var j = 0;
while(i < clen){
j = i + alen;
if (document.cookie.substring(i, j) == arg)
return Mage.Cookies.getCookieVal(j);
i = document.cookie.indexOf(" ", i) + 1;
if(i == 0)
break;
}
return null;
};
Mage.Cookies.clear = function(name) {
if(Mage.Cookies.get(name)){
document.cookie = name + "=" +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
};
Mage.Cookies.getCookieVal = function(offset){
var endstr = document.cookie.indexOf(";", offset);
if(endstr == -1){
endstr = document.cookie.length;
}
return unescape(document.cookie.substring(offset, endstr));
};
var LiveChatPeriodUpdater = null;
String.prototype.trim = function()
{
return this.replace(/(?:^\s+|\s+$)/g, "");
}
function SendMessage()
{
var customermessage = document.getElementById('textmessage').value.trim();
document.getElementById('textmessage').value = '';
if (customermessage != '')
{
var img = document.getElementById('livachat_ajax_loader');
if (img != null)
{
img.style.display = 'inline';
}
var request = new Ajax.Updater(
'livechat_messages',
urlSendMessage,
{
method: 'get',
parameters: { message: customermessage },
onSuccess: function(transport, json) {
var img = document.getElementById('livechat_ajax_loader');
if (img != null) {
img.style.display = 'none';
}
SetUpdater();
},
insertion: Insertion.Bottom
}
);
}
}
function SetUpdater()
{
//alert(LiveChatPeriodUpdater);
if (LiveChatPeriodUpdater == null)
{
LiveChatPeriodUpdater = new Ajax.PeriodicalUpdater(
'livechat_messages',
urlUpdater,
{
frequency: frequency,
decay: decay
}
);
}
}
function LiveChatKeyPress(e) {
if (e.keyCode == 13) {
SendMessage();
}
}
|