// -------------------- setJS -------------------- //

var setjs = {
	setVol : function(v, e){
		$.cookie("gafas_vol", v, { expires:365, path:'/' });
		$.cookie("gafas_equ", e, { expires:365, path:'/' });
	},
	setWindow : function(u){
		var p = "width=850,height=700,menubar=yes,toolbar=no,location=yes,status=yes,resizable=yes,scrollbars=yes";
		var w = window.open(u, "external", p);
		w.focus();
	},
	setPage : function(p){
		var query = "#/";
		var page = (p == "home")? query : query+p;
		var url = location.href.split(query)[0] + page;
		if(location.href != url) location.href = url;
		setjs.setTitle();
	},
	setTitle : function(){
		var p = location.href.split("#/")[1];
		var tit = "";
		if(p == "theme") tit = "Theme | ";
		else if(p == "concept") tit = "G.B.Gafas Concept | ";
		else if(p == "store") tit = "Stores Location | ";
		document.title = tit + "G.B. Gafas";
		setjs.swf = (p)? p : "intro";
	}
}
setjs.setTitle();


// -------------------- resizeWin -------------------- //

var resizewin = {
	setInit : function(){
		resizewin.setSize();
		$(window).resize(function(){
			resizewin.setSize();
		});
	},
	setSize : function(){
		var w = ($(window).width() < 950)? "950px" : "100%";
		var h = ($(window).height() < 660)? "660px" : "100%";
		$("#flash_index").css("width", w).css("height", h);
	}
}


// -------------------- Flash -------------------- //

// アンカー取り出し
var now = parseInt(location.search.substring(2));
if(!now) now = 1; 

var setflash = {
	setInit : function(){
//		var v = $.cookie("gafas_vol");
//		var e = $.cookie("gafas_equ");
//		v = (v)? v : 50;
//		e = (e)? e : 1;
		var v = 50;
		var e = 1;

		var p = setjs.swf;

		var url = "/gafas/swf/index.swf";
		var id = "swf_index";
		var w = "100%";
		var h = "100%";
		var version = "8";
		var express = "";
		var flashvars = {
			id: now,
			qv: v,
			qe: e,
			qp: p
		};
		var attributes = {};
		var params = {
			quality: "high",
			menu: "false",
			wmode: "opaque",
			allowScriptAccess: "always"
		};
		swfobject.embedSWF(url, id, w, h, version, express, flashvars, params, attributes);
	}
}


// -------------------- START -------------------- //

$(document).ready(function(){
	// resizeWin
	resizewin.setInit();

	// Flash
	setflash.setInit();
});


