
// mouseover script
// @param なし
// @return なし
$(function imgOver() {
    $('img, input:image').each(function() {
        var node = this;
        if(node.src.match("_off.")) {
            node.originalSrc = node.src;
            node.temporarySrc = node.originalSrc.replace(/_off/,'');
            node.rolloverSrc = node.temporarySrc.replace(/(\.gif|\.jpg|\.png)/,'_on'+"$1");
            node.activeSrc = node.temporarySrc.replace(/(\.gif|\.jpg|\.png)/,'_active'+"$1");
            //画像のプリロード処理開始
            preloadImage(node.rolloverSrc);
            //Mouseover
            node.onmouseover = function() {
                if(this.className!='active') {
                    this.src = this.rolloverSrc;
                }
            }
            //Mouseout
            node.onmouseout = function() {
                if(this.className!='active') {
                    this.src = this.originalSrc;
                }
            }
        }
    });
});

// 画像のプリロードを行う関数
// @param string 画像のパス
// @return なし
preloadImages = [];
preloadImage = function(path) {
    var pre = preloadImages;
    var len = pre.length;
    pre[len] = new Image();
    pre[len].src = path;
}


//デザイン修正
$(function addTrClass() {
    $('#Sidebox .mybox .listin .keepbox .keepin .list:last-child').addClass('last');
    $('#PLBOX .tbl_box01_in table tr:last-child').addClass('last');
    $('#PLBOX .tbl_box01_in table td .tbl_inner td:last-child').addClass('last');
    $('#PLBOX .tbl_box02_in table td:last-child').addClass('last');
    $('#PLBOX .tbl_box02_in table tr:even').addClass('even_row');
    $('#PLBOX .tbl_box02_in table tr:last').addClass('end');
    $('#PLBOX .tbl_box03_in table tr:last').addClass('end');    
    $('#PLBOX .tbl_box03_in table td:last-child').addClass('last');    
    $('#PLBOX .pl_repo_rsnbox .pl_repo_rsnboxin:last-child').addClass('end');
    $('#PLBOX .gallery_box .sub_box .navibox_in ul li:last-child').addClass('last');

	//2010/11/10追加
    $('#MNBOX .addsalebox .salein .inner table td ul li:last').addClass('bot');
});


//外部リンクにクラス名「external」、target="_blank"を追加
$(function addBlankExtLink() {
    var selfDomain = document.domain;
    $('a').each(function() {
        if((this.href.indexOf(selfDomain)==-1) && (this.href.indexOf('mailto')==-1) && (this.href.indexOf('http://www.adobe.com/')==-1)) {
            $(this).addClass('external');
            $(this).attr('target','_blank');
        }
    });
});

//ページスクロール
$(function pagetop() {
        $('.com_pagetop a').click(function () {
            $(this).blur();

			if (window.opera)
			{
				$('html').animate({ scrollTop: 0 }, 'fast');
			}else{
				$('html,body').animate({ scrollTop: 0 }, 'fast');
			}
            return false;
        });
});
//フェア管理 おすすめ設定
function setFairRecommend(val) {
    $.post('/mgr/fair/recommend.php', {
        'hall_id':$('#hall-id').val(),
        'id':$('#id').val(),
        'is_recommended':val
        },
        function(data) {
            if (data.error) {
                alert(data.error);
            }
            if (data.result.data['is_recommended'] == 1) {
                $('#recommend-on').attr('style', 'display:none');
                $('#recommend-off').attr('style', 'display:inline');
            }
            else {
                $('#recommend-on').attr('style', 'display:inline');
                $('#recommend-off').attr('style', 'display:none');
            }
            $('#is-recommended').attr('value', data.result.data['is_recommended']);
        }
        ,'json');
}
//プラン管理 公開非公開設定
function setPlanStatus(id, current_status) {
    $.post('/mgr/plan/status.php', {
        'hall_id':$('#hall-id').val(),
        'id':id,
        'status':current_status
    },      
    function(data) {
        if (data.error) {
            alert(data.error);
        }       
        if (data.result.data['status'] == 1) { 
            $('#img-open-'+id).attr('style', 'display:inline');
            $('#img-close-'+id).attr('style', 'display:none');
            $('#btn-open-'+id).attr('style', 'display:inline');
            $('#btn-close-'+id).attr('style', 'display:none');
        }       
        else {  
            $('#img-open-'+id).attr('style', 'display:none');
            $('#img-close-'+id).attr('style', 'display:inline');
            $('#btn-open-'+id).attr('style', 'display:none');
            $('#btn-close-'+id).attr('style', 'display:inline');
        }       
    }       
    ,'json');
}
//フェア管理 公開非公開設定
function setFairStatus(id, current_status) {
    $.post('/mgr/fair/status.php', {
        'hall_id':$('#hall-id').val(),
        'id':id,
        'status':current_status
    },      
    function(data) {
        if (data.error) {
            alert(data.error);
        }       
        if (data.result.data['status'] == 1) { 
            $('#img-open-'+id).attr('style', 'display:inline');
            $('#img-close-'+id).attr('style', 'display:none');
            $('#btn-open-'+id).attr('style', 'display:inline');
            $('#btn-close-'+id).attr('style', 'display:none');
        }       
        else {  
            $('#img-open-'+id).attr('style', 'display:none');
            $('#img-close-'+id).attr('style', 'display:inline');
            $('#btn-open-'+id).attr('style', 'display:none');
            $('#btn-close-'+id).attr('style', 'display:inline');
        }       
    }       
    ,'json');
}

//入力フォーム、ポップアップメッセージ
$(function() {
    if($.browser.msie && $.browser.version < 7) {
        $('form input').focus(function() {
            $(this).siblings(".com_hide").show();
        }).blur(function() {
            $(this).siblings(".com_hide").hide();
        });
    } else {
        $('form input').focus(function() {
            $(this).siblings(".com_hide").fadeIn();
        }).blur(function() {
            $(this).siblings(".com_hide").hide();
        });
    }
}); 


