//トップのランダム画像
function PickUpClick(num){
	num=num;
	location.href = "rooms.htm?"+num;
}

//トップのランダム画像
function PickUp(){
var imglist = new Array("205","208","212","216");
var selectnum = Math.floor((Math.random() * 100)) % imglist.length;
var output = '<a href="javascript:PickUpClick('+imglist[selectnum]+')"><img src="img/top/pickup_' + imglist[selectnum] + '.jpg" border="0"></a>';
document.write(output);
}


//■サブウィンドウを開く処理
function OpenW(url){
subw=window.open(url, "rooms","width=600,height="+screen.height+",scrollbars=yes,resizable=yes,status=yes");
}
//親ウインドウが閉じると子ウインドウも閉じる
function subclose(){
if(window.subw)subw.close();
}
window.onunload = subclose;

//■子ウインドウのリンクを親ウインドウに
function mLink(url){
if(!window.opener || window.opener.closed){ //親ウィンドウの存在をチェック
window.alert('メインウィンドウがありません'); //存在しない場合は警告ダイアログを表示
}
else{
window.opener.location.href = url; //存在する場合はページを切りかえる
}
//リンクと同時に子ウインドウを閉じる
window.close();
}

//コピー
function year(){
myD=new Date();
myY=myD.getYear();
myYear=(myY<2000)?myY+1900:myY;
document.write("Copyright &copy; "+myYear+" AVANZA. AllRightReserved.");
}

//メール収集ロボット回避用
function mailto(add){
	document.write('<a href="mailto:',add,'@','hotel-avanza','.com','">',add,'@','hotel-avanza','.com</a>');
}

//リンクの枠線を出さない
function noOutline() {
 var blur = function () { this.blur() };
 for (var i = 0; i < document.links.length; i++){
  document.links[i].onfocus = blur;
	}
}
window.onload=noOutline;

//URLからファイル名を取得
function GetFileName(file_url){
 file_url = file_url.substring(file_url.lastIndexOf("/")+1,file_url.length);//最後のスラッシュ以降の文字を取得
 file_url = file_url.substring(0,file_url.indexOf("."));//拡張子を取り除く
 return file_url;
}

//部屋の号数表示
function roomNum(){
 document.write('<img src="img/rooms/num/'+GetFileName(location.href)+'.gif">');
}

//部屋の写真表示
function roomImg(){
 document.write('<img name="photo" src="img/rooms/room/'+GetFileName(location.href)+'.jpg" galleryimg="no">')
}

function BathBtn(){
	var n =GetFileName(location.href);
	if(n=='201'||n=='205'||n=='207'||n=='211'||n=='305'||n=='307'||n=='308'||n=='311'){
		document.write('<tr>',
                 '<td colspan="2" id="btn_bath" align="right"><img src="img/rooms/btn_bath.gif" onmouseover="ImgChange(1)" onmouseout="ImgChange(0)" style="cursor:pointer;"></td>',
                 '</tr>');
	}
}

function ImgChange(photoFlg){
	if(photoFlg){
		window.document.images["photo"].src  = 'img/rooms/bath/'+GetFileName(location.href)+'.jpg';
	}else{
		window.document.images["photo"].src  = 'img/rooms/room/'+GetFileName(location.href)+'.jpg';
	}
}

//次・前の部屋へのリンク
function NextLink(){
	if(GetFileName(location.href) == '203' || GetFileName(location.href) == '213' || GetFileName(location.href) == '303' || GetFileName(location.href) == '313'){
  document.write('<a href="'+(Number(GetFileName(location.href))+2)+'.htm">'+(Number(GetFileName(location.href))+2)+'号室へ</a>');
 }else if(GetFileName(location.href) == '216'){
		document.write('<a href="'+(Number(GetFileName(location.href))+87)+'.htm">'+(Number(GetFileName(location.href))+87)+'号室へ</a>');
 }else if(GetFileName(location.href) == '316'){
		document.write('');
	}else{
		document.write('<a href="'+(Number(GetFileName(location.href))+1)+'.htm">'+(Number(GetFileName(location.href))+1)+'号室へ</a>');
	}
}
function PrevLink(){
	if(GetFileName(location.href) == '205' || GetFileName(location.href) == '215' || GetFileName(location.href) == '305' || GetFileName(location.href) == '315'){
  document.write('<a href="'+(Number(GetFileName(location.href))-2)+'.htm">'+(Number(GetFileName(location.href))-2)+'号室へ</a>');
 }else if(GetFileName(location.href) == '201'){
		document.write('');
 }else if(GetFileName(location.href) == '303'){
		document.write('<a href="'+(Number(GetFileName(location.href))-87)+'.htm">'+(Number(GetFileName(location.href))-87)+'号室へ</a>');
	}else{
		document.write('<a href="'+(Number(GetFileName(location.href))-1)+'.htm">'+(Number(GetFileName(location.href))-1)+'号室へ</a>');
	}
}

//TRの色を交互に変える
function setTableColor(){
	targetTable=document.getElementById('specialItem');
	targetTr=targetTable.getElementsByTagName('TR');
	for(i=0; i<targetTr.length; i++){
		TrColor = (i%2) ? "#999999":"#cccccc";
		targetTr[i].setAttribute("bgColor",TrColor);
	}
}

//当月末日を取得
function Edate() {
    var dt;
    dt = new Date();
    dt.setMonth(dt.getMonth() + 2);
    dt.setDate(0);              // 0指定でsetDateすると前月末日がとれる 
    // 年月日に分解
    var    y = dt.getFullYear();
    var    m = dt.getMonth() + 1;
    var    d = dt.getDate();

    // 表示
    document.write (y+"年"+m+"月"+d+"日");
}