/**
 * This file contains common functions.
 *
 * @package     webroot
 * @subpackage  js
 * @created     2009/3/5
 */

var isStatisJob = true;
var countOfCommunication = 0;
var href_submit_btn = "#";

//クッキーの代わりにグローバル変数を利用
var cookie_business = "";
var cookie_employment = "";
var cookie_moneyclass = "";
var cookie_moneyvalue = "";
var cookie_detailview = "";
var cookie_keyword = "";
var cookie_area = "";
var cookie_areaname = "";
var cookie_job = "";
var cookie_jobname = "";
var cookie_railway = "";

$(document).ready(function(){
    if ($('input#UserPrivacy').size() > 0 && $('div#blockArea').size() > 0 && $('a#submit_btn').size() > 0){
        href_submit_btn = $("a#submit_btn").attr("href");
        if ($('input#UserPrivacy').attr('checked')) {
            _executeEnable();
        } else {
            _executeDisable();
        }
        
        $('input#UserPrivacy').click(function () {
            if ($(this).attr('checked')) {
                _executeEnable();
            } else {
                _executeDisable();
            }
        })
    }
    //入力エラーの際エラーの位置にスクロールを移動させる
    if ($('div.error-message-center').size() > 0) {
        $.scrollTo("div.error-message-center:first", 1000);
    } else if ($('div.error-message').size() > 0) {
        $.scrollTo("div.error-message:first", 1000);
    }
    //各種職種ページでcookie_area、cookie_areanameを初期化する
    var job_code = $("input#job_code").val();
    if (job_code === undefined)
    {
        job_code = "";
    }
    if (job_code != "") 
    {
        cookie_area = $.cookie('guppy.www.search.area');
        cookie_areaname = $.cookie('guppy.www.search.areaname');
        var railway = $("input#railway_id").val();
        if (railway === undefined)
        {
            railway = "";
        }
        if (job_code != "") 
        {
            cookie_railway = railway;
        }        
    }
});

//フォーム内のコントロールを入力、選択できないようにする
function _executeDisable()
{
    $.blockUI.defaults.css = {
        padding:        10,
        margin:         0,
        width:          '30%',
        top:            '40%',
        left:           '35%',
        textAlign:      'center',
        color:          '#000',
        border:         '3px solid #aaa',
        backgroundColor:'#fff',
        cursor:         'default'
    };
     $.blockUI.defaults.overlayCSS = {
        backgroundColor: '#fff',
        opacity:         '0.6',
        cursor:         'default'
    };
    
    var obj = '「利用規約」「プライバシーポリシー」をご確認のうえ、上にある『同意する』にチェックをつけてください。';
    $('div#blockArea').block({ message: obj });
    $("a#submit_btn").attr("href", "javascript:void(0);");
}

//フォーム内のコントロールを入力、選択できるようにする
function _executeEnable()
{
    $('div#blockArea').unblock();
    $("a#submit_btn").attr("href", href_submit_btn);
}

function initForIE() {
    if (document.all) {
        $(".navOne li").hoverClass ("sfHover");
    } else {
        $(".navOne li").hover(function() {
            //  check whether the menu contains one or more items, or not
            if( $(this).children('ul').find('li').size() < 1 ) {
                $(this).children('ul').css('visibility', 'hidden');
            } else {
                $(this).children('ul').css('visibility', 'visible');
            }
        }, function() {
        });
    }
}

$.fn.hoverClass = function(c) {
    return this.each(function(){
        $(this).hover( 
            function() { 
                //  check whether the menu contains one or more items, or not
                //alert( $(this).children('ul').find('li').size() );
                if( c == "sfHover" ) {
                    if( $(this).children('ul').find('li').size() < 1 ) {
                        $(this).children('ul').css('visibility', 'hidden');
                    } else {
                        $(this).addClass(c);
                        $(this).children('ul').css('visibility', 'visible');
                    }
                    return;
                }
                $(this).addClass(c);
            }, function() {
                $(this).removeClass(c);
                if( c == "sfHover" ) {
                    $(this).children('ul').css('visibility', 'hidden');
                }
            }
        );
    });
};

function settingHoverEffect(elementObj) {
    if (elementObj == null) {
        elementObj = $('ul.navOne').children('li');
    }

    //    each of navOne-object
    var maxItemLength = 0;
    var curLen = 0;
    var emLength = maxItemLength * 1.15;
    elementObj.each( function() {
        //    check items' max length
        maxItemLength = 0;
        $(this).children('ul').children('li').each(function() {
            curLen = $(this).children('a').text().length;
            if( curLen > maxItemLength ) {
                maxItemLength = curLen;
            }
        });

        //    reset all items' length
        emLength = Math.round(maxItemLength * 1.13);
        //ulLength = Math.round(parseInt($(this).children('ul').css("width"),"10") / parseInt($(this).children('ul').children('li').css("width"),"10")) * emLength;
        if ($(this).attr('id') == 'placesub') {
            ulLength = emLength * 7;
        } else {
            ulLength = emLength * 3;
        }
        $(this).children('ul').css("width", (ulLength) + "em");
        $(this).children('ul').children('li').each(function() {
            $(this).css("width", emLength + "em");
            $(this).children('a').css("width", emLength + "em");
        });
        //    show & hide according to items' count
        if( $(this).children('ul').find('li').size() < 1 ) {
            $(this).children('ul').css('visibility', 'hidden');
        }
    }
    );

    //    set hover-handler
    elementObj.children('ul').children('li').hover(function(){
        var thisCLS = $(this).attr('class');        
        if (thisCLS == "bgOrange") {
            return false;
        } else if(thisCLS == "grayHover") {
            $(this).css("background-color","");
            $(this).css("background-color","#DDD");
            $(this).children('a').css("background-color","#DDD");
        }
        return false
    },function(){
        var thisCLS = $(this).attr('class');
        if (thisCLS == "bgOrange") {
            return false;
        } else if(thisCLS == "grayHover") {
            $(this).css("background-color","");
            $(this).children('a').css("background-color","");
        }
        return false;
    });
}

function chOrangeBg(elementObj) {
    elementObj.removeClass("grayHover");
    elementObj.css("background-color","");
    elementObj.children('a').css("background-color","");
    elementObj.children('a').removeClass("grayHover");
    elementObj.addClass("bgOrange");
    elementObj.children('a').addClass("bgOrange");
}

function chGrayBg(elementObj) {   
    elementObj.removeClass("bgOrange");
    elementObj.children('a').removeClass("bgOrange");
    elementObj.addClass("grayHover");
    elementObj.children('a').addClass("grayHover");   
}

function getJsonURL(idOfLi) {
    var jsonURL = "";
    switch (idOfLi) {
        case "place" : 
            jsonURL = "train_prefectures";
            break;
        case "placesub" :
            jsonURL = "location_city";
            break;
        case "job" :
            jsonURL = "job";
            break;
        case "business" :
            jsonURL = "business";
            break;
        case "employment" :
            jsonURL = "employment";
            break;
        case "placeFirst" :
            jsonURL = "location_prefectures";
            break;
        case "jobFirst" :
            jsonURL = "job";
            break;
        default :
            jsonURL = "location_prefectures";
    }    
    var result = "/ajax/" + jsonURL;
    return result;
}

//   show 'Loading..." while ajax is communicating...
function showAjaxStatus( mode )
{
    /*if( $('span#ajax_status').is('span') == false ) {
        return;
    }*/
    if( mode == 1 ) {
        if (countOfCommunication == 0) {
            var obj = "<img src='/img/search/loading.gif' alt='' width='32px' height='32px' class='loading' />";
            $('#searchBox').block({ message: obj });
        }
        countOfCommunication++;
    } else if ( mode == 2 ) {
        countOfCommunication--;
        if (countOfCommunication == 0) {
            $('span#ajax_status').html('');
            $('#searchBox').unblock();
        }
    }        
}

//   ---    comma-splited string functions    ---
function isValueIncluded(total, value) {
    total = total + "";
    var items = total.split( "," );
    for ( var i = 0; i < items.length; i ++ ) {
        if( items[i] == value ) {
            return true;
        }
    }
    return false;
}

function removeValue(total, value) {
    total = total + "";
    var items = total.split( ',' );
    var newItems = new Array();
    var i, nCount = 0;

    for ( i = 0; i < items.length; i ++ ) {
        if ( items[i] != value && items[i] != "" && items[i] != "-1" && items[i] != "null" ) {
            newItems[nCount] = items[i];
            nCount ++;
        }
    }

    return newItems.join(",");
}

function addValue( total, value ) {
    if ( isValueIncluded( total, value ) == true ) {
        return total;
    }
    if ( total == "" || total == "-1" || total == null ) {
        total = value;
    } else {
        total = total + ",";
        total = total + value;
    }

    return total;
}

function getSelectedString(obj, ids) {
    var idArr = ids.split( ',' );
    var strTotal = "";

    for ( var i = 0; i < idArr.length; i ++ ) {
        if ( idArr[i] == "-1" ) {
            continue;
        }
        if ( strTotal.length > 0 ) {
            strTotal = strTotal + ",";
        }
        strTotal = strTotal + obj.children('li#'+idArr[i]).children('a').text();        
    }

    return strTotal;
}

function refreshValues(obj, ids) {
    var newValue = "";
    var elements = obj.children('li').size();
    var newIDs = new Array();
    var selIDs = ids.split( ',' );

    var i, j;

    var liObj = obj.find('li');
    for ( i = 0; i < elements; i ++ ) {
        newIDs[i] = liObj.attr('ID');
        liObj = liObj.next();
    }

    for( j = 0; j < selIDs.length; j ++ ) {
        for( i = 0; i < elements; i ++ ) {
            if( newIDs[i] == selIDs[j] ) {
                break;
            }
        }
        if( i < elements ) {
            if( newValue.length > 0 ) {
                newValue = newValue + ",";
            }
            newValue = newValue + selIDs[j];
        }
    }

    return newValue;
}

function getDefaultComboText(comboID) {
    switch (comboID) {
        case 'place':
            return "希望勤務地";
        case 'placesub':
            return "市区町村";
        case 'job':
            return "希望職種";
        case 'business':
            return "希望業種";
        case 'employment':
            return "雇用形態";
    }
}

function getDefaultComboValue(comboID) {
    var result = -1;
    switch (comboID) {
        case 'place':
            result = -1; break;
        case 'job':
            result = -1; break;
    }
    return result;
}

function getCookie(param, mode) {
    var result = -1;
    var job_code = $("input#job_code").val();
    if (job_code === undefined) {
        job_code = "";
    }
    switch (param) {
        case 'place':
            if (job_code == "") {
                result = $.cookie('guppy.www.search.area');
            } else {
                result = cookie_area;
            }
            break;
        case 'placename':
            if (job_code == "") {
                result = $.cookie('guppy.www.search.areaname');
            } else {
                result = cookie_areaname;
            }
            break;
        case 'placesub':
            //result = $.cookie('guppy.www.search.city');
            break;
        case 'placesubname':
            //result = $.cookie('guppy.www.search.cityname');         
            break;
        case 'job':
            if (job_code == "" || (job_code != "" && mode > 1)) {
                //各職種インデックスでクッキーエリアにはクッキーの設定値を表示
                result = $.cookie('guppy.www.search.job');
                if (mode > 1) {
                    mode = mode - 2;
                }
//                _changeDisplayText('jobname', $.cookie('guppy.www.search.jobname'), mode);
            } else {
                if (mode > 1) {
                    mode = mode - 2;
                }
                result = cookie_job;
//                _changeDisplayText('jobname', cookie_jobname, mode);
            }            
            break;
        case 'jobname':
            if (job_code == "" || (job_code != "" && mode > 1)) {
                //各職種インデックスでクッキーエリアにはクッキーの設定値を表示
                result = $.cookie('guppy.www.search.jobname');
            } else {
                result = cookie_jobname;
            }
            break;
        case 'business':
            result = cookie_business;
            //result = $.cookie('guppy.www.search.business');            
            break;
        case 'employment':
            result = cookie_employment;
            //result = $.cookie('guppy.www.search.employment');
            break;
        case 'moneyclass':
            result = cookie_moneyclass;
            //result = $.cookie('guppy.www.treat.search.conditions.moneyclass');
            break;
        case 'moneyvalue':
            result = cookie_moneyvalue;
            //result = $.cookie('guppy.www.treat.search.conditions.moneyvalue');
            break;
        case 'detailview':
            result = cookie_detailview;
            //result = $.cookie('guppy.www.treat.search.conditions.detailview');
            break;
        case 'keyword':
            result = cookie_keyword;
            //result = $.cookie('guppy.www.treat.search.conditions.keyword');
            break;
        case 'railway':
            if (job_code == "") {
                result = $.cookie('guppy.www.search.railway');
            } else {
                result = cookie_railway;
            }
            break;
        case 'lat':
            result = $.cookie('guppy.www.search.map.center.lat');
            break;
        case 'lng':
            result = $.cookie('guppy.www.search.map.center.lng');
            break;
    }
    if (result == null || result == '') {
        result = -1;        
    }
    return result;
}

function setCookie(param, value, mode) {
    var job_code = $("input#job_code").val();
    if (job_code === undefined) {
        job_code = "";
    }
    switch (param) {
        case 'place':
            if (job_code == "" || (job_code != "" && mode > 1)) {
                //各職種インデックスでクッキーエリアにはクッキーの設定値を表示
                $.cookie('guppy.www.search.area', value, { expires: 7, path: '/' });
                //$.cookie('guppy.www.search.city', -1, { expires: 7, path: '/' });
                //$.cookie('guppy.www.search.cityname', '', { expires: 7, path: '/' });
                $.cookie('guppy.www.search.railway', -1, {expires: 7, path: '/'});
                setPlaceActionLog(value);
            } else {
                cookie_area = value;
            }
            break;
        case 'placename':
            if (job_code == "" || (job_code != "" && mode > 1)) {
                //各職種インデックスでクッキーエリアにはクッキーの設定値を表示
                $.cookie('guppy.www.search.areaname', value, { expires: 7, path: '/' });
            } else {
                cookie_areaname = value;
            }
            //refreshCookieArea();
            break;
        case 'placesub':
            //$.cookie('guppy.www.search.city', value, { expires: 7, path: '/' });
            break;
        case 'placesubname':         
            //$.cookie('guppy.www.search.cityname', value, { expires: 7, path: '/' });
            break;
        case 'job':
            if (job_code == "" || (job_code != "" && mode > 1)) {
                //各職種インデックスでクッキーエリアにはクッキーの設定値を表示
                $.cookie('guppy.www.search.job', value, { expires: 7, path: '/' });
                cookie_business = -1;
                cookie_employment = -1;
                cookie_moneyclass = -1;
                cookie_moneyvalue = -1;
                //$.cookie('guppy.www.search.business', -1, { expires: 7, path: '/' });
                //$.cookie('guppy.www.search.employment', -1, { expires: 7, path: '/' });
                //$.cookie('guppy.www.treat.search.conditions.moneyclass', -1, { expires: 7, path: '/' });
                //$.cookie('guppy.www.treat.search.conditions.moneyvalue', -1, { expires: 7, path: '/' });
                setJobActionLog(value);
            } else {
                cookie_job = value;
            }
            break;
        case 'jobname':
            if (job_code == "" || (job_code != "" && mode > 1)) {
                //各職種インデックスでクッキーエリアにはクッキーの設定値を表示
                $.cookie('guppy.www.search.jobname', value, { expires: 7, path: '/' });
            } else {
                cookie_jobname = value;
            }
            if (mode > 1) {
                mode = mode - 2;
            }
//            _changeDisplayText('jobname', value, mode);
            //refreshCookieArea();
            break;
        case 'business':
            cookie_business = value;
            //$.cookie('guppy.www.search.business', value, { expires: 7, path: '/' });
            break;
        case 'employment':  
            cookie_employment = value;
            //$.cookie('guppy.www.search.employment', value, { expires: 7, path: '/' });
            break;
        case 'moneyclass':
            cookie_moneyclass = value;
            //$.cookie('guppy.www.treat.search.conditions.moneyclass', value, { expires: 7, path: '/' });
            break;
        case 'moneyvalue':
            cookie_moneyvalue = value;
            //$.cookie('guppy.www.treat.search.conditions.moneyvalue', value, { expires: 7, path: '/' });
            break;
        case 'detailview':
            cookie_detailview = value;
            //$.cookie('guppy.www.treat.search.conditions.detailview', value, { expires: 7, path: '/' });
            break;
        case 'keyword':
            cookie_keyword = value;
            //$.cookie('guppy.www.treat.search.conditions.keyword', value, { expires: 7, path: '/' });
            break;
        case 'railway':
            if (job_code == "") {
                $.cookie('guppy.www.search.railway', value, { expires: 7, path: '/' });
            } else {
                cookie_railway = value;
            }
            break;
        case 'lng':  
            $.cookie('guppy.www.search.map.center.lng', value, { expires: 7, path: '/' });
            break;
        case 'lat':  
            $.cookie('guppy.www.search.map.center.lat', value, { expires: 7, path: '/' });
            break;
        case 'httpmode':  
            $.cookie('guppy.www.http.mode', value, { expires: 7, path: '/' });
            break;
    }    
}

function _changeDisplayText(param, value, mode) {
    if (param == 'jobname' && mode ) {
        var common_select_msg1 = 'グッピー';
        var common_select_msg2 = 'グッピー医療求人';
        var common_select_msg3 = 'グッピー{職種}求人 トップへ';
        var common_select_msg4 = 'グッピー医療求人　トップへ';
        var common_select_msg5 = '';
        var common_select_msg6 = '[グッピー求人] 医師 看護師 薬剤師 歯科医師等の求人・転職・募集';
        var common_select_msg7 = '[グッピー求人]';
        var common_select_msg8 = 'の求人・転職・募集';
        //法人、勤務先ページの場合には、common_select_msg5="求人"にする
        if ($('input#wahtisjuliet').size() > 0) {
            common_select_msg5='求人';
        }
        if (value != -1 && value != '' && value != null) {
            $('div#topicPathList').children('ol').children('li').children('a:first').text(common_select_msg1 + value + common_select_msg5);
            $('p.right').children('a').text(common_select_msg3.replace('{職種}', value));
            if ($('p#tagline').size() > 0) {
                $('p#tagline').text(common_select_msg7 + value + common_select_msg8);
            }
        } else {
            $('div#topicPathList').children('ol').children('li').children('a:first').text(common_select_msg2);
            $('p.right').children('a').text(common_select_msg4);
            if ($('p#tagline').size() > 0) {
                $('p#tagline').text(common_select_msg6);
            }
        }
    }
}

//function refreshCookieArea() {
//    if ($('div#loginArea').is('div') == false) {
//        $('div#cookieBtnBox').hide();
//        return;
//    }
//
//    if ( $('td.firstBannerRightTd').is('td') ) {
//        $('div#cookieBtnBox').hide();
//        return;
//    }
//
//    //   現在設定されているクッキーの表示文字列を取得する。
//    var cookieDisplay = '';
//    if (getCookie('placename', 0) != -1 && getCookie('jobname', 2) != -1) {
//        cookieDisplay += "[" + getCookie('placename', 0) + "]" + "[" + getCookie('jobname', 2) + "]";
//    } else if (getCookie('placename', 0) != -1) {
//        cookieDisplay += "[" + getCookie('placename', 0) + "]";
//    } else if (getCookie('jobname', 2) != -1) {
//        cookieDisplay +=  "[" + getCookie('jobname', 2) + "]";
//    } else {
//        $('div#cookieBtnBox').hide();
//        return;
//    }
//
//    //   クッキーの表示欄が存在すると、
//    if ( $('div#cookieBtnBox').children('span.totalArea').is('span') == true ) {
//        $('span#cookieDisplay').html(cookieDisplay);
//        $('div#cookieBtnBox').show();
//    }
//}

function _refreshCookieArea_Ex() {
    if($('div#myCookieConfig').is('div') == false) {
        return;
    }
    $('input#my_job').val(getCookie('job', 2));
    $('input#my_jobname').val(getCookie('jobname', 2));
}

function getRelationComboCondition(comboID) {
    var relationComboCondtion = -1;
    if (comboID == 'placesub') {
        relationComboCondtion = getCookie('place');
    } else if (comboID == 'employment' || comboID == 'business') {
        relationComboCondtion = getCookie('job');
    }
    if (relationComboCondtion == null) {
        relationComboCondtion = -1;
    }
    return relationComboCondtion;
}

function checkAreaAndJob(placevalue, jobvalue) {
    if (Number(placevalue) > 0 && checkJobValue(jobvalue)) {
        return true;
    } else {
        return false;
    }
}
function checkJobValue(jobvalue) {
    return Number(jobvalue) > 0;
}

/**
 * HTTPパラメータ列から指定したパラメータを削除する。
 *
 * @param string query
 * @param string param 削除したいパラメータの名
 * @return string
 */
function _deleteParam(query, param) {
    var iEnd = 0, iPos = query.indexOf('?'+param+'=');
    if ( iPos == -1 ) {
        iPos = query.indexOf('&'+param+'=');
    }
    if ( iPos == -1 ) {
        return query;
    }
    if ( iPos == 0 ) {
        iPos = 1;
    }
    iEnd = query.indexOf('&', iPos+param.length);
    if ( iEnd == -1 ) {
        iEnd = query.length;
    }
    query = query.substr(0, iPos) + query.substr(iEnd);
    return query;
}

function gotoURL(page, mode) {
    /*
    ** mode = 0：求人検索タブをクリックした際
    */
    if (!mode) {
        if (checkAreaAndJob(getCookie('place', 0), getCookie('job', 0))) {
            location.href = page;
        } else {
            displayAlert();
        }
        return;
    }
    var inputs = "{";
    inputs += "'data[currentpage]':'" + page + "'";
    
    inputs += "}";
    eval("var jsonData="+inputs);
    
    var formtype = '';
    switch (mode) {
        case 'search_map':
            formtype = 'searchForm';
            break;
        case 'search_station':
            formtype = 'formStation';
            break;
        case 'search_treat':
            formtype = 'formTreat';
            break;    
    }
    
    $.ajax({
        type: 'POST',
        url: $('form#'+formtype).attr('action'),
        data: jsonData,
        success: function(data) {
            $('div#detailAllListArea').html(data);
        }
    });    
    return;
}

function setStaticJob() {
    var comboID = 'job';
    //    if there is job's information from php...
    if ( $('span#static_job').is('span') == true ) {
        $('ul.navOne').children('li#'+comboID).children('input#' + comboID + 'Txt').val($('span#static_job').children('input#job_name').val());
        $('ul.navOne').children('li#'+comboID).children('input#' + comboID + 'Txt').attr("readOnly","true");
        $('ul.navOne').children('li#'+comboID).children('input#' + comboID + 'Txt').attr("disabled","");
        $('ul.navOne').children('li#'+comboID).children('input#' + comboID + 'Value').val($('span#static_job').children('input#job_id').val());
        //$('ul.navOne').children('li#'+comboID).children('a').children('img').attr('src', '/img/search/btn/btn_open_off.jpg');
        //$('ul.navOne').children('li#'+comboID).children('a').removeClass('btnOpe');
        //$('ul.navOne').children('li#'+comboID).children('a').addClass('btnOpeOff');
        
        setCookie('job', $('span#static_job').children('input#job_id').val(), 1);
        setCookie('jobname', $('span#static_job').children('input#job_name').val(), 1);
        _refreshCookieArea_Ex();
    } else {
        var job_code = $("input#job_code").val();
        if (job_code === undefined) {
            job_code = "";
        }
        if (job_code != "") {
            setCookie('job', $('input#job').val(), 1);
            setCookie('jobname', $('input#job_name').val(), 1);
        }
        if (getCookie('job', 0) > 0) {
            $('ul.navOne').children('li#'+comboID).children('input#' + comboID + 'Txt').val(getCookie('jobname', 0));
            $('ul.navOne').children('li#'+comboID).children('input#' + comboID + 'Value').val(getCookie('job', 0));
        }
        $('ul.navOne').children('li#'+comboID).children('input#' + comboID + 'Txt').attr("readOnly","true");
        $('ul.navOne').children('li#'+comboID).children('input#' + comboID + 'Txt').attr("disabled","");        
        //$('ul.navOne').children('li#'+comboID).children('a').children('img').attr('src', '/img/search/btn/btn_open_off.jpg');
        //$('ul.navOne').children('li#'+comboID).children('a').removeClass('btnOpe');
        //$('ul.navOne').children('li#'+comboID).children('a').addClass('btnOpeOff');
    }
}

function common_sort(param, page) {   
    $('input#sort').val(param);
    
    var inputs = "{";
    inputs += "'data[currentpage]':'1'";
    inputs += ", '" + $("input#sort").attr('name') + "':'" + $("input#sort").val() + "'";
    inputs += "}";
    eval("var jsonData="+inputs);
         
    $.ajax({
        type: 'POST',
        url: $('form#'+page).attr('action'),
        data: jsonData,
        success: function(data) {
            $('div#detailAllListArea').html(data);
        }
    });    
    return;
}

function executeReset(param) {
    
    setCookie('business', -1, 1);
    setCookie('employment', -1, 1);
    setCookie('detailview', -1, 1);
    setCookie('moneyclass', -1, 1);
    setCookie('moneyvalue', '', 1);
    setCookie('keyword', '', 1);

    var emptyArr = new Array();
    //if( window.refreshAdver || refreshAdver )
    //求人検索、新着検索、各種職種検索ページのみに動作するようにする
    if ($('div#searchBox').size() > 0) {
        //refreshAdver(emptyArr);
    }
    mode = 1;
    //求人詳細ページの場合には、mode=0にする
    if ($('input#wahtisjuliet').size() > 0) {
        mode = 0;
    }
    /*
    ** param = 1：ログインエリアのリセットボタン
    ** param = 0：待遇検索画面のリセットボタン
    */
    if (param) {
        setCookie('place', -1, mode+2);
        setCookie('placename', '', mode+2);
        setCookie('job', -1, mode+2);
        setCookie('jobname', -1, mode+2);
        location.href = '/';
    } else {
        setCookie('placesub', -1, mode);
        setCookie('placesubname', '', mode);
        setCookie('railway', -1, mode);
    }
    return;
}

function executeChange() {
    /*
    if($('div#myCookieConfig').is('div') == false)
    {
        return;
    }
    var cookieDisplay = "";
    var my_place = $('input#my_place').val();
    var my_placename = $('input#my_placename').val();
    var my_job = $('input#my_job').val();
    var my_jobname = $('input#my_jobname').val();
    if (my_place == '' || my_placename == '' || my_job == '' || my_jobname == '')
    {
        return;
    }
    mode = 1;
    //求人詳細ページの場合には、mode=0にする
    if ($('input#wahtisjuliet').size() > 0)
    {
        mode = 0;
    }
    setCookie('place', my_place, mode+2);
    setCookie('placename', my_placename, mode+2);
    setCookie('job', my_job, mode+2);
    setCookie('jobname', my_jobname, mode+2);
    */
    location.href = '/user/profile/#profileConditionsBox';
}

function setPlaceActionLog(value) {
    var ajaxURL = '/ajax/set_place';	
    $.ajax({
        type: 'POST',
        url: ajaxURL,
        data : { value : value },
        success: function(data) {
        }
    });
}

function setJobActionLog(value) {
    var ajaxURL = '/ajax/set_job';	
    $.ajax({
        type: 'POST',
        url: ajaxURL,
        data : { value : value },
        success: function(data) {
        }
    });
}

function displayAlert() {
    var job_code = $("input#job_code").val();
    if (job_code === undefined) {
        job_code = "";
    }
    if (job_code != "" ) {
        alert( 'エリアを選択してください。' );
    } else {
        alert( '都道府県と職種を選択してください。' );
        location.href = "/";
    }
}