/*==============================================
 init
==============================================*/
$(function(){
	$('body').removeClass('nojs');
	$('p.image>a,p.zoom>a','#goods #content').colorbox();
	$('p.linernotes>a','#discography #content').colorbox({opacity:0.45});
	$('#index').each(function(){
		$('#wrapper').css('backgroundImage','none');
		$(window).load(function() {
		var dummy = $("#mcs2_container").clone();
		$("#mcs2_container").after(dummy).remove();
		$("#mcs2_container").mCustomScrollbar("vertical",200,"easeOutCirc",1.25,"fixed","yes","no",0); 
		});
	});
});

/*==============================================
 IE bgfix
==============================================*/
try{document.execCommand("BackgroundImageCache", false, true);} catch(e){}



/*==============================================
mCustomScrollbar
==============================================*/
/* function to fix the -10000 pixel limit of jquery.animate */
$.fx.prototype.cur = function(){
    if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
      return this.elem[ this.prop ];
    }
    var r = parseFloat( jQuery.css( this.elem, this.prop ) );
    return typeof r == 'undefined' ? 0 : r;
}


/*==============================================
pulldown
==============================================*/

$(function(){
var target = 'ul.global_nav li:has(ul)';
$(target).hover(function(){
	$(this).addClass('childshow');
},function(){
	$(this).removeClass('childshow');
});

var target2 = 'ul.global_nav li ul li:has(ul)';
$(target2)
.hover(function(){
	$(this).children('ul').animate({width:198,marginLeft: 0}, 200 , function(){
		$(this).addClass('childshow');
	});
},function(){
	$(this).children('ul').animate({width:0,marginLeft: 198}, 200 , function(){
		$(this).delay(300).removeClass('childshow');
	});
})
.children('ul').css({width:0,marginLeft: 198});
	

var postfix = '_off';
    $('ul.global_nav a img').not('[src*="'+ postfix +'."]').each(function() {
        var img = $(this);
        var src = img.attr('src');
        var src_on = src.substr(0, src.lastIndexOf('.'))
                   + postfix
                   + src.substring(src.lastIndexOf('.'));
        $('<img>').attr('src', src_on);
        img.hover(
            function() {
                img.attr('src', src_on);
            },
            function() {
                img.attr('src', src);
            }
        );
    });

});



/*==============================================
page-up
==============================================*/

$(function(){

var $frame = $('#content-inner'); 

var $trigger = $('p.pageup>a');

$trigger.click(function(){

    $frame.animate({scrollTop:0},"normal");
    $frame.animate({pageYOffset:0},"normal");

    return false;

});

});


/*==============================================
player
==============================================*/

$(document).ready(function(){
	var $jpl = $('#player');
	if(!$.fn.jPlayer) return false;
	var $play = $('#play');
	var $pause = $('#pause');
	
	

   $jpl.jPlayer({
		ready: function () {
			$jpl.jPlayer("volume", 30 );
			$jpl.jPlayer("setFile","./audio/music.mp3").jPlayer("pause");
		},
		swfPath: 'common/js',
		customCssIds: true
	});
	$jpl.jPlayer("onSoundComplete", function() {
		 $play.show();
		 $pause.hide();
	});

	$("#pause").hide();
	
	$play.click(function() {
		$jpl.jPlayer("play");
		 $pause.show();
		 $play.hide();
		$(this).blur();
		return false;
	});

	$pause.click(function() {
		$jpl.jPlayer("pause");
		 $play.show();
		 $pause.hide();
		$(this).blur();
		return false;
	});

});



