$(document).ready(function() {    if ($('input#status').val() == 1) {        intGadgetTool();        setSortable();            initMiniButton();        initCloseButton();        initSettingButton();        initOkButton();        initCancelButton();    }});function intGadgetTool() {    $('div#addListBox').click(function() {        $(this).next('div').slideToggle();    });        $('div#access_li').children('a').click(function() {        $('div#jobInfoRecordArea').show();        if ($('div#firstNaviBar').children('div.minNaviBtnIcon').children('a.toggle').children('img').attr('class') == 'btn minus') {            $('div#jobInfoRecordArea').children('div').show();        }        $(this).parent('div').slideUp('slow', function(){            if ($('div#add_box').children('div:not(:hidden)').length == 0) {                $('div#gadgetAddArea').slideUp('slow');            }            saveGadgetStatus('open', '');        });    });        $('div#blog_li').children('a').click(function() {        $('div#newBlogArea').show();        if ($('div#secondNaviBar').children('div.minNaviBtnIcon').children('a.toggle').children('img').attr('class') == 'btn minus') {            $('div#newBlogArea').children('div').show();        }        $(this).parent('div').slideUp('slow', function(){            if ($('div#add_box').children('div:not(:hidden)').length == 0) {                $('div#gadgetAddArea').slideUp('slow');            }            saveGadgetStatus('open', 'newBlogArea');        });    });}function setSortable() {    //$('div#naviBoxArea').sortable({    $('div.naviBoxArea').sortable({        opacity: 0.7,        update:function(){            $('div.handleBar').each(function(i,v){                if (i == 0)                {                    saveGadgetStatus('order', $(this).parent('div').attr('id'));                }            });        }            });    $('div.handleBar').css('cursor', 'move');}function initMiniButton() {    $('a.toggle').click(function() {		$(this).parent('div').parent('div').next('div').slideToggle("slow",function(){		    		    var img = $(this).prev('div').children('div.minNaviBtnIcon').children('a.toggle').children('img');		    var id = $(this).parent('div').attr('id');		    		    if ($(this).css('display') == 'none') {    		        img.attr('src', '/img/common/tools/btn/un_btn_plus.gif');    		        img.attr('class', 'btn plus');    		        saveGadgetStatus('mini', $(this).parent('div').attr('id'));		    } else {    		        img.attr('src', '/img/common/tools/btn/un_btn_minus.gif');    		        img.attr('class', 'btn minus');    		        saveGadgetStatus('max', $(this).parent('div').attr('id'));		    }    		    initsetButtonImages();		});    });}function initCloseButton() {    if ($('div#jobInfoRecordArea').css('display') != 'none' )    {        $('div#access_li').hide();    }    if ($('div#newBlogArea').css('display') != 'none' )    {        $('div#blog_li').hide();    }        $('a.close').click(function() {        $('div#gadgetAddArea').show();        $('div#add_box').show();                if ($(this).attr('id') == 'access_close') {            $('div#access_li').slideDown();        } else {            $('div#blog_li').slideDown();        }                $(this).parent('div').parent('div').next('div').slideUp('slow', function() {            $(this).parent('div').hide();        });        saveGadgetStatus('close', $(this).parent('div').parent('div').parent('div').attr('id'));    });}function initSettingButton() {    $('a.switchConfigArea').click(function() {        $(this).parent('div').prev('div').slideToggle('slow', function() {            var id = $(this).parent('div').parent('div').attr('id');        });        return;    });}function initOkButton() {    $("input.plus_menu[@type='button']").click(function() {        var showItems = $(this).prev('select').val()*2 -1;        $(this).parent('div').parent('div').children('div.item').each(function(index) {            if (index < showItems) {                $(this).show();            } else {                $(this).hide();            }        });        $(this).parent('div').slideToggle('slow');        if ($(this).parent('div').parent('div').parent('div').attr('id') == 'newBlogArea') {            saveGadgetStatus('count_blog', $(this).prev('select').val());        } else {            saveGadgetStatus('count_access', $(this).prev('select').val());        }    });}function initCancelButton() {    $("input.min_menu[@type='button']").click(function() {                $(this).parent('div').slideToggle('slow', function() {            var id = $(this).parent('div').parent('div').attr('id');        });    });}function saveGadgetStatus(mode, value) {        if (mode == 'count_access')    {        $('input#gadget2Value1').val(value);    }    if (mode == 'count_blog')    {               $('input#gadget1Value1').val(value);    }    if (mode == 'close')    {        if (value == 'newBlogArea') {            $('input#gadget1Value2').val(0);        } else {            $('input#gadget2Value2').val(0);        }    }    if (mode == 'mini')    {        if (value == 'newBlogArea') {            $('input#gadget1Value3').val(0);        } else {            $('input#gadget2Value3').val(0);        }    }    if (mode == 'max')    {        if (value == 'newBlogArea') {            $('input#gadget1Value3').val(1);        } else {            $('input#gadget2Value3').val(1);        }    }    if (mode == 'open')    {        if (value == 'newBlogArea') {            $('input#gadget1Value2').val(1);        } else {            $('input#gadget2Value2').val(1);        }    }    if (mode == 'order')    {        if (value == 'newBlogArea') {            $('input#firstOrder').val(1);        } else {            $('input#firstOrder').val(2);        }    }    var inputs = {                 'blogvalue1':$('input#gadget1Value1').val(),                  'blogvalue2':$('input#gadget1Value2').val(),                  'blogvalue3':$('input#gadget1Value3').val(),                  'firstOrder':$('input#firstOrder').val(),                 'accessvalue1':$('input#gadget2Value1').val(),                  'accessvalue2':$('input#gadget2Value2').val(),                  'accessvalue3':$('input#gadget2Value3').val()    };        $.ajax({        type: 'POST',        url: '/ajax/gadget',        data:inputs,        success: function(data) {        }    });    }