
//名豊興運株式会社

window.addEvent('domready', function(){
	var head = $("header-wrapper");
	new mooFixed(head,{onload:true});
	
	var analogimg = '<img src="images/analog.png" />';
	if(Browser.Engine.trident && Browser.Engine.version < 5){
		new Element("a",{
			"href":"http://www.microsoft.com/japan/windows/products/winfamily/ie/function/default.mspx",
			"title":"Internet Explorer8のダウンロードサイトへ",
			"target":"_blank",
			"styles":{
				"position":"absolute",
				"right":"5px",
				"top":"5px",
				"color":"#8f929c",
				"padding":"5px",
				"font-size":"10px"
			},
			events:{
				"mouseover":function(){
					this.setStyles({ "background-color":"#52C3FD","color":"#fff"});
					this.set("html","当サイトはIE7以上を推奨しています。今すぐデジタル環境へアップグレード");
				},
				"mouseout":function(){
					this.setStyles({"background-color":"transparent","color":"#8f929c"});
					this.set("html",analogimg);
				}
			},
			html:analogimg
		}).inject(head);
	}
});

/**
 * mooFixed
 * @author Tenderfeel
 * @ver 1.2
 * @HOME http://tenderfeel.xsrv.jp/
 * 
 * @Need:mootools 1.2
 * 
 * ---MIT License--------------------------------------------
 * Copyright (c) 2008 Tenderfeel all rights reserved.
 * 以下に定める条件に従い、本ソフトウェアおよび関連文書の
 * ファイル（以下「ソフトウェア」）の複製を取得するすべての
 * 人に対し、ソフトウェアを無制限に扱うことを無償で許可します。
 * これには、ソフトウェアの複製を使用、複写、変更、結合、
 * 掲載、頒布、サブライセンス、および/または販売する権利、
 * およびソフトウェアを提供する相手に同じことを許可する権利も無制限に含まれます。
 * 
 * 上記の著作権表示および本許諾表示を、
 * ソフトウェアのすべての複製または重要な部分に記載するものとします。
 * 
 * ソフトウェアは「現状のまま」で、明示であるか暗黙であるかを問わず、
 * 何らの保証もなく提供されます。ここでいう保証とは、商品性、
 * 特定の目的への適合性、および権利非侵害についての保証も含みますが、
 * それに限定されるものではありません。作者または著作権者は、
 * 契約行為、不法行為、またはそれ以外であろうと、
 * ソフトウェアに起因または関連し、あるいはソフトウェアの使用
 * またはその他の扱いによって生じる一切の請求、損害、
 * その他の義務について何らの責任も負わないものとします。 
 * ----------------------------------------------------------
 */
var mooFixed = new Class({
	
	Implements: [Options],

	options: {
		onload : false,
		bottomFix : false,
		marginAuto: false
	},
	initialize: function(element,options) {
		this.setOptions(options);
		if(element==null){
			return false;
		}else{
			this.element = element;
			this.elpos = null;
			this.parent = this.element.getParent();
			this.win = null;
			this.eStyle = null;
			this.scrollsize = null;
			this.flag = false;
			this.getElPosition();
			this.IeLeft = 0;
			this.IeTop = this.elpos.top;
			if(this.options.onload == true){
				this.getScrollsize();
				this.createDiv();
				this.fix();
			}
			window.addEvents({
				"scroll":function(){
					this.getScrollsize();
					this.createDiv();
					this.IeLeft += this.scrollsize.x;
					this.IeTop = (this.elpos.top + this.scrollsize.y);
					this.fix();
				}.bind(this),
				"resize":function(){
					this.IeLeft = (window.getSize().x/2-this.elpos.width/2).toInt();
					this.fix();
				}.bind(this)
			});
		}
	},
	fix:function(){
		if(this.options.bottomFix==true) this.setElStylesBtm();
		else this.setElStyles();
	},
	getElPosition: function() {
		this.elpos = this.element.getCoordinates();
		this.win = window.getSize();
		this.eStyle = this.element.getStyles("margin","padding","height","width");
		this.elpos.width = (this.elpos.width == this.win.x) ? "100%":this.elpos.width;
	},
	getScrollsize:function(){
		this.scrollsize = window.getScroll();
	},
	createDiv:function(){
		if(this.flag==false){
			new Element("div",{"class":"fixedSpacer",styles:{"margin":this.eStyle.margin,"padding":this.eStyle.padding,"height":this.eStyle.height,"width":this.eStyle.width}}).inject(this.element,"after");
			this.flag = true;
		}
	},
	setElStylesBtm:function(){
		if(Browser.Engine.trident && Browser.Engine.version < 5){
			var top = (this.win.y-this.elpos.height) + this.scrollsize.y;
			this.IeTop = (this.elpos.top < top) ? this.elpos.top: top;
			this.element.setStyles({"position":"absolute","width":this.elpos.width,"height":this.elpos.height,"left":this.IeLeft+"px","top":this.IeTop+"px","z-index":99});	
		}else{
			var option = {"position":"fixed","bottom":"0px","width":this.elpos.width,"height":this.elpos.height,"z-index":99};
			if(this.options.marginAuto == true) $extend(option,{"left":this.IeLeft});
			this.element.setStyles(option);
		}
	},
	setElStyles:function(){
		if(Browser.Engine.trident && Browser.Engine.version < 5){
			this.element.setStyles({"position":"absolute","width":this.elpos.width,"height":this.elpos.height,"left":this.IeLeft+"px",top:this.IeTop+"px","z-index":99});	
		}else{
			this.element.setStyles({"position":"fixed","width":this.elpos.width,"height":this.elpos.height,"z-index":99});	
		}
	}
});

