var Toolbox = {
	setLocation: function(url){
		window.location.href = Toolbox.makeURL(url);
		window.location = Toolbox.makeURL(url);
		location.href = Toolbox.makeURL(url);
		
	},
	makeURL: function(url){
		base = document.getElementsByTagName('base');
		has_http = /^http:/;
		if (!has_http.test(url)) {
			if(url.substr(0,1) != '/'){
				if (base.length > 0) {
					base = document.getElementsByTagName('base')[0].href;
				} else if(redirect_url != undefined){
					base = redirect_url;
				} else {
					base = '';
				}
				if(base.substr(base.length-1) != '/'){
					base = base+'/';
				}
				url = base+url;
			}
		}
		return url;	
	},
	openPopup: function(url, width, height){
		window.open(Toolbox.makeURL(url),null,'resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,fullscreen=no,dependent=no,width='+width+',height='+height);	
	},
	toggleElement: function(element){
		if(element.style.display == 'none'){
			new Effect.Parallel([
				new Effect.BlindDown(element, { sync: true }), 
				new Effect.Appear(element, { sync: true }) 
				], { duration: 0.5 });
		} else {
			new Effect.Parallel([
				new Effect.BlindUp(element, { sync: true }), 
				new Effect.Fade(element, { sync: true }) 
				], { duration: 0.5 });
		}		
	},
	toggleBookingBox: function(element, yesno, zipcode){
		if(element.style.display == 'none' && yesno == 'yes'){
			new Effect.Parallel([
				new Effect.BlindDown(element, { sync: true }), 
				new Effect.Appear(element, { sync: true }) 
				], { duration: 0.5 });
			getBookingTable(zipcode);
		} else if(yesno == 'no'){
			new Effect.Parallel([
				new Effect.BlindUp(element, { sync: true }), 
				new Effect.Fade(element, { sync: true }) 
				], { duration: 0.5 });
		}		
	},
	toggleOrderBox: function(element){
		if(element.style.display == 'none'){
			new Effect.Parallel([
				new Effect.BlindDown(element, { sync: true }), 
				new Effect.Appear(element, { sync: true }) 
				], { duration: 0.5 });
			$('orderboxprice').innerHTML = '1.986';
		} else {
			new Effect.Parallel([
				new Effect.BlindUp(element, { sync: true }), 
				new Effect.Fade(element, { sync: true }) 
				], { duration: 0.5 });
			$('orderboxprice').innerHTML = '1.986';
		}		
	},
	convertXMLToXHTML: function(elm){
		if(elm.nodeName){
			switch(elm.nodeName){
				case '#text':
					return document.createTextNode(elm.nodeValue);
					break;
				default:
					var iElement = document.createElement(elm.nodeName);
					for (var i = 0; i < elm.attributes.length; i++) {
						iElement.setAttribute(elm.attributes[i].nodeName, elm.attributes[i].nodeValue);
					}
					for (var i = 0; i < elm.childNodes.length; i++) {
						iElement.appendChild(Toolbox.convertXMLToXHTML(elm.childNodes[i]));
					}
					return iElement;
					break;
			}
		}
							
	},
	event: {
		events: new Array(),
		handlers: new Array(),
			
		register: function(event, handler){
			this.handlers[this._getEventID(event)].push(handler);
		},
		trigger: function(event, param){
			var eventID = this._getEventID(event);
			for(var i = 0; i <= (this.handlers[eventID].length - 1); i++){
				this.handlers[eventID][i](param);
			}
		},
		_getEventID: function(event){
			for(var i = 0; i <= (this.events.length - 1); i++){
				if(this.events[i] == event){
					return i;
				}
			}
			this.events.push(event);
			var eventID = (this.events.length - 1);
			this.handlers[eventID] = new Array();
			return eventID;
		}		
	}
};

/*

function getQuestions(customertype){
	
	type = customertype.id;
	
	if(type == 'customer-yes'){
		type = 1;
	}else if(type == 'customer-no'){
		type = 2;
	}
	
	new Ajax.Request(Toolbox.makeURL('signalquiz/step/'), {
		method: 'get',
		parameters: 'type='+type+'&quiz='+2,
		onFailure: function(){
			
		},
		onSuccess: function(transport) {
			var rootNode = transport.responseXML.getElementsByTagName('questions');
			
			var nodes = rootNode.item(0).getElementsByTagName('question');
			
			step2 = document.getElementById('step_2');
			step3 = document.getElementById('step_3');
			
			step2.innerHTML = '';
			step3.innerHTML = '';
			step2.style.display = 'none';
			step3.style.display = 'none';
			
			for(i=0; i<nodes.length;i++){
				
				question = nodes.item(i);
				
				/** Step 2 of the quiz 
				h3 = document.createElement('h3');
				h3.innerHTML = question.getAttribute('question');
				
				table = document.createElement('table');
				Element.addClassName(table, 'questions-table');
				
				tbody = document.createElement('tbody');

				if(question.hasChildNodes()){
					answers = question.getElementsByTagName('answer');
					
					for(a=0;a<answers.length;a++){
						answer = answers.item(a);
						
						if(answers.length > 2){
							count = a + 1;
							mod = count % 3;
							if(mod == 0 || a == 0){
								tr = document.createElement('tr');
							}
						}else{
							tr = document.createElement('tr');
						}

						td = document.createElement('td');
						Element.addClassName(td, 'input-type');
						
						input = document.createElement('input');
						input.setAttribute('name', question.getAttribute('id'));
						input.setAttribute('type', 'radio');
						input.setAttribute('value', answer.getAttribute('value'));

						td.appendChild(input);
						td2 = document.createElement('td');
						Element.addClassName(td2, 'text');
						
						p = document.createElement('p');
						
						label = document.createElement('label');
						label.innerHTML = answer.getAttribute('answer');
						
						p.appendChild(label);
						
						td2.appendChild(p);
						
						tr.appendChild(td);
						tr.appendChild(td2);
						
						tbody.appendChild(tr);
						
					}
					
				}
				table.appendChild(tbody);
				
				if(i < 3){
					step2.appendChild(h3);
					step2.appendChild(table);
				}else{
					step3.appendChild(h3);
					step3.appendChild(table);
				}
				
			}
			hr = document.createElement('hr');
			hr.setAttribute('class', 'ie-control');
			hr.setAttribute('style', 'margin-right: 50px;');
			
			hr2 = document.createElement('hr');
			hr2.setAttribute('class', 'ie-control');
			hr2.setAttribute('style', 'margin-right: 50px;');
			
			img = document.createElement('img');
			img.setAttribute('src', 'share/web/images/page/layout/continue-button.png');
			img.setAttribute('alt', 'forts&aelig;t');
			
			
			img.setAttribute('onclick', 'showStep(1, 2)');
			step2.appendChild(hr);
			step2.appendChild(img);
			step2.appendChild(hr2);
			
			alert('here'); 	
			
			img.setAttribute('onclick', 'showStep(1, 2)');
			step3.appendChild(hr);
			step3.appendChild(img);
			step3.appendChild(hr2);
			
			
		}
	});
	
}

function showStep(oldstep, newstep){
	
	oldStep = document.getElementById('step_'+oldstep);
	
	oldStep.style.display = 'none';
	
	newStep = document.getElementById('step_'+newstep);
	
	newStep.style.display = 'block';
	
}
**/
