// JavaScript Document

jQuery(document).ready(function($) {
	
	// init rollover
	JsRoller.initialize( 'rollover' );
	
});


// scrollTo
function move(n){
	$.scrollTo(n, 500);
}


//ON AIR SCHEDULE Tab
$(function(){
    $("div.panel ul:not("+$("ul.tab li a.selected").attr("href")+")").hide();
    $("ul.tab li a").click(function(){
        $("ul.tab li a").removeClass("selected");
        $(this).addClass("selected");
		$("div.panel ul").hide();
        $($(this).attr("href")).show();
		
        return false;
		
		
    })
})



//POPUP Artist detail page
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}





//mainNavi display on off
$(document).ready(function() {
	$("#navi01").hover(function(){
		$(this).css("cursor","pointer");
	},
	function(){
		$(this).css("cursor","default"); 
		});
	
	$("#navi01").click(function(){
		
		$("#box2").css("display","none");
		$("#box1").slideToggle("normal");
		});
	
	$("#navi03").click(function(){
		$("#box1").css("display","none");
		$("#box2").slideToggle("normal");
		});
	
	$(".btn_close1").click(function(){
		$("#box1").slideToggle("normal");
	});
	$(".btn_close2").click(function(){
		$("#box2").slideToggle("normal");
	});
	
	
});


//News Ticker
$(function(){
			function newsFader(elm,fadeSpeed,fadeInterval){
				if(elm.length<=1) return false;
				
				elm.each(function(i){
					$(this).attr("id","news-"+i);
					if(i!=0) $(this).hide();
				});
				
				var start = count = 0,
					end = elm.length-1,
					fadeTimer = setInterval(function(){
						$("#news-"+(start==1 ? count==0 ? end : count-1 : count)).hide();
						$("#news-"+(start==1 ? (++count)-1 : ++count)).fadeIn(fadeSpeed);
						if(start==0 && count>=end){
							count = 0;
							start = 1;
						}else if(start==1 && count>end){
							count = 0;
						}
					},fadeInterval);
			}
			newsFader($("li","div#newsTicker ul"),"slow",3000);
		});

//ランダムバナー
function rdmad() {
        totalprobability = 0;
        rdmadi=0;
	ad=new Array();
	//基本入力項目
	//ad[0]=new adlist('確率(入力値/入力値の合計)','URLを記述','バナー広告の画像パスを入力','バナーのALTタグ用のタイトル');
	ad[0]=new adlist('33','http://www.jeanasis.jp/index.html','img/banner/jeanasis.gif','JEANASIS');
	ad[1]=new adlist('33','http://www.globalwork.jp/oto-fukei/','img/banner/globalwork.jpg','GLOBALWORK');
	ad[2]=new adlist('33','http://www.kawaiiexpo.jp/','img/banner/lowrysfarm.gif','LOWRYSFARM');

        //確率の合計を計算
        for(i=0; i < ad.length ;i++) {
            totalprobability += parseInt(ad[i].probability);
        }

	//乱数を発生させる
	//rdmadi=Math.floor(ad.length * Math.random());
        rdmadi=Math.floor(totalprobability * Math.random());

	totalprobability = 0 ;
        //確率の合計を計算
        for(i=0; i < ad.length ; i++) {
            totalprobability += parseInt(ad[i].probability);
            if (rdmadi <= totalprobability) {
                rdmadi = i;
                break;
            }
        }

	//乱数をインデックスとして利用し、配列から広告データ取り出す
	document.write ('<a href=\"' + ad[rdmadi].url + '\" target=\"_blank\"><img src=\"' + ad[rdmadi].imgpath + '\" alt=\"' + ad[rdmadi].title + '\"  width=\"528\" border=\"0\" height=\"83\"></a>');
	document.close();
}

//adlistクラス
function adlist(probability,url, imgpath, title){
	this.probability=probability;	//Probability
	this.url=url;		//URL
	this.imgpath=imgpath;	//Image Path
        this.title=title;	//Title
}
