var Class = { create: function() { return function() { this.initialize.apply(this, arguments); } } } Object.extend = function(destination, source) { for (property in source) { destination[property] = source[property]; } return destination; } Function.prototype.bind = function(object) { var __method = this; return function() { return __method.apply(object, arguments); } } function $() { var elements = new Array(); for (var i = 0; i < arguments.length; i++) { var element = arguments[i]; if (typeof element == 'string') element = document.getElementById(element); if (arguments.length == 1) return element; elements.push(element); } return elements; } //------------------------- document.getElementsByClassName = function(className) { var children = document.getElementsByTagName('*') || document.all; var elements = new Array(); for (var i = 0; i < children.length; i++) { var child = children[i]; var classNames = child.className.split(' '); for (var j = 0; j < classNames.length; j++) { if (classNames[j] == className) { elements.push(child); break; } } } return elements; } //------------------------- if (!window.Element) { var Element = new Object(); } Object.extend(Element, { remove: function(element) { element = $(element); element.parentNode.removeChild(element); }, hasClassName: function(element, className) { element = $(element); if (!element) return; var a = element.className.split(' '); for (var i = 0; i < a.length; i++) { if (a[i] == className) return true; } return false; }, addClassName: function(element, className) { element = $(element); Element.removeClassName(element, className); element.className += ' ' + className; }, removeClassName: function(element, className) { element = $(element); if (!element) return; var newClassName = ''; var a = element.className.split(' '); for (var i = 0; i < a.length; i++) { if (a[i] != className) { if (i > 0) newClassName += ' '; newClassName += a[i]; } } element.className = newClassName; }, // removes whitespace-only text node children cleanWhitespace: function(element) { element = $(element); for (var i = 0; i < element.childNodes.length; i++) { var node = element.childNodes[i]; if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) Element.remove(node); } } }); //effects library var fx = new Object(); var cImg; fx.Base = function(){}; fx.Base.prototype = { setOptions: function(options) { this.options = { duration: 500, interval: 20, onComplete: '' } Object.extend(this.options, options || {}); }, go: function() { this.duration = this.options.duration; this.startTime = (new Date).getTime(); this.timer = setInterval (this.step.bind(this), this.options.interval); }, step: function() { var time = (new Date).getTime(); var Tpos = (time - this.startTime) / (this.duration); if (this.to==0 && (time>=((this.duration+this.startTime)-this.duration/10))){ this.el.style.display='none'; } if (time >= this.duration+this.startTime) { this.el.style.height = this.to + 'px'; this.now = this.to; clearInterval (this.timer); this.timer = null; if (this.options.onComplete) setTimeout(this.options.onComplete.bind(this), 10); } else { this.now = ((-Math.cos(Tpos*Math.PI)/2) + 0.5) * (this.to-this.from) + this.from; this.increase(); //this time-position, sinoidal transition thing is from script.aculo.us } /* if(this.now == this.to) { if (this.el.offsetHeight > 0) { document.getElementById(cImg).src=u.src; } else { document.getElementById(cImg).src=d.src; } } */ }, custom: function(from, to) { if (this.timer != null) return; this.from = from; this.to = to; this.go(); }, hide: function() { this.now = 0; this.increase(); } } //stretchers fx.Layout = Class.create(); fx.Layout.prototype = Object.extend(new fx.Base(), { initialize: function(el, options) { this.el = $(el); this.el.style.overflow = "hidden"; this.el.iniWidth = this.el.offsetWidth; this.el.iniHeight = this.el.offsetHeight; this.setOptions(options); } }); fx.Height = Class.create(); Object.extend(Object.extend(fx.Height.prototype, fx.Layout.prototype), { increase: function() { if(this.now>1) this.el.style.height = this.now + "px"; }, toggle: function(source,hideOnly) { if (this.el.offsetHeight > 0) { document.getElementById('SC'+source).innerHTML='∨'; document.getElementById('C'+source).style.backgroundColor=''; document.getElementById('C'+source).style.borderTop='0px'; document.getElementById('C'+source).style.borderBottom='0px'; document.getElementById('C'+source).style.fontWeight='normal'; this.custom(this.el.offsetHeight, 0); } else if (hideOnly===null || hideOnly!==true){ document.getElementById('C'+source).style.borderTop='1px solid #CCCCCC'; document.getElementById('C'+source).style.borderBottom='1px solid #CCCCCC'; document.getElementById('C'+source).style.fontWeight='bold'; document.getElementById('SC'+source).innerHTML='∧'; if(source!=null) this.el.innerHTML=document.getElementById(source).innerHTML; this.el.style.height='1px'; this.el.style.display='block'; //this.el.style.height='1px'; this.custom(0, this.el.scrollHeight+10); } } }); function instAJAX() { var request = false; try { request = new XMLHttpRequest(); } catch (trymicrosoft) { try { request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (othermicrosoft) { try { request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (failed) { request = false; } } } if (!request) alert("Error initializing XMLHttpRequest!"); return request; } function doAddEntryOptions(sel){ var subcat = document.getElementById('subcat'); var subcatVal = subcat.options[subcat.selectedIndex].value; if(subcatVal != 'MAKESELECT'){ var ajaxObj = instAJAX(); var url = 'http://www.doctorwhotoybox.co.uk/index.php/page/itemt/subcat/' + subcatVal; ajaxObj.open("GET", url, true); ajaxObj.onreadystatechange = changeTitleSelect; ajaxObj.send(null); } function changeTitleSelect() { if (ajaxObj.readyState == 4){ document.getElementById('formItemFields').style.display='block'; var list = ajaxObj.responseXML; var coptions = list.childNodes[0]; var field = document.getElementById('variant'); while(field.childNodes.length>0){ field.removeChild(field.childNodes[0]); } for(i=0; i 0){ document.getElementById('year').options[no].selected = true; } }