/*===================================================
*
*	Common Script
*	Site http://www.unitedcinemas.jp
*	Last Update 2007-08-22
*
====================================================*/

/*--------------------------------------------------
[theater select config]
--------------------------------------------------*/
var $theater = {
	1  : "otsu",
	2  : "kanazawa",
	3  : "sapporo",
	4  : "niigata",
	5  : "kishiwada",
	6  : "inazawa",
	7  : "fukuoka",
	8  : "agui",
	9  : "nagasaki",
	10 : "iruma",
	11 : "toshimaen",
	12 : "canalcity",
	13 : "nakama",
	14 : "toyohashi",
	15 : "shinsei",
	16 : "toyosu",
	17 : "maebashi",
	18 : "kamisato",
	19 : "urawa",
	20 : "kasukabe",
	21 : "minamifuruya"
};

/*--------------------------------------------------
[image Hover]

xxx.gif     // Normal
xxx_ov.gif  // hover

<img src="xxx.gif" alt="xxx" class="hoverImg" />

--------------------------------------------------*/

$hover = {
	init: function() {
		$('IMG.hoverImg')
			.bind('mouseover', this.enter)
			.bind('mouseout', this.exit)
			.each(this.preload);
	},

	preload: function() {
		this.preloaded = new Image;
		this.preloaded.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_ov$2");
	},

	enter: function() {
		this.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_ov$2");
	},

	exit: function() {
		this.src = this.src.replace(/^(.+)_ov(\.[a-z]+)$/, "$1$2");
	}
};

/*--------------------------------------------------
move banner
--------------------------------------------------*/
function bannerSCHD(){

//バナーの設定
	var move_page    = ["scheduleWeek","scheduleDay"]; //動くバナーのページのbodyタグのclassを設定
	var no_move_page = [ ];                   //固定バナーのページのbodyタグのclassを設定

	var image_path  = "/nine/images/move_banner.jpg"; //バナー画像のパス
	var image_alt   = "「NINE」3月19日（金）公開 詳細はこちら";            //バナー画像のalt 
	var image_width = 120;                             //画像の横幅
	var link_url    = "nine/index.html?from=bnr";        //バナーのリンク先
	var target_win  = "_self";        //ターゲット（_blank or _self）


	var swf = {
		path: "/nine/images/move_banner.jpg",
		name: "percy",
		ver : '7',
		bgcolor: "#000000",
		height: 240,
		width: image_width
	};
	swf = undefined;	// Flashを使わないときはコメントを外す

	//バナーの設定ここまで。ここからメイン処理

	var is_move = false;
	for(i=0;i<move_page.length;i++){
		if( $("body." + move_page[i]).size() ) is_move = true;
	}

	var is_no_move = false;
	for(i=0;i<no_move_page.length;i++){
		if( $("body." + no_move_page[i]).size() ) is_no_move = true;
	}

	if(is_move == false && is_no_move == false) return;

	var html = '<div id="moveBannerImage">';
	html += '<a href="' + link_url + '"><img src="' + image_path + '" alt="' + image_alt + '" /></a>';
	html += '</div>';
	var scrollTop  = document.body.scrollTop  || document.documentElement.scrollTop;
	
	$("#wrapper").append(html).css("position","relative");
	image_width += 20;
	$("#moveBannerImage").css( {
		"position": "absolute",
		"top": "10px",
		"right": "-" + image_width + "px",
		"margin-top": "3px"
		}
	);

// for Flash
if (typeof swf != 'undefined') {
	var so = new SWFObject(swf.path, swf.name, swf.width, swf.height, swf.ver, swf.bgcolor);
	so.useExpressInstall('/fla/expressinstall.swf');
	so.addParam("wmode","transparent");
	so.write("moveBannerImage");
}

	if(is_move) moveBanner();
}

function moveBanner() {
	var targetPos = document.body.scrollTop  || document.documentElement.scrollTop;
	var initPos = $("#moveBannerImage").offset().top;
	if (targetPos != initPos) {
		var movePos = initPos + ( (targetPos - initPos) / 6 );
		if($.browser.msie) movePos += 1;
		$("#moveBannerImage").css("top",movePos + "px");
	}
	setTimeout('moveBanner()',"20");
}


/*--------------------------------------------------
onload function
--------------------------------------------------*/

$(function(){
	$hover.init();

	bannerSCHD();

	//theater jump
	$('#theaterSelect').change(function(){
		tid = this.value;
		location.href = "http://" + document.domain + "/" + $theater[tid] + "/index.html";
	});
	
	if(navigator.userAgent.indexOf("Netscape")==-1)
		$('.JsMarquee').wrap('<marquee scrollamount="4" truespeed=""></marquee>');
});


/*--------------------------------------------------
old function
--------------------------------------------------*/

function openWinX(w, h) {
	if (screen.width < w)
		w = screen.width;
	if (screen.height < h)
		h = screen.height;
	w = w? w: 600;
	h = h? h: 600;

	subWin = window.open("","text", "toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+w+",height="+h);
}
//2009/5/11 aoyagi added
function openWinVideo(w, h,url) {
	if (screen.width < w)
		w = screen.width;
	if (screen.height < h)
		h = screen.height;
	w = w? w: 600;
	h = h? h: 600;
	subWin = window.open(url,"text", "toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+w+",height="+h);
}

function openWin()
{subWin = window.open("","text","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=600");}
function openWin2()
{subWin = window.open("","text2","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=420,height=460");}
function openWin3()
{subWin = window.open("","text3","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=480,height=280");}
function openWin4()
{subWin = window.open("","text4","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=480,height=220");}
function openWin5()
{subWin = window.open("","text5","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=530,height=540");}
function openWin6()
{subWin = window.open("","job","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=540,height=600");}
function openWin7()
{subWin = window.open("","text3","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=500,height=350");}
function openWin8()
{subWin = window.open("","text6","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=540,height=420");}
function openWin9()
{subWin = window.open("","text9","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=630,height=420");}
function OpenWin20(url)
{window.open(url,"page","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=570,height=600");}
function OpenWin9(url)
{window.open(url,"page","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=600");}
function openWin10()
{subWin = window.open("","text10","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=620,height=680");}
function openWin20()
{subWin = window.open("","text","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=660,height=600");}
function openWin30()
{subWin = window.open("","sincity","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=810");}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//2009/5/14 send vars to flash(base.swf)
function separator(){
	var thisPage = this.location.href
	a = thisPage.split("/");
	currentAddress = "/"+a[3];	
	if(a[3] == undefined ||a[3] == "index.html"){
	currentAddress = "/top";	
	}
}
