/*====================================================================================================
//////////////////////////////////////////////////////////////////////////////////////////////////////

 author : http://www.yomotsu.net
 created: 2008/04/05
 update : 
 
 Licensed under the GNU Lesser General Public License version 2.1
 
 リンク先のHTML文書など body 要素内のソースを現在のページ内にモーダルウインドウとして表示する

//////////////////////////////////////////////////////////////////////////////////////////////////////
====================================================================================================*/

var yomotsuModalWindow_k = {
	cur_id:null,

	conf : {
		triggerClassName       : "show-detail", // クリックしたときウインドウを開く a 要素につける class 属性
		displayBasePositionTop : 150, // ( px )　
		displayBaseMaxWidth    : 626, // ( px )　
		backgroundMaxOpacity   : 0.30 // [ 0.00 ~ 1.00 ]
	},
	
	start : function(){
		try {
			window.addEventListener('load', this.trigger, false);
		} catch (e) {
			window.attachEvent('onload', this.trigger);
		}
	},
	
	trigger : function(){
	 var a = document.links;
	 for(var i=0; i<a.length; i++){
	 	if(new RegExp("\\b" + yomotsuModalWindow_k.conf.triggerClassName + "\\b").exec(a[i].className)){
			a[i].onclick = function(){
				if(this.href.match(/\..*html?|\.xml|\.php|\.asp/)){
					yomotsuModalWindow_k.set(this.href);
					return false;
				}
			}
		}
	 }
	},

	set : function(URI){
		cur_id=URI;
		displayBase = document.getElementById(cur_id);
		displayBase.id = "display-base";
		displayBase.style.position = "absolute";
		displayBase.style.zIndex   = "100";
		
		tmp = displayBase;
		while(tmp = tmp.parentNode) {
			if (tmp.id == "left") {
				displayBase.style.left = 60 + "px";
				break;
			} else if (tmp.id == "right") {
				displayBase.style.right = 240 + "px";
				break;
			}
		}
		//displayBase.style.left     = getPageSize().width / 2 - ( yomotsuModalWindow_k.conf.displayBaseMaxWidth / 2) -130 + "px";
		/*
		displayBase.style.top      = getPageOffset().yOffset + yomotsuModalWindow_k.conf.displayBasePositionTop + "px";
		displayBase.style.left     = getPageSize().width / 2 - ( yomotsuModalWindow_k.conf.displayBaseMaxWidth / 2) + "px";
		*/
		
		var elems = document.getElementsByTagName("select");
		for (i = 0; i < elems.length; i++) {
		 elems[i].style.display = "none";
		}
		displayBase.style.display="";
		backScreen_k.set();
	},
	
	remove : function(){
		var displayBase = document.getElementById("display-base");
		
		if (document.getElementById(cur_id + "_n")) {
			var temptext = "";
			var ElementsList = displayBase.getElementsByTagName("input");
			for (i = 0; i < ElementsList.length; i++) {
				if (ElementsList[i].type == 'checkbox' && ElementsList[i].checked == true) {
					if (ElementsList[i].nextSibling.tagName == "LABEL") {
						curtext = ElementsList[i].nextSibling.innerHTML;
					} else {
						curtext = ElementsList[i].nextSibling.nodeValue;
					}
					if (temptext.length + curtext.length > 15) {
						temptext += "...";
						break;
					}
					else {
						if (temptext != "") {
							temptext += "、";
						}
						temptext += curtext;
					}
				}
			}
			if (temptext == "") {
				temptext = "+指定なし";
			}
			document.getElementById(cur_id + "_n").innerHTML = temptext;
		}
		if (displayBase) {
			displayBase.style.display = "none";
			displayBase.id = cur_id;
		}
		var elems = document.getElementsByTagName("select");
		for (i = 0; i < elems.length; i++) {
		 elems[i].style.display = "";
		}
		backScreen_k.remove(cur_id);
	}
	
};


yomotsuModalWindow_k.start();

//-----------------------------------------------------
//  backScreen_k
//-----------------------------------------------------


var backScreen_k = {
	alpha : 0,
	
	set : function(){
		var backScreen_k = document.createElement("div");
		
		backScreen_k.id = "back-screen";
		backScreen_k.style.position = "absolute";
		backScreen_k.style.left     = 0;
		backScreen_k.style.top      = 0;
		backScreen_k.style.zIndex   = 99;
		backScreen_k.style.width    = Math.max(getPageSize().width, yomotsuModalWindow_k.conf.displayBaseMaxWidth) +"px";
		backScreen_k.style.height   = getPageSize().height +"px";
		backScreen_k.style.filter     ="alpha(opacity="+this.alpha*100+")";
		backScreen_k.style.MozOpacity =this.alpha;
		backScreen_k.style.opacity    =this.alpha;
		
		document.getElementById('display-base').parentNode.appendChild(backScreen_k);
		
		this.alpha = 0;
		this.fadeIn();
	},
	
	fadeIn : function(){
		var backScreen_k = document.getElementById("back-screen");
		this.alpha += 0.10;
		if(backScreen_k.style.opacity)        	backScreen_k.style.opacity    = this.alpha;
		else if(backScreen_k.style.MozOpacity)	backScreen_k.style.MozOpacity = this.alpha;
		else if(backScreen_k.style.filter)	    backScreen_k.style.filter     = "alpha(opacity="+this.alpha*100+")";
		if (this.alpha < yomotsuModalWindow_k.conf.backgroundMaxOpacity ) {
			backScreen_k.onclick = function(){return};
			window.setTimeout("backScreen_k.fadeIn()", 25);
		}
		else {
			backScreen_k.onclick = yomotsuModalWindow_k.remove;
		}
	},
	
	fadeOut : function(curid){
		var backScreen_k = document.getElementById("back-screen");
		backScreen_k.onclick = function(){return};
		this.alpha -= 0.10;
		if(backScreen_k.style.opacity)        	backScreen_k.style.opacity    = this.alpha;
		else if(backScreen_k.style.MozOpacity)	backScreen_k.style.MozOpacity = this.alpha;
		else if(backScreen_k.style.filter)	    backScreen_k.style.filter     = "alpha(opacity="+this.alpha*100+")";
		if (this.alpha > 0.05) {
			window.setTimeout("backScreen_k.fadeOut('"+curid+"')", 20);
		}else{
			if (document.getElementById(curid)) {
				document.getElementById(curid).parentNode.removeChild(backScreen_k);
			}
			this.alpha = 0;
		}
	},
	
	remove : function(curid){
		var backScreen_k = document.getElementById("back-screen");
		if(backScreen_k)
			this.fadeOut(curid);
	},
	
	fix : function(){
		var backScreen_k = document.getElementById("back-screen");
		if(backScreen_k){
			backScreen_k.style.width  = getPageSize().width  +"px";
			backScreen_k.style.height = getPageSize().height +"px";
		}
	}
};

try {
	window.addEventListener('resize', backScreen_k.fix, false);
} catch (e) {
	window.attachEvent('onresize', backScreen_k.fix);
};












function showoffer(url,burl){
	document.offer_form.action=url;
	document.offer_form.burl.value=burl;
	document.offer_form.submit();
};

