
/* Roll Over Images Script
---------------------------------------------------- */
function addEvent(elm, evType, func, useCapture) {
	if (elm.addEventListener) {
		elm.addEventListener(evType, func, useCapture);
		return true;
	} else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, func);
		return r;
	} else {
		elm['on' + evType] = func;
	}
}

function initRollovers() {
	if (!document.getElementById) return;
	
	var overPath = "_on";
	

	if(document.getElementById("koenInfo")){
		document.getElementById("koenInfo_navi").src = "/images/sche/btn_koen01_on.gif";
		$("#koenInfo_navi").removeClass("imgover");
		overPath = "_on";
		
		var index = $("#koenTab li").index( $("#koenInfo_navi").parent().parent() );
		$("#koenTab").addClass("line"+index);
		
	}

	if(document.getElementById("koenSche")){
		document.getElementById("koenSche_navi").src = "/images/sche/btn_koen02_on.gif";
		$("#koenSche_navi").removeClass("imgover");
		overPath = "_on";
		
		var index = $("#koenTab li").index( $("#koenSche_navi").parent().parent() );
		$("#koenTab").addClass("line"+index);
	}

	if(document.getElementById("koenTicket")){
		document.getElementById("koenTicket_navi").src = "/images/sche/btn_koen03_on.gif";
		$("#koenTicket_navi").removeClass("imgover");
		overPath = "_on";
		
		var index = $("#koenTab li").index( $("#koenTicket_navi").parent().parent() );
		$("#koenTab").addClass("line"+index);
	}

	if(document.getElementById("koenVacancy")){
		document.getElementById("koenVacancy_navi").src = "/images/sche/btn_koen04_on.gif";
		$("#koenVacancy_navi").removeClass("imgover");
		overPath = "_on";
		
		var index = $("#koenTab li").index( $("#koenVacancy_navi").parent().parent() );
		$("#koenTab").addClass("line"+index);
	}

	if(document.getElementById("koenMedia")){
		document.getElementById("koenMedia_navi").src = "/images/sche/btn_koen05_on.gif";
		$("#koenMedia_navi").removeClass("imgover");
		overPath = "_on";
		
		var index = $("#koenTab li").index( $("#koenMedia_navi").parent().parent() );
		$("#koenTab").addClass("line"+index);
	}
	
	if(document.getElementById("koenSp")){
		document.getElementById("koenSp_navi").src = "/images/sche/btn_koen06_on.gif";
		$("#koenSp_navi").removeClass("imgover");
		overPath = "_on";
		
		var index = $("#koenTab li").index( $("#koenSp_navi").parent().parent() );
		$("#koenTab").addClass("line"+index);
	}



	if(document.getElementById("floorMain")){
		document.getElementById("floorMain_navi").src = "/images/guide/btn_floor01_on.gif";
		$("#floorMain_navi").removeClass("imgover");
		overPath = "_on";
	}


	if(document.getElementById("floorDrama")){
		document.getElementById("floorDrama_navi").src = "/images/guide/btn_floor02_on.gif";
		$("#floorDrama_navi").removeClass("imgover");
		overPath = "_on";
	}


	
	
var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, overPath+ftype);
			//hsrc = 'over' + hsrc;

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace(overPath+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

addEvent(window, 'load', initRollovers, false);








/* スクロール
---------------------------------------------------- */



/* Smooth scrolling
   Changes links that link to other parts of this page to scroll
   smoothly to those links rather than jump to them directly, which
   can be a little disorienting.
   
   sil, http://www.kryogenix.org/
   
   v1.0 2003-11-11
   v1.1 2005-06-16 wrap it up in an object
*/

var ss = {
  fixAllLinks: function() {
    // Get a list of all links in the page
    var allLinks = document.getElementsByTagName('a');
    // Walk through the list
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if ((lnk.href && lnk.href.indexOf('#') != -1) && 
          ( (lnk.pathname == location.pathname) ||
	    ('/'+lnk.pathname == location.pathname) ) && 
          (lnk.search == location.search)) {
        // If the link is internal to the page (begins in #)
        // then attach the smoothScroll function as an onclick
        // event handler
        ss.addEvent(lnk,'click',ss.smoothScroll);
      }
    }
  },

  smoothScroll: function(e) {
    // This is an event handler; get the clicked on element,
    // in a cross-browser fashion
    if (window.event) {
      target = window.event.srcElement;
    } else if (e) {
      target = e.target;
    } else return;

    // Make sure that the target is an element, not a text node
    // within an element
    if (target.nodeName.toLowerCase() != 'a') {
      target = target.parentNode;
    }
  
    // Paranoia; check this is an A tag
    if (target.nodeName.toLowerCase() != 'a') return;
  
    // Find the <a name> tag corresponding to this href
    // First strip off the hash (first character)
    anchor = target.hash.substr(1);
    // Now loop all A tags until we find one with that name
    var allLinks = document.getElementsByTagName('a');
    var destinationLink = null;
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if (lnk.name && (lnk.name == anchor)) {
        destinationLink = lnk;
        break;
      }
    }
    if (!destinationLink) destinationLink = document.getElementById(anchor);

    // If we didn't find a destination, give up and let the browser do
    // its thing
    if (!destinationLink) return true;
  
    // Find the destination's position
    var destx = destinationLink.offsetLeft; 
    var desty = destinationLink.offsetTop;
    var thisNode = destinationLink;
    while (thisNode.offsetParent && 
          (thisNode.offsetParent != document.body)) {
      thisNode = thisNode.offsetParent;
      destx += thisNode.offsetLeft;
      desty += thisNode.offsetTop;
    }
  
    // Stop any current scrolling
    clearInterval(ss.INTERVAL);
  
    cypos = ss.getCurrentYPos();
  
    ss_stepsize = parseInt((desty-cypos)/ss.STEPS);
    ss.INTERVAL =
setInterval('ss.scrollWindow('+ss_stepsize+','+desty+',"'+anchor+'")',10);
  
    // And stop the actual click happening
    if (window.event) {
      window.event.cancelBubble = true;
      window.event.returnValue = false;
    }
    if (e && e.preventDefault && e.stopPropagation) {
      e.preventDefault();
      e.stopPropagation();
    }
  },

  scrollWindow: function(scramount,dest,anchor) {
    wascypos = ss.getCurrentYPos();
    isAbove = (wascypos < dest);
    window.scrollTo(0,wascypos + scramount);
    iscypos = ss.getCurrentYPos();
    isAboveNow = (iscypos < dest);
    if ((isAbove != isAboveNow) || (wascypos == iscypos)) {
      // if we've just scrolled past the destination, or
      // we haven't moved from the last scroll (i.e., we're at the
      // bottom of the page) then scroll exactly to the link
      window.scrollTo(0,dest);
      // cancel the repeating timer
      clearInterval(ss.INTERVAL);
      // and jump to the link directly so the URL's right
      location.hash = anchor;
    }
  },

  getCurrentYPos: function() {
    if (document.body && document.body.scrollTop)
      return document.body.scrollTop;
    if (document.documentElement && document.documentElement.scrollTop)
      return document.documentElement.scrollTop;
    if (window.pageYOffset)
      return window.pageYOffset;
    return 0;
  },

  addEvent: function(elm, evType, fn, useCapture) {
    // addEvent and removeEvent
    // cross-browser event handling for IE5+,  NS6 and Mozilla
    // By Scott Andrew
    if (elm.addEventListener){
      elm.addEventListener(evType, fn, useCapture);
      return true;
    } else if (elm.attachEvent){
      var r = elm.attachEvent("on"+evType, fn);
      return r;
    } else {
      alert("Handler could not be removed");
    }
  } 
}

ss.STEPS = 25;

ss.addEvent(window,"load",ss.fixAllLinks);









/* ドロップダウンメニュー
---------------------------------------------------- */



$(function(){
	$("ul#mainNav li").hover(function(){
		$("> ul:not(:animated)" , this).animate({
			height : "toggle",
			opacity : "toggle"
		}, 300 );

		if (typeof document.documentElement.style.maxHeight != "undefined") {

		} else { //IE6
			$("ul#mainNav li").bgiframe(); //jquery.bgiframe.min.jsを選択エリアに適用
		}
	},
	function(){
		$("> ul" , this).fadeOut("slow");
	});
});






/* 外部リンクアイコン
---------------------------------------------------- */


  $(function() {

   
   $("a.blank").each( function() {
    
	var img = $(this).find("img");
	
	if ( img.length == 0 ) {
    	$(this).after('<img src="/images/share/icon_outlink.gif" width="15" height="11" />');
	}
	
   });
   

   //$("a.blank").after('<img src="/images/share/icon_outlink.gif" width="15" height="11" />');

  });
  
  
  
  
  
  // target blank window

window.onload=autoPOP;

function autoPOP()
{
	var x = document.getElementsByTagName('a');
	for (var i=0;i<x.length;i++)
	{
		if (x[i].getAttribute('className') == 'blank' || x[i].getAttribute('class') == 'blank')
		{
			x[i].target = '_blank';
		}
	}
};
  



  /* 新着一覧背景色
---------------------------------------------------- */

$(function(){
	$('#secondmain #listBack dl:even').addClass('box');
});




  /* 最後の行だけボーダーなし
---------------------------------------------------- */
$(function(){
	
	var bodyid = $("body").attr("id");
	
	if ( bodyid == "top" || bodyid == "ticket") {
		$("#campaign .push:last").addClass("noBorder");
	}
	
});


/* moviePlayer
---------------------------------------------------- */

var mp_moviePlayerCount = 1;

function movieInc( flv, w, h, flv_l, w2, h2 ) {
	
	if ( !w ) w = 220;
	if ( !h ) h = 190;
	
	var mp_name = "mpContainer" + mp_moviePlayerCount;
	
	this.document.write('<div>');
	this.document.write('<div id="' + mp_name + '">');
	this.document.write('動画を再生するにはFlashPlayer9以上が必要です。');
	this.document.write('</div>');
	this.document.write('</div>');
	
	swfobject.embedSWF("/swf/movieplayer.swf", mp_name, w, h, "9", "/swf/expressInstall.swf", { flvFile: flv, flvFile_l:flv_l, width_l:w2, height_l:h2 }, { menu : false, wmode: "opaque" } );
	
	mp_moviePlayerCount++;
	
}


/* moviePlayer 拡大表示用
---------------------------------------------------- */
function movieInc2() {
	
	var temp = location.search.substr( 1 ).split("&");
	var flv = temp[0];
	var w = temp[1];
	var h = temp[2];
	
	var mp_name = "mpContainer" + mp_moviePlayerCount;
	
	this.document.write('<div id="' + mp_name + '">');
	this.document.write('動画を再生するにはFlashPlayer9以上が必要です。');
	this.document.write('</div>');
	
	swfobject.embedSWF("/swf/movieplayer.swf", mp_name, w, h, "9", "/swf/expressInstall.swf", { flvFile: flv }, { menu : false, wmode: "opaque" } );
	
	mp_moviePlayerCount++;
	
}

function openMoviePlayer( flv, w, h ) {
	
	if ( !w ) w = 480;
	if ( !h ) h = 385;
	
	w2 = w + 60;
	h2 = h + 100;
	
	$.colorbox({href:"/common/movieplayer.html?"+flv+"&"+w+"&"+h,width:w2, height:h2,iframe:true});
	
}





/* firefox　印刷用
---------------------------------------------------- */


var firefox = (navigator.userAgent.indexOf("Firefox") != -1)? true : false;
if(firefox) document.write('<link rel="stylesheet" type="text/css" media="print" href="/common/css/print_fx.css" />');





/* 画像のみ右クリック禁止
---------------------------------------------------- */


$(function(){
$("img").bind("contextmenu",function(e){
return false;
});
});






