var InputBgSwap = new Class({

	initialize: function() { 
		this.contentPath = $('staticContentPath').value;
		
		var emailBox = $("emailBox");		
		if($chk(emailBox)) {
			emailBox.onfocus = this.swapBg("emailBox").bindAsEventListener(this);
			emailBox.onblur = this.resetBg("emailBox").bindAsEventListener(this);
			if(emailBox.value == "") {
				emailBox.style.backgroundImage = "url(" + this.contentPath + "images/bg/input_email_address.png)";
			}
		}
		
		var passwordBox = $("passwordBox");
		if($chk(passwordBox)) {
			passwordBox.onfocus = this.swapBg("passwordBox").bindAsEventListener(this);
			passwordBox.onblur = this.resetBg("passwordBox").bindAsEventListener(this);
			if(passwordBox.value == "") {
				passwordBox.style.backgroundImage = "url(" + this.contentPath + "images/bg/input_password.png)";
			}
		}
		
		var emailLabel = $("email-label");
		if($chk(emailLabel)) {
			emailLabel.style.display = "none";
		}
		
		var passwordLabel = $("password-label");
		if($chk(passwordLabel)) {
			passwordLabel.style.display = "none";
		}
	},
	
	swapBg: function(id) {
		var me = this;
		return function() {
		
			$(id).style.backgroundImage = "url(" + me.contentPath + "images/bg/input_background.png)";
		}
	},
	
	resetBg: function(id) {
		var me = this;
		return function() {
			
			var elt = $(id);
			if(elt.value == "") {
				var img;
				
				if(id == "emailBox") {
					img = "url(" + me.contentPath + "images/bg/input_email_address.png)";
				}
				else if(id == "passwordBox") {
					img = "url(" + me.contentPath + "images/bg/input_password.png)";
				}
				
				elt.style.backgroundImage = img;
			}
		}	
	}
});

var FlashLoader = new Class({

	initialize: function(languagePath) {
		var flashvars = {
  		webkinzLocaleCookie: languagePath
		};
		
		if($('adunit1')) {
			swfobject.embedSWF('flash/L1_banner.swf', 'adunit1', '728', '90', '9.0.0', '', flashvars);
		}
		if($('adunit2')) {
			swfobject.embedSWF('flash/S1_banner.swf', 'adunit2', '160', '600', '9.0.0', '', flashvars);
		}
		if($('mainpromo')) {
			swfobject.embedSWF('flash/MP1_banner.swf', 'mainpromo', '560', '300', '9.0.0', 'flash/playerProductInstall.swf', flashvars);
		}
		
	}
});

var inputBgSwap;
var flashLoader;
