﻿// JavaScript Document

$(document).ready(function(){
						   

if ($.browser.msie )
{
$("a").focus(function(){
$(this).blur();
});
$("img").attr("title","");
}


//PIE
if ($.browser.msie ){
$('#alpha,.detail,.floor-links,p.feature span,.history .box,.rules .box,.contact .box,.ml_area,.resi_index ul').each(function()
{
	PIE.attach(this);
	 $(this).css("position","relative")
	
});
}

//top pick up batch
$("#top_left .pickup_sec .menu_ph").css("position","relative")

$("#top_left .pickup_sec .menu_ph span").css({
											 "position":"absolute",
											 "width":"48px",
											 "height":"49px",
											 "right":"0"
											 })

$("#top_left .rest .menu_ph span").css({
											 "background":"url(/img/stk_food.png)"
											 })

$("#top_left .cafe .menu_ph span").css({
											 "background":"url(/img/stk_cafe.png)"
											 })

$("#top_left .shop .menu_ph span").css({
											 "background":"url(/img/stk_shop.png)"
											 })



//en ttl cng
$("body.lang-en #snavi h2:not(.ttl_eng) img").each(function(){
$(this).attr("src",$(this).attr("src").replace(".","_en."))										  
});



//tile
$("#top_left .pickup_sec .pickup_sec_item ").tile(3);



///wink
$("").hover(function(){
$(this).css("opacity", "0.5");
$(this).fadeTo("slow", 1.0);
});
///wink


crrent();

g_crrent();

media_change();



});/////////readyEND



function crrent(){
var href = location.href.split(/[#?]/)[0];
var href = href.replace(/[/]$/,'/index.html');
//var href = href.replace(/.*\//,'');

$("a").each(function() {
var myhref = this.href;
var myhref = myhref.replace(/[/]$/,'/index.html');
//var myhref = myhref.replace(/.*\//,'');

if (href==myhref){
$(this).addClass("current");
}
});//each
}

function g_crrent(){
	
$("#header-content .menu a").each(function() {

var c = $(this).parent().attr("class").replace("en","")
var c = c.replace("zh","")
var c = c.replace("kr","")
$(this).append('<img class="c_arr" src="/img/'+c+'on.gif"/>')


var myhref = this.href;
var location = window.location.href;
if (location.match(myhref)){
$(this).parent().addClass('c_current')
}

});
}

function media_change(){

var re = document.referrer;
if(re.match("http://www.mai-b.co.jp/lite/")){
$.cookie('lite','1',{ path:'/'});
}

if (navigator.userAgent.indexOf('iPhone') > 0  || navigator.userAgent.indexOf('iPod') > 0 || navigator.userAgent.indexOf('Android') > 0 /*|| navigator.userAgent.indexOf('Chrome') > 0*/) {
if ($.cookie('lite') != "1"){
location.href = "http://www.mai-b.co.jp/lite/";
} else  {
$("#header").prepend('<a id="go_mb" href="/lite/" style="display:block; background:#eee; "><span style="margin:30px; display:inline-block; font-size:50px;">モバイル版で見る<span></a>')	

$("#go_mb").click(function() {
$.cookie('lite',null,{ path:'/'});
});

}
}

	
//var ref = location.href;
//if(ref.match("/lite/")){
//$.cookie('lite','1',{ path:'/'});
//}

}//fun end

/*
CSS Browser Selector v0.3.1
Rafael Lima (http://rafael.adm.br)
*/
function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',h=document.getElementsByTagName('html')[0],b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3')?g+' ff3':is('gecko/')?g:/opera(\s|\/)(\d+)/.test(ua)?'opera opera'+RegExp.$2:is('konqueror')?'konqueror':is('chrome')?w+' '+s+' chrome':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);
//* CSS Browser Selector  END


/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
(function($) {
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
})(jQuery);

///Cookie pluginEND

/**
 * Flatten height same as the highest element for each row.
 *
 * Copyright (c) 2011 Hayato Takenaka
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * @author: Hayato Takenaka (http://urin.take-uma.net)
 * @version: 0.0.2
**/
(function($) {
	$.fn.tile = function(columns) {
		var tiles, max, c, h, last = this.length - 1, s;
		if(!columns) columns = this.length;
		this.each(function() {
			s = this.style;
			if(s.removeProperty) s.removeProperty("height");
			if(s.removeAttribute) s.removeAttribute("height");
		});
		return this.each(function(i) {
			c = i % columns;
			if(c == 0) tiles = [];
			tiles[c] = $(this);
			h = tiles[c].height();
			if(c == 0 || h > max) max = h;
			if(i == last || c == columns - 1)
				$.each(tiles, function() { this.height(max); });
		});
	};
})(jQuery);




