//default
//backopenvar new1,win1p,win1;

function backopen (img) {

	if (win1p=="on") {
	if (new1.closed) {} else {new1.close();}
	}

	win1p = "on";

new1=  window.open("","newwin",'resizable=1,width=520,height=500');
new1.document.write("<html><body background="+img+">");
new1.document.writeln("</body></html>");
}

var new2,win2p,win2;

function backopen2 (img) {

	if (win2p=="on") {
	if (new2.closed) {} else {new2.close();}
	}

	win1p = "on";

new2=  window.open("","newwin",'resizable=1,width=800,height=600');
new2.document.write("<html><body background="+img+">");
new2.document.writeln("</body></html>");
}

var new3,win3p,win3;

function backopen3 (img) {

	if (win3p=="on") {
	if (new3.closed) {} else {new3.close();}
	}

	win1p = "on";

new3=  window.open("","newwin",'resizable=1,width=1000,height=500');
	   new3.moveTo(0,0);
new3.document.write("<html><body background="+img+">");
new3.document.writeln("</body></html>");
}

var new4,win4p,win4,h0,w0;

function backopen4 (img) {

	if (win4p=="on") {
	if (new4.closed) {} else {new4.close();}
	}

	win1p = "on";

	h0=screen.height;
	if(h0>900){h0=900;}
	w0=600*(h0/900);
new4=window.open("","newwin",'resizable=1,width='+(w0*0.9)+',height='+(h0*0.9));
new4.document.write("<html><body>");
new4.document.write("<img src="+img+" height="+(h0*0.85)+">");
new4.document.writeln("</body></html>");
}

var new5,win5p,win5;

function backopen5 (img) {

	if (win5p=="on") {
	if (new5.closed) {} else {new5.close();}
	}

	win1p = "on";

new5=  window.open("","newwin",'resizable=1,width=1000,height=500');
new5.document.write("<html><body background="+img+">");
new5.document.writeln("</body></html>");
}
var new6,win6p,win6;

function backopen6 (img) {

	if (win6p=="on") {
	if (new6.closed) {} else {new6.close();}
	}

	win1p = "on";

new6=  window.open("","newwin",'resizable=1,width=350,height=600');
new6.document.write("<html><body background="+img+">");
new6.document.writeln("</body></html>");
}
//pop
function popit(url) {
	var largerflik = window.open(url, "_popups", "toolbar=yes,status=yes,location=yes,menubar=yes,height=460,width=410,scrollbars=yes,resizable=no");
        largerflik.focus();
        }

function pop0(url) {
	var largerflik = window.open(url, "_popups", "toolbar=no,status=no,location=no,menubar=no,height=630,width=580,scrollbars=no,resizable=no");
        largerflik.focus();
        }

function pop2(url) {
	var largerflik = window.open(url, "_popups", "toolbar=no,status=no,location=no,menubar=no,height=630,width=780,scrollbars=yes,resizable=no");
        largerflik.focus();
        }

function pop3(url) {
	var largerflik = window.open(url, "_popups", "toolbar=no,status=no,location=no,menubar=no,height=380,width=230,scrollbars=no,resizable=no");
	largerflik.focus();
	largerflik.moveTo(0,0);
        }


function pop4(url,a,b) {
	win = window.open(url, "_popups", "toolbar=no,status=no,location=no,menubar=no,height=385,width=230,scrollbars=no,resizable=no");
	win.moveTo(a,b);
        }
//version
function getBrowserVersion()
  {
  str = navigator.appName.toUpperCase();
  version = 0;
  appVer = navigator.appVersion;
  if (str.indexOf("NETSCAPE") >= 0)
  {
  s = appVer.indexOf(" ",0);
  version = eval(appVer.substring(0,s));
  if (version >= 5) version++;
  }
  if (str.indexOf("MICROSOFT") >= 0)
  {
  appVer = navigator.userAgent;
  s = appVer.indexOf("MSIE ",0) + 5;
  e = appVer.indexOf(";",s);
  version = eval(appVer.substring(s,e));
  }
  return version;
}
function anim(){
	v=getBrowserVersion();
	if(v>6){str="anim_00";}else{str="anim_01";}
	this[str]();
}
//anim
  var imageSet0=1;
  alt=new Array();
  link=new Array();
  alt=["振袖ページへ","色留袖ページへ","夏物ページへ","ゆかたページへ"];
  link=["./item/furisode/index.html","./item/original/index.html","./item/natsu/index.html","./item/yukata/index.html"];
function setText(string){
  document.getElementById("linkarea").innerHTML=string;
}
function anim_00(){
  image0.filters.item("DxImageTransForm.Microsoft.Fade").Apply();
  image0.filters.item("DxImageTransForm.Microsoft.Fade").Enabled=true;
  image0.filters.item("DxImageTransForm.Microsoft.Fade").overlap=0.5;
  document.animation.src="./common/img/top/"+imageSet0+".png";
  document.animation.alt=alt[imageSet0];
  document.links[9].href=link[imageSet0];
  setText("▲&nbsp;画像をクリックすると "+alt[imageSet0]+"&nbsp;▲");
  image0.filters.item("DxImageTransForm.Microsoft.Fade").play();
  imageSet0++;
  if(imageSet0>3){
  imageSet0=0;
  }
  }
function anim_01(){
  document.animation.src="./common/img/top/"+imageSet0+".png";
  document.animation.alt=alt[imageSet0];
  document.links[9].href=link[imageSet0];
  setText("▲&nbsp;画像をクリックすると "+alt[imageSet0]+"&nbsp;▲");
  imageSet0++;
  if(imageSet0>3){
  imageSet0=0;
  }
  }
//switch
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
