
//************* popup *************

function openWindow(theURL, width, height, features, winName) { //v2.0
	if(typeof(width) == "undefined" || width == 0){
		width = 500;
	}
	
	if(typeof(height) == "undefined" || height == 0){
		height = 500;
	}
	
	if(typeof(features) == "undefined" || features == ""){
		features = "status=yes,menubar=no,scrollbars=yes,resizable=yes";
	}
	
	features = features + ', width = ' + width + ', height = ' + height;
	
  window.open(theURL,winName,features);
}


function openWindow2(theURL, winName) { //v2.0
/*
	if(typeof(width) == "undefined" || width == 0){
		width = 500;
	}
	
	if(typeof(height) == "undefined" || height == 0){
		height = 500;
	}
	if(typeof(features) == "undefined" || features == ""){
		features = "status=yes,menubar=yes,scrollbars=yes,resizable=yes";
	}
*/	
	
  var newWin = window.open(theURL,winName);
  newWin.focus();
  
}

//************* rollover *************

rollovers=function(off,on){
	img=document.getElementsByTagName("img");p=[];
	off_reg=new RegExp(off+"(\.[a-z]+$)","i");
	on_reg=new RegExp(on+"(\.[a-z]+$)","i");
	for(var x=0,i;i=img[x];x++){
		if(i.src.match(off_reg)){
			p[x]=new Image();
			p[x].src=i.src.replace(off_reg,on+"$1");
			
	i.onmouseover=function(){
		this.src=this.src.replace(off_reg,on+"$1");};
	i.onmouseout=function(){
		this.src=this.src.replace(on_reg,off+"$1");};};};};
		
onloader = function(){	rollovers( "_d" , "_on" );}		
if (window.attachEvent){
	window.attachEvent('onload', onloader);
}
else {
	window.addEventListener('load', onloader, false);
}

rolloversIp=function(off,on){
	input=document.getElementsByTagName("input");p=[];
	off_reg=new RegExp(off+"(\.[a-z]+$)","i");
	on_reg=new RegExp(on+"(\.[a-z]+$)","i");
	for(var x=0,i;i=input[x];x++){
		if(i.src.match(off_reg)){
			p[x]=new Image();
			p[x].src=i.src.replace(off_reg,on+"$1");
			
	i.onmouseover=function(){
		this.src=this.src.replace(off_reg,on+"$1");};
	i.onmouseout=function(){
		this.src=this.src.replace(on_reg,off+"$1");};};};};
		
onloader = function(){	rolloversIp( "_d" , "_on" );}		
if (window.attachEvent){
	window.attachEvent('onload', onloader);
}
else {
	window.addEventListener('load', onloader, false);
}

$(document).ready(function(){

$("#top #header .rgt .about a").hover(function(){
	$("#top #header .rgt").addClass("on");
	},
	function(){
	$("#top #header .rgt").removeClass("on");
	}
	);

$("#btn_rss a").hover(function(){
	$("#btn_rss").addClass("on");
	},
	function(){
	$("#btn_rss").removeClass("on");
	}
	);

$("#btn_r25 a").hover(function(){
	$("#btn_r25").addClass("on");
	},
	function(){
	$("#btn_r25").removeClass("on");
	}
	);

});


//************* heightLine *************

new function(){
	
	function heightLine(){
	
		this.className="heightLine";
		this.parentClassName="heightLineParent"
		reg = new RegExp(this.className+"-([a-zA-Z0-9-_]+)", "i");
		objCN =new Array();
		var objAll = document.getElementsByTagName ? document.getElementsByTagName("*") : document.all;
		for(var i = 0; i < objAll.length; i++) {
			var eltClass = objAll[i].className.split(/\s+/);
			for(var j = 0; j < eltClass.length; j++) {
				if(eltClass[j] == this.className) {
					if(!objCN["main CN"]) objCN["main CN"] = new Array();
					objCN["main CN"].push(objAll[i]);
					break;
				}else if(eltClass[j] == this.parentClassName){
					if(!objCN["parent CN"]) objCN["parent CN"] = new Array();
					objCN["parent CN"].push(objAll[i]);
					break;
				}else if(eltClass[j].match(reg)){
					var OCN = eltClass[j].match(reg)
					if(!objCN[OCN]) objCN[OCN]=new Array();
					objCN[OCN].push(objAll[i]);
					break;
				}
			}
		}


//check font size
		var e = document.createElement("div");
		var s = document.createTextNode("S");
		e.appendChild(s);
		e.style.visibility="hidden"
		e.style.position="absolute"
		e.style.top="0"
		document.body.appendChild(e);
		var defHeight = e.offsetHeight;
		
		changeBoxSize = function(){
			for(var key in objCN){
				if (objCN.hasOwnProperty(key)) {
					//parent type
					if(key == "parent CN"){
						for(var i=0 ; i<objCN[key].length ; i++){
							var max_height=0;
							var CCN = objCN[key][i].childNodes;
							for(var j=0 ; j<CCN.length ; j++){
								if(CCN[j] && CCN[j].nodeType == 1){
									CCN[j].style.height="auto";
									max_height = max_height>CCN[j].offsetHeight?max_height:CCN[j].offsetHeight;
								}
							}
							for(var j=0 ; j<CCN.length ; j++){
								if(CCN[j].style){
									var stylea = CCN[j].currentStyle || document.defaultView.getComputedStyle(CCN[j], '');
									var newheight = max_height;
									if(stylea.paddingTop)newheight -= stylea.paddingTop.replace("px","");
									if(stylea.paddingBottom)newheight -= stylea.paddingBottom.replace("px","");
									if(stylea.borderTopWidth && stylea.borderTopWidth != "medium")newheight-= stylea.borderTopWidth.replace("px","");
									if(stylea.borderBottomWidth && stylea.borderBottomWidth != "medium")newheight-= stylea.borderBottomWidth.replace("px","");
									CCN[j].style.height =newheight+"px";
								}
							}
						}
					}else{
						var max_height=0;
						for(var i=0 ; i<objCN[key].length ; i++){
							objCN[key][i].style.height="auto";
							max_height = max_height>objCN[key][i].offsetHeight?max_height:objCN[key][i].offsetHeight;
						}
						for(var i=0 ; i<objCN[key].length ; i++){
							if(objCN[key][i].style){
								var stylea = objCN[key][i].currentStyle || document.defaultView.getComputedStyle(objCN[key][i], '');
									var newheight = max_height;
									if(stylea.paddingTop)newheight-= stylea.paddingTop.replace("px","");
									if(stylea.paddingBottom)newheight-= stylea.paddingBottom.replace("px","");
									if(stylea.borderTopWidth && stylea.borderTopWidth != "medium")newheight-= stylea.borderTopWidth.replace("px","")
									if(stylea.borderBottomWidth && stylea.borderBottomWidth != "medium")newheight-= stylea.borderBottomWidth.replace("px","");
									objCN[key][i].style.height =newheight+"px";
							}
						}
					}
				}
			}
		}
		
		checkBoxSize = function(){
			if(defHeight != e.offsetHeight){
				changeBoxSize();
				defHeight= e.offsetHeight;
			}
		}
		changeBoxSize();
		setInterval(checkBoxSize,1000)
		window.onresize=changeBoxSize;
	}
	
	function addEvent(elm,listener,fn){
		try{
			elm.addEventListener(listener,fn,false);
		}catch(e){
			elm.attachEvent("on"+listener,fn);
		}
	}
	addEvent(window,"load",heightLine);
}

/*====== カルチャー 第6回 選手村で恋が生まれることはあるの？ 後編対応 ======*/
var nowURL = document.URL;
var compStr = "110000006407/part/2"
if(nowURL.indexOf(compStr) != -1){
	document.write("<script type=\"text/javascript\" src=\"/dpc_js/common/lytebox.js\"></script>");
	document.write("<link rel=\"stylesheet\" href=\"/dpc_css/common/lytebox.css\" type=\"text/css\" media=\"screen\" />");
}
