function bodyToggle(id){
	var selector = 'slide-'+id;
	var button = 'button-'+id;
	var o = 'http://'+location.hostname+'/images/pod-body-open.gif';
	var x = 'http://'+location.hostname+'/images/pod-body-close.gif';
	var oReg = new RegExp('open\.gif','i');

	$("#"+selector).slideToggle("fast",function(){
		if($("#"+button).css('background-image').match(oReg)){
			$("#"+button).css({'background-image':'url('+x+')'});
		}else{
			$("#"+button).css({'background-image':'url('+o+')'});
		}
	});
}

function downLoadPod(file){
	location.href = 'http://'+location.hostname+'/podcasting/sub/download.php?file='+file;
	return;
}

function listenPodcast(path){
	var path = 'http://'+location.hostname+'/podcasting/sub/pod/'+path;
	var option = 'width=410,';
		option += 'height=320,';
		option += 'menubar=no,';
		option += 'toolbar=no,';
		option += 'location=no,';
		option += 'status=no,';
		option += 'scrollbars=no';

	window.open(path,'playPod',option);
	return;
}

function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");

		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_off."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
				}
			}
		}
	}
}

if(window.addEventListener) {
	window.addEventListener("load", smartRollover, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", smartRollover);
}

function cartPop(){
	cartWin = window.open("http://www.monoglobe.jp/cart_b/neocart.php","CartWindow","width=772,height=560,resizable=1,scrollbars=1");
	cartWin.focus();
	return false;
}

function popUpimgA(href){
	var o = location.hostname;
	var imgObj = new Image();
	imgObj.src = decodeURIComponent(href);
	var wo = '';
/*
	wo += 'width=200,'
	wo += 'height=300,'
	wo += 'directories=0,';
	wo += 'location=0,';
	wo += 'menubar=0,';
	wo += 'resizable=0,';
	wo += 'scrollbars=0,';
	wo += 'status=0,';
	wo += 'toolbar=0,';
*/
	//window.open('','newWin',wo);


	var openWin = function(a,b){
		w = Number(a)+60;
		h = Number(b)+128;

		var wo = '';
		wo += 'width='+a+','
		wo += 'height='+b+','
		wo += 'directories=0,';
		wo += 'location=0,';
		wo += 'menubar=0,';
		wo += 'resizable=0,';
		wo += 'scrollbars=0,';
		wo += 'status=0,';
		wo += 'toolbar=0,';

		var pUrl = 'http://www.monoglobe.jp/popup.php?img='+encodeURI(href)+'&w='+w+'&h='+h;

		window.open(pUrl,'newWin',wo);
	};

	var loadingComplete = function(){

		if(imgObj.complete){
			var a = imgObj.width;
			var b = imgObj.height;
			openWin(a,b);
		}else{
			setTimeout(loadingComplete,100);
		}
	};

	loadingComplete();

}

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);
}

var yomotsuClearDefaultValue = {
	main : function(){
		var i;
		var input = document.getElementsByTagName("input");
		var textarea = document.getElementsByTagName("textarea");
		
		// input ---
		for (i=0;i<input.length;i++){
			if((input[i].getAttribute("type") == "text")||(input[i].getAttribute("type") == null)){
				if (input[i].value == input[i].defaultValue){
					input[i].className += " default-value"
				}
				input[i].onfocus = yomotsuClearDefaultValue.Focus;
				input[i].onblur  = yomotsuClearDefaultValue.Blur;
			}
		}
		
		// textarea ---
		for (i=0;i<textarea.length;i++){
			if (textarea[i].value == textarea[i].defaultValue){
				textarea[i].className += " default-value"
			}
			textarea[i].onfocus = yomotsuClearDefaultValue.Focus;
			textarea[i].onblur  = yomotsuClearDefaultValue.Blur;
		}
	},
	
	Focus : function(){
		if (this.value == this.defaultValue){
			this.value = "";
			this.className = this.className.replace(/default-value/, "");
		}
	},
	
	Blur : function(){
		if (this.value == ""){
			this.value = this.defaultValue;
			this.className += " default-value";
		}
	},
	
	addEvent : function(){
		try {
			window.addEventListener('load', yomotsuClearDefaultValue.main, false);
		} catch (e) {
			window.attachEvent('onload', yomotsuClearDefaultValue.main);
		}
	}
	
}

yomotsuClearDefaultValue.addEvent();