function getNextIndex(objs) {
	var maxId = -1;
	for ( var i = 0; i < objs.length; i++) {
		var eleid = objs[i].id;
		var spls = eleid.split("_");
		var id = spls[spls.length - 1];
		if (!isNaN(id)) {
			maxId = Math.max(id, maxId);
		}
	}
	return Math.max(maxId + 1, objs.length);
}

function gotoAction(formId, action) {
	$("#" + formId).attr("action", action);
	$("#" + formId).submit();
}
function createProgress(msg){
	var $div = $('<table border="1" style="opacity: .70;filter:Alpha(Opacity=70);background-color:#cfcfcf;position:absolute;left:0px;top:0px;width:100%;height:100%;border: 1px solid #000000;z-Index:10000;" align="center"><tr><td align="center" valign="middle">请稍候，'+ msg + '......<br/><br/><img src="images/wait.gif" width="150" height="13"/></td></tr></table>');
	$('body').append($div);
	return $div;
}

/*
function animation() {
	$('.tooltip').bt({
		showTip : function(box) {
			var $content = $('.bt-content', box).hide();
			var $canvas = $('canvas', box).hide();
			var origWidth = $canvas[0].width;
			var origHeight = $canvas[0].height;
			$(box).show();
			$canvas.css( {
				width : origWidth * .5,
				height : origHeight * .5,
				left : origWidth * .25,
				top : origHeight * .25,
				opacity : .1
			}).show().animate( {
				width : origWidth,
				height : origHeight,
				left : 0,
				top : 0,
				opacity : 1
			}, 400, 'easeOutBounce', function() {
				$content.show()
			});
		},
		hideTip : function(box, callback) {
			var $content = $('.bt-content', box).hide();
			var $canvas = $('canvas', box);
			var origWidth = $canvas[0].width;
			var origHeight = $canvas[0].height;
			$canvas.animate( {
				width : origWidth * .5,
				height : origHeight * .5,
				left : origWidth * .25,
				top : origHeight * .25,
				opacity : 0
			}, 400, 'swing', callback);
		},
		fill : '#FFF',
		cornerRadius : 10,
		shrinkToFit : true,
		strokeWidth : 0,
		shadow : true,
		shadowOffsetX : 3,
		shadowOffsetY : 3,
		shadowBlur : 8,
		shadowColor : 'rgba(0,0,0,.9)',
		shadowOverlap : false,
		noShadowOpts : {
			strokeStyle : '#999',
			strokeWidth : 2
		},
		positions : ['bottom'],
		hoverIntentOpts : {
			interval : 0,
			timeout : 0
		}
	})
}
*/
function replaceName(html ,expr ,count){
	var start = html.indexOf(expr) + expr.length;
	var chars = html.substr(start ,10);
	var end = chars.indexOf("]");
	if (end != -1) {
		var expr1 = expr + chars.substr(0 ,end) + "]";
		var expr2 = expr + count + "]";
//		html = html.replace(new RegExp(expr1 ,"gm") ,expr2);
		while (html.indexOf(expr1) != -1)
			html = html.replace(expr1 ,expr2);//new RegExp(expr1 ,"gm") ,expr2);
	}
	return html;
}

function previousPage(formId ,action ,divId){
	var start = $("#pageStart").val();
	$("#pageStart").val(start - 1);
	var params = $('#' +formId).serialize();
	$.ajax({type:'POST',url:action ,data: params,success:function(msg){
		$('#'+divId).html(msg);
	}});
}

function nextPage(formId ,action ,divId){
	var start = $("#pageStart").val();
	$("#pageStart").val(start - 0 + 1);
	var params = $('#' +formId).serialize();
	$.ajax({type:'POST',url:action ,data: params,success:function(msg){
		$('#'+divId).html(msg);
	}});
}

//是否为日期
String.prototype.isDate = function(){
	var regexp = /^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$/;
	return regexp.test(this);
}

//是否为数字
String.prototype.isNumber = function(){
	var regexp = /^\d*$/;
	return regexp.test(this);
}

//是否为字母
String.prototype.isLetter = function(){
	var regexp = /^[a-zA-Z]+$/;
	return regexp.test(this);
}
