/*
 * SimpleModal Confirm Modal Dialog
 * http://www.ericmmartin.com/projects/simplemodal/
 * http://code.google.com/p/simplemodal/
 *
 * Copyright (c) 2008 Eric Martin - http://ericmmartin.com
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Revision: $Id: confirm.js 132 2008-05-23 16:05:17Z emartin24 $
 *
 */


function confirm(message, callback,callback1) {
	$('#confirm').modal({
		close:false, 
		overlayId:'confirmModalOverlay',
		containerId:'confirmModalContainer', 
		onShow: function (dialog) {
			dialog.data.find('.message').append(message);

			// if the user clicks "yes"
			dialog.data.find('.yes').click(function () {
				// call the callback
				if ($.isFunction(callback)) {
					callback.apply();
				}
				// close the dialog
				$.modal.close();
			});
        }
	});
}

function alert(message,callback){
    $('#alert').modal({
		close:false,
		overlayId:'confirmModalOverlay',
		containerId:'confirmModalContainer',
		onShow: function (dialog) {
			dialog.data.find('.message').append(message);

			// if the user clicks "yes"
			dialog.data.find('.yes').click(function () {
                if ($.isFunction(callback)) {
					callback.apply();
				}
                $.modal.close();
			});
		}
	});
}

function expendPanel(scrollDivId,titleHrefId) {
        var dv = document.getElementById(scrollDivId);
        dv.style.display == 'none' ? dv.style.display = 'block' : dv.style.display = 'none';
        var opDiv = document.getElementById(titleHrefId);
        if (dv.style.display == 'none') {
            opDiv.className = '';
            opDiv.className = 'closeDiv';
        } else {
            opDiv.className = '';
            opDiv.className = 'openDiv';
        }
    }
 function changeDisplay(divId){
               var dv=document.getElementById(divId);
               var topDV=document.getElementById(divId+"title");
               dv.style.display == 'none' ? (dv.style.display = 'block',topDV.className='close') : (dv.style.display = 'none',topDV.className='open');
         }

function $moveTo(toward,width,second) {
//         var $li=$('#scroll_list li:first-child');
//         var liWidth=parseInt($li.css('width'))+parseInt($li.css('padding-left'))+parseInt($li.css('padding-right'))+parseInt($li.css('margin-left'))+parseInt($li.css('margin-right'));
        if(isCanMove()){
            for (var i = 0; i < 40; i++) {
//                setTimeout("$move("+liWidth+","+toward+ ")", 40 * i);
                setTimeout("$move("+width+","+toward+ ")", second * i);
            }
        }
    }
    function $move(width,toward) {
        if(isCanMove(toward)){
            document.getElementById('scroll_list').style.left = document.getElementById('scroll_list').offsetLeft +width/40 *toward+ 'px';
        }
    }
    function isCanMove(toward){
        var left=document.getElementById('scroll_list').offsetLeft;
        var showWidth=parseInt($('#scroll_con').css('width'));
        var listWidth=parseInt($('#scroll_list').css('width'));
        var canshow=-1*listWidth+showWidth;
        if(toward>0&&left>=0) return false;
        if(toward<0&&left<=canshow) return false;
        return true;
    }