﻿// topimage
function changeImage(){
	img = new Array
	img[0] = '<img src="images/main_img.jpg" width="880" height="305" />';
	img[1] = '<img src="images/main_img_artist.jpg" width="880" height="305" />';

	rnd = Math.floor(Math.random() * img.length);
	document.write(img[rnd]);
}


// openwindow
function openwindow(src, winName){
	NewWin=window.open(src,winName,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=660,height=600');
}


// schedule
function schedule(src, winName){
	NewWin=window.open(src,winName,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=680,height=650');
}


// playback
function showimg(changeImg){
	document.area1.src = changeImg;
}

// coupon
function couponMap(src, winName){
	NewWin=window.open(src,winName,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=660,height=650');
}

// artistMessage
function artistMessage(src, winName){
	NewWin=window.open(src,winName,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=660,height=420');
}

// white
function white(src, winName){
	NewWin=window.open(src,winName,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=880,height=650');
}

// yuga.js 0.7.1
(function($) {

	$(function(){
    var $targetElement = '.wordBreak';
    if($.browser.msie) {
        $($targetElement).css('word-break', 'break-all');
    } else {
        $($targetElement).each(function(){
            if(navigator.userAgent.indexOf('Firefox/2') != -1) {
                $(this).html($(this).text().split('').join('<wbr />'));
            } else {
                $(this).html($(this).text().split('').join(String.fromCharCode(8203)));
            }
        });
    }
});
	
$(function() {
	$.yuga.rollover();
	$.yuga.scroll();
	$.yuga.tab();
	$.yuga.stripe();
	$.yuga.css3class();
});

//---------------------------------------------------------------------

$.yuga = {
	// URIり・似"・・Iブジェクトり答・unction
	Uri: function(path){
		var self = this;
		this.originalPath = path;
		//雪女｝スり後
		this.absolutePath = (function(){
			var e = document.createElement('span');
			e.innerHTML = '<a href="' + path + '" />';
			return e.firstChild.href;
		})();
		//雪女｝スり套
		var fields = {'schema' : 2, 'username' : 5, 'password' : 6, 'host' : 7, 'path' : 9, 'query' : 10, 'fragment' : 11};
		var r = /^((\w+):)?(\/\/)?((\w+):?(\w+)?@)?([^\/\?:]+):?(\d+)?(\/?[^\?#]+)?\??([^#]+)?#?(\w*)/.exec(this.absolutePath);
		for (var field in fields) {
			this[field] = r[fields[field]];
		}
		this.querys = {};
		if(this.query){
			$.each(self.query.split('&'), function(){
				var a = this.split('=');
				if (a.length == 2) self.querys[a[0]] = a[1];
			});
		}
	},
	//ロールオーバー
	rollover: function(options) {
		var c = $.extend({
			hoverSelector: '.imgover, .allimg img',
			groupSelector: '.imggroup',
			postfix: '_on'
		}, options);
		//ロールオーバーｌ"・mードｖ拷器
		var rolloverImgs = $(c.hoverSelector).filter(isNotCurrent);
		rolloverImgs.each(function(){
			this.originalSrc = $(this).attr('src');
			this.rolloverSrc = this.originalSrc.replace(new RegExp('('+c.postfix+')?(\.gif|\.jpg|\.png)$'), c.postfix+"$2");
			this.rolloverImg = new Image;
			this.rolloverImg.src = this.rolloverSrc;
		});
		//グループ内鉾mg要素り詣剃・・Zレクタ遂
		var groupingImgs = $(c.groupSelector).find('img').filter(isRolloverImg);
			//瀦咲#香[ルオーバー
		rolloverImgs.not(groupingImgs).hover(function(){
			$(this).attr('src',this.rolloverSrc);
		},function(){
			$(this).attr('src',this.originalSrc);
		});
		//グループ猿"・蛟・香[ルオーバー
		$(c.groupSelector).hover(function(){
			$(this).find('img').filter(isRolloverImg).each(function(){
				$(this).attr('src',this.rolloverSrc);
			});
		},function(){
			$(this).find('img').filter(isRolloverImg).each(function(){
				$(this).attr('src',this.originalSrc);
			});
		});
		
		//フィルタ用function
		function isNotCurrent(i){
			return Boolean(!this.currentSrc);
		}
		function isRolloverImg(i){
			return Boolean(this.rolloverSrc);
		}
		},
	//ページ内♀ンクｗ"・・・・Xクロール
	scroll: function(options) {
		//ドキュメントｖ々クロールり私,窶・・Iブジェクト
		var scroller = (function() {
			var c = $.extend({
				easing:100,
				step:30,
				fps:60,
				fragment:''
			}, options);
			c.ms = Math.floor(1000/c.fps);
			var timerId;
			var param = {
				stepCount:0,
				startY:0,
				endY:0,
				lastY:0
			};
			//スクロール中ｕ.遂sｊ"蛟・unction
			function move() {
				if (param.stepCount == c.step) {
					//スクロール終絡.
					setFragment(param.hrefdata.absolutePath);
					window.scrollTo(getCurrentX(), param.endY);
				} else if (param.lastY == getCurrentY()) {
					//瀦咲#Xクロール
					param.stepCount++;
					window.scrollTo(getCurrentX(), getEasingY());
					param.lastY = getEasingY();
					timerId = setTimeout(move, c.ms); 
				} else {
					//キャンセル這0
					if (getCurrentY()+getViewportHeight() == getDocumentHeight()) {
						//峨舶㍾摩・・Xクロール終
						setFragment(param.hrefdata.absolutePath);
					}
				}
			}
			function setFragment(path){
				location.href = path
			}
			function getCurrentY() {
				return document.body.scrollTop  || document.documentElement.scrollTop;
			}
			function getCurrentX() {
				return document.body.scrollLeft  || document.documentElement.scrollLeft;
			}
			function getDocumentHeight(){
				return document.documentElement.scrollHeight || document.body.scrollHeight;
			}
			function getViewportHeight(){
				return (!$.browser.safari && !$.browser.opera) ? document.documentElement.clientHeight || document.body.clientHeight || document.body.scrollHeight : window.innerHeight;
			}
			function getEasingY() {
				return Math.floor(getEasing(param.startY, param.endY, param.stepCount, c.step, c.easing));
			}
			function getEasing(start, end, stepCount, step, easing) {
				var s = stepCount / step;
				return (end - start) * (s + easing / (100 * Math.PI) * Math.sin(Math.PI * s)) + start;
			}
			return {
				set: function(options) {
					this.stop();
					if (options.startY == undefined) options.startY = getCurrentY();
					param = $.extend(param, options);
					param.lastY = param.startY;
					timerId = setTimeout(move, c.ms); 
				},
				stop: function(){
					clearTimeout(timerId);
					param.stepCount = 0;
				}
			};
		})();
		$('a[href^=#], area[href^=#]').not('a[href=#], area[href=#]').each(function(){
			this.hrefdata = new $.yuga.Uri(this.getAttribute('href'));
		}).click(function(){
			var target = $('#'+this.hrefdata.fragment);
			if (target.length == 0) target = $('a[name='+this.hrefdata.fragment+']');
			if (target.length) {
				scroller.set({
					endY: target.offset().top,
					hrefdata: this.hrefdata
				});
				return false;
			}
		});
	},
	//タブ機能
	tab: function(options) {
		var c = $.extend({
			tabNavSelector:'.tabNav',
			activeTabClass:'active'
		}, options);
		$(c.tabNavSelector).each(function(){
			var tabNavList = $(this).find('a[href^=#], area[href^=#]');
			var tabBodyList;
			tabNavList.each(function(){
				this.hrefdata = new $.yuga.Uri(this.getAttribute('href'));
				var selecter = '#'+this.hrefdata.fragment;
				if (tabBodyList) {
					tabBodyList = tabBodyList.add(selecter);
				} else {
					tabBodyList = $(selecter);
				}
				$(this).unbind('click');
				$(this).click(function(){
					tabNavList.removeClass(c.activeTabClass);
					$(this).addClass(c.activeTabClass);
					tabBodyList.hide();
					$(selecter).show();
					return false;
				});
			});
			tabBodyList.hide()
			tabNavList.filter(':first').trigger('click');
		});
	},
	//願0煤A苦飼り桁3≒・
	stripe: function(options) {
		var c = $.extend({
			oddClass:'odd',
			evenClass:'even'
		}, options);
		$('ul, ol').each(function(){
			//JSｓ"厘ｅ"・狽ム・摩・venｓ_ddり液ｕ.w
			$(this).children('li:odd').addClass(c.evenClass);
			$(this).children('li:even').addClass(c.oddClass);
		});
		$('table, tbody').each(function(){
			$(this).children('tr:odd').addClass(c.evenClass);
			$(this).children('tr:even').addClass(c.oddClass);
		});
	},
	//css3ｖ¨ラスり数)
	css3class: function() {
		//:first-child, :last-childり¨ラスｓ・註・
		$('body :first-child').addClass('firstChild');
		$('body :last-child').addClass('lastChild');
		//css3ｖ8emptyり¨ラスｓ・註・
		$('body :empty').addClass('empty');
	}
};
})(jQuery);
