$(function () {


	setbg();
	$(window).bind("resize", function() {setbg();});

	/*var requestedDate = new Date('2010', '08', '01');
	$('#datepicker').datepicker({		defaultDate: requestedDate,
		onSelect: function(dateText, inst) {
			var req_date = dateText.replace(/(\d+).(\d+).(\d+)/, "$3-$2-$1");
		;}
	});*/

	if($("#scrollwrap").length){$("#scrollwrap").jScrollPane({scrollbarWidth:15, scrollbarMargin:10, showArrows:true});}

	if($('.news').length) {
		$('.news li').hover(
			function(){
				$('.bg', this).stop(true, true).animate({
					opacity: 0.9
				}, 1000 );
				$('.news img', this).stop(true, true).animate({
					borderTopColor: '#ff0'
				}, 1000 );
			},
			function(){
				$('.bg', this).stop(true, true).animate({
					opacity: 0
				}, 1000 );
				$('.news img', this).stop(true, true).animate({
					borderTopColor: '#fff'
				}, 1000 );
			}
		);
	}

	if($('.n_item').length) {
		var anim_speed = 700;
		$('.n_item').hover(
			function(){
				$('.bg', this).stop(true, true).animate({
					opacity: 1
				}, anim_speed );
				$('.n_ttl', this).stop(true, true).animate({
					color: "#e2e2e2",
					marginLeft: "50px"
				}, anim_speed );
				$('.date', this).stop(true, true).animate({
					color: "#e2e2e2"
				}, anim_speed );
				$('.n_info a', this).stop(true, true).animate({
					color: "#ff0"
				}, anim_speed );

			},
			function(){
				$('.bg', this).stop(true, true).animate({
					opacity: 0
				}, anim_speed );
				$('.n_ttl', this).stop(true, true).animate({
					color: "#303030",
					marginLeft: "0px"
				}, anim_speed );
				$('.date', this).stop(true, true).animate({
					color: "#1f1c18"
				}, anim_speed );
				$('.n_info a', this).stop(true, true).animate({
					color: "#1f1c18"
				}, anim_speed );
			}
		);
	}

});

function setbg() {
	var sw = $(window).width();
	var wd = null;
	if(sw <= 1024) {
		wd = 1;
	} else if((sw > 1024)&&(sw <= 1280)) {
		wd = 2;
	} else if((sw > 1280)&&(sw <= 1440)) {
		wd = 3;
	} else if((sw > 1440)&&(sw <= 1680)) {
		wd = 4;
	} else  {
		wd = 5;
	}
	$('#wrapper').css('background', 'url(/web/themes/default/img/bg/bg_' + wd +'.jpg) no-repeat center top');
}
function PNG(element){
	if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent)){
	var src;
	if (element.tagName=='IMG'){
			if (/\.png$/.test(element.src)){
				src = element.src;
				element.src = "/web/themes/default/img/t.gif";
			}
		}
		else {
			src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i)
			if(src){
				src = src[1];
				element.runtimeStyle.backgroundImage="none";
			}
		}
	if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
	}
}
