$(function(){
	$('.tShadeLine01 tbody tr:even').addClass('even');
	$('.tShadeLine01 tbody tr:odd').addClass('odd');
});

$(function(){
	setEqualHeight($('.j_sameHight .j_sameHightChild'));
	toggleSwich($('.j_toggleSingle li'), $('.j_toggleAll li'));
	boxLink()
});


function setEqualHeight(columns){
	var tallestcolumn = 0;

	columns.each(
		function(){
			currentHeight = $(this).height();
			if(currentHeight > tallestcolumn){
				tallestcolumn  = currentHeight;
			}
		}
	);
	columns.height(tallestcolumn);
}

function toggleSwich(single, alle){
	var area = single.parent().prev();
	area.hide();

	single
	.click(function(){
		$(this)
		.toggleClass('close')
		.parent()
		.prev()
		.toggleClass('open')
		.slideToggle(300);
	});
	
	alle
	.click(function(){
		$(this)
		.toggleClass('close');
		
		if(!$(this).hasClass('close')){

			area
			.each(function(){
				if($(this).hasClass('open')){
					$(this)
					.removeClass('open')
					.slideUp(300)
					.next()
					.find('li')
					.removeClass('close');
				}
			});
		} else if($(this).hasClass('close')){

			area
			.each(function(){
				if(!$(this).hasClass('open')){
					$(this)
					.addClass('open')
					.slideDown(300)
					.next()
					.find('li')
					.addClass('close');
				}
			});
			
		}
	});
}

function boxLink(){
	var area = $('dl.j_boxLink');
	var anch = $('dl.j_boxLink a');
	var oImages = area.find('.onInBox');

	oImages
	.each(function(){
		var osrc = $(this).attr('src');
		var hsrc = osrc.substring(0, osrc.lastIndexOf('.')) + '_on' + osrc.substring(osrc.lastIndexOf('.'));
		preload = new Image();
		preload.src = hsrc;
	});


	anch.click(function(e){
		e.stopPropagation();
	});	
	
	area
	.css('cursor','pointer')
	.each(function(){
		var a = $(this).find('a');
		var href = a.attr('href');
		
		$(this)
		.click(function(){
			if(a.attr('target') == 'blank'){
				window.open('href','','')
			} else {
				window.location.href = href;
			};
		})
		.hover(
			function(){
				$(this)	.addClass('on');
				$(this).find('.onInBox').attr("src", function() {
					return this.src.substring(0, this.src.lastIndexOf(".")) + "_on" + this.src.substring(this.src.lastIndexOf("."));
				});
			},
			function(){
				$(this).removeClass('on');
				$(this).find('.onInBox').attr("src", function() {
					return this.src.substring(0, this.src.search(/_on\./)) + this.src.substring(this.src.lastIndexOf("."));
				});
			}
		);
	});
}

function openEco() {
	var url = 'http://www.ecodream.jp/';
	var wn = 'ecodream';
	var ww = 770;
	var hh = 522;
	var tt = (screen.height-hh)/2;
	var ll = (screen.width-ww)/2;
	var fea = "top="+tt+",left="+ll+",width="+ww+",height="+hh+",scrollbars=1,resizable=0";
	window.open(url,wn,fea);
}

function openWin(url){
	window.open(url + location.href,'newwin');
}

function contactLink(pass) {
	
	function opeContactnWin(url){
		window.open(url + location.href,'contactwin');
	};
	
	var num = pass;
	if(num == '00'){
			location.href="/contact/index.html?" + location.href;
	}else if(num == '01'){
			opeContactnWin("/contact/con_cn0210.html?");
	}else if(num == '02'){
			//opeContactnWin("/contact/con_cn0010.html?");
			opeContactnWin("/contact/con_cn0210.html?");
	}else if(num == '03'){
			//opeContactnWin("/contact/con_cn0050.html?");
			opeContactnWin("/contact/con_cn0210.html?");
	}else if(num == '04'){
			//opeContactnWin("/contact/con_cn0070.html?");
			opeContactnWin("/contact/con_cn0210.html?");
	}else if(num == '05'){
			//opeContactnWin("/contact/con_cn0110.html?");
			opeContactnWin("/contact/con_cn0210.html?");
	}else if(num == '06'){
			//opeContactnWin("/contact/con_cn0100.html?");
			opeContactnWin("/contact/con_cn0210.html?");
	}else if(num == '07'){
			//opeContactnWin("/contact/con_cn0150.html?");
			opeContactnWin("/contact/con_cn0210.html?");
	}else if(num == '08'){
			//opeContactnWin("/contact/con_cn0190.html?");
			opeContactnWin("/contact/con_cn0210.html?");
	}else if(num == '09'){
			//opeContactnWin("/contact/con_cn0213.html?");
			opeContactnWin("/contact/con_cn0210.html?");
	}else{
			location.href="/contact/index.html?" + location.href;
	}
}

