// Legal Footer for Core Template
// by Eric Shepherd
// October 2005

// Requires /pages/v4/script/dhtml_lib.js

legalFooterHelper = {
	
	exitSite : function(from, destination, windowName, options, goesto, pid, sSite) {
		while (destination.indexOf('+') != -1)
			destination = destination.replace('+', 'FPSMBplusFPSMB');
	
		if (destination.indexOf("golink.asp") != -1)
			newWindow = window.open(destination + '&FPFrom=' + from, windowName, options);
		else
			newWindow = window.open('/' + sSite + '/leaving.asp?FPDest=' + escape(destination) + '&FPFrom=' + escape(from) + '&goto=' + escape(goesto) + '&pid=' + pid, windowName, options);
	},
	
	openCs : function(e) {
		var theHref = document.getElementById('customer_service').href;
		thisSite = theHref.match(/(\w{1,})(?=\/default)/g)[0];
		legalFooterHelper.exitSite('/'+thisSite+'/default.asp?', theHref, 'MATTELCR', 'left=5,top=10,screenX=100,screenY=100,resizable=yes,location=yes,scrollbars=yes,toolbar=yes,menubar=yes,width=790,height=470', 'Customer Service', '-1', thisSite);
		EventHelper.CancelDefault(e);
	},
	
	openHelp : function(e) {
		sUrl = this.href;
		window.open(sUrl, 'fphelp', 'left=5,top=10,screenX=100,screenY=100,resizable=yes,location=yes,scrollbars=yes,toolbar=yes,menubar=yes,width=790,height=470');
		EventHelper.CancelDefault(e);
	},
	
	openEmail : function(e) {
		var sUrl = this.href;
		window.open(sUrl, 'emailWindow', 'left=150,top=50,screenX=200,screenY=100,resizable=yes,scrollbars=yes,toolbar=no,width=500,height=560');
		EventHelper.CancelDefault(e);
	},
	
	init : function() {
		if (!document.getElementById) return;
		
		var customerService = document.getElementById('customer_service');
		var fpHelp = document.getElementById('fp_help');
		var emailFriend = document.getElementById('email_friend');

		if (customerService != null) EventHelper.AddEvent(customerService, 'click', legalFooterHelper.openCs, false);
		if (fpHelp != null) EventHelper.AddEvent(fpHelp, 'click', legalFooterHelper.openHelp, false);
		if (emailFriend != null) EventHelper.AddEvent(emailFriend, 'click', legalFooterHelper.openEmail, false);
	}
};

EventHelper.AddEvent(window, 'load', legalFooterHelper.init, false);