function setYear(){
	var d_obj = new Date();
	document.write(d_obj.getFullYear());
}

function swf_object(SWF,WID,HEI){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width='+ WID +' height='+ HEI +'>');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="allowFullScreen" value="false" />');
	document.write('<param name="movie" value="swf/'+ SWF +'.swf" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="bgcolor" value="#000000" />');
	document.write('<embed src="./swf/'+ SWF +'.swf" quality="high" bgcolor="#000000" width='+ WID +' height='+ HEI +' name="coverflow" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}


function init() {
	smartRollover();
	photoChange();
	winClose();
	prepareLinks();
	border_none();
	formtext();
	//news_fade();
	
	
	
	
	
	//********* 年末年始ご案内用 ***********
	
	//nenmatsu("12/31、1/1はお休み。1/2は10:00～18:00受付", "1/3はお休み。4日から通常営業となります。", "#ffffff", 100, 12);
	
	//********* 年末年始ご案内用 ***********
	
	
	
	
	
	
	crossfade("newslist",1000,3000);
}
window.onload=init;



//********* 年末年始のご案内 ********************************
var nenmatsu = function(_desc, _desc2, _color, _top, _left) {
	var header = document.getElementById("header");
	header.style.position = "relative";
	
	var annai = document.createElement("p");
	var eigyo = document.createTextNode("-年末年始営業のご案内-");
	var br = document.createElement("br");
	var desc = document.createTextNode(_desc);
	var br2 = document.createElement("br");
	var desc2 = document.createTextNode(_desc2);
	
	annai.appendChild(eigyo);
	annai.appendChild(br);
	annai.appendChild(desc);
	annai.appendChild(br2);
	annai.appendChild(desc2);
	header.appendChild(annai);
	
	annai.style.position = "absolute";
	annai.style.top = _top + "px";
	annai.style.left = _left + "px";
	annai.style.fontSize = 13 + "px";
	annai.style.fontWeight = "bold";
	annai.style.color = _color;
}
//***********************************************************




//ロールオーバーイメージ
function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");

		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_out."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_out.", "_over."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_over.", "_out."));
				}
			}
		}
	}
}

function border_none(){
	var all_link = document.links;
	for(i=0;i<all_link.length;i++){
		all_link[i].onfocus = function(){
			this.blur();
		}
	}
}
function photoChange(){
	if(document.getElementById("image")){
		var base = document.getElementById("image").getElementsByTagName("img")[0];
		base.style.display = "none";

		var imageList = new Array();
		for(i=0;i<3;i++){
			tmpImage = new Image();
			tmpImage.src = "pic0"+(i+1)+".jpg";
			imageList.push(tmpImage);
		}

		if(imageList[0].width > 300){
			base.style.marginTop = "50px";
		}
		base.style.display = "";

		var sumArray = document.getElementsByTagName("img");
		for(i=0;i<sumArray.length;i++){

			if(sumArray[i].className == "ladySum"){
			
				sumArray[i].onmouseover = function(){

					var targetImg = document.getElementById("image").getElementsByTagName("img")[0];
					
					var tmpSrc = this.src.split("thumb0");
					var tmpNumber = tmpSrc[1].split(".");
					var srcNumber = tmpNumber[0]-1;
					
					targetImg.src = imageList[srcNumber].src;
					
					if(imageList[srcNumber].height ==300){
						targetImg.style.marginTop = "50px";
					}else{
						targetImg.style.marginTop = "0";
					}
				}
			}
		}
	}
}
function winClose(){
	if(!document.getElementById("close")){
		return false;
	}
	var btnClose = document.getElementById("close").lastChild;
	btnClose.onclick = function(){
		window.close();
	}
}

function prepareLinks() {
	if(!document.getElementsByTagName){
		return false;
	}
	var links = document.getElementsByTagName("a");
	for (var i=0; i<links.length; i++) {
		if(links[i].getAttribute("className") == "popup" || links[i].getAttribute("class") == "popup") {

			links[i].onclick = function() {
				popUp(this.getAttribute("href"));
				return false;
			}

			links[i].onmouseover = function() {
				this.firstChild.style.filter = "alpha(opacity=80)";
				this.firstChild.style.opacity = "0.8";
				return false;
			}
			links[i].onmouseout = function() {
				this.firstChild.style.filter = "alpha(opacity=100)";
				this.firstChild.style.opacity = "1.0";
				return false;
			}
		}
	}
}
function popUp(winURL) {
	var winFocus;
	winFocus = window.open(winURL,"popup","width=818,height=700,scrollbars=yes");
    winFocus.focus();
}

function formtext(){
	if(!document.getElementById("mailmagazine")){
		return false;
	}
	var mailmaga = document.getElementById("mailmagazine");
	var formclick = document.getElementsByTagName("input");
	for (var i=0; i<formclick.length; i++){
		formclick[i].onfocus =function(){
			if(this.getAttribute("value") == "メールアドレスを入力して下さい。"){
				this.value="";
			}
		}
	}
}

function news_fade(){

	if(!document.getElementById("news")){
		return;
	}
	var ul = document.getElementById("news").getElementsByTagName("ul")[0];

	Ajax = create_Ajax();
	//送信
	Ajax.open("GET","news/xml/news.xml");
	Ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
	Ajax.send(null);
	//受信
	Ajax.onreadystatechange = function(){

		if(Ajax.readyState == 4 && Ajax.status == 200){

			newsXML = Ajax.responseXML;
			
			newsList = newsXML.getElementsByTagName("item");
			new_ul = document.createElement("ul");

			for(i=0;i<newsList.length;i++){
				var time = newsList[i].getElementsByTagName("time")[0].firstChild.nodeValue;
				var desc = newsList[i].getElementsByTagName("desc")[0].firstChild.nodeValue;
				li = document.createElement("li");
				li.innerHTML = time+desc;
				li.style.margin = "0 0 20px 0";
				
				/*li.appendChild(time);
				li.appendChild(desc);*/
				new_ul.appendChild(li);
			}
			document.getElementById("news").replaceChild(new_ul,ul);
		}
	}
}

function create_Ajax(){

	if(window.XMLHttpRequest){
		Ajax = new XMLHttpRequest();
	}else if(window.ActiveXObject){
		try {
			Ajax = new ActiveXObject("Msxm21.XMLHTTP");
		} catch(e) {
			Ajax = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return Ajax;
}





function crossfade(IDname , fadetime , speed){
	if(!document.getElementById(IDname)){
		return;
	}
	var news = document.getElementById(IDname);
	var newslinks = news.getElementsByTagName("li");
	for(var i=0; i<newslinks.length; i++){
		newslinks[i].id = [i];
		newlength = new Array([i]);
	}
	for(var j=0; j<newslinks.length; j++){
		newlength[j]=[j];
	}
	new Crossfader(newlength, fadetime, speed );
}

var useBSNns;

if (useBSNns){
	if (typeof(bsn) == "undefined")
		bsn = {}
	var _bsn = bsn;
}else{
	var _bsn = this;
}

_bsn.Crossfader = function (divs, fadetime, delay ){
	this.nAct = -1;
	this.aDivs = divs;
	
	for (var i=0;i<divs.length;i++){
		document.getElementById(divs[i]).style.opacity = 0;
		document.getElementById(divs[i]).style.position = "absolute";
		document.getElementById(divs[i]).style.filter = "alpha(opacity=0)";
		document.getElementById(divs[i]).style.visibility = "hidden";
	}
	
	this.nDur = fadetime;
	this.nDelay = delay;
	this._newfade();
}

_bsn.Crossfader.prototype._newfade = function(){
	if (this.nID1)
		clearInterval(this.nID1);
	
	this.nOldAct = this.nAct;
	this.nAct++;
	if (!this.aDivs[this.nAct])	this.nAct = 0;
	
	if (this.nAct == this.nOldAct)
		return false;
	
	document.getElementById( this.aDivs[this.nAct] ).style.visibility = "visible";
	
	this.nInt = 50;
	this.nTime = 0;
	
	var p=this;
	this.nID2 = setInterval(function() { p._fade() }, this.nInt);
}

_bsn.Crossfader.prototype._fade = function(){
	this.nTime += this.nInt;
	
	var ieop = Math.round( this._easeInOut(this.nTime, 0, 1, this.nDur) * 100 );
	var op = ieop / 100;
	document.getElementById( this.aDivs[this.nAct] ).style.opacity = op;
	document.getElementById( this.aDivs[this.nAct] ).style.filter = "alpha(opacity="+ieop+")";
	
	if (this.nOldAct > -1){
		document.getElementById( this.aDivs[this.nOldAct] ).style.opacity = 1 - op;
		document.getElementById( this.aDivs[this.nOldAct] ).style.filter = "alpha(opacity="+(100 - ieop)+")";
	}
	
	if (this.nTime == this.nDur){
		clearInterval( this.nID2 );
		
		if (this.nOldAct > -1)
			document.getElementById( this.aDivs[this.nOldAct] ).style.visibility = "hidden";	
		
		var p=this;
		this.nID1 = setInterval(function() { p._newfade() }, this.nDelay);
	}
}

_bsn.Crossfader.prototype._easeInOut = function(t,b,c,d){
	return c/2 * (1 - Math.cos(Math.PI*t/d)) + b;
}



function magazineWin(){
	window.open("","magazine","width=500,height=400,scrollbars=no");
	
	return true;
}