////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// NEUTRAL
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////




$(function(){
	
	
	$('#box_r .epic')
	.bind('mouseover', onHomePicOver)
	.bind('mouseout', onHomePicOut);
	
	$('#box_r .entry_data')
	.animate({'opacity':0.0},0.0);
	
	$('#box_l a')
	.bind('mouseover', onLeftNaviOver)
	.bind('mouseout', onLeftNaviOut);
	
	$('#box_r .pnavi a')
	.bind('mouseover', onLeftNaviOver)
	.bind('mouseout', onLeftNaviOut);
	
	$('#logo img:eq(1)')
	.bind('mouseover', onLogoOver)
	.bind('mouseout', onLogoOut);
		
	var opts = $('#sbox_archive option');
	for(var i=0,len=opts.length; i<len; i++){
		var txt = $(opts[i]).text();
		$(opts[i]).html(translateMonthInEnglish(txt));
	}
	
	
});



function onHomePicOver(e){
	$(this).parent()
	.find('.entry_data')
	.stop(false, true)
	.animate({'opacity':1.0}, 150);
	$(this).stop(false, true)
	.animate({'opacity':0.2}, 400, 'easeInOutSine');
}



function onHomePicOut(e){
	$(this).parent().
	find('.entry_data')
	.stop(false, true)
	.animate({'opacity':0.0}, 150);
	$(this).stop(false, true)
	.animate({'opacity':1.0}, 400, 'easeInOutSine');

}



function onLogoOver(e){
	$(this).stop(false, true)
	.animate({'opacity':0.0}, 200);
}
function onLogoOut(e){
	$(this).stop(false, true)
	.animate({'opacity':1.0}, 400, 'easeInOutSine');
}



function onLeftNaviOver(e){
	$(this).stop(false, true).animate({ backgroundColor: '#262626' }, 150);
}
function onLeftNaviOut(e){
	$(this).stop(false, true).animate({ backgroundColor: '#FFFFFF' }, 400, 'easeInOutSine');
}




function setNeuDropDown(_arg){
	
	if ($.browser.msie) return false;
	
	var selectorName
	var targets;
	var length;
	var width;
	var height;
	var bgPathOff;
	var bgPathOn;
	
	if(_arg){
		selectorName = _arg.selectorName;
		targets = $(selectorName);
		length = $(selectorName).size();
		width = _arg.width;
		height = _arg.height;
		bgPathOff = _arg.bgPathOff;
		bgPathOn = _arg.bgPathOn;
	}else{
		return false;
	}
	
	for(var i=0; i<length; i++){
		
		var $target = $(targets[i]); 
		
		//-------------------------------------------------------
		//SELECT
		$target
		.css({
			'opacity': 0.0,
			'width': (width-10)+'px',
			'height': (height-10)+'px',
			'margin':'5px 0 0 5px',
			'cursor':'pointer'
		})
		.wrap('<div class="ntdd" />');
		
		//-------------------------------------------------------
		//WRAP
		$target.parent()
		.css({
			'position':'relative',
			'width': width+'px',
			'height': height+'px',
			'cursor':'pointer'
		})
		.prepend('<div class="ntdd-btn"><p class="ntdd_stitle">'
				+$(targets[i]).find('option:eq(0)').text()
				+'</p></div>')
		.bind('mouseover', function(){ $(this).find('.ntdd-btn').css({ 'background-image':'url('+bgPathOn+')' }); })
		.bind('mouseout', function(){ $(this).find('.ntdd-btn').css({ 'background-image':'url('+bgPathOff+')' }); });
		
		//-------------------------------------------------------
		//BTN
		$target.parent().find('.ntdd-btn')
		.css({
			'position':'absolute',
			'top':'0',
			'left':'0',
			'width': width+'px',
			'height': height+'px',
			'background-image':'url('+bgPathOff+')',
			'background-repeat':'no-repeat'
		});
		
		//-------------------------------------------------------
		//TITLE
		$target.parent().find('.ntdd_stitle')
		.css({
			'color':'#888888',
			'font-size':'12px',
			'display':'block',
			'height': height+'px',
			'line-height': height+'px',
			'margin':'0 0 0 8px'
		});	
	}
	
}


function translateMonthInEnglish(_str){

	var origin = _str;
	var res = "";
	var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
	var year = origin.match(/\d+[年]/g);
	var month = origin.match(/\d+[月]/g);
	var num = origin.match(/\(.+?\)/g);
	if(year){
		var y = parseInt(year[0]);
		var m = parseInt(month[0])-1;
		var n = num[0];
		res = months[m] + ' ' + y + ' ' + num;
	}else{
		res = origin;
	}
	return res;

}

