/*
filename:function.js
UPDATE:20090529
*/
/**
* フラッシュのjs読み込み関数
* @param {Number} flaurl フラッシュファイルのパス
* @param {Number} flawidth　横幅
* @param {Number} flaheigth　縦幅
*/
function flashImport( flaurl, flawidth, flaheigth){
	flashdoc = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+flawidth+'" height="'+flaheigth+'">';
	flashdoc += '<param name="movie" value="'+flaurl+'">';
	flashdoc += '<param name="quality" value="high">';
	flashdoc += '<param name="wmode"value="transparent" />';
	flashdoc += '<embed src="'+flaurl+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+flawidth+'" height="'+flaheigth+'"></embed>';
	flashdoc += '</object>';
	document.write(flashdoc);
}


/**
 * OS判別でwindows or mac 個別のCSSを読み込む
 */
function includeCss(){
	if(navigator.userAgent.indexOf("Win") != -1 ){
		// Windows系OSでのみ実行されるスクリプト
		document.write('<link href="/css/windows.css" rel="stylesheet" type="text/css" media="all" />');
	}
	if(navigator.userAgent.indexOf("Mac") != -1 ){
		// MacOSでのみ実行されるスクリプト
		document.write('<link href="/css/mac.css" rel="stylesheet" type="text/css" media="all" />');
	}
}

$(document).ready(function(){

		//各テーブルの背景交互指定
		/*
		$(".tbl1 tr:odd").addClass("tbl1-th-odd");
		$(".tbl1 tr:odd").addClass("tbl1-td-odd");
		$(".tbl1 tr:even").addClass("tbl1-th-even");
		$(".tbl1 tr:even").addClass("tbl1-td-even");

		$(".tbl2 tr:odd").addClass("tbl2-th-odd");
		$(".tbl2 tr:odd").addClass("tbl2-td-odd");
		$(".tbl2 tr:even").addClass("tbl2-th-even");
		$(".tbl2 tr:even").addClass("tbl2-td-even");
		*/
});

//font size を指定するjavascript
function fontSizeLoad(fontStyle){

	var url = retHost();
	
	var img_s = '<img src="/images/hed_btn_01.gif" alt="小" width="16" height="15" onclick="fontSizeCookie(\'small\')" />';
	var img_m = '<img src="/images/hed_btn_02.gif" alt="中" width="16" height="15" onclick="fontSizeCookie(\'medium\')" />';
	var img_l = '<img src="/images/hed_btn_03.gif" alt="大" width="16" height="15" onclick="fontSizeCookie(\'large\')" />';
							
	var img_s_on = '<img src="/images/hed_btn_01_on.gif" alt="小" width="16" height="15" onclick="fontSizeCookie(\'small\')" />';
	var img_m_on = '<img src="/images/hed_btn_02_on.gif" alt="中" width="16" height="15" onclick="fontSizeCookie(\'medium\')" />';
	var img_l_on = '<img src="/images/hed_btn_03_on.gif" alt="大" width="16" height="15" onclick="fontSizeCookie(\'large\')" />';
	
	//f-size-s.l
	$("body").removeClass("f-size-s f-size-l");
	switch (fontStyle){
		case "small":
			$("#small").html(img_s_on);
			$("#large").html(img_l);
			$("#medium").html(img_m);
			$("body").addClass("f-size-s");
			break;
		case "large":
			$("#small").html(img_s);
			$("#large").html(img_l_on);
			$("#medium").html(img_m);
			$("body").addClass("f-size-l");
			break;
		case "medium":
		default:
			$("#small").html(img_s);
			$("#large").html(img_l);
			$("#medium").html(img_m_on);
			break;
	}
}
//ホスト名をリターン
function retHost(){
		var pro = location.protocol;
		var host= location.hostname;
		var url = pro + "//" + host + "/";
		return url;
}
//クリック時
function fontSizeCookie(fontStyle){
	$.cookie('fontSize', fontStyle, {path:'/'});
	fontSizeLoad( fontStyle);
}
//ロード時
$(document).ready(function(){
	var fontStyle = $.cookie('fontSize');
	if( fontStyle == null){ fontStyle = "medium";}
	fontSizeLoad( fontStyle);
});

//画像マウスオーバー・アウト用
function hover( myObj, img){
	myObj.src = img;
}

// 送信用
function formSubmit( form_name){
		document.forms[form_name].submit();
}

// 送信用 戻る
function formMode( form_name, mode){
		$("#mode").attr({value:mode});
		document.forms[form_name].submit();
}


/*** ポップアップ ***/
function openPopWin(htmlurl) {
　　window.open(htmlurl, "openPopWin","scrollbars,toolbar=no,width=500,height=700");
}
function openPopWin2(htmlurl) {
　　window.open(htmlurl, "openPopWin","scrollbars,toolbar=no,width=700,height=700");
}

/** 別窓 **/
function openWin( page, width, height){
		var param = "width="+width+",height="+height+",menubar=no,stoolbar=no,tatus=no,resizable=yes,scrollbars=yes";
		var wObj = window.open( page, "new", param);
}

/** マンガページ別窓 **/
function mangaWin( page){
		var param = "width=550,height=580,menubar=no,stoolbar=no,tatus=no,resizable=yes,scrollbars=yes";
		var wObj = window.open("/manga.html?page="+page, "ma", param);
		wObj.focus();
}
/** 動画再生ページ別窓 **/
function movieWin( movie){
		var param = "width=530,height=580,menubar=no,stoolbar=no,tatus=no,resizable=yes,scrollbars=no";
		var wObj = window.open("/movie.html?movie="+movie, "mv", param);
		wObj.focus();
}
function movieWideWin( movie){
		var param = "width=500,height=590,menubar=no,stoolbar=no,tatus=no,resizable=yes,scrollbars=no";
		var wObj = window.open("/movie_wide.html?movie="+movie, "mvw", param);
		wObj.focus();
}

/** 時間取得関数 **/
function setTimes(){
		myTbl     = new Array("日","月","火","水","木","金","土");
		myD       = new Date();

		myYear    = myD.getYear();
		myYear4   = (myYear < 2000) ? myYear+1900 : myYear;
		myMonth   = myD.getMonth() + 1;
		myDate    = myD.getDate();
		myDay     = myD.getDay();
		myHours   = myD.getHours();
		myMinutes = myD.getMinutes();
		mySeconds = myD.getSeconds();

		myMess1 = myYear4 + "年" + myMonth + "月" + myDate + "日" + myTbl[myDay] + "曜日";
		myMess2 = myHours + "時" + myMinutes + "分" + mySeconds + "秒";
		document.form1.date_ymd.value = myMess1;
		document.form1.date_hms.value = myMess2;
}


/*** Bookクラス ***/
var Book = function( mid, tid, pri, mpri){
	this.my_id = mid;//html input id
	this.tr_id = tid;//html target id
	this.price = pri;//料金
	this.member_price = mpri;//会員料金
	this.numbers;//個数
	this.sums;//合計

	this.setup();
}
Book.prototype = {
	setup: function(){
	},
	sum: function(){
		//入力個数の型チェック
		this.numbers = $("#"+this.my_id).val();
		if(this.numbers.match(/[^0-9]+/)){
			this.numbers = 0;
			$("#"+this.my_id+"_err").html("<br />※半角数字を<br />入力して下さい。");
		} else {
			$("#"+this.my_id+"_err").html("");
		}
		if( $("#member_check1").attr("checked") == true){
			this.sums = this.numbers * this.price;
		}
		if( $("#member_check2").attr("checked") == true){
			this.sums = this.numbers * this.member_price;
		}
		if( this.sums == 0){
			this.sums = "0";
		}
	},
	setsum: function(){
		this.sum();
		$("#"+this.tr_id).html( this.sums);
	}
}
/*** Bookクラス ***/

