function show_cart_spinner(){Element.hide($('cart_product_result_suc'));Element.hide($('cart_product_result_fail'));Element.show($('cart_spinner'))}function hide_cart_spinner(){Element.hide($('cart_spinner'))}function show_cart_spinner_ess(essid){Element.hide($('cart_product_result_suc_'+essid));Element.hide($('cart_product_result_fail_'+essid));Element.show($('cart_spinner_'+essid))}function hide_cart_spinner_ess(essid){Element.hide($('cart_spinner_'+essid))}function show_cart_aj_blank(){$('cart_content_ajax').innerHTML="<br /><center><strong></strong></center><br /><br />"}function show_cart_aj_modify_delprice(newprice){$('cart_content_ajax').innerHTML="<br /><center><strong>Loading...</strong></center><br /><br />";var url="/ajax_cart.php";var rrr="";params="displaytype=display&newdelprice="+newprice+"&sessid="+rrr;var ajax=new Ajax.Request(url,{method:'post',onComplete:cart_result_ajax,parameters:params})}function show_cart_aj(){var url="/ajax_cart.php";var rrr="";params="displaytype=display&sessid="+rrr;var ajax=new Ajax.Request(url,{method:'post',onComplete:cart_result_ajax,parameters:params})}function add_cart_aj(){var url="/ajax_cart.php";show_cart_spinner();var r=document.addtocartform.pid.value;var rr=document.addtocartform.quantity.value;var rrr=document.addtocartform.sessid.value;if(document.addtocartform.elements['colour']==null||document.addtocartform.elements['colour']=="undefined"||document.addtocartform.elements['colour']==undefined){var cc=""}else{var c=document.addtocartform.elements['colour'];var cc=c.options[c.selectedIndex].value}params="displaytype=addcart&pid="+r+"&addshopping=addnow&quantity="+rr+"&sessid="+rrr+"&colour="+cc;var ajax=new Ajax.Request(url,{method:'post',onComplete:cart_result_ajax,parameters:params})}function add_cart_aj_ess(formname,essid){var url="/ajax_cart.php";show_cart_spinner_ess(essid);var theform=document.getElementById(formname);var r=theform.pid.value;var rr=theform.quantity.value;var rrr=theform.sessid.value;if(theform.elements['colour']==null||theform.elements['colour']=="undefined"||theform.elements['colour']==undefined){var cc=""}else{var c=theform.elements['colour'];var cc=c.options[c.selectedIndex].value}params="displaytype=addcart&pid="+r+"&addshopping=addnow&quantity="+rr+"&sessid="+rrr+"&colour="+cc+"&essid="+essid;var ajax=new Ajax.Request(url,{method:'post',onComplete:cart_result_ajax_ess,parameters:params})}function cart_result_ajax_ess(output){var output_array=output.responseText.split("|");var essid="1";if(output_array[3]!=null){essid=output_array[3]}if(output_array[1]=="addcart"){hide_cart_spinner_ess(essid)}if(output_array[2]==''||output_array[2]=="undefined"||output_array[2]==null||output_array[2]==undefined){$('cart_content_ajax').innerHTML="Cart is empty";if(output_array[1]=="addcart"){Element.show($('cart_product_result_fail_'+essid))}return}else{$('cart_content_ajax').innerHTML=output_array[2];if(output_array[1]=="addcart"){Element.show($('cart_product_result_suc_'+essid));document.addedtobasket.gohome()}}}function add_cart_aj_search(formname){var url="/ajax_cart.php";var formname_array=formname.split("_");var lastNumber=formname_array[1];Element.show($('cart_spinner_'+lastNumber));Element.hide($('cart_product_result_fail_'+lastNumber));Element.hide($('cart_product_result_suc_'+lastNumber));var thisForm=document.forms[0];for(var i=0;i<document.forms.length;i++){if(document.forms[i].name==formname){thisForm=document.forms[i]}}var r=thisForm.pid.value;var rr=thisForm.quantity.value;var rrr=thisForm.sessid.value;if(thisForm.elements['colour']==null||thisForm.elements['colour']=="undefined"||thisForm.elements['colour']==undefined){var cc=""}else{var c=thisForm.elements['colour'];var cc=c.options[c.selectedIndex].value}params="displaytype=addcart_"+lastNumber+"&pid="+r+"&addshopping=addnow&quantity="+rr+"&sessid="+rrr+"&colour="+cc;var ajax=new Ajax.Request(url,{method:'post',onComplete:cart_result_ajax_search,parameters:params})}function cart_result_ajax_search(output){var output_array=output.responseText.split("|");var formname_array=output_array[1].split("_");var lastNumber=formname_array[1];var firstName=formname_array[0];if(firstName=="addcart"){Element.hide($('cart_spinner_'+lastNumber))}if(output_array[2]==''||output_array[2]=="undefined"||output_array[2]==null||output_array[2]==undefined){$('cart_content_ajax').innerHTML="Cart is empty";if(firstName=="addcart"){Element.show($('cart_product_result_fail_'+lastNumber))}return}else{$('cart_content_ajax').innerHTML=output_array[2];if(firstName=="addcart"){Element.show($('cart_product_result_suc_'+lastNumber))}}}function cart_result_ajax(output){var output_array=output.responseText.split("|");if(output_array[1]=="addcart"){hide_cart_spinner()}if(output_array[2]==''||output_array[2]=="undefined"||output_array[2]==null||output_array[2]==undefined){$('cart_content_ajax').innerHTML="Cart is empty";if(output_array[1]=="addcart"){Element.show($('cart_product_result_fail'))}return}else{$('cart_content_ajax').innerHTML=output_array[2];if(output_array[1]=="addcart"){Element.show($('cart_product_result_suc'));document.addedtobasket.gohome()}}}function productpage_tab_click(tabname,pid){var url="";var thisImage1=document.getElementById("tab_desription");if(thisImage1){if(tabname=='description'){thisImage1.src="images/gfx/glowstick_productpage_tab_des.jpg"}else{thisImage1.src="images/gfx/glowstick_productpage_tab_des_on.jpg"}}var thisImage2=document.getElementById("tab_reviews");if(thisImage2){if(tabname=='reviews'){thisImage2.src="images/gfx/glowstick_productpage_tab_review.jpg"}else{thisImage2.src="images/gfx/glowstick_productpage_tab_review_on.jpg"}}var thisImage3=document.getElementById("tab_bookmark");if(thisImage3){if(tabname=='bookmark'){thisImage3.src="images/gfx/glowstick_productpage_tab_bookmark.jpg"}else{thisImage3.src="images/gfx/glowstick_productpage_tab_bookmark_on.jpg"}}var thisImage4=document.getElementById("tab_tellafriend");if(thisImage4){if(tabname=='tellafriend'){thisImage4.src="images/gfx/glowstick_productpage_tab_tell.jpg"}else{thisImage4.src="images/gfx/glowstick_productpage_tab_tell_on.jpg"}}if(tabname=='description'){url="/content/viewproduct_tab_description.php"}else if(tabname=='reviews'){url="/content/viewproduct_tab_reviews.php"}else if(tabname=='bookmark'){url="/content/viewproduct_tab_bookmark.php"}else if(tabname=='tellafriend'){url="/content/viewproduct_tab_tellafriend.php"}params="pid="+pid;var ajax=new Ajax.Request(url,{method:'post',onComplete:productpage_tab_result,parameters:params})}function productpage_tab_result(output){$('productDescription').innerHTML=output.responseText}function BookmarkThis(){var url=document.title;var title=location.href;if(window.sidebar){window.sidebar.addPanel(title,url,"")}else if(window.external){window.external.AddFavorite(url,title)}else if(window.opera&&window.print){alert('Sorry, we cannot automatically add a bookmark for opera. Please add a bookmark by pressing CTRL + D or by clicking the Bookmarks menu.');return true}}function CreateBookmark(){if(window.sidebar){window.sidebar.addPanel(document.title,location.href,"")}else if(window.external){window.external.AddFavorite(location.href,document.title)}else if(window.opera&&window.print){return true}}function setMainpageBlock(){var winW=630;var winH=460;var browserV="IE";if(parseInt(navigator.appVersion)>3){if(navigator.appName=="Netscape"){winW=window.innerWidth;winH=window.innerHeight;browserV="Others"}if(navigator.appName.indexOf("Microsoft")!=-1){winW=document.body.offsetWidth;winH=document.body.offsetHeight}}if(winW>1870){var lineN=5}else if(winW>1540){var lineN=4}else if(winW>1234){var lineN=3}else if(winW>966){var lineN=2}else{var lineN=1}var shouldmargin=((winW-350)-308*lineN)/2;if(browserV!="IE"){shouldmargin=shouldmargin-4}var objDialog=document.getElementById("mainpageblock");if(!objDialog){}else{var oS=objDialog.style;oS.cssText="float:left;margin:"+"0px 0px "+shouldmargin+"px "+shouldmargin+"px;"}}function anchorJump(anchor){var targAnchor=null,anchorID=anchor.replace(/.*#([^\?]+).*/,'$1');var end=false;if(!(targAnchor=document.getElementById(anchorID)))for(var i=0,found=false,da=document.anchors,len=da.length;i<len&&!targAnchor;i++)targAnchor=(da[i].name==anchorID?da[i]:null);if(targAnchor){disp=getElemOffset(targAnchor);scrolling(disp.x,disp.y,1)}else alert('Did not find anchor/element "'+anchorID+'"');function getElemOffset(elem){var left=!!elem.offsetLeft?elem.offsetLeft:0;var top=!!elem.offsetTop?elem.offsetTop:0;while((elem=elem.offsetParent)){left+=!!elem.offsetLeft?elem.offsetLeft:0;top+=!!elem.offsetTop?elem.offsetTop:0}return{x:left,y:top}}return false}function scrolling(tx,ty,t){var req=30;var newty=ty/30*t;window.scrollTo(tx,newty);t=t+1;if(t<30){setTimeout("scrolling("+tx+","+ty+","+t+")",10)}else{}}function getImageURL(theURL){var thisI=document.getElementById("bigImage");if(thisI){thisI.src="/images/products/"+theURL;var newalpha=0;if(window.sidebar){thisI.style.MozOpacity=newalpha/100}else{thisI.style.cssText="-moz-opacity:"+newalpha+"%;filter:alpha(opacity="+newalpha+")"}fading(1)}else{}}function fading(t){var thisI=document.getElementById("bigImage");if(thisI){var newalpha=10*t;if(window.sidebar){thisI.style.MozOpacity=newalpha/100}else{thisI.style.cssText="-moz-opacity:"+newalpha+"%;filter:alpha(opacity="+newalpha+")"}t=t+1;if(t<11){setTimeout("fading("+t+")",10)}else{}}else{}}function findSimularSearch(inputtext){Element.hide($('search_simular_list_container'));$('search_simular_list_container').innerHTML="";if(inputtext!=""){var paramValue=inputtext;var params="keyword="+paramValue;var url="/ajax_searchsimular.php";var ajax=new Ajax.Request(url,{method:'post',onComplete:showSimularSearch,parameters:params})}}function showSimularSearch(output){if(output.responseText==''){return}else{var output_array=output.responseText.split("|");var selectSize=0;var optionstr;for(var i=1;i<output_array.length;i++){opval=output_array[i];if("undefined"!=opval&&opval!=""){optionstr+="<option value='"+opval+"'>"+opval+"</option>";selectSize++}}if(selectSize>10){selectSize=10}if(selectSize>=1){Element.show($('search_simular_list_container'));$('search_simular_list_container').innerHTML="<select width='100' class=\"sml_txt\" name=\"search_simular_select\" size="+selectSize+" onClick=\"fillMySearchiInput(this)\">"+optionstr+"</select>"}}}function fillMySearchiInput(inputtext){document.adsearch.searchnow.value=inputtext.value;Element.hide($('search_simular_list_container'));if(document.adsearch.searchnow.value!=""){document.adsearch.submit()}}var Prototype={Version:'1.6.0',Browser:{IE:!!(window.attachEvent&&!window.opera),Opera:!!window.opera,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,ElementExtensions:!!window.HTMLElement,SpecificElementExtensions:document.createElement('div').__proto__&&document.createElement('div').__proto__!==document.createElement('form').__proto__},ScriptFragment:'<script[^>]*>([\\S\\s]*?)<\/script>',JSONFilter:/^\/\*-secure-([\s\S]*)\*\/\s*$/,emptyFunction:function(){},K:function(x){return x}};if(Prototype.Browser.MobileSafari)Prototype.BrowserFeatures.SpecificElementExtensions=false;if(Prototype.Browser.WebKit)Prototype.BrowserFeatures.XPath=false;var Class={create:function(){var parent=null,properties=$A(arguments);if(Object.isFunction(properties[0]))parent=properties.shift();function klass(){this.initialize.apply(this,arguments)}Object.extend(klass,Class.Methods);klass.superclass=parent;klass.subclasses=[];if(parent){var subclass=function(){};subclass.prototype=parent.prototype;klass.prototype=new subclass;parent.subclasses.push(klass)}for(var i=0;i<properties.length;i++)klass.addMethods(properties[i]);if(!klass.prototype.initialize)klass.prototype.initialize=Prototype.emptyFunction;klass.prototype.constructor=klass;return klass}};Class.Methods={addMethods:function(source){var ancestor=this.superclass&&this.superclass.prototype;var properties=Object.keys(source);if(!Object.keys({toString:true}).length)properties.push("toString","valueOf");for(var i=0,length=properties.length;i<length;i++){var property=properties[i],value=source[property];if(ancestor&&Object.isFunction(value)&&value.argumentNames().first()=="$super"){var method=value,value=Object.extend((function(m){return function(){return ancestor[m].apply(this,arguments)}})(property).wrap(method),{valueOf:function(){return method},toString:function(){return method.toString()}})}this.prototype[property]=value}return this}};var Abstract={};Object.extend=function(destination,source){for(var property in source)destination[property]=source[property];return destination};Object.extend(Object,{toQueryString:function(object){return $H(object).toQueryString()},keys:function(object){var keys=[];for(var property in object)keys.push(property);return keys},clone:function(object){return Object.extend({},object)},isHash:function(object){return object instanceof Hash},isFunction:function(object){return typeof object=="function"},isString:function(object){return typeof object=="string"},isUndefined:function(object){return typeof object=="undefined"}});Object.extend(Function.prototype,{argumentNames:function(){var names=this.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].split(",").invoke("strip");return names.length==1&&!names[0]?[]:names},bind:function(){if(arguments.length<2&&arguments[0]===undefined)return this;var __method=this,args=$A(arguments),object=args.shift();return function(){return __method.apply(object,args.concat($A(arguments)))}},bindAsEventListener:function(){var __method=this,args=$A(arguments),object=args.shift();return function(event){return __method.apply(object,[event||window.event].concat(args))}},curry:function(){if(!arguments.length)return this;var __method=this,args=$A(arguments);return function(){return __method.apply(this,args.concat($A(arguments)))}},delay:function(){var __method=this,args=$A(arguments),timeout=args.shift()*1000;return window.setTimeout(function(){return __method.apply(__method,args)},timeout)},wrap:function(wrapper){var __method=this;return function(){return wrapper.apply(this,[__method.bind(this)].concat($A(arguments)))}},methodize:function(){if(this._methodized)return this._methodized;var __method=this;return this._methodized=function(){return __method.apply(null,[this].concat($A(arguments)))}}});Function.prototype.defer=Function.prototype.delay.curry(0.01);Date.prototype.toJSON=function(){return'"'+this.getUTCFullYear()+'-'+(this.getUTCMonth()+1).toPaddedString(2)+'-'+this.getUTCDate().toPaddedString(2)+'T'+this.getUTCHours().toPaddedString(2)+':'+this.getUTCMinutes().toPaddedString(2)+':'+this.getUTCSeconds().toPaddedString(2)+'Z"'};var Try={these:function(){var returnValue;for(var i=0,length=arguments.length;i<length;i++){var lambda=arguments[i];try{returnValue=lambda();break}catch(e){}}return returnValue}};Object.extend(String,{interpret:function(value){return value==null?'':String(value)},specialChar:{'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','\\':'\\\\'}});Object.extend(String.prototype,{strip:function(){return this.replace(/^\s+/,'').replace(/\s+$/,'')},escapeHTML:function(){var self=arguments.callee;self.text.data=this;return self.div.innerHTML},unescapeHTML:function(){var div=new Element('div');div.innerHTML=this.stripTags();return div.childNodes[0]?(div.childNodes.length>1?$A(div.childNodes).inject('',function(memo,node){return memo+node.nodeValue}):div.childNodes[0].nodeValue):''},toQueryParams:function(separator){var match=this.strip().match(/([^?#]*)(#.*)?$/);if(!match)return{};return match[1].split(separator||'&').inject({},function(hash,pair){if((pair=pair.split('='))[0]){var key=decodeURIComponent(pair.shift());var value=pair.length>1?pair.join('='):pair[0];if(value!=undefined)value=decodeURIComponent(value);if(key in hash){if(!Object.isArray(hash[key]))hash[key]=[hash[key]];hash[key].push(value)}else hash[key]=value}return hash})},include:function(pattern){return this.indexOf(pattern)>-1}});var $break={};var Enumerable={each:function(iterator,context){var index=0;iterator=iterator.bind(context);try{this._each(function(value){iterator(value,index++)})}catch(e){if(e!=$break)throw e}return this},all:function(iterator,context){iterator=iterator?iterator.bind(context):Prototype.K;var result=true;this.each(function(value,index){result=result&&!!iterator(value,index);if(!result)throw $break});return result},any:function(iterator,context){iterator=iterator?iterator.bind(context):Prototype.K;var result=false;this.each(function(value,index){if(result=!!iterator(value,index))throw $break});return result},collect:function(iterator,context){iterator=iterator?iterator.bind(context):Prototype.K;var results=[];this.each(function(value,index){results.push(iterator(value,index))});return results},include:function(object){if(Object.isFunction(this.indexOf))if(this.indexOf(object)!=-1)return true;var found=false;this.each(function(value){if(value==object){found=true;throw $break}});return found},inject:function(memo,iterator,context){iterator=iterator.bind(context);this.each(function(value,index){memo=iterator(memo,value,index)});return memo},invoke:function(method){var args=$A(arguments).slice(1);return this.map(function(value){return value[method].apply(value,args)})}};Object.extend(Enumerable,{map:Enumerable.collect,find:Enumerable.detect,select:Enumerable.findAll,filter:Enumerable.findAll,member:Enumerable.include,entries:Enumerable.toArray,every:Enumerable.all,some:Enumerable.any});function $A(iterable){if(!iterable)return[];if(iterable.toArray)return iterable.toArray();var length=iterable.length,results=new Array(length);while(length--)results[length]=iterable[length];return results}if(Prototype.Browser.WebKit){function $A(iterable){if(!iterable)return[];if(!(Object.isFunction(iterable)&&iterable=='[object NodeList]')&&iterable.toArray)return iterable.toArray();var length=iterable.length,results=new Array(length);while(length--)results[length]=iterable[length];return results}}Array.from=$A;Object.extend(Array.prototype,Enumerable);if(!Array.prototype._reverse)Array.prototype._reverse=Array.prototype.reverse;Object.extend(Array.prototype,{_each:function(iterator){for(var i=0,length=this.length;i<length;i++)iterator(this[i])},clear:function(){this.length=0;return this},first:function(){return this[0]},last:function(){return this[this.length-1]},compact:function(){return this.select(function(value){return value!=null})},flatten:function(){return this.inject([],function(array,value){return array.concat(Object.isArray(value)?value.flatten():[value])})},without:function(){var values=$A(arguments);return this.select(function(value){return!values.include(value)})},reverse:function(inline){return(inline!==false?this:this.toArray())._reverse()},reduce:function(){return this.length>1?this:this[0]},uniq:function(sorted){return this.inject([],function(array,value,index){if(0==index||(sorted?array.last()!=value:!array.include(value)))array.push(value);return array})},intersect:function(array){return this.uniq().findAll(function(item){return array.detect(function(value){return item===value})})},clone:function(){return[].concat(this)},size:function(){return this.length},inspect:function(){return'['+this.map(Object.inspect).join(', ')+']'},toJSON:function(){var results=[];this.each(function(object){var value=Object.toJSON(object);if(value!==undefined)results.push(value)});return'['+results.join(', ')+']'}});if(!Array.prototype.lastIndexOf)Array.prototype.lastIndexOf=function(item,i){i=isNaN(i)?this.length:(i<0?this.length+i:i)+1;var n=this.slice(0,i).reverse().indexOf(item);return(n<0)?n:i-n-1};Array.prototype.toArray=Array.prototype.clone;function $w(string){if(!Object.isString(string))return[];string=string.strip();return string?string.split(/\s+/):[]}if(Prototype.Browser.Opera1){Array.prototype.concat=function(){var array=[];for(var i=0,length=this.length;i<length;i++)array.push(this[i]);for(var i=0,length=arguments.length;i<length;i++){if(Object.isArray(arguments[i])){for(var j=0,arrayLength=arguments[i].length;j<arrayLength;j++)array.push(arguments[i][j])}else{array.push(arguments[i])}}return array}}Object.extend(Number.prototype,{toColorPart:function(){return this.toPaddedString(2,16)},succ:function(){return this+1},times:function(iterator){$R(0,this,true).each(iterator);return this},toPaddedString:function(length,radix){var string=this.toString(radix||10);return'0'.times(length-string.length)+string},toJSON:function(){return isFinite(this)?this.toString():'null'}});$w('abs round ceil floor').each(function(method){Number.prototype[method]=Math[method].methodize()});function $H(object){return new Hash(object)};var Hash=Class.create(Enumerable,(function(){if(function(){var i=0,Test=function(value){this.key=value};Test.prototype.key='foo';for(var property in new Test('bar'))i++;return i>1}()){function each(iterator){var cache=[];for(var key in this._object){var value=this._object[key];if(cache.include(key))continue;cache.push(key);var pair=[key,value];pair.key=key;pair.value=value;iterator(pair)}}}else{function each(iterator){for(var key in this._object){var value=this._object[key],pair=[key,value];pair.key=key;pair.value=value;iterator(pair)}}}function toQueryPair(key,value){if(Object.isUndefined(value))return key;return key+'='+encodeURIComponent(String.interpret(value))}return{initialize:function(object){this._object=Object.isHash(object)?object.toObject():Object.clone(object)},_each:each,set:function(key,value){return this._object[key]=value},get:function(key){return this._object[key]},unset:function(key){var value=this._object[key];delete this._object[key];return value},toObject:function(){return Object.clone(this._object)},keys:function(){return this.pluck('key')},values:function(){return this.pluck('value')},index:function(value){var match=this.detect(function(pair){return pair.value===value});return match&&match.key},merge:function(object){return this.clone().update(object)},update:function(object){return new Hash(object).inject(this,function(result,pair){result.set(pair.key,pair.value);return result})},toQueryString:function(){return this.map(function(pair){var key=encodeURIComponent(pair.key),values=pair.value;if(values&&typeof values=='object'){if(Object.isArray(values))return values.map(toQueryPair.curry(key)).join('&')}return toQueryPair(key,values)}).join('&')},inspect:function(){return'#<Hash:{'+this.map(function(pair){return pair.map(Object.inspect).join(': ')}).join(', ')+'}>'},toJSON:function(){return Object.toJSON(this.toObject())},clone:function(){return new Hash(this)}}})());Hash.prototype.toTemplateReplacements=Hash.prototype.toObject;Hash.from=$H;var ObjectRange=Class.create(Enumerable,{initialize:function(start,end,exclusive){this.start=start;this.end=end;this.exclusive=exclusive},_each:function(iterator){var value=this.start;while(this.include(value)){iterator(value);value=value.succ()}},include:function(value){if(value<this.start)return false;if(this.exclusive)return value<this.end;return value<=this.end}});var $R=function(start,end,exclusive){return new ObjectRange(start,end,exclusive)};var Ajax={getTransport:function(){return Try.these(function(){return new XMLHttpRequest()},function(){return new ActiveXObject('Msxml2.XMLHTTP')},function(){return new ActiveXObject('Microsoft.XMLHTTP')},function(){return new IFrameRequest()})||false},activeRequestCount:0};Ajax.Responders={responders:[],_each:function(iterator){this.responders._each(iterator)},register:function(responder){if(!this.include(responder))this.responders.push(responder)},unregister:function(responder){this.responders=this.responders.without(responder)},dispatch:function(callback,request,transport,json){this.each(function(responder){if(Object.isFunction(responder[callback])){try{responder[callback].apply(responder,[request,transport,json])}catch(e){}}})}};Object.extend(Ajax.Responders,Enumerable);Ajax.Responders.register({onCreate:function(){Ajax.activeRequestCount++},onComplete:function(){Ajax.activeRequestCount--}});Ajax.Base=Class.create({initialize:function(options){this.options={method:'post',asynchronous:true,contentType:'application/x-www-form-urlencoded',encoding:'UTF-8',parameters:'',evalJSON:true,evalJS:true};Object.extend(this.options,options||{});this.options.method=this.options.method.toLowerCase();if(Object.isString(this.options.parameters))this.options.parameters=this.options.parameters.toQueryParams()}});Ajax.Request=Class.create(Ajax.Base,{_complete:false,initialize:function($super,url,options){$super(options);this.transport=Ajax.getTransport();this.request(url)},request:function(url){this.url=url;this.method=this.options.method;var params=Object.clone(this.options.parameters);if(!['get','post'].include(this.method)){params['_method']=this.method;this.method='post'}this.parameters=params;if(params=Object.toQueryString(params)){if(this.method=='get')this.url+=(this.url.include('?')?'&':'?')+params;else if(/Konqueror|Safari|KHTML/.test(navigator.userAgent))params+='&_='}try{var response=new Ajax.Response(this);if(this.options.onCreate)this.options.onCreate(response);Ajax.Responders.dispatch('onCreate',this,response);this.transport.open(this.method.toUpperCase(),this.url,this.options.asynchronous);if(this.options.asynchronous)this.respondToReadyState.bind(this).defer(1);this.transport.onreadystatechange=this.onStateChange.bind(this);this.setRequestHeaders();this.body=this.method=='post'?(this.options.postBody||params):null;this.transport.send(this.body);if(!this.options.asynchronous&&this.transport.overrideMimeType)this.onStateChange()}catch(e){this.dispatchException(e)}},onStateChange:function(){var readyState=this.transport.readyState;if(readyState>1&&!((readyState==4)&&this._complete))this.respondToReadyState(this.transport.readyState)},setRequestHeaders:function(){var headers={'X-Requested-With':'XMLHttpRequest','X-Prototype-Version':Prototype.Version,'Accept':'text/javascript, text/html, application/xml, text/xml, */*'};if(this.method=='post'){headers['Content-type']=this.options.contentType+(this.options.encoding?'; charset='+this.options.encoding:'');if(this.transport.overrideMimeType&&(navigator.userAgent.match(/Gecko\/(\d{4})/)||[0,2005])[1]<2005)headers['Connection']='close'}if(typeof this.options.requestHeaders=='object'){var extras=this.options.requestHeaders;if(Object.isFunction(extras.push))for(var i=0,length=extras.length;i<length;i+=2)headers[extras[i]]=extras[i+1];else $H(extras).each(function(pair){headers[pair.key]=pair.value})}for(var name in headers)this.transport.setRequestHeader(name,headers[name])},success:function(){var status=this.getStatus();return!status||(status>=200&&status<300)},getStatus:function(){try{return this.transport.status||0}catch(e){return 0}},respondToReadyState:function(readyState){var state=Ajax.Request.Events[readyState],response=new Ajax.Response(this);if(state=='Complete'){try{this._complete=true;(this.options['on'+response.status]||this.options['on'+(this.success()?'Success':'Failure')]||Prototype.emptyFunction)(response,response.headerJSON)}catch(e){this.dispatchException(e)}var contentType=response.getHeader('Content-type');if(this.options.evalJS=='force'||(this.options.evalJS&&contentType&&contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i)))this.evalResponse()}try{(this.options['on'+state]||Prototype.emptyFunction)(response,response.headerJSON);Ajax.Responders.dispatch('on'+state,this,response,response.headerJSON)}catch(e){this.dispatchException(e)}if(state=='Complete'){this.transport.onreadystatechange=Prototype.emptyFunction}},getHeader:function(name){try{return this.transport.getResponseHeader(name)}catch(e){return null}},evalResponse:function(){try{return eval((this.transport.responseText||'').unfilterJSON())}catch(e){this.dispatchException(e)}},dispatchException:function(exception){(this.options.onException||Prototype.emptyFunction)(this,exception);Ajax.Responders.dispatch('onException',this,exception)}});Ajax.Request.Events=['Uninitialized','Loading','Loaded','Interactive','Complete'];Ajax.Response=Class.create({initialize:function(request){this.request=request;var transport=this.transport=request.transport,readyState=this.readyState=transport.readyState;if((readyState>2&&!Prototype.Browser.IE)||readyState==4){this.status=this.getStatus();this.statusText=this.getStatusText();this.responseText=String.interpret(transport.responseText);this.headerJSON=this._getHeaderJSON()}if(readyState==4){var xml=transport.responseXML;this.responseXML=xml===undefined?null:xml;this.responseJSON=this._getResponseJSON()}},status:0,statusText:'',getStatus:Ajax.Request.prototype.getStatus,getStatusText:function(){try{return this.transport.statusText||''}catch(e){return''}},getHeader:Ajax.Request.prototype.getHeader,getAllHeaders:function(){try{return this.getAllResponseHeaders()}catch(e){return null}},getResponseHeader:function(name){return this.transport.getResponseHeader(name)},getAllResponseHeaders:function(){return this.transport.getAllResponseHeaders()},_getHeaderJSON:function(){var json=this.getHeader('X-JSON');if(!json)return null;json=decodeURIComponent(escape(json));try{return json.evalJSON(this.request.options.sanitizeJSON)}catch(e){this.request.dispatchException(e)}},_getResponseJSON:function(){var options=this.request.options;if(!options.evalJSON||(options.evalJSON!='force'&&!(this.getHeader('Content-type')||'').include('application/json')))return null;try{return this.transport.responseText.evalJSON(options.sanitizeJSON)}catch(e){this.request.dispatchException(e)}}});Ajax.Updater=Class.create(Ajax.Request,{initialize:function($super,container,url,options){this.container={success:(container.success||container),failure:(container.failure||(container.success?null:container))};options=options||{};var onComplete=options.onComplete;options.onComplete=(function(response,param){this.updateContent(response.responseText);if(Object.isFunction(onComplete))onComplete(response,param)}).bind(this);$super(url,options)},updateContent:function(responseText){var receiver=this.container[this.success()?'success':'failure'],options=this.options;if(!options.evalScripts)responseText=responseText.stripScripts();if(receiver=$(receiver)){if(options.insertion){if(Object.isString(options.insertion)){var insertion={};insertion[options.insertion]=responseText;receiver.insert(insertion)}else options.insertion(receiver,responseText)}else receiver.update(responseText)}if(this.success()){if(this.onComplete)this.onComplete.bind(this).defer()}}});function $(element){if(arguments.length>1){for(var i=0,elements=[],length=arguments.length;i<length;i++)elements.push($(arguments[i]));return elements}if(Object.isString(element))element=document.getElementById(element);return Element.extend(element)}if(Prototype.BrowserFeatures.XPath){document._getElementsByXPath=function(expression,parentElement){var results=[];var query=document.evaluate(expression,$(parentElement)||document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);for(var i=0,length=query.snapshotLength;i<length;i++)results.push(Element.extend(query.snapshotItem(i)));return results}}if(!window.Node)var Node={};if(!Node.ELEMENT_NODE){Object.extend(Node,{ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12})}(function(){var element=this.Element;this.Element=function(tagName,attributes){attributes=attributes||{};tagName=tagName.toLowerCase();var cache=Element.cache;if(Prototype.Browser.IE&&attributes.name){tagName='<'+tagName+' name="'+attributes.name+'">';delete attributes.name;return Element.writeAttribute(document.createElement(tagName),attributes)}if(!cache[tagName])cache[tagName]=Element.extend(document.createElement(tagName));return Element.writeAttribute(cache[tagName].cloneNode(false),attributes)};Object.extend(this.Element,element||{})}).call(window);Element.cache={};Element.Methods={hide:function(element){$(element).style.display='none';return element},show:function(element){$(element).style.display='';return element},identify:function(element){element=$(element);var id=element.readAttribute('id'),self=arguments.callee;if(id)return id;do{id='anonymous_element_'+self.counter++}while($(id));element.writeAttribute('id',id);return id}};Element.Methods.identify.counter=1;Object.extend(Element.Methods,{getElementsBySelector:Element.Methods.select,childElements:Element.Methods.immediateDescendants});Element._attributeTranslations={write:{names:{className:'class',htmlFor:'for'},values:{}}};Element.Methods.ByTag={};Object.extend(Element,Element.Methods);if(!Prototype.BrowserFeatures.ElementExtensions&&document.createElement('div').__proto__){window.HTMLElement={};window.HTMLElement.prototype=document.createElement('div').__proto__;Prototype.BrowserFeatures.ElementExtensions=true}Element.extend=(function(){if(Prototype.BrowserFeatures.SpecificElementExtensions)return Prototype.K;var Methods={},ByTag=Element.Methods.ByTag;var extend=Object.extend(function(element){if(!element||element._extendedByPrototype||element.nodeType!=1||element==window)return element;var methods=Object.clone(Methods),tagName=element.tagName,property,value;if(ByTag[tagName])Object.extend(methods,ByTag[tagName]);for(property in methods){value=methods[property];if(Object.isFunction(value)&&!(property in element))element[property]=value.methodize()}element._extendedByPrototype=Prototype.emptyFunction;return element},{refresh:function(){if(!Prototype.BrowserFeatures.ElementExtensions){Object.extend(Methods,Element.Methods);Object.extend(Methods,Element.Methods.Simulated)}}});extend.refresh();return extend})();


 

