window.onload = function(){
	startUp();
}

window.onresize = function(event){
	setLayout();
}

function goOuter(mode) {
	new Effect.Opacity($('menubutton'), { to: 0.0, duration: 0.0 });
	$('main-topmenu').morph('margin-left: -220px;', {delay: 0.0, duration : 1.0});
	$('top-images').morph('margin-left: 0px;', {delay: 0.0, duration : 1.0});
	$('main').morph('height: 10px; margin-top: -5px', {delay: 1.0, duration : 1.0});
	$('main').morph('height: 0px; width: 0%; margin-top: 0px; margin-left: 0%;', {delay: 2.0, duration : 1.0});
	closeLayers();
	if(mode == 'rakuten') {
		setTimeout(function(){location.href = 'http://www.rakuten.co.jp/luggagetrade/';}, 3000);
	} else if(mode == 'quadro7717blackblack') {
		setTimeout(function(){location.href = 'https://www.shopmaker.jp/pro/order.cgi?user=sh045123&number=7717-01';}, 3000);
	} else if(mode == 'quadro7717blackdarkbrown') {
		setTimeout(function(){location.href = 'https://www.shopmaker.jp/pro/order.cgi?user=sh045123&number=7717-10';}, 3000);
	} else if(mode == 'quadro7717darkbrownblack') {
		setTimeout(function(){location.href = 'https://www.shopmaker.jp/pro/order.cgi?user=sh045123&number=7717-21';}, 3000);
	} else if(mode == 'quadro7718blackblack') {
		setTimeout(function(){location.href = 'https://www.shopmaker.jp/pro/order.cgi?user=sh045123&number=7718-01';}, 3000);
	} else if(mode == 'quadro7718blackdarkbrown') {
		setTimeout(function(){location.href = 'https://www.shopmaker.jp/pro/order.cgi?user=sh045123&number=7718-10';}, 3000);
	} else if(mode == 'quadro7718darkbrownblack') {
		setTimeout(function(){location.href = 'https://www.shopmaker.jp/pro/order.cgi?user=sh045123&number=7718-21';}, 3000);
	} else if(mode == 'rnd7491black') {
		setTimeout(function(){location.href = 'https://www.shopmaker.jp/pro/order.cgi?user=sh045123&number=7491-01';}, 3000);
	} else if(mode == 'rnd7491brown') {
		setTimeout(function(){location.href = 'https://www.shopmaker.jp/pro/order.cgi?user=sh045123&number=7491-03';}, 3000);
	} else if(mode == 'rnd7491beige') {
		setTimeout(function(){location.href = 'https://www.shopmaker.jp/pro/order.cgi?user=sh045123&number=7491-04';}, 3000);
	} else if(mode == 'rnd7492black') {
		setTimeout(function(){location.href = 'https://www.shopmaker.jp/pro/order.cgi?user=sh045123&number=7492-01';}, 3000);
	} else if(mode == 'rnd7492brown') {
		setTimeout(function(){location.href = 'https://www.shopmaker.jp/pro/order.cgi?user=sh045123&number=7492-03';}, 3000);
	} else if(mode == 'rnd7492beige') {
		setTimeout(function(){location.href = 'https://www.shopmaker.jp/pro/order.cgi?user=sh045123&number=7492-04';}, 3000);
	} else if(mode == 'rnd7493black') {
		setTimeout(function(){location.href = 'https://www.shopmaker.jp/pro/order.cgi?user=sh045123&number=7493-01';}, 3000);
	} else if(mode == 'rnd7493navy') {
		setTimeout(function(){location.href = 'https://www.shopmaker.jp/pro/order.cgi?user=sh045123&number=7493-06';}, 3000);
	} else if(mode == 'rnd7494black') {
		setTimeout(function(){location.href = 'https://www.shopmaker.jp/pro/order.cgi?user=sh045123&number=7494-01';}, 3000);
	} else if(mode == 'rnd7494navy') {
		setTimeout(function(){location.href = 'https://www.shopmaker.jp/pro/order.cgi?user=sh045123&number=7494-06';}, 3000);
	} else if(mode == 'rnd7498black') {
		setTimeout(function(){location.href = 'https://www.shopmaker.jp/pro/order.cgi?user=sh045123&number=7498-01';}, 3000);
	} else if(mode == 'rnd7498brown') {
		setTimeout(function(){location.href = 'https://www.shopmaker.jp/pro/order.cgi?user=sh045123&number=7498-03';}, 3000);
	} else if(mode == 'rnd7499black') {
		setTimeout(function(){location.href = 'https://www.shopmaker.jp/pro/order.cgi?user=sh045123&number=7499-01';}, 3000);
	} else if(mode == 'rnd7499brown') {
		setTimeout(function(){location.href = 'https://www.shopmaker.jp/pro/order.cgi?user=sh045123&number=7499-03';}, 3000);
	} else if(mode == 'pdf') {
		setTimeout(function(){location.href = '/catalogue.pdf';}, 3000);
	} else if(mode == 'torin') {
		setTimeout(function(){location.href = 'http://www.torin-bag.com/';}, 3000);
	} else if(mode == 'carryingcase') {
		setTimeout(function(){location.href = 'http://www.carryingcase.net/';}, 3000);
	} else if(mode == 'edit') {
		setTimeout(function(){location.href = 'http://www.lagasha-style.com/list_items.cgi?cat_pkg=lagsty-edit';}, 3000);
	} else if(mode == 'wave') {
		setTimeout(function(){location.href = 'http://www.lagasha-style.com/list_items.cgi?cat_pkg=lagsty-wave';}, 3000);
	} else if(mode == 'laboratory') {
		setTimeout(function(){location.href = 'http://www.lagasha-style.com/list_items.cgi?cat_pkg=lagsty-labora';}, 3000);
	} else if(mode == 'pod') {
		setTimeout(function(){location.href = 'http://www.lagasha-style.com/list_items.cgi?cat_pkg=lagsty-pod';}, 3000);
	} else if(mode == 'gadget2' || mode == 'gadget2p2') {
		setTimeout(function(){location.href = 'http://www.lagasha-style.com/list_items.cgi?cat_pkg=lagsty-gadget2';}, 3000);
	} else if(mode == 'york') {
		setTimeout(function(){location.href = 'http://www.lagasha-style.com/list_items.cgi?cat_pkg=lagsty-york';}, 3000);
	} else if(mode == 'revise') {
		setTimeout(function(){location.href = 'http://www.lagasha-style.com/list_items.cgi?cat_pkg=lagsty-revise';}, 3000);
	} else if(mode == 'zeal') {
		setTimeout(function(){location.href = 'http://www.lagasha-style.com/list_items.cgi?cat_pkg=lagsty-zeal';}, 3000);
	} else if(mode == 'travelmaster') {
		setTimeout(function(){location.href = 'http://www.lagasha-style.com/list_items.cgi?cat_pkg=lagsty-tabi';}, 3000);
	} else if(mode == 'clip') {
		setTimeout(function(){location.href = 'http://www.lagasha-style.com/list_items.cgi?cat_pkg=lagsty-clip';}, 3000);
	} else if(mode == 'tact') {
		setTimeout(function(){location.href = 'http://www.lagasha-style.com/list_items.cgi?cat_pkg=lagsty-tact';}, 3000);
	} else if(mode == 'annex') {
		setTimeout(function(){location.href = 'http://www.lagasha-style.com/list_items.cgi?cat_pkg=lagsty-annex';}, 3000);
	} else if(mode == 'ccollabo9332') {
		setTimeout(function(){location.href = 'http://www.carryingcase.net/group_detail.cgi?group_id=ccn-lg9332';}, 3000);
	} else if(mode == 'ccollabo9301') {
		setTimeout(function(){location.href = 'http://www.carryingcase.net/group_detail.cgi?group_id=ccn-lg9301';}, 3000);
	} else if(mode == 'ccollabo9303') {
		setTimeout(function(){location.href = 'http://www.carryingcase.net/group_detail.cgi?group_id=ccn-lg9303';}, 3000);
	} else if(mode == 'ccollabo9306') {
		setTimeout(function(){location.href = 'http://www.carryingcase.net/group_detail.cgi?group_id=ccn-lg9306';}, 3000);
	} else if(mode == 'ccollabo9310') {
		setTimeout(function(){location.href = 'http://www.carryingcase.net/group_detail.cgi?group_id=ccn-lg9310';}, 3000);
	} else if(mode == 'ccollabo9316') {
		setTimeout(function(){location.href = 'http://www.carryingcase.net/group_detail.cgi?group_id=ccn-lg9316';}, 3000);
	} else if(mode == 'ccollabo9317') {
		setTimeout(function(){location.href = 'http://www.carryingcase.net/group_detail.cgi?group_id=ccn-lg9317';}, 3000);
	} else if(mode == 'ccollabo9318') {
		setTimeout(function(){location.href = 'http://www.carryingcase.net/group_detail.cgi?group_id=ccn-lg9318';}, 3000);
	} else if(mode == 'ccollabo9319') {
		setTimeout(function(){location.href = 'http://www.carryingcase.net/group_detail.cgi?group_id=ccn-lg9319';}, 3000);
	} else if(mode == 'ccollabo9323') {
		setTimeout(function(){location.href = 'http://www.carryingcase.net/group_detail.cgi?group_id=ccn-lg9323';}, 3000);
	} else if(mode == 'ccollabo9324') {
		setTimeout(function(){location.href = 'http://www.carryingcase.net/group_detail.cgi?group_id=ccn-lg9324';}, 3000);
	} else if(mode == 'ccollabo9325' || mode == 'ccollabo9326' || mode == 'ccollabo9327') {
		setTimeout(function(){location.href = 'http://www.carryingcase.net/group_detail.cgi?group_id=ccn-lggncm';}, 3000);
	} else if(mode == 'ccollabo9328') {
		setTimeout(function(){location.href = 'http://www.carryingcase.net/group_detail.cgi?group_id=ccn-lg9328';}, 3000);
	} else if(mode == 'ccollabo9330') {
		setTimeout(function(){location.href = 'http://www.carryingcase.net/group_detail.cgi?group_id=ccn-lg9329';}, 3000);
	}
}

function setLayout() {
	if($('menubutton').getAttribute('status') == '0') {
		var x = parseInt(getMainX()+20);
		var y = parseInt(getMainY()+25);
		$('menubutton').morph('margin-top:'+y+'px; margin-left:'+x+'px;', {delay: 0.0, duration : 0.1});
	} else {
		var x = parseInt(getMainX()-25);
		var y = parseInt(getMainY()+25);
		$('menubutton').morph('margin-top:'+y+'px; margin-left:'+x+'px;', {delay: 0.0, duration : 0.1});
	}
}

function closeMenu() {
	$('main-topmenu').morph('margin-left: -220px;', {delay: 0.0, duration : 1.0});
	new Effect.Opacity($('top-images'), { to: 0.0, duration: 1.0 });
//	$('top-images').morph('margin-left: 0px;', {delay: 0.0, duration : 1.0});
	var x = parseInt(getMainX()-25);
	$('menubutton').morph('margin-left: '+x+'px;', {delay: 0.7, duration : 0.3});
	$('menubutton').setAttribute('status', '1');
	$('main-topmenu').setAttribute('lock', 1);
}

function openMenu() {
	if($('main-topmenu').getAttribute('lock') == 1) {
		var y = parseInt(getMainX()+20);
		$('menubutton').morph('margin-left: '+y+'px;', {delay: 0.3, duration : 0.3});
		$('menubutton').setAttribute('status', '0');
		$('main-topmenu').morph('margin-left: 0px;', {delay: 0.3, duration : 1.0});
		new Effect.Opacity($('top-images'), { to: 1.0, duration: 1.0 });
//		$('top-images').morph('margin-left: -600px;', {delay: 0.3, duration : 1.0});
		closeLayers();
	}
}

function closeLayers() {
	$('main').setAttribute('openlayer', '');
	$('allserieslayer').morph('margin-left: -1020px;', {delay: 0.0, duration : 1.0});
	$('allserieslayer').setAttribute('x', -1020);
	seriesOpacity();
	$('allseriescontroller').morph('margin-left: -100px;', {delay: 0.0, duration : 1.0});
	$('seriesimglayer').morph('margin-left: -200px;', {delay: 0.0, duration : 1.0});
	new Effect.Opacity($('seriesimglayer'), { delay: 0.0, to: 0.0, duration: 1.0 });
	$('closeseriesdetail').morph('margin-left: -200px;', {delay: 1.0, duration : 0.5});
	$('allcollabolayer').morph('margin-left: -1020px;', {delay: 0.0, duration : 1.0});
	$('allcollabolayer').setAttribute('x', -1020);
	collabosOpacity();
	$('collabosimglayer').morph('margin-left: -200px;', {delay: 0.0, duration : 1.0});
	new Effect.Opacity($('collabosimglayer'), { delay: 0.0, to: 0.0, duration: 1.0 });
	$('closecollabosdetail').morph('margin-left: -200px;', {delay: 1.0, duration : 0.5});
	$('prodslayer').morph('margin-left: -850px;', {delay: 0.0, duration : 1.0});
	$('seriesselecter').morph('margin-top: -490px;', {delay: 0.0, duration: 0.5});
	$('collabosselecter').morph('margin-top: -490px;', {delay: 0.0, duration: 0.5});
	$('medialayer').morph('margin-left: -580px;', {delay: 0.0, duration : 1.0});
	$('shoplayer').morph('margin-left: -680px;', {delay: 0.0, duration : 1.0});
	setTimeout(function(){
		$('seriesimg').getElementsByTagName('img')[0].setAttribute('src', '/img/dummy.gif');
		$('typetitle').morph('margin-left: -300px;', {delay: 0.1, duration: 0.0});
		$('arrowleft').morph('margin-left: -20px;', {delay: 0.1, duration: 0.0});
		$('arrowright').morph('margin-left: -20px;', {delay: 0.1, duration: 0.0});
		$('typeinfo').morph('margin-left: -300px;', {delay: 0.1, duration: 0.0});
		for(var i = 0; i < $('prodslayer').getElementsByClassName("color").length; i++) {
			$('color'+(i+1)).morph('margin-left: -60px;', {delay: 0.1, duration: 0.0});
		}
		$('collabosimg').getElementsByTagName('img')[0].setAttribute('src', '/img/dummy.gif');
		setShopInfoLayer('');
	}, 1000);
}
