// JavaScript Document
			var CSS_LINK_ID = "csslink";
			var SCREEN_CSS_FILE = "style.css";
			var PRINT_CSS_FILE = "print.css";
			var PRINT_DIALOG_PARAM = "";
			
// Modified by D.S.
// <<< 20070809_0
			
			var DIALOG_KEY = "print";

// 20070809_0 END
			
			addListener(window, "load", setCssLink);
		
			function setCssLink(){
				
// Modified by D.S.
// <<< 20070809_1
				/*
				if(!window.opener) return;
				*/
								
				if(!Query.paramSet()[DIALOG_KEY]) return;
				
// 20070809_1 END

				document.getElementById(CSS_LINK_ID).href = document.getElementById(CSS_LINK_ID).href.replace(SCREEN_CSS_FILE, PRINT_CSS_FILE);
			}
		
			function openPrintWindow(){
				
// Modified by D.S.
// <<< 20070809_2

				var params = Query.paramSet();
				params[DIALOG_KEY] = true;

// Modified by D.S.
// <<< 20070823
				if(!!window.location.search){
//					window.open(window.location.href.replace(window.location.search, Query.build(params)), "", PRINT_DIALOG_PARAM);
					window.open(window.location.href.replace(window.location.search, Query.build(params)).replace(/#[^?&]*/, ""), "", PRINT_DIALOG_PARAM);
				}
				else{
//					window.open(window.location.href + Query.build(params), "", PRINT_DIALOG_PARAM);
					window.open(window.location.href.replace(/#[^?&]*/, "") + Query.build(params), "", PRINT_DIALOG_PARAM);
				}
// 20070823 END

				/*
				window.open(window.location.href, "", PRINT_DIALOG_PARAM);
				*/
// 20070809_2 END
			}
		
			function printout(){
				
				if(!!window.print){
					window.print();
				}
				else{
					window.document.execCommand("Print", true, 0);
				}
			}
			
			function addListener(target, evnt, func){
				if(!!navigator.userAgent.toLowerCase().match(/msie/)){
					target.attachEvent("on" + evnt, func);
				}
				else{
					target.addEventListener(evnt, func, false);
				}
			}
			
			
// Modified by D.S.
// <<< 20070809_3
						
			function Query(){

				// クエリ → HashTable
				Query.paramSet = function(query){
					query = query == null ? window.location.search : query;
					if(!query) return {};
					for(var result={},q=query.substring("?".length).split("&"),i=0;i<q.length; i++){
						var sepIndex = q[i].indexOf("=");
						result[sepIndex >= 0 ? q[i].substring(0, sepIndex) : q[i]] = sepIndex >= 0 ? q[i].substring(sepIndex + 1) : null;
					}
					return result;
				}
				
				// HashTable → クエリ
				Query.build = function(params){
					var result = "";
					for(var key in params){
						result += (!!result ? "&" : "?") + key + "=" + params[key];
					}
					return result;
				}
			}
			Query();
			
// 20070809_3 END