	function getCookie(name)
	{
		var search = name + "=";
		if (document.cookie.length > 0)
		{
			offset = document.cookie.indexOf(search);
			if (offset != -1)
			{
				offset += search.length;
				end = document.cookie.indexOf(";", offset);
				if (end == -1)
					end = document.cookie.length;
				return unescape(document.cookie.substring(offset, end));
			}
		}
	}
	
	function setCookie(name, value, expire)
	{
		document.cookie = name + "=" + escape(value) + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
	}
	
	function panel(id)
	{
		var ojj = document.getElementById(id + "Img");
		var t = document.getElementById(id);
		var today = new Date();
		var expires = new Date();
		expires.setTime(today.getTime() + 1000*60*60*24*365);
		if (t.className == 'displayed')
		{
			t.className = 'hided';
			ojj.src = 'pictures/panelOpeningDown.gif';
			setCookie(id,'hided', expires);
		}
		else
		{
			t.className = 'displayed';
			ojj.src = 'pictures/panelOpeningUp.gif';
			setCookie(id,'displayed', expires);
		}
	}
	
	function panelStart(id)
	{
		var ojj = document.getElementById(id + "Img");
		var t = document.getElementById(id);
		var cookie = getCookie(id);
		if (cookie)
		{
			t.className = cookie;
			if (cookie == 'displayed')
			{
				ojj.src = 'pictures/panelOpeningUp.gif';
			}
		}
		else
		{
			// Első indulása a cuccnak
			var today = new Date();
			var expires = new Date();
			expires.setTime(today.getTime() + 1000*60*60*24*365);
			t.className = 'displayed';
			ojj.src = 'pictures/panelOpeningUp.gif';
			setCookie(id,'displayed', expires);
		}
	}
	
	function changeUserContactSameAsBilling(ojj)
	{
		ojjektum = document.getElementById("userContactSameAsBillingID");
		if (ojj.checked)
		{
			ojjektum.className = "hided";
		}
		else
		{
			ojjektum.className = "displayed";
		}
	}
	
	function changeDiv(ojj)
	{
		val = ojj[ojj.selectedIndex].value;
		val2 = ojj[ojj.selectedIndex].className;
		val3 = ojj[ojj.selectedIndex].text;
		if (val2)
			val = val2;
		myRE = new RegExp(ojj.name + "_","i");
		for (var i = 0; i < document.calculatorForm.elements.length; i++)
		{
			if (document.calculatorForm.elements[i].name.match(myRE))
			{
				if (document.calculatorForm.elements[i].name.substr(document.calculatorForm.elements[i].name.length-4,1) == '_')
				{
					ojjX = document.getElementById(document.calculatorForm.elements[i].name.substr(0,document.calculatorForm.elements[i].name.length-1));
				}
				else
				{
					ojjX = document.getElementById(document.calculatorForm.elements[i].name);
				}
				if (ojjX)
				{
					ojjX.className = 'hided';
				}
			}
		}
		ojj2 = document.getElementById(ojj.name + '_' + val);
		if (ojj2)
		{
			ojj2.className = 'displayed';
		}
		ojj3 = document.getElementById(ojj.name + '_' + val + '_text');
		if (ojj3)
		{
			ojj3.value = val3 + ':';
		}
		
		if (ojj.name == 'calc')
		{
			document.calculatorForm.calc_1.selectedIndex = 0;
			document.calculatorForm.calc_2.selectedIndex = 0;
			document.calculatorForm.calc_3.selectedIndex = 0;
		}
		
		changeVal(ojj);
	}
	
	function printfire()
	{
		if (document.createEvent)
		{
			printfire.args = arguments;
			var ev = document.createEvent("Events");
			ev.initEvent("printfire", false, true);
			dispatchEvent(ev);
		}
	}
	
	function writit(text,id)
	{
		if (document.getElementById)
		{
			x = document.getElementById(id);
			x.innerHTML = '';
			x.innerHTML = text;
		}
		else if (document.all)
		{
			x = document.all[id];
			x.innerHTML = text;
		}
		else if (document.layers)
		{
			x = document.layers[id];
			text2 = '<P CLASS="testclass">' + text + '</P>';
			x.document.open();
			x.document.write(text2);
			x.document.close();
		}
	}
	
	function getPageSize(){
		
		var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}
	
	
		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
		return arrayPageSize;
	}
	
	function showOverlay()
	{
		var objOverlay = document.getElementById('overlay');
		var arrayPageSize = getPageSize();
		
		// set height of Overlay to take up whole page and show
		objOverlay.style.height = (arrayPageSize[1] + 'px');
		objOverlay.style.display = 'block';
	}
	
	function initOverlay()
	{
		var objBody = document.getElementsByTagName("body").item(0);
		
		// create overlay div and hardcode some functional styles (aesthetic styles are in CSS file)
		var objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','overlay');
		objOverlay.style.display = 'none';
		objOverlay.style.position = 'absolute';
		objOverlay.style.top = '0';
		objOverlay.style.left = '0';
		objOverlay.style.zIndex = '90';
	 	objOverlay.style.width = '100%';
		objBody.insertBefore(objOverlay, objBody.firstChild);
	}
	
	function hideOverlay()
	{
		// get objects
		objOverlay = document.getElementById('overlay');
	
		// hide lightbox and overlay
		objOverlay.style.display = 'none';
	}
	
	function addLoadEvent(func)
	{	
		var oldonload = window.onload;
		if (typeof window.onload != 'function'){
	    	window.onload = func;
		} else {
			window.onload = function(){
			oldonload();
			func();
			}
		}
	
	}