
function rollover() {
    $('.swap').rollover();
}

function showLayout(id) {
    $(id).fadeIn('slow');
}

function hideElement(id) {
    $(id).slideUp('normal');
}

function _save_cookie(id, value) {
    var cookiename = 'ini' + id;
    $.cookie(cookiename, value, { expires: 180, path: '/'});
}

function _load_cookie(id) {
    var cookiename = 'ini' + id;
    return $.cookie(cookiename);
}

function showErrorMessage() {
    blindDownEffect('message_dialog');
}

function showhide(id) {
    if(document.getElementById){
        if(document.getElementById(id).style.display == "none")
            document.getElementById(id).style.display = "block";
        else
            document.getElementById(id).style.display = "none";
    }
}

function showIndicator() {
    id = 'indicator'
    window.scroll(0, 0);
    document.getElementById(id).style.display = "block";
}

function disableElements(elements, flag) {
    if (elements != null && elements.length > 0) {
        for (var i=0; i < elements.length; i++) {
            disableElement(elements[i], flag);
        }
    }
}

function disableElement(id, flag) {
    if (document.getElementById(id) != null) {
        document.getElementById(id).disabled = flag;
    }
}

function searchAddress(zip1, zip2, prefecture, city, address) {
    //var url = "";
    var zip = $(zip1).val() + $(zip2).val();

    $.ajax({
        url : url,
        dataType : "jsonp",
        data : {
            zip : zip
        },
        jsonp: 'jsonp',
        success : function(json){
            //set
            $(prefecture).val(json.prefecture);
            $(city).attr('value', json.city);
            $(address).attr('value', json.address);
        },
        error : function(){
            alert('郵便番号が正しくありません');
        }
    });
}

function checkSearchField() {
    var value = $('#searchField').attr('value');
    if (value != null && value.length > 0) {
        $('#searchClearLink').show();
        $('#searchSubmit').attr("disabled", false);
    } else {
        $('#searchClearLink').hide();
        $('#searchSubmit').attr("disabled", true);
    }
}


function topZIndex(id) {
    $(id).css('z-index', 99999);
}

var getMaxZIndex = function(){
    var largestZIndex = 0; 
    var defaultView = document.defaultView;
    var func = function(tagname){
        var elements = document.getElementsByTagName(tagname);
        for (var i=0; i< elements.length; i++){
            var element = elements[i];
            var zIndex = element.style.z-index;
            if (!zIndex) {
                var css = element.currentStyle || defaultView.getComputedStyle(element, null);
                zIndex = css ? css.zIndex : 0;
            }
            zIndex -= 0;
            if(largestZIndex < zIndex) largestZIndex=zIndex;
        }
    };
    if(arguments.length == 0) {
        func('*');
    } else {
        for(var i=0; i<arguments.length; i++) {
            func(arguments[i]);
        }
    }
    return largestZIndex;
};
