var cyo_configuratorVersion = '_20091022xml_int';

function toggleContainer() {
	$('div#flashConfig').slideUp();
	$('div#flashConfig').removeClass('configOpen').addClass('configClosed');
} 

function createDictionary(qString) {
	var qArray = new Array();
	var nameValues = qString.split('&');
	for (n=0; n<nameValues.length; n++) {
		nameValue = nameValues[n].split('=');
		qArray[ unescape(nameValue[0]) ] = unescape(nameValue[1]);
		qArray[n] = { name:unescape(nameValue[0]), value:unescape(nameValue[1])};
	}
	return qArray;
}

$(document).ready(function() {
	var nstyles = '';
	nstyles += '<style type="text/css">\n';
	nstyles += '#launchConfig {cursor: pointer; } div#flashConfig {background-color: transparent; width: 700px; height: 466px; overflow: visible; position: absolute; z-index: 750;}\n';
	nstyles += '.configOpen {top: 133px; left: 223px;}\n';
	nstyles += '.configClosed {top: -700px; left: 165px;}\n';
	nstyles += '</style>\n';
	$('head').append(nstyles);

	//new
	$('div#mainBox').prepend('<div id="flashConfig"></div>');

	$('div#flashConfig').hide();

	$('#closeConfig').click(function() {
		$('div#flashConfig').slideUp();
		$('div#flashConfig').removeClass('configOpen').addClass('configClosed');
	});
	
	// grab the domain from the page's URL and the productId from the add to cart hidden form fields
	var cyo_fqdn = 'www.disneystore.com';
	var cyo_storeId = '0';
	var cyo_productId = '0';
	try {
		cyo_fqdn = document.location.host;
		cyo_storeId = document.OrderItemAddForm.storeId.value;
		cyo_productId = document.OrderItemAddForm.productId.value;
	} catch(e) { }

	$('#launchConfig').click(function() {
		$('div#flashConfig').slideDown();
		$('div#flashConfig').removeClass('configClosed').addClass('configOpen');

		var so = new SWFObject("http://aimg.disneystore.com/content/misc/configurator/"+cyo_configuratorVersion+"/DSIconfigurator.swf?"+(new Date()).getTime(), "featureSWF", "700", "466", "9");
		so.addParam("flashvars", "crossdomainURL=http://aimg.disneystore.com/crossdomain.xml&xmlURL=http://"+cyo_fqdn+"/disney/store/DSICYOXmlLoader/"+cyo_storeId+"/"+cyo_productId+"/?"+(new Date()).getTime());
		so.addParam("quality", "best");
		so.addParam("wmode", "transparent");
		so.addParam("salign", "t");
		so.addParam("allowScriptAccess", "always");
		so.write("flashConfig");
	});
});

