﻿MJL.event.add(window, "load", function() {
    MJL.enable.window("popup1", { width : 720 });
	MJL.enable.window("popup2", { width : 846 });
	MJL.enable.window("popup3", { width : 910 });
    MJL.enable.rollover("roll", { disable : "unroll" });
	MJL.enable.rollover("list-btn-01", { disable : "unroll" });
	MJL.enable.rollover("list-btn-02", { disable : "unroll" });
	MJL.enable.rollover("list-btn-03", { disable : "unroll" });
	MJL.enable.rollover("list-btn-04", { disable : "unroll" });
	MJL.enable.rollover("btn-contact", { disable : "unroll" });
	MJL.enable.rollover("box-index-02", { disable : "unroll" });
	MJL.enable.rollover("nav-utility");
	MJL.enable.rollover("nav-pagetop");
	MJL.enable.rollover("nav-tab-01", { disable : "current" });
	MJL.enable.rollover("nav-01", { disable : "current" });
	
	MJL.enable.heightEqualizer("equalize");
	MJL.enable.heightEqualizer("col2",{groupBy:2});
	MJL.enable.heightEqualizer("col3",{groupBy:3});
	MJL.enable.heightEqualizer("col4",{groupBy:4});
	MJL.enable.heightEqualizer("col5",{groupBy:5});
	MJL.enable.heightEqualizer("col6",{groupBy:6});
	MJL.enable.heightEqualizer("list-flowed1");
	MJL.enable.heightEqualizer("img-col2",{groupBy:2});
	MJL.enable.heightEqualizer("img-col3",{groupBy:3});
	MJL.enable.heightEqualizer("img-col4",{groupBy:4});
	MJL.enable.heightEqualizer("hsep1");
	MJL.enable.heightEqualizer("hsep2");
	MJL.enable.heightEqualizer("hsep3");
	MJL.enable.heightEqualizer("hsep4");
	
	
	
	MJL.enable.heightEqualizer("lyt-column2",{groupBy:2,collect:function(parent) {return MJL.getElementsByClassName(parent, "group-equalize1");}});
	MJL.enable.heightEqualizer("lyt-column2",{groupBy:2,collect:function(parent) {return MJL.getElementsByClassName(parent, "group-equalize2");}});
	MJL.enable.heightEqualizer("lyt-column2",{groupBy:2,collect:function(parent) {return MJL.getElementsByClassName(parent, "group-equalize3");}});
	MJL.enable.heightEqualizer("lyt-column2",{groupBy:2,collect:function(parent) {return MJL.getElementsByClassName(parent, "group-equalize4");}});
	MJL.enable.heightEqualizer("lyt-column2",{groupBy:2,collect:function(parent) {return MJL.getElementsByClassName(parent, "seg1");}});
	MJL.enable.heightEqualizer("lyt-column2",{groupBy:2,collect:function(parent) {return MJL.getElementsByClassName(parent, "seg2");}});
	MJL.enable.heightEqualizer("lyt-column2",{groupBy:2,collect:function(parent) {return MJL.getElementsByClassName(parent, "seg3");}});
	MJL.enable.heightEqualizer("lyt-column2",{groupBy:2,collect:function(parent) {return MJL.getElementsByClassName(parent, "seg4");}});
	MJL.enable.heightEqualizer("lyt-column2",{groupBy:2,collect:function(parent) {return MJL.getElementsByClassName(parent, "seg5");}});
	MJL.enable.heightEqualizer("lyt-column2",{groupBy:2,collect:function(parent) {return MJL.getElementsByClassName(parent, "seg6");}});
	MJL.enable.heightEqualizer("lyt-column3",{groupBy:3,collect:function(parent) {return MJL.getElementsByClassName(parent, "group-equalize1");}});
	MJL.enable.heightEqualizer("lyt-column3",{groupBy:3,collect:function(parent) {return MJL.getElementsByClassName(parent, "group-equalize2");}});
	MJL.enable.heightEqualizer("lyt-column3",{groupBy:3,collect:function(parent) {return MJL.getElementsByClassName(parent, "group-equalize3");}});
	MJL.enable.heightEqualizer("lyt-column3",{groupBy:3,collect:function(parent) {return MJL.getElementsByClassName(parent, "group-equalize4");}});
	MJL.enable.heightEqualizer("lyt-column3",{groupBy:3,collect:function(parent) {return MJL.getElementsByClassName(parent, "seg1");}});
	MJL.enable.heightEqualizer("lyt-column3",{groupBy:3,collect:function(parent) {return MJL.getElementsByClassName(parent, "seg2");}});
	MJL.enable.heightEqualizer("lyt-column3",{groupBy:3,collect:function(parent) {return MJL.getElementsByClassName(parent, "seg3");}});
	MJL.enable.heightEqualizer("lyt-column3",{groupBy:3,collect:function(parent) {return MJL.getElementsByClassName(parent, "seg4");}});
	MJL.enable.heightEqualizer("lyt-column3",{groupBy:3,collect:function(parent) {return MJL.getElementsByClassName(parent, "seg5");}});
	MJL.enable.heightEqualizer("lyt-column3",{groupBy:3,collect:function(parent) {return MJL.getElementsByClassName(parent, "seg6");}});
	
	MJL.enable.heightEqualizer("lyt-column2",{
		groupBy:2,
		collect:function(parent) {
			return MJL.getElementsByClassName(parent, "box-em-02");
		}
	});
	
	MJL.enable.heightEqualizer("lyt-column3",{
		groupBy:3,
		collect:function(parent) {
			return MJL.getElementsByClassName(parent, "box-em-02");
		}
	});
	
	MJL.enable.heightEqualizer("lyt-column2",{
		groupBy:2,
		collect:function(parent) {
			return MJL.getElementsByClassName(parent, "box-index-01");
		}
	});
	
	MJL.enable.heightEqualizer("lyt-column3",{
		groupBy:3,
		collect:function(parent) {
			return MJL.getElementsByClassName(parent, "box-index-01");
		}
	});
	
	MJL.enable.heightEqualizer("lyt-column2",{
		groupBy:2,
		collect:function(parent) {
			return MJL.getElementsByClassName(parent, "box-01");
		}
	});
	
	MJL.enable.heightEqualizer("lyt-column2",{
		groupBy:2,
		collect:function(parent) {
			return MJL.getElementsByClassName(parent, "block-index-01");
		}
	});
	
	MJL.enable.heightEqualizer("box-closeup-01",{
		groupBy:2,
		collect:function(parent) {
			return MJL.getElementsByClassName(parent, "col-content");
		}
	});
	
		
	MJL.enable.heightEqualizer("nav-sitemap",{
		groupBy:5,
        collect:function(parent) {
            return MJL.convArray(parent.getElementsByTagName("dt"));
        }
    });
	
	MJL.enable.heightEqualizer("block-lead-01",{
		groupBy:3,
        collect:function(parent) {
            return MJL.convArray(parent.getElementsByTagName("li"));
        }
    });
	
	MJL.enable.heightEqualizer("tbl-property-02",{
		groupBy:2,
        collect:function(parent) {
            return MJL.getElementsByClassName(parent, "data");
        }
    });
	
	MJL.enable.heightEqualizer("dir",{
		groupBy:2,
		collect:function(parent) {
			return MJL.getElementsByClassName(parent, "segment");
		}
	});

	
});


// Image Layout
// ------------------------------------------------------------------------------

$(function(){
$('p.lyt-image').each(function(){
	var obj = $(this);
	var imgWidth = $('img', obj).outerWidth();
	if (imgWidth > 0){
		imgWidth = imgWidth;    // 画像のborder,paddingを含めた値
		$(this).css('width', imgWidth);
		}
	});
});

$(function(){
$('ul.lyt-image li').each(function(){
	var obj = $(this);
	var imgWidth = $('p img', obj).outerWidth();
	if (imgWidth > 0){
		imgWidth = imgWidth;    // 画像のborder,paddingを含めた値
		$('p', obj).css('width', imgWidth);
		}
	});
});

$(function(){
$('div.lyt-image').each(function(){
	var obj = $(this);
	var imgWidth = $('div.img img', obj).outerWidth();
	if (imgWidth > 0){
		imgWidth = imgWidth;    // 画像のborder,paddingを含めた値
		$('div.img', obj).css('width', imgWidth);
		}
	});
});


// Box Area
// ------------------------------------------------------------------------------

$(function(){
$('.box-area-01').each(function(){
	var obj = $(this);
	var imgHeight = $('.map img', obj).outerHeight();
	if (imgHeight > 0){
		imgHeight = imgHeight;    // 画像のborder,paddingを含めた値
		$(this).css('min-height', imgHeight);
		}
	});
});


// Search Box(Place Holder)
// ------------------------------------------------------------------------------

$(function(){
	$('#search-site input.text').val('サイト内検索').one('focus' ,function(){
		$(this).val('');
	}).blur(function(){
		if($(this).val() == ''){
			$(this).val('サイト内検索').one('focus' , function(){
				$(this).val('');										 
				});
			};
	});	   
});

// Place Holder
// ------------------------------------------------------------------------------

$(function(){
	$('input.set-station').each(function(){
		var	ph_area = $(this),
			ph_val = '六本木、など駅名を入力';
		if($(this).val() == '') $(this).val(ph_val);
	
		ph_area.focus(function () {
			if(ph_area.val() == ph_val) ph_area.val('');
		}).blur(function () {
			if(ph_area.val() == '') ph_area.val(ph_val);
		});
		ph_area.parents('form').submit(function () {
			if(ph_area.val() == ph_val) ph_area.val('');
		});
	});
});

// form
$(function(){
	$('textarea.placeholder,input.placeholder').each(function(){
		var	ph_area = $(this),
			ph_val = $(this).val();
		if($(this).val() == '') $(this).val(ph_val);
	
		ph_area.focus(function () {
			if(ph_area.val() == ph_val) ph_area.val('');
		}).blur(function () {
			if(ph_area.val() == '') ph_area.val(ph_val);
		});
		ph_area.parents('form').submit(function () {
			if(ph_area.val() == ph_val) ph_area.val('');
		});
	});
});


// Stripe Table
// ------------------------------------------------------------------------------

$(function(){
	$('table.tbl-stripe-01').each(function(){
	$('tr:odd',this).addClass('even');
	});	   		   
});

$(function(){
	$('table.tbl-link-01').each(function(){
	$('tr:odd',this).addClass('even');
	});	   		   
});


// linked Table
// ------------------------------------------------------------------------------

$(function(){
	
	$('table.tbl-property-01 tbody td').mouseover(function(){
			var obj2 = $('.list-btn-01', this);
			if(obj2.length == 0){											   
			$(this).closest("tbody").addClass('mouseover');
			};
		}).mouseout(function(){
			var obj2 = $('.list-btn-01', this);
			if(obj2.length == 0){	
			$(this).closest("tbody").removeClass();
			};
		}).click(function(){
			var obj2 = $('.list-btn-01', this);
			if(obj2.length == 0){
			window.location=$(this).closest("tbody").find('a.btn').attr('href');
        	return false;
			};
	});	
});



// Roll Over (Optional)
// ------------------------------------------------------------------------------

$(function(){
	$(".box-contact-01 p.btn a").mouseover(function(){
	var obj = $(this);
    	$('img',obj).attr("src",$('img',obj).attr("src").replace(/^(.+)(\.[a-z]+)$/,"$1_o$2"));
			return false;
	}).mouseout(function(){
	var obj = $(this);
 	   $('img',obj).attr("src",$('img',obj).attr("src").replace(/^(.+)_o(\.[a-z]+)$/,"$1$2"));
			return false;
	}).each(function(){
	var obj = $(this);
        $("<img>").attr("src",$('img',obj).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_o$2"))
	})
	
	$(".box-contact-01 p.btn input").mouseover(function(){
	    	$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/,"$1_o$2"));
			return false;
	}).mouseout(function(){
	    	$(this).attr("src",$(this).attr("src").replace(/^(.+)_o(\.[a-z]+)$/,"$1$2"));
			return false;
	})	
	
	$(".content-title ul.utility a").mouseover(function(){
	var obj = $(this);
    	$('img',obj).attr("src",$('img',obj).attr("src").replace(/^(.+)(\.[a-z]+)$/,"$1_o$2"));
			return false;
	}).mouseout(function(){
	var obj = $(this);
 	   $('img',obj).attr("src",$('img',obj).attr("src").replace(/^(.+)_o(\.[a-z]+)$/,"$1$2"));
			return false;
	}).each(function(){
	var obj = $(this);
        $("<img>").attr("src",$('img',obj).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_o$2"))
	})
	
	
	$(".content-title ul.utility input").mouseover(function(){
    	$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/,"$1_o$2"));
			return false;
	}).mouseout(function(){
	
		$(this).attr("src",$(this).attr("src").replace(/^(.+)_o(\.[a-z]+)$/,"$1$2"));
			return false;
	})
	
	
	$(".block-contact-02 dd a").mouseover(function(){
	var obj = $(this);
    	$('img',obj).attr("src",$('img',obj).attr("src").replace(/^(.+)(\.[a-z]+)$/,"$1_o$2"));
			return false;
	}).mouseout(function(){
	var obj = $(this);
    	$('img',obj).attr("src",$('img',obj).attr("src").replace(/^(.+)_o(\.[a-z]+)$/,"$1$2"));
			return false;
	}).each(function(){
	var obj = $(this);
    	$("<img>").attr("src",$('img',obj).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_o$2"))
	})
	
	
	$(".block-contact-03 dd a").mouseover(function(){
	var obj = $(this);
    	$('img',obj).attr("src",$('img',obj).attr("src").replace(/^(.+)(\.[a-z]+)$/,"$1_o$2"));
			return false;
	}).mouseout(function(){
	var obj = $(this);
    	$('img',obj).attr("src",$('img',obj).attr("src").replace(/^(.+)_o(\.[a-z]+)$/,"$1$2"));
			return false;
	}).each(function(){
	var obj = $(this);
        $("<img>").attr("src",$('img',obj).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_o$2"))
	})
	
	
	$(".block-contact-04 dd a").mouseover(function(){
	var obj = $(this);
    	$('img',obj).attr("src",$('img',obj).attr("src").replace(/^(.+)(\.[a-z]+)$/,"$1_o$2"));
			return false;
	}).mouseout(function(){
	var obj = $(this);
    	$('img',obj).attr("src",$('img',obj).attr("src").replace(/^(.+)_o(\.[a-z]+)$/,"$1$2"));
			return false;
	}).each(function(){
	var obj = $(this);
        $("<img>").attr("src",$('img',obj).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_o$2"))
	})
	
	
	$(".block-contact-05 dd a").mouseover(function(){
	var obj = $(this);
    	$('img',obj).attr("src",$('img',obj).attr("src").replace(/^(.+)(\.[a-z]+)$/,"$1_o$2"));
			return false;
	}).mouseout(function(){
	var obj = $(this);
    	$('img',obj).attr("src",$('img',obj).attr("src").replace(/^(.+)_o(\.[a-z]+)$/,"$1$2"));
			return false;
	}).each(function(){
	var obj = $(this);
        $("<img>").attr("src",$('img',obj).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_o$2"))
	})
	
	$(".block-contact-05 dd input").mouseover(function(){
    	$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/,"$1_o$2"));
			return false;
	}).mouseout(function(){
    	$(this).attr("src",$(this).attr("src").replace(/^(.+)_o(\.[a-z]+)$/,"$1$2"));
			return false;
	})	
	
	$(".block-index-01 .img a").mouseover(function(){
	var obj = $(this);
    	$('img',obj).attr("src",$('img',obj).attr("src").replace(/^(.+)(\.[a-z]+)$/,"$1_o$2"));
			return false;
	}).mouseout(function(){
	var obj = $(this);
 	   $('img',obj).attr("src",$('img',obj).attr("src").replace(/^(.+)_o(\.[a-z]+)$/,"$1$2"));
			return false;
	}).each(function(){
	var obj = $(this);
        $("<img>").attr("src",$('img',obj).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_o$2"))
	})
	
});


// Column Layout
// ------------------------------------------------------------------------------

$(function(){
	$('.col').each(function(){
	var obj = $('.segment', this);
	for(var i = 0; i < obj.length; i++){
		obji = obj[i];
		j = i + 1
		$(obji).addClass('seg' + j);
		}
	});	
});


// tbl-list-01
// ------------------------------------------------------------------------------

$(function(){
	var tblWidth = $('body.free .tbl-list-01 table.tbl-01').outerWidth();
	var marginSides = 120;
	var winWidth = tblWidth + marginSides;
	var contentWidth = 790;

	if(tblWidth > contentWidth){
		$('body.free').css('width', winWidth);
	}
});

$(window).scroll(function() {
	var tblWidth = $('body.free .tbl-list-01 table.tbl-01').outerWidth();
	var marginSides = 120;
	var winWidth = tblWidth + marginSides;
	var contentWidth = 790;
						   
	if(tblWidth > contentWidth){
		$('body.free').css('width', winWidth);
	}
});


// Toggle
// ------------------------------------------------------------------------------

$(function(){


$('.box-toggle-01').each(function(){
	
	var objkey = $('.toggle-content', this);
								  
	$('.toggle-switch', this).click(function() {
  		$(objkey).toggle();
	});
});	



$('.toggle-content').css('display', 'none');

});


// Last Child
// ------------------------------------------------------------------------------

$(function(){
	$('.box-em-03 .box-content-main > *:last-child').addClass('last-child');
});


// ctrlWin
// ------------------------------------------------------------------------------

function ctrlWin(){
    window.opener.location.href = "/company/list/";
}

/*function ctrlWin(url){
    window.opener.location.href = url;
}*/


// Send Mail
// ------------------------------------------------------------------------------

$(function(){
	$('.lease .block-sendmail-01 :radio[name=device]').click(function(){
		var selected_divice = $(':radio[name=device]:checked').val();
		$('.input_form_block').each(function(){
			if($(this).is('.' + selected_divice)){
				$(this).show();
			}else{
				$(this).hide();
			}
		});
	});
	$('.btn input').click(function(){
		var unselected_divice = $(':radio[name=device]:not(:checked)').val();
		$('.input_form_block.' + unselected_divice).remove();
		return true;
	});
	$('.lease .block-sendmail-01 p.pc').hide();
});



// SearchArea check over
// ------------------------------------------------------------------------------
$(function(){
	var	SearchArea = $('#SearchArea'),
		SearchArea_class = $('#SearchArea').hasClass('buy'),
		SearchArea_input = $('#SearchArea > table td > input'),
		SearchArea_map_yokohama = $('#map-yokohama'),
		SearchArea_input_yokohama = $('#area18'),
		SearchArea_active = $('#SearchArea > ul');
	
	//reloadチェック
	var SearchArea_input_length = SearchArea_input.length;
	for(i=1; i<1+SearchArea_input_length ; i++){
		var	SearchArea_input_check_id = $('#SearchArea > table td:eq('+i+') > input:checked').attr('id');
		
		if(SearchArea_input_check_id == 'area18'){
			SearchArea_map_yokohama.attr('src',SearchArea_map_yokohama.attr('src').replace(/(_o)*\.png$/,'_o.png'));
			if(SearchArea_class){
				SearchArea_active.children('.area18').css('display','block');
			};
		}else{
			SearchArea_active.children('.'+SearchArea_input_check_id+'').css('display','block');
		};
	};
	
	//inputクリック
	SearchArea_input.click(function(){
		var	area_id = $(this).attr('id'),
			input = $(this),
			input_checked = $(this).attr('checked');
		
		if(area_id == 'area18'){
			if(input_checked == undefined){
				SearchArea_map_yokohama.attr('src',SearchArea_map_yokohama.attr('src').replace('_o.png','.png'));
				if(SearchArea_class){
					SearchArea_active.children('.area18').css('display','none');
				};
			}else{
				SearchArea_map_yokohama.attr('src',SearchArea_map_yokohama.attr('src').replace(/(_o)*\.png$/,'_o.png'));
				if(SearchArea_class){
					SearchArea_active.children('.area18').css('display','block');
				};
			};
		}else{
			if(input_checked == undefined){
				SearchArea_active.children('.'+area_id+'').css('display','none');
			}else{
				SearchArea_active.children('.'+area_id+'').css('display','block');
			};
		};
	});
	
	//地図クリック
	$('p > map > area',SearchArea).click(function(){
		var	SearchArea_img_src = $('p > img',SearchArea).attr('src').replace(/\/shared\/images\/img-area_kanto_01_area([0-9]+)\.png$/,'area$1');
			area_class = $(this).attr('class'),
			SearchArea_input_checked = SearchArea_input.filter('#'+area_class+'').attr('checked');
		
		if(SearchArea_input_checked == undefined){
			SearchArea_active.children('.'+area_class+'').css('display','block');
			SearchArea_input.filter('#'+area_class+'').attr('checked',true);
			if(area_class == 'area18' && SearchArea_class){
				SearchArea_map_yokohama.attr('src',SearchArea_map_yokohama.attr('src').replace(/(_o)*\.png$/,'_o.png'));
			};
		}else{
			SearchArea_active.children('.'+area_class+'').css('display','none');
			SearchArea_input.filter('#'+area_class+'').attr('checked',false);
			if(area_class == 'area18' && SearchArea_class){
				SearchArea_map_yokohama.attr('src',SearchArea_map_yokohama.attr('src').replace('_o.png','.png'));
			};
		};
		return false;
	});
	
	//横浜クリック
	SearchArea_map_yokohama.click(function(){
		var	SearchArea_input_checked = SearchArea_input_yokohama.attr('checked');
		
		if(SearchArea_input_checked == undefined){
			SearchArea_input_yokohama.attr('checked',true);
			$(this).attr('src',SearchArea_map_yokohama.attr('src').replace(/(_o)*\.png$/,'_o.png'));
			if(SearchArea_class){
				SearchArea_active.children('.area18').css('display','block');
			};
		}else{
			SearchArea_input_yokohama.attr('checked',false);
			$(this).attr('src',SearchArea_map_yokohama.attr('src').replace('_o.png','.png'));
			if(SearchArea_class){
				SearchArea_active.children('.area18').css('display','none');
			};
		}
		return false;
	});
});

// Gallery viewer
// ------------------------------------------------------------------------------

//物件詳細
$(function(){
	if(!$('.box-gallery-02').size() || $('.box-gallery-01').size()) return false;
	var thumbs_flag = 0, inside_flag = 1, outside_flag = 1;
	var inside_total, outside_total, floorplan_total, first_view;
	var floorplan = $('#floorplan'), inside = $('#gallery-inside'), outside = $('#gallery-outside');
	var photo_frame = $('.photo');
	var tboxs_str = '<div class="thumbnail-boxs"></div>';
	var tframe_str = '<div class="thumbnail-wrap"><div class="thumbnail-frame"></div></div>';
	var circle_str = '<li class="circle-nav"><a href="dummy"><img src="/shared/images/nav-gallery-01_01.png" alt="●" width="8" height="8" /></a></li>';
	
	var thumbs_total = $('li.thumbs').size();
	
	if(thumbs_total > 0) {
		
		
		
		if(thumbs_total > 1) {
			$('.group-pagination .prev a').bind('click', function () {
				(thumbs_flag == 0) ? draw_photo(thumbs_total - 1) : draw_photo(thumbs_flag - 1);
				return false;
			});
		
			$('.group-pagination .next a').bind('click', function () {
				(thumbs_flag == (thumbs_total - 1)) ? draw_photo(0) : draw_photo(thumbs_flag + 1);
				return false;
			});
			
		} else {
			$('.group-pagination .prev, .group-pagination .next').hide();
		}

		$('#thumbs-total').text(thumbs_total);
		inside_total = getthumbs_total(inside);
		outside_total = getthumbs_total(outside);
		floorplan_total = getthumbs_total(floorplan);
		
		if(inside_total > 0) gallery_func(inside);
		if(outside_total > 0) gallery_func(outside);
		
		$('.thumbs a').each( function (INDEX) {
			var _obj = $(this);
			_obj.parent().append('<span></span>');
			_obj.bind('click',function() {
				draw_photo(INDEX);
				return false;
			});
		});
		
		install();
		
	}
	
	function install() {
		(floorplan_total > 0) ? first_view = thumbs_total - floorplan_total : first_view = 0 ;
		$('.group-nav-gallery-01 .prev').hide();
		draw_photo(first_view);
		return false;
	}
	
	function gallery_func(_obj) {
			_obj.find('h3 span').text('（' + eval(get_ctegory(_obj) + '_total') + '枚）');
			var tlength = _obj.find('.thumbnail').length;
			if(tlength > 1) {
				for(var i=0; i < tlength; i++) {
					_obj.find('.pagination').append(circle_str);
				}
				
				_obj.find('.thumbnail').hide();
				
				$('.thumbnail:eq(0)', _obj).show();
				
				$('.circle-nav a', _obj).bind('click',function() {
					var this_index = $(this).index('#' + _obj[0].id + ' .circle-nav a');
					frame_move(_obj, '', this_index + 1);
					return false;
				});
				
				$('.circle-nav:eq(0) img', _obj).attr('src', '/shared/images/nav-gallery-01_01_o.png');
				
				_obj.find('.thumbs').each(function () {
					var p_index = $(this).parent().index();
					$(this).data('info', { category : get_ctegory(_obj), group: p_index });
				});
				_obj.find('.thumbnail').wrap(tboxs_str);
				_obj.find('.thumbnail-boxs').wrapAll(tframe_str);
				var fwidth = ($('.thumbnail-boxs').width() * tlength);
				_obj.find('.thumbnail-frame').width(fwidth);
				$('.prev a', _obj).bind('click', function (event) {
					if(eval(get_ctegory(_obj) + '_flag != 1')) frame_move(_obj, 'prev', eval(get_ctegory(_obj) + '_flag - 1'));
					return false;
				});
			
				$('.next a', _obj).bind('click', function (event) {
					event.preventDefault();
					if(eval(get_ctegory(_obj) + '_flag != tlength')) frame_move(_obj, 'next', eval(get_ctegory(_obj) + '_flag + 1'));
					return false;
				});
				
			} else {
				_obj.find('.pagination').hide();
			}
	}
	//サムネールスライド
	function frame_move(_obj, _type, _nth) {
		
		(_nth == 1) ? _obj.find('.prev').hide() : _obj.find('.prev').show();
		(_nth == _obj.find('.thumbnail').length) ? _obj.find('.next').hide() : _obj.find('.next').show();
		
		var move_nth = _nth - 1;
		var move_int = move_nth * (_obj.find('.thumbnail-boxs').width() * -1);
		_obj.find('.thumbnail').show();
		
		
		$('.circle-nav img', _obj).attr('src', '/shared/images/nav-gallery-01_01.png');
		$('.circle-nav:eq('+ move_nth +') img', _obj).attr('src', '/shared/images/nav-gallery-01_01_o.png');
		$('.thumbnail:eq('+ move_nth +')', _obj).show();
		_obj.find('.thumbnail-frame:animated').stop();
		_obj.find('.thumbnail-frame').animate({
			left: move_int + 'px'
			}, 500, function() {
				_obj.find('.thumbnail').not($('.thumbnail:eq('+move_nth+')', _obj)).hide();
		});
		
		eval(get_ctegory(_obj) + '_flag=' + _nth);
		
		return false;
	}
	
	function get_ctegory(_obj) {
		return _obj[0].id.split('-')[1];
	}
	
	function getthumbs_total(_obj) {
		return _obj.find('.thumbs').length;
	}

	function draw_photo(_num) {
		var old_obj = getObj(thumbs_flag), new_obj = getObj(_num);
		var _href = new_obj.find('a').attr('href'), caption = new_obj.find('img').attr('alt');
		photo_frame.empty().addClass('loading');
		var img = new Image();
			$(img).load(function() {
			
			photo_frame.removeClass('loading').append(this).width($(this).width());
			$(this).css({ opacity: "0" }).attr({ width: $(this).width()}).animate({ opacity: "1" }, 500, function() {
				if(caption) {
					$(this).parent().append('<span class="caption"></span>');
					photo_frame.find('span').text(caption);
				}
			});
		}).attr({ src : _href , alt: "" });
		
		var stay_num = _num + 1;
		
		if(floorplan_total > 0) (stay_num <= thumbs_total - floorplan_total) ? stay_num += floorplan_total : stay_num -= (thumbs_total - floorplan_total);

		$('.location em').text(stay_num);
		if(new_obj.data('info')) {
			var this_flag = eval(new_obj.data('info').category + '_flag');
			if(new_obj.data('info').group != this_flag) {
				frame_move(eval(new_obj.data('info').category), '', new_obj.data('info').group);
			}
		}
		old_obj.removeClass('view');
		new_obj.addClass('view');
		thumbs_flag = _num;
		return false;
	}
	
	function getObj(_num) {
		return $('#content-main .thumbs:eq('+ _num +')');
	}
});

//物件一覧

$(function(){
	if(!$('.box-gallery-01').size() || $('.box-gallery-02').size()) return false;
	
	var flg_num = 0;
	var canvas = $('.photo');
	var prev = $('.block-gallery-01 .prev'), next = $('.block-gallery-01 .next');
	var auto_time = 2000, auto_move;
	var obj_nums = $('.thumbnail li').length;
	var target;
	
	if(obj_nums > 0) {
		fint();
		$('.thumbnail li a').each( function(Index) {
			var _obj = $(this);
			_obj.parent().append('<span></span>');
			$(_obj).bind('click', function () {
				clearInterval(auto_move);
				view_frame(_obj, Index);
				return false;
			});
		});
	}

	prev.click(function () {
		clearInterval(auto_move);
		if(flg_num != 0) {
			target = getObj(flg_num - 1).find('a');
			view_frame(target, (flg_num - 1));
		}
		return false;
	});
	
	next.click(function () {
		clearInterval(auto_move);
		if(flg_num != obj_nums) {
			target = getObj(flg_num + 1).find('a');
			view_frame(target, (flg_num + 1));
		}
		return false;
	});
	
	function fint() {
		getObj(flg_num).addClass("view");
		canvas.height('168');
		prev.hide();
		chageCanvas(0);
	}
	
	function getAttr(_obj, _type) {
		return _obj.attt(_type);
	}
	
	function getObj(_num) {
		return $('.thumbnail li:eq(' + _num + ')');
	}
	
	function chageCanvas(_num) {
		$('.block-gallery-01').width(355);
		canvas.css('margin', '0 auto');
		var _src = getObj(_num).find('a').attr('href');
		canvas.empty();
		var img = new Image();
		$(img).load(function() {
			$(this).hide();
			canvas.width(224).height(168).append(this);
			//canvas.append(this).width($(this).width()).height($(this).height());
			$(this).fadeIn().attr({ width: "224", height: "168" });
			//$(this).fadeIn().attr({ width: $(this).width(), height: $(this).height() });
		}).attr({ src : _src, alt: "" });
	}
	
	auto_move = setInterval(function(){
		if(flg_num == (obj_nums - 1)) {
			view_frame(getObj(0).find('a'), 0)
		} else {
			view_frame(getObj(flg_num + 1).find('a'), flg_num + 1)
		}
	}, auto_time);
	
	function view_frame(_obj, _nth) {
		(_nth == 0) ? prev.hide() : prev.show();
		(_nth == (obj_nums - 1)) ? next.hide() : next.show();
		chageCanvas(_nth);
		getObj(flg_num).removeClass("view");
		flg_num = _nth;
		_obj.parent().addClass("view");
		$('#stay').text(flg_num);
		return false;
	}
	
});

