////////////////////////////////////////////////////////////////////////////////////////////////////

function bindMethod(obj, method) {
	return function() { return method.apply(obj, arguments); }
}

if(!Object.extend) {
	Object.extend = function(destination, source) {
		for (var property in source) {
			destination[property] = source[property];
		}
		return destination;
	};
};
var OptIn = {
	run : function(vars) {
		if(this.validate()) this.save(vars);
		else return false;
	},

	save : function(vars) {
		new Ajax.Request('/includes/ajaxOptin.php', {
			parameters : vars,
			onSuccess : this.handler,
			onFailure : this.error
		});
	},

	validate : function() {
		var error = '';
		if(!checkEmail($('lbEmail'))) error += "Please supply a valid email address.\n";
		if($('lbZip').value == "") error += "Please supply a zip code.\n";
		if($('lbCountry').value == "") error += "Please fill out the country field.";

		if(error != "") alert(error);
		else return true;
	},

	handler : function(t) {
		result = t.responseText
		$('lbFormContent').innerHTML = '<div style="text-align:center; font-weight:normal; padding-top:50px;">Thank You.  Your email address has been added to our mailing list.</div>';
	},

	error : function() {

	}
};

var $DKNYOPTIN = bindMethod(OptIn, OptIn.run);

function checkEmail(obj) {
	var str=obj.value;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(str)) {
		return true;
	} else {
		return false;
	}
}

var openedFaq = "";
function openFaq(id) {
	if(id != openedFaq) {
		if(openedFaq) {
			document.getElementById(openedFaq).style.display = "none";
		}
		document.getElementById(id).style.display = "block";
		openedFaq = id;
	} else {
		document.getElementById(id).style.display = "none";
		openedFaq = "";
	}
}

function closeAllFaqs() {
	document.getElementById(openedFaq).style.display = "none";
	openedFaq = "";
}
var openCampaign = function() {
	mywindow = window.open("http://s7d3.scene7.com/s7ondemand/brochure/flash_brochure.jsp?company=eFashion&sku=DKNY_Spring&config=DKNY_Spring&zoomwidth=630&zoomheight=530&ww=640&wh=615","cozy","scrollbars=no");
	return false;
}
var openCampaign2 = function() {
	mywindow = window.open("http://s7d3.scene7.com/s7ondemand/brochure/flash_brochure.jsp?company=eFashion&sku=fall_2007&config=fall_2007&zoomwidth=940&zoomheight=460&ww=942&wh=502","cozy","scrollbars=no");
	return false;
}
var openDonnaInspiration = function() {
	mywindow = window.open("/video.php","fallshow","scrollbars=no,width=320,height=280");
	return false;
}
var openDonnaInspirationFall08 = function() {
	mywindow = window.open("/DKvideo.php","fallshow","scrollbars=no,width=320,height=280");
	return false;
}

var openFall08 = function() {
	mywindow = window.open("/runwayshow_fall08.php","fallshow","scrollbars=no,width=320,height=280");
	return false;
}

var open12WaystoWearCozy = function() {
	mywindow = window.open("http://s7d3.scene7.com/s7ondemand/brochure/flash_brochure.jsp?company=eFashion&sku=DKNY_cozy&config=DKNY_cozy&zoomwidth=630&zoomheight=510&ww=636&wh=550","cozy","scrollbars=no");
	return false;
}
var openRunwayShow = function() {
	mywindow = window.open("/runwayshow.php","RunwayShow","scrollbars=no,width=320,height=270");
	return false;
}
var openFallShow = function() {
	mywindow = window.open("/fallshow.php","fallshow","scrollbars=no,width=320,height=270");
	return false;
}
var openFallShow2 = function() {
	mywindow = window.open("/fallshow2.php","fallshow","scrollbars=no,width=320,height=270");
	return false;
}
var openSpring08 = function() {
	mywindow = window.open("/spring08.php","fallshow","scrollbars=no,width=320,height=270");
	return false;
}

var openFall08 = function() {
	mywindow = window.open("/fall_08.php","fallshow","scrollbars=no,width=320,height=280");
	return false;
}
var openSpring08Flash = function() {
	mywindow = window.open("/spring08.php","fallshow","scrollbars=no,width=320,height=270");
}
var cspopup = function(show) {
	window.open("/cartpopup.php?show="+show,"cartpopup","toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=no,width=450,height=400");
}
var openMailerFlipbook = function() {
	mywindow = window.open("http://s7d3.scene7.com/s7ondemand/brochure/flash_brochure.jsp?company=eFashion&sku=runway08mailer&config=runway08mailer&zoomwidth=630&zoomheight=635&ww=640&wh=635","cozy","scrollbars=no");
	return false;
}

var openSpringMailerFlipbook = function() {
	mywindow = window.open("http://s7d3.scene7.com/s7ondemand/brochure/flash_brochure.jsp?company=eFashion&sku=spring%20mailer%202008&config=spring%20mailer%202008&zoomwidth=630&zoomheight=635&ww=583&wh=550","cozy","status=0,scrollbars=0,resizable=0,width=583,height=526");
	return false;
}

var openSummerMailerFlipbook = function() {
	mywindow = window.open("http://s7d3.scene7.com/s7ondemand/brochure/flash_brochure.jsp?company=eFashion&sku=DKNY%20summer%20mailer&config=DKNY%20summer%20mailer&zoomwidth=630&zoomheight=635&ww=583&wh=550","cozy","status=0,scrollbars=0,resizable=0,width=583,height=526");
	return false;
}
var open2008_fall_runway_mailer = function() {
	mywindow = window.open("http://s7d3.scene7.com/s7ondemand/brochure/flash_brochure.jsp?company=eFashion&sku=fallo8%20runwaymailer&config=fallo8%20runwaymailer&zoomwidth=630&zoomheight=635&ww=583&wh=550","cozy","status=0,scrollbars=0,resizable=0,width=583,height=526");
	return false;
}

var openFallConsumerMailer08 = function() {
	mywindow = window.open("http://s7d3.scene7.com/s7ondemand/brochure/flash_brochure.jsp?company=eFashion&sku=Fall%20Consumer%20Mailer08&config=Fall%20Consumer%20Mailer08&zoomwidth=630&zoomheight=635&ww=583&wh=550","cozy","status=0,scrollbars=0,resizable=0,width=683,height=525");
	return false;
}
	
var openResortMailer08 = function() {
	mywindow = window.open("http://s7d3.scene7.com/s7ondemand/brochure/flash_brochure.jsp?company=eFashion&sku=HolidayResort08&config=HolidayResort08&zoomwidth=630&zoomheight=635&ww=583&wh=550","cozy","status=0,scrollbars=0,resizable=0,width=683,height=525");
	return false;
}


////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Change currency prefs via ajax call for checkout
//
////////////////////////////////////////////////////////////////////////////////////////////////////

function set_currency(symbol)
{
	vars = "&ajax=1&symbol="+symbol;
	new Ajax.Request('/e4x.php', {parameters:vars,
	method:'post',
	onSuccess : handlerFunc,
	onFailure : errFunc});
	return false;
}

var handlerFunc = function(t)
{
	result = t.responseText
	redirect = $('e4x_redirect');
	if(redirect.value != "") {
		window.location = redirect.value;
	} else {
		$('currency_change').submit();
	}
}

var errFunc = function(t)
{
	alert('We have encountered a problem while trying to update your currency options.\n\nPlease try again in a few moments.');
}

////////////////////////////////////////////////////////////////////////////////////////////////////
