//JQueryJson
var jQueryJson = {};
function AjaxRequet(targetUrl,data){
    $.ajax({
        type: "POST",
        url: targetUrl,
        data: data,
        dataType: "json",
        async: false,
        success: function(json){
            jQueryJson = json;
        },
        error: function(msg){
            jQueryJson = msg;
            alert('通信に失敗しました');
        }
    });
    return jQueryJson;
}

//jQueryAjaxgetHTML
function jQueryAjaxgetHTML(target, targetUrl, data){
    $.ajax({
        type: "POST",
        url: targetUrl,
        data: data,
        dataType: "html",
        success: function(html){
            $(target).html(html);
        },
        error: function(){
            alert('通信に失敗しました');
        }
    });
    return jQueryJson;
}

//RollOverImage
function initRollOverImages(){
    var image_cache = new Object();
    $("img.swap").each(function(i){
        var imgsrc = this.src;
        var dot = this.src.lastIndexOf('.');
        var imgsrc_on = this.src.substr(0, dot) + '_over' + this.src.substr(dot, 4);
        image_cache[this.src] = new Image();
        image_cache[this.src].src = imgsrc_on;
        $(this).hover(
            function() { this.src = imgsrc_on; },
            function() { this.src = imgsrc; });
    });
}
//PopUpWindow
function initPopupWindow(){
    $(".PopUp").bind("click", function(event){
        var url    = $(this).attr("href");
        var param  = url.match(/\.*?width=(.*?)&height=(.*?)&winname=(.*?)$/);
        var width  = param[1];
        var height = param[2];
        var name   = param[3];
        var option = "menubar=yes,scrollbars=yes,toolbar=no,resizable=yes" + "," + "width=" + width + "," + "height=" + height;
        window.open(url,name,option);
        event.preventDefault();
    });
}
//ToolTip
function initToolTip(){
    $(".Tooltip").hover(
        function(){
            var displayText = $(this).attr("title");
            var W = displayText.length + 1;
            $(this).append('<div class="Tooltips">' + displayText + '</div>').css("position","relative");
            $(".Tooltips").
            css("color","#fff").
            css("text-decoration","none").
            css("position","absolute").
            css("top","-45px").
            css("left","5px").
            css("width",W + "em").
            css("line-height","26px").
            css("text-align","center").
            css("padding","3px 0 15px 0").
            css("font-weight","normal").
            css("background","transparent url(../share/images/tooltip.gif) left bottom no-repeat").
            hide().fadeIn(1000);
        },
        function(){
            $(".Tooltips").remove();
    });
}

//SameBoxHeight
function BoxHeightUniform(){
    var n = 0;
    $('.BoxUniform').each(function(){
        h = $(this).height();
        n = (n < h) ? h : n;
    });
    $('.BoxUniform').css('height',n);
}

$(document).ready(initRollOverImages);
$(document).ready(initPopupWindow);
$(document).ready(initToolTip);
$(document).ready(BoxHeightUniform);
