
//――――――――――――――――――――――――――――――――――――――
// PRINT 
//――――――――――――――――――――――――――――――――――――――
function PrintPage(){
	if(document.getElementById || document.layers){
		window.print();		//印刷をします
	}
}


//--------------------------------------------------
// POPUP WIN OPEN
//--------------------------------------------------
function pop2URL(wk1,WW,HH){
	var PopWidth  = "";
	var PopHeight = "";
	if(WW){ PopWidth  = ",width=" + WW; }
	if(HH){ PopHeight = ",height=" + HH; }
	var PopDetail = "scrollbars=1,toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1" + PopWidth + PopHeight;
	PopWin = window.open(wk1,"pop",PopDetail);
	PopWin.focus();
}

function popUp(path,w,h){
	if(w){var PopWidth = ",width=" + w;}
	if(h){var PopHeight = ",height=" + h;}
	var PopDetail = "toolbar=1,location=0,directories=0,status=1,menubar=1,resizable=0,scrollbars=1" + PopWidth + PopHeight;
	var win = window.open(path,'popup',PopDetail);
		win.resizeTo(w,h);
		win.focus();
}
function popUp2(path,w,h){
	if(w){var PopWidth = ",width=" + w;}
	if(h){var PopHeight = ",height=" + h;}
	var PopDetail = "toolbar=1,location=1,directories=1,status=1,menubar=1,resizable=1,scrollbars=1" + PopWidth + PopHeight;
	var win = window.open(path,'popup',PopDetail);
		win.resizeTo(w,h);
		win.focus();
}

function enterFocus(id, message) {
    if ($('#' + id).val() == message) {
        $('#' + id).val('');
        $('#' + id).css('color', '#000000');
        $('#' + id).css('font-style', 'normal');
    }
}
function enterBlur(id, message) {
    if ($('#' + id).val() == '') {
        $('#' + id).val(message);
        $('#' + id).css('color', '#D0D0D0');
        $('#' + id).css('font-style', 'italic');
    }
}
function deleteExample(id, message) {
    if ($('#' + id).val() == message) {
        $('#' + id).val('');
    }
}
function check_column(id) {
    if ($('#' + id).attr('checked')) {
        $('#' + id).removeAttr('checked');
    }
    else {
        $('#' + id).attr('checked', true);
    }
}
function check_column_radio(id) {
    if (!$('#' + id).attr('checked')) {
        $('#' + id).attr('checked', true);
    }
}
function controll_column(id, val, target) {
    if ($('#' + id).val() == val) {
        $('#' + target).hide();
    }
    else {
        $('#' + target).show();
    }
}
function func_changeMakeIndex(host, selected_message) {
    $.getJSON(host + 'common_ajax.php', {
        type: 'model_list',
        make: $('#make').val()
    },
    function(model_list){
        var i = 0;
        var option_list = new Array();
        option_list.push("<option value='-1' selected='selected'>" + selected_message + "</option>");
        for (key in model_list) {
            var model = model_list[key];
            option_list.push("<option value='" + model_list[key]['model_name'] + "'>" + model_list[key]['model_name'] + "</option>");
        }
        $('#smodel').empty();
        $('#smodel').append(option_list.join(''));
    });
}
function func_changeMakeIndex_stock(host, selected_message) {
    $.getJSON(host + 'common_ajax.php', {
        type: 'model_list',
        make: $('#make').val()
    },
    function(model_list){
        var i = 0;
        var option_list = new Array();
        option_list.push("<option value='-1' selected='selected'>" + selected_message + "</option>");
        for (key in model_list) {
            var model = model_list[key];
            option_list.push("<option value='" + model_list[key]['model_name'] + "'>" + model_list[key]['model_name'] + "</option>");
        }
        $('.make-index-stock').map(function() {
            $(this).empty();
            $(this).append(option_list.join(''));
        });
    });
}
function func_changeMakeIndexALL(host, selected_message) {
    $.getJSON(host + 'common_ajax.php', {
        type: 'model_list_all',
        make: $('#make').val()
    },
    function(model_list){
        var i = 0;
        var option_list = new Array();
        option_list.push("<option value='-1' selected='selected'>" + selected_message + "</option>");
        for (key in model_list) {
            var model = model_list[key];
            option_list.push("<option value='" + model_list[key]['model_name'] + "'>" + model_list[key]['model_name'] + "</option>");
        }
        $('#smodel').empty();
        $('#smodel').append(option_list.join(''));
    });
}
function func_changeMakePartsOrder(url) {
    $.getJSON(url, {
        make: $('#make').val()
    },
    function(model_list) {
        var i = 0;
        var option_list = new Array();
        option_list.push("<option value='' selected='selected'>Any</option>");
        for (key in model_list) {
            var model = model_list[key];
            option_list.push("<option value='" + model_list[key]['model_name'] + "'>" + model_list[key]['model_name'] + "</option>");
        }
        $('#model').empty();
        $('#model').append(option_list.join(''));
    });
}

function func_search_reset(uri) {
    document.SearchVehicles.action = uri;
    document.SearchVehicles.method = "post";
    document.SearchVehicles.submit();
}
function func_search_reset2(uri, key) {
    var a = "SearchVehicles" + key;
    var b = document.getElementById(a);
    b.action = uri;
    b.method = "post";
    b.submit();
}
function func_country_option_tag (container, p_id, p_name) {
    return "<option container='" + container + "' value='" + p_id + "'>" + p_name + "</option>";
}

function func_name_html (name, flg, required) {
    var message = "";
    if (flg == '@OK@') {
        message = "<span class='ok'> OK</span>";
    }
    else {
        message = "<span class='required'> " + required + "</span>"
    }
    return name + "<br />" + message;
}

function func_order_url (qe, vid, lang, opt) {
    var p_opt = "";
    if (opt) {
        p_opt = "&opt=" + opt;
    }
    return "order.php?pass=" + qe + "&vid=" + vid + "&lang=" + lang + p_opt;
}

function func_mypage_request_ft (from, to) {
    if (document.specialRequest.elements[from].selectedIndex > document.specialRequest.elements[to].selectedIndex) {
        document.specialRequest.elements[to].selectedIndex = document.specialRequest.elements[from].selectedIndex;
    }
}

function func_recommend(vid) {
    kbmjRecommend("sim", "id[]=" + vid + "&type=1", "UTF-8", "kbmj_sim1");
}
//3桁カンマ区切り
function money_formatter(str) {
    var num = new String(str).replace(/,/g, "");
    while(num != (num = num.replace(/^(-?\d+)(\d{3})/, "$1,$2")));
    return num;
}

