muze.namespace("webprint.product");
webprint.product.selection = function() {
	return {
		load : function(theme, combined_type) {
			newcontent = muze.load("product.selection.html?theme=" + theme + "&combined_type=" + combined_type, true, false);
			// if (newcontent) {
				document.getElementById("selection").innerHTML = newcontent;
				webprint.product.preview.attach();
			// }
		}
	}
}();

muze.namespace("webprint.projectlist");
webprint.projectlist.toggle = function(link, type) {
	var target = document.getElementById("projects_of_type_" + type);
	if (target.style.display == 'none') {
		target.style.display = "block";
		link.innerHTML = "Sluit"; // FIXME: NLS
	} else {
		target.style.display = "none";
		link.innerHTML = "Open"; // FIXME: NLS
	}
};

muze.namespace("webprint.editor");
webprint.editor = function() {
	return {
		isDirty  : false,
		state : "normal",
		sizes : new Array(),
		addressArgs : {},
		setDirty : function( dirty ) {
			if( dirty ) {
				webprint.editor.isDirty = true;
			} else {
				webprint.editor.isDirty = false;
			}
		},
		onBeforeUnload : function() {
			if( webprint.editor.isDirty ) {
				return "U heeft wijzigingen in uw project nog niet opgeslagen. Als u de editor verlaat verliest u uw wijzigingen.";
			}
		},
		savesizes : function(id) {
			var elm = document.getElementById(id);
			if (elm) {
				webprint.editor.sizes[id] = new Array();
				webprint.editor.sizes[id]['width'] = elm.style.width;
				webprint.editor.sizes[id]['height'] = elm.style.height;
				webprint.editor.sizes[id]['top'] = elm.style.top;
				webprint.editor.sizes[id]['left'] = elm.style.left;
				webprint.editor.sizes[id]['padding-left'] = elm.style.paddingLeft;
				webprint.editor.sizes[id]['padding-right'] = elm.style.paddingRight;
			}
		},
		restoresizes : function(id) {
			var elm = document.getElementById(id);
			if (elm && webprint.editor.sizes[id]) {
				elm.style.height = webprint.editor.sizes[id]['height'];
				elm.style.width = webprint.editor.sizes[id]['width'];
				elm.style.left = webprint.editor.sizes[id]['left'];
				elm.style.top = webprint.editor.sizes[id]['top'];
				elm.style.paddingLeft = webprint.editor.sizes[id]['padding-left'];
				elm.style.paddingRight = webprint.editor.sizes[id]['padding-right'];
			}
		},
		tofullscreen : function(id) {
			var elm = document.getElementById(id);
			if (elm) {
				elm.style.height = "100%";
				elm.style.width = "100%";
				elm.style.left = "0px";
				elm.style.top = "0px";
				elm.style.paddingLeft = "0px";
				elm.style.paddingRight = "0px";
			}
		},
		fullscreen : function() {
			if (webprint.editor.state == "fullscreen") {
				webprint.editor.normalview();
			} else {
				if (webprint.editor.state == "normal") {
					webprint.editor.savesizes("product_editor");
					webprint.editor.savesizes("content");
					webprint.editor.savesizes("wrapper");
					webprint.editor.savesizes("container");

					webprint.editor.tofullscreen("product_editor");
					webprint.editor.tofullscreen("content");
					webprint.editor.tofullscreen("wrapper");
					webprint.editor.tofullscreen("container");

					if (document.getElementById("header")) {
						document.getElementById("header").style.display = "none";
					}
					if (document.getElementById("footerblocker")) {
						document.getElementById("footerblocker").style.display = "none";
					}
					var editor = document.getElementById("product_editor");
					if (editor.getElementsByTagName("EMBED") && editor.getElementsByTagName("EMBED")[0]) {
						webprint.editor.normal_embed_height = parseInt(editor.getElementsByTagName("EMBED")[0].offsetHeight);
						webprint.editor.normal_embed_width = parseInt(editor.getElementsByTagName("EMBED")[0].offsetWidth);
						editor.getElementsByTagName("EMBED")[0].height = "100%";
						editor.getElementsByTagName("EMBED")[0].width = "100%";
					}

					webprint.editor.state = "fullscreen";
				}
			}
		},
		normalview : function() {
			if (webprint.editor.state == "fullscreen") {
				webprint.editor.restoresizes("product_editor");
				webprint.editor.restoresizes("content");
				webprint.editor.restoresizes("wrapper");
				webprint.editor.restoresizes("container");

				if (document.getElementById("header")) {
					document.getElementById("header").style.display = "block";
				}
				if (document.getElementById("footerblocker")) {
					document.getElementById("footerblocker").style.display = "block";
				}

				var editor = document.getElementById("product_editor");
				if (editor.getElementsByTagName("EMBED") && editor.getElementsByTagName("EMBED")[0]) {
					editor.getElementsByTagName("EMBED")[0].height = webprint.editor.normal_embed_height;
					editor.getElementsByTagName("EMBED")[0].width = webprint.editor.normal_embed_width;
				}

				webprint.editor.state = "normal";
			}
		},
		order : function(project_id) {
			// vul form in, order project
		},
		updateprice : function () {
			//  pas de prijs aan die op de website getoond wordt.
		},
		getAddress : function(field, current_address_id, used_address_ids) {
		//	alert(field);
		//	alert(current_address_id);
		//	alert(used_address_ids);

			// Zet variabelen klaar voor de lightbox
			webprint.editor.setAddressArgs(field, current_address_id, used_address_ids);

			var target = 'http://www.webprint.nl/mijn-webprint/mijn-adressen/address.select.html';

			// Open lightbox
			$.fancybox({
			//	'width'			: 934,
			//	'height'		: 400,
				'autoScale'		: true,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'			: 'iframe',
				'scrolling'		: 'no',
				'href'			: target
			});
			return false;
		},
		setAddressArgs : function(field, current_address_id, used_address_ids) {
			webprint.editor.addressArgs = {
				field : field,
				current_address_id : current_address_id,
				used_address_ids : used_address_ids
			};
		},
		getAddressArgs : function() {
			return webprint.editor.addressArgs;
		},
		setAddress : function(field, address_id) {
			if (address_id !== false) {
		//		alert('set address on field ' + field + ' with id ' + address_id);
				if (document.getElementById("product_editor").webprint_editor_setAddress) {
		//			alert("w_e_s");
					document.getElementById('product_editor').webprint_editor_setAddress(field, parseInt(address_id));
				} else if (document.getElementById("product_editor").setAddress) {
		//			alert("s");
					document.getElementById('product_editor').setAddress(field, parseInt(address_id));
				} else {
					alert("setaddress function not found");
				}
			}

			$.fancybox.close();
		}
	}
}();

webprint.addresses = function() {
	return {
		findAddressInfo : function(zipcode) {
			if (zipcode) {
				var myurl = "http://www.webprint.nl/graphics/findZipcode.json?zipcode=" + zipcode;
				var addressdata = muze.load(myurl, true, false);
				if (addressdata) {
					addressinfo = eval('(' + addressdata + ')');
					if(typeof(addressinfo) == 'object') {
						return addressinfo;
					}
				}
			}
			return false;
		}
	}
}();

muze.namespace("webprint.form.autofill_address");
webprint.form.autofill_address= function() {
	return {
		attach : function() {	
			inputs = document.getElementsByTagName("DIV");
			for (i=0; i<inputs.length; i++) {
				if (inputs[i] && inputs[i].className && inputs[i].className.indexOf("webprint_autofill_address") != -1) {
					inputelm = inputs[i].getElementsByTagName("INPUT")[0];
					muze.event.attach(inputelm, "change", webprint.form.autofill_address.execute);
					muze.event.attach(inputelm, "focus", webprint.form.autofill_address.showhint);
					muze.event.attach(inputelm, "blur", webprint.form.autofill_address.hidehint_delayed);
				}
			}
		},
		showhint : function() {
			if (webprint.form.autofill_address.hidetimer) {
				clearTimeout(webprint.form.autofill_address.hidetimer);
			}
			hintelm = document.getElementById("zipcode_hint");
			if (hintelm) {
				hintelm.className = "form_hint";
				hintelm.innerHTML = "Wij proberen aan de hand van je postcode de adresinformatie te vinden.";
				hintelm.style.display = "block";
			}
		},
		showloading : function() {
			hintelm = document.getElementById("zipcode_hint");
			if (hintelm) {
				hintelm.className = "form_hint";
				hintelm.innerHTML = "Adres wordt gezocht...";
				hintelm.style.display = "block";
			}
		},
		showerror : function() {
			hintelm = document.getElementById("zipcode_hint");
			if (hintelm) {
				hintelm.className = "form_error";
				hintelm.innerHTML = "We hebben bij deze postcode geen adresinformatie gevonden.";
				hintelm.style.display = "block";
			}			
		},
		showsuccess : function() {
			hintelm = document.getElementById("zipcode_hint");
			if (hintelm) {
				hintelm.className = "form_notify";
				hintelm.innerHTML = "De adresgegevens zijn aangevuld.";
				hintelm.style.display = "block";
			}
		},
		hidehint_delayed : function() {
			if (webprint.form.autofill_address.hidetimer) {
				clearTimeout(webprint.form.autofill_address.hidetimer);
			}
			webprint.form.autofill_address.hidetimer = setTimeout(webprint.form.autofill_address.hidehint, 5000);

		},
		hidehint : function () {
			hintelm = document.getElementById("zipcode_hint");
			if (hintelm) {
				hintelm.style.display = "none";
			}		
		},
		execute : function() {
			form = this.form;
			webprint.form.autofill_address.showloading();
			if (form.country.value == "Nederland") { // Alleen Nederlandse postcodetabel beschikbaar.
				addressinfo = webprint.addresses.findAddressInfo(form.zipcode.value);
				if (addressinfo) {
				//	if (!form.street.value || form.street.value == '') {
						form.street.value = addressinfo['street'];
				//	}
				//	if (!form.city.value || form.city.value == '') {
						form.city.value = addressinfo['city'];
				//	}
					webprint.form.autofill_address.showsuccess();
					webprint.form.autofill_address.hidehint_delayed();
					if (document.getElementById("house_number")) {
						document.getElementById("house_number").focus();
					}
				} else {
					webprint.form.autofill_address.showerror();
				}
			} else {
				webprint.form.autofill_address.showerror();
			}
		}
	}
}();

muze.namespace("webprint.form.clearonfocus");
webprint.form.clearonfocus = function() {
	return {
		attach : function() {
			inputs = document.getElementsByTagName("INPUT");
			for (i=0; i<inputs.length; i++) {
				if (
					(inputs[i] && inputs[i].className && inputs[i].className.indexOf("webprint_clearonfocus") != -1) ||
					(inputs[i] && inputs[i].parentNode && inputs[i].parentNode.className && inputs[i].parentNode.className.indexOf("webprint_clearonfocus") != -1)
				) {
					inputelm = inputs[i];
					inputelm.initialvalue = inputelm.value;
					muze.event.attach(inputelm, "focus", webprint.form.clearonfocus.execute);
				}
			}			
		},
		execute : function() {
			if (this.value == this.initialvalue) {
				this.value = '';
			}
		}
	}
}();

muze.namespace("webprint.form.show_subselection");
webprint.form.show_subselection = function() {
	return {
		attach : function() {
			inputs = document.getElementsByTagName("DIV");
			for (i=0; i<inputs.length; i++) {
				if (inputs[i] && inputs[i].className && inputs[i].className.indexOf("webprint_show_subselection") != -1) {
					inputelm = inputs[i].getElementsByTagName("SELECT")[0];
					if (inputelm) {
						muze.event.attach(inputelm, "change", webprint.form.show_subselection.execute);
					}
					radiooptions = inputs[i].getElementsByTagName("INPUT");
					for (j=0; j<radiooptions.length; j++) {
						if (radiooptions[j]) {
							muze.event.attach(radiooptions[j], "click", webprint.form.show_subselection.execute);
							muze.event.attach(radiooptions[j], "change", webprint.form.show_subselection.execute);
						}
					}
					if (inputelm) {
						webprint.form.show_subselection.execute_on_target(inputelm);
					}
				}
			}			
		},
		execute : function() {
			webprint.form.show_subselection.execute_on_target(this);
		},
		execute_on_target : function(targetelm) {
			inputs = targetelm.form.getElementsByTagName("DIV");
			for (i=0; i<inputs.length; i++) {
				if (inputs[i] && inputs[i].className && inputs[i].className.indexOf("webprint_subselection") != -1) {
					inputelm = inputs[i];
					inputelm.style.display = "none";
				}
				if (inputs[i] && inputs[i].className && inputs[i].className.indexOf(targetelm.value+"_subselection") != -1) {
					inputelm = inputs[i];
					inputelm.style.display = "block";
				}
			}
		}
	}
}();

muze.namespace("webprint.form.checkout_update_receipt");
webprint.form.checkout_update_receipt = function() {
	return {
		inputtimer : false,
		inputtarget : false,
		attach : function() {
			var parenttags = ["DIV", "TD"];

			for (j=0; j<parenttags.length; j++) {
				inputs = document.getElementsByTagName(parenttags[j]);
				for (i=0; i<inputs.length; i++) {
					if (inputs[i] && inputs[i].className && inputs[i].className.indexOf("webprint_checkout_update_receipt") != -1) {
						inputelm = inputs[i].getElementsByTagName("INPUT")[0];
						if (inputelm.type == "text" || inputelm.type == "textarea") {
							muze.event.attach(inputelm, "change", webprint.form.checkout_update_receipt.settimer);
							muze.event.attach(inputelm, "keydown", webprint.form.checkout_update_receipt.settimer);
						} else if (inputelm.type == "checkbox" || inputelm.type == "radio") {
							muze.event.attach(inputelm, "change", webprint.form.checkout_update_receipt.settimer);
							muze.event.attach(inputelm, "click", webprint.form.checkout_update_receipt.settimer);
						} else {
							muze.event.attach(inputelm, "change", webprint.form.checkout_update_receipt.settimer);
							muze.event.attach(inputelm, "keydown", webprint.form.checkout_update_receipt.settimer);
							muze.event.attach(inputelm, "click", webprint.form.checkout_update_receipt.settimer);
						}
					}
				}			
			}
		},
		settimer : function() {
			clearTimeout(webprint.form.checkout_update_receipt.inputtimer);
			webprint.form.checkout_update_receipt.inputtimer = setTimeout(webprint.form.checkout_update_receipt.execute, 300);
		},
		execute : function() {
			clearTimeout(webprint.form.checkout_update_receipt.inputtimer);
			webprint.payment.receipt_update();
			webprint.form.checkout_update_receipt.inputtimer = setTimeout(webprint.form.checkout_update_receipt.execute, 60000);
		}
	}
}();

muze.namespace("webprint.form.toggle_multi_address");
webprint.form.toggle_multi_address = function() {
	return {
		attach : function() {
			inputs = document.getElementsByTagName("A");
			for (i=0; i<inputs.length; i++) {
				if (inputs[i] && inputs[i].className && inputs[i].className.indexOf("webprint_toggle_multi_address") != -1) {
					inputelm = inputs[i];
					muze.event.attach(inputelm, "click", webprint.form.toggle_multi_address.execute);
				}
			}			
		},
		execute : function() {	
			webprint.payment.toggle_multiple_address_select();
			return false;
		}
	}
}();

muze.namespace("webprint.form.toggle_address");
webprint.form.toggle_address = function() {
	return {
		attach : function() {
			inputs = document.getElementsByTagName("A");
			for (i=0; i<inputs.length; i++) {
				if (inputs[i] && inputs[i].className && inputs[i].className.indexOf("webprint_toggle_address") != -1) {
					inputelm = inputs[i];
					muze.event.attach(inputelm, "click", webprint.form.toggle_address.execute);
				}
			}			
		},
		execute : function() {	
			webprint.payment.show_address_select();
			return false;
		}
	}
}();

muze.namespace("webprint.product.preview");
webprint.product.preview = function() {
	return {
		attach : function() {
			inputs = document.getElementsByTagName("A");
			for (i=0; i<inputs.length; i++) {
				if (inputs[i] && inputs[i].className && inputs[i].className.indexOf("webprint_product_preview") != -1) {
					inputelm = inputs[i];
					muze.event.attach(inputelm, "click", webprint.product.preview.execute);
				}
			}
		},
		execute : function(evt) {
			newcontent = muze.load(this.rel + "product_template.zoom.html", true, false);
			document.getElementById("product_preview").innerHTML = newcontent;
			inputs = document.getElementById("product_preview").getElementsByTagName("A");
			for (i=0; i<inputs.length; i++) {
				if (inputs[i] && inputs[i].className && inputs[i].className.indexOf("webprint_product_preview_close") != -1) {
					inputelm = inputs[i];
					muze.event.attach(inputelm, "click", webprint.product.preview.hide);
				}
			}
			
			webprint.product.preview.show();
			muze.event.cancel(evt);
			return false;
		},
		show : function() {
			document.getElementById("product_preview").style.display = "block";
			// document.getElementById("product_preview").scrollIntoView();
		},
		hide : function(evt) {
			document.getElementById("product_preview").style.display = "none";
			muze.event.cancel(evt);
			return false;
		}
	}
}();

muze.namespace("webprint.form.cancelenter");
webprint.form.cancelenter = function() {
	return {
		attach : function() {
			forms = document.getElementsByTagName("FORM");
			for (i=0; i<forms.length; i++) {
				if (forms[i] && forms[i].className && forms[i].className.indexOf("webprint_form_cancelenter") != -1) {
					inputs = forms[i].getElementsByTagName("INPUT");
					for (j=0; j<inputs.length; j++) {
						inputelm = inputs[j];
						muze.event.attach(inputelm, "keypress", webprint.form.cancelenter.execute);
					}
				}
			}
		},
		execute : function(evt) {
			var keyCode = evt.keyCode ? evt.keyCode : evt.which ? evt.which : evt.charCode;
			if (keyCode == 13) {
				muze.event.cancel(evt);
				return false;
			}
		}
	}
}();

muze.namespace("webprint.form.numbersonly");
webprint.form.numbersonly = function() {
	return {
		attach: function() {
			inputs = document.getElementsByTagName("INPUT");
			for (i=0; i<inputs.length; i++) {
				if (inputs[i] && inputs[i].className && inputs[i].className.indexOf("webprint_form_numbersonly") != -1) {
					muze.event.attach(inputs[i], "keypress", webprint.form.numbersonly.execute);
				}
			}
		},
		execute : function(evt) {
			var keyCode = evt.keyCode ? evt.keyCode : evt.which ? evt.which : evt.charCode;
			if (
				keyCode == 8 || 	// backspace
				keyCode == 9 || 	// tab
				keyCode == 46 ||	// keypad del
				(keyCode > 36 && keyCode < 41) // arrow keys
			) {
				return true;
			}
			if (keyCode<48 || keyCode > 57) { // if the key is not a number
				muze.event.cancel(evt);
				return false;
			}
		}
	}
}();

muze.namespace("webprint.banner");
webprint.banner.track = function() {
	return {
		attach : function() {
			links = document.getElementsByTagName("A");
			for (i=0; i<links.length; i++) {
				if (links[i] && links[i].className && links[i].className.indexOf("webprint_banner") != -1) {
					muze.event.attach(links[i], "click", webprint.banner.track.execute);
				}
			}
		},
		execute : function() {
			try {
				pageTracker._trackEvent('Banners', this.getAttribute('name'));
			} catch (e) {
			}
		}
	}
}();


webprint.form.calendar = function() {
	return {
		target : null,
		calendar : null,
		attach: function() {
			inputs = document.getElementsByTagName("INPUT");
			for (i=0; i<inputs.length; i++) {
				if (inputs[i] && inputs[i].className && inputs[i].className.indexOf("webprint_form_calendar") != -1) {
					muze.event.attach(inputs[i], "focus", webprint.form.calendar.execute);
				}
			}
		},
		execute : function() {
			webprint.form.calendar.target = this;
			if (webprint.form.calendar.calendar) {
				if (this.value == "13-02-2012") {
					currentvalue = this.value.split('-');
					currentdate = currentvalue[1] + '/' + currentvalue[0] + '/' + currentvalue[2];
					webprint.form.calendar.calendar.select(currentdate);
				}
				webprint.form.calendar.calendar.show();
			} else {
				tomorrow = new Date();
				tomorrow.setTime(tomorrow.getTime() + (1000*3600*24)); // Add one day to today.

				webprint.form.calendar.calendar = new YAHOO.widget.Calendar("calendar", "senddate_calendar", {mindate:tomorrow});
				
				webprint.form.calendar.calendar.cfg.setProperty("MONTHS_SHORT",   ["Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"]);  
				webprint.form.calendar.calendar.cfg.setProperty("MONTHS_LONG",    ["Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December"]);
				webprint.form.calendar.calendar.cfg.setProperty("WEEKDAYS_1CHAR", ["Z", "M", "D", "W", "D", "V", "Z"]);   
				webprint.form.calendar.calendar.cfg.setProperty("WEEKDAYS_SHORT", ["Zo", "Ma", "Di", "Wo", "Do", "Vr", "Za"]);
				webprint.form.calendar.calendar.cfg.setProperty("WEEKDAYS_MEDIUM",["Zon", "Maa", "Din", "Woe", "Don", "Vri", "Zat"]);   
				webprint.form.calendar.calendar.cfg.setProperty("WEEKDAYS_LONG",  ["Zondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag"]);   

				if (this.value != "dd-mm-jjjj") {
					currentvalue = this.value.split('-');
					currentdate = currentvalue[1] + '/' + currentvalue[0] + '/' + currentvalue[2];
					webprint.form.calendar.calendar.select(currentdate);
					webprint.form.calendar.calendar.cfg.setProperty("pagedate", currentvalue[1] + "/" + currentvalue[2]);
				}

				webprint.form.calendar.calendar.render();
				webprint.form.calendar.calendar.selectEvent.subscribe(webprint.form.calendar.selectEvent, webprint.form.calendar.calendar, true);  
			}
		},
		selectEvent : function() {
			if (webprint.form.calendar.calendar.getSelectedDates().length > 0) {
				var selDate = webprint.form.calendar.calendar.getSelectedDates()[0];

				// Pretty Date Output, using Calendar's Locale values: Friday, 8 February 2008
				var dStr = selDate.getDate();
				dStr = (dStr < 10 ? '0' : '') + dStr;

				var mStr = selDate.getMonth() + 1;
				mStr = (mStr < 10 ? '0' : '') + mStr;

				var yStr = selDate.getFullYear();
				webprint.form.calendar.target.value = dStr + "-" + mStr + "-" + yStr;
			} else {
				webprint.form.calendar.target.value = "";
			}
			webprint.form.calendar.calendar.hide();
		}
	}
}();

muze.namespace("muze.googleanalytics");

muze.googleanalytics.formtracker = function() {
	return {
		trackedform : null,
		attach : function() {
			forms = document.getElementsByTagName("FORM");
			for (i=0; i<forms.length; i++) {
				muze.event.attach(forms[i], "submit", muze.googleanalytics.formtracker.execute);
			}
		},
		execute : function(evt) {
			muze.googleanalytics.formtracker.trackedform = evt.target;
			muze.event.cancel(evt);
			try {
				pageTracker._trackEvent('Form submits', this.getAttribute('action'));
				setTimeout(muze.googleanalytics.formtracker.resubmit, 100);
			} catch(err) {}
		},
		resubmit : function() {
			if (muze.googleanalytics.formtracker.trackedform) {
				muze.googleanalytics.formtracker.trackedform.submit();
			}
		}
	}
}();

muze.namespace("webprint.login");
webprint.login.fillform = function() {
	if (document.getElementById("login") && document.getElementById("login").className && document.getElementById("login").className.indexOf("delayed") != -1) {
		logincontent = muze.load("http://www.webprint.nl/view.loginmenu.html", true, false);
		if (logincontent.length > 100) {
			document.getElementById("login").innerHTML = logincontent;
			webprint.form.clearonfocus.attach();
		}
		document.getElementById("login").className = document.getElementById("login").className.replace(/\bdelayed\b/, '');
	}
}

// muze.event.attach(window, "load", muze.googleanalytics.formtracker.attach);
muze.event.attach(window, "load", webprint.login.fillform);
muze.event.attach(window, "load", webprint.form.autofill_address.attach);
muze.event.attach(window, "load", webprint.form.clearonfocus.attach);
muze.event.attach(window, "load", webprint.form.show_subselection.attach);
muze.event.attach(window, "load", webprint.form.checkout_update_receipt.attach);
muze.event.attach(window, "load", webprint.form.toggle_address.attach);
muze.event.attach(window, "load", webprint.form.toggle_multi_address.attach);
muze.event.attach(window, "load", webprint.form.cancelenter.attach);
muze.event.attach(window, "load", webprint.product.preview.attach);
muze.event.attach(window, "load", webprint.banner.track.attach);
muze.event.attach(window, "load", webprint.form.calendar.attach);
muze.event.attach(window, "load", webprint.form.numbersonly.attach);

muze.event.attach(window, "load", muze.util.pngfix);

muze.event.attach(window, "load", function() { window.onbeforeunload = webprint.editor.onBeforeUnload; } );

