// JavaScript Document

var Window = function(){
	
	this.multi = false;
	
	this.Id = '';
	
	this.className = '';
	
	this.width = 750;
	
	this.height = 700;
	
	this.scrollbars = 'yes';
	
	this.confirm = false;
	
	this.redirect = false;
	
	this.close = false;
}

Window.prototype = {
	
	multiOpen:function(id,className,conf){
// @@ 2010.07.10 なんかようわからんが、IE8でおちる.
//		var links = document.getElementById(id).getElementsByClassName(className);
		var links = document.getElementsByClassName(className);
		
		for(i = 0; i < links.length; ++i){
			for(j =0; j < links[i].getElementsByTagName('a').length; ++j){
				this.Open(links[i].getElementsByTagName('a')[j]);
			}
		}
	},
	
	Open:function(tg){

		var width = this.width;
		var height = this.height;
		var scrollbars = this.scrollbars;
		
		var op = function(evt){
			window.open(tg.href,null,"width="+width+",height="+height+",scrollbars="+scrollbars).focus();
			if(evt.preventDefault) { evt.preventDefault(); }
			return false;
		}
		
		if(this.confirm){
			
			op = function(evt){
			
				if(window.confirm(tg.title)){
					
					window.open(tg.href,null,"width="+width+",height="+height+",scrollbars="+scrollbars).focus();
					if(evt.preventDefault) { evt.preventDefault(); }
					return false;
					
				}else{
					if(evt.preventDefault) { evt.preventDefault(); }
					return false;					
				}
			
			}
		}
		
		dom.addListener(tg,'click',op);
	},
	
	Close:function(){
		
		var tg = document.getElementById(this.Id);
		
		var cl = function(){
			window.close();	
		}
		
		dom.addListener(tg,'click',cl);
		
	},
	
	Set:function(){
		
		if(this.multi){
			this.multiOpen(this.id,this.className);
			
		}
		else if(this.close){
			this.Close();	
		}		
		else if(this.redirect){
			
			this.Redirect();
		
		}

		else{
			this.Open(document.getElementById(this.id));
		}
	},
	
	Redirect:function(){
		
		var tg = document.getElementById(this.Id);
		
		var rd = function(evt){
			window.opener.location.href = tg.href;
			if(evt.preventDefault) { evt.preventDefault(); }
			return false;
		}
		
		dom.addListener(tg,'click',rd);
	}
}

var o = function(){
	var win1 = new Window();
	win1.multi = true;
	win1.id = 'target';
	win1.className = 'win';
	win1.width = 400;
	win1.height = 400;
	win1.confirm = true;
	
	win1.Set();
}

var n = function(){
	var win1 = new Window();
	win1.multi = true;
	win1.id = 'target';
	win1.className = 'photo';
	win1.width = 320;
	win1.height = 600;
	
	win1.Set();
}

var d = function(){
	var win1 = new Window();
	win1.multi = false;
	win1.id = 'target';
	win1.width = 320;
	win1.height = 300;
	
	win1.Set();
}

var m = function(){
	var win1 = new Window();
	win1.multi = true;
	win1.id = 'target';
	win1.className = 'win';
	win1.width = 400;
	win1.height = 400;
	
	win1.Set();
}
