//start page function
var ct_page = 1;
var no_page = 8;

function firstPage(){
	var max_page = $('#pagebar').find('#max_page').html();
	if(ct_page != 1){
		initTable(1);
		ct_page = 1;
		initPageBar(ct_page);
	}
}
function previousPage(){
	var max_page = $('#pagebar').find('#max_page').html();
	if(ct_page <= max_page && ct_page>1){
		initTable(ct_page-1);
		ct_page--;
		initPageBar(ct_page);
	}
}
function nextPage(){
	var max_page = $('#pagebar').find('#max_page').html();
	if(ct_page < max_page){
		initTable(ct_page+1);
		ct_page++;
		initPageBar(ct_page);
	}
}
function lastPage(){
	var max_page = $('#pagebar').find('#max_page').html();
	
	if(max_page != null && ct_page != max_page){
		initTable(max_page);
		ct_page = max_page;
		initPageBar(ct_page);
	}
}
//end page function

//start message function
function showSuccessMessage(msg){
	var ss = [];
	ss.push('<div id="message-green">');
	ss.push('<table border="0" width="100%" cellpadding="0" cellspacing="0">');
	ss.push('<tr>');
	ss.push('<td class="green-left">'+msg+'</td>');
	ss.push('<td class="green-right"><a class="close-green"><img src="images/table/icon_close_green.gif"   alt="" /></a></td>');
	ss.push('</tr>');
	ss.push('</table>');
	ss.push('</div>');
	
	$('#message_show').html(ss.join(''));
	
	$(".close-green").click(function () {
		$("#message-green").fadeOut("slow");
	});
}

function showErrorMessage(msg){
	var ss = [];
	ss.push('<div id="message-red">');
	ss.push('<table border="0" width="100%" cellpadding="0" cellspacing="0">');
	ss.push('<tr>');
	ss.push('<td class="red-left">'+msg+'</td>');
	ss.push('<td class="red-right"><a class="close-red"><img src="images/table/icon_close_red.gif"   alt="" /></a></td>');
	ss.push('</tr>');
	ss.push('</table>');
	ss.push('</div>');
	
	$('#message_show').html(ss.join(''));
	
	$(".close-red").click(function () {
		$("#message-red").fadeOut("slow");
	});
}

function showTipsMessage(msg){
	var ss = [];
	ss.push('<div id="message-yellow">');
	ss.push('<table border="0" width="100%" cellpadding="0" cellspacing="0">');
	ss.push('<tr>');
	ss.push('<td class="yellow-left">'+msg+'</td>');
	ss.push('<td class="yellow-right"><a class="close-yellow"><img src="images/table/icon_close_yellow.gif"   alt="" /></a></td>');
	ss.push('</tr>');
	ss.push('</table>');
	ss.push('</div>');
	
	$('#message_show').html(ss.join(''));
	
	$(".close-yellow").click(function () {
		$("#message-yellow").fadeOut("slow");
	});
}

function showWelcomeMessage(msg){
	var ss = [];
	ss.push('<div id="message-blue">');
	ss.push('<table border="0" width="100%" cellpadding="0" cellspacing="0">');
	ss.push('<tr>');
	ss.push('<td class="blue-left">'+msg+'</td>');
	ss.push('<td class="blue-right"><a class="close-blue"><img src="images/table/icon_close_blue.gif"   alt="" /></a></td>');
	ss.push('</tr>');
	ss.push('</table>');
	ss.push('</div>');
	
	$('#message_show').html(ss.join(''));
	
	$(".close-blue").click(function () {
		$("#message-blue").fadeOut("slow");
	});
}
//end message function

//start mutil array
jQuery.extend({  
	uniqueArray:function(a) {  
    	var r=[];  
        for (var i=0,l=a.length; i<l; ++i)jQuery.inArray(a[i],r)<0&&r.push(a[i]);  
        return r;  
    }  
})  
//end mutil array

//start cn date
jQuery(function($){
        $.datepicker.regional['zh-cn'] = {
                prevText: '上月',
                nextText: '下月',
                currentText: '今天',
                monthNames: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
                monthNamesShort: ['一','二','三','四','五','六','七','八','九','十','十一','十二'],
                dayNames: ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'],
                dayNamesShort: ['周日','周一','周二','周三','周四','周五','周六'],
                dayNamesMin: ['日','一','二','三','四','五','六'],
                weekHeader: '周',
                dateFormat: 'yy年mm月dd日',
                firstDay: 0,
                isRTL: false,
                showMonthAfterYear: true};
        $.datepicker.setDefaults($.datepicker.regional['zh-cn']);
	});
//end cn date
	
function ForDight(Dight,How){  
	Dight = Math.round(Dight*Math.pow(10,How))/Math.pow(10,How);  
    return Dight;  
} 

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};


