function fnPage(page_no) {
	document.form1['page_no'].value = page_no;
	document.form1.submit();
}

function DrawImage(ImgD,FitWidth,FitHeight){
   var image=new Image();
   image.src=ImgD.src;
   if(image.width>0 && image.height>0){
       if(image.width/image.height>= FitWidth/FitHeight){
           if(image.width>FitWidth){
               ImgD.width=FitWidth;
               ImgD.height=(image.height*FitWidth)/image.width;
           }else{
               ImgD.width=image.width;
               ImgD.height=image.height;
           }
       } else{
           if(image.height>FitHeight){
               ImgD.height=FitHeight;
               ImgD.width=(image.width*FitHeight)/image.height;
           }else{
               ImgD.width=image.width;
               ImgD.height=image.height;
           }
       }
   }
}
function MM_goToURL() { 
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function resubmit( url ) {
	document.form1.action = url;
	document.form1.submit();
}
function redirect( redirect_url ) {
	window.location = redirect_url;
	return false;
}
function redirect_submit( url ) {
	document.form1.action = url;
	document.form1.submit();
}
function login_submit( url ) {
	document.login_form.action = url;
	document.login_form.submit();
}
//checkbox use
function Choose() {
	count = 0;
	for (var i=0;i<document.form1.elements.length;i++){
		if (document.form1.elements[i].name=="id[]") {
			document.form1.elements[i].checked = true;
			count ++;
		}
	}
}
function ChooseRece() {
	count = 0;
	for (var i=0;i<document.rece_form.elements.length;i++){
		if (document.rece_form.elements[i].name=="rece_sms_id[]") {
			document.rece_form.elements[i].checked = true;
			count ++;
		}
	}
}
function ChooseSend() {
	count = 0;
	for (var i=0;i<document.send_form.elements.length;i++){
		if (document.send_form.elements[i].name=="send_sms_id[]") {
			document.send_form.elements[i].checked = true;
			count ++;
		}
	}
}
function CheckAgree() {
	if(document.be_form.agree.checked == false){
		window.alert('请确认已阅读注册须知');
	}else{
		document.be_form.submit();
	}
}
function DeleteRece() {
	count = 0;
	for (var i=0;i<document.rece_form.elements.length;i++){
		if ((document.rece_form.elements[i].name=="rece_sms_id[]") && (document.rece_form.elements[i].checked)) {
			count ++;
		}
	}
	if (count < 1) {
		window.alert('未选择项目');
		return false;
	} else {
		msg = '确定要删除吗？';
		if (confirm(msg)) {
			document.rece_form.submit();
		}
	}
}
function DeleteSend() {
	count = 0;
	for (var i=0;i<document.send_form.elements.length;i++){
		if ((document.send_form.elements[i].name=="send_sms_id[]") && (document.send_form.elements[i].checked)) {
			count ++;
		}
	}
	if (count < 1) {
		window.alert('未选择项目');
		return false;
	} else {
		msg = '确定要删除吗？';
		if (confirm(msg)) {
			document.send_form.submit();
		}
	}
}
// cancel all checkbox
function Cancel() {
	count = 0;
	for (var i=0;i<document.form1.elements.length;i++){
		if (document.form1.elements[i].name=="id[]") {
			document.form1.elements[i].checked = false;
			count ++;
		}
	}
}
function ChooseCancel() {
	count = 0;
	if(document.getElementById('checkall').checked){
		for (var i=0;i<document.form1.elements.length;i++){
			if (document.form1.elements[i].name=="id[]") {
				document.form1.elements[i].checked = true;
				count ++;
			}
		}
	}else{
		for (var i=0;i<document.form1.elements.length;i++){
			if (document.form1.elements[i].name=="id[]") {
				document.form1.elements[i].checked = false;
				count ++;
			}
		}
	}
}
//checkbox use
function Delete() {
	count = 0;
	for (var i=0;i<document.form1.elements.length;i++){
		if ((document.form1.elements[i].name=="id[]") && (document.form1.elements[i].checked)) {
			count ++;
		}
	}
	if (count < 1) {
		window.alert('未选择项目');
		return false;
	} else {
		msg = '确定要删除吗？';
		if (confirm(msg)) {
			$("#mode").val("delete");
			document.form1.submit();
		}
	}
}
//checkbox use
function DeleteItem(url) {
		msg = '确定要删除吗？';
		if (confirm(msg)) {
			window.location.href = url;
		}
}
function LoginCheck() {
	
	if((document.login_form['login_name'].value=='')||(document.login_form['login_pass'].value=='')){
		window.alert("请输入用户名和密码");
	}else{
		document.login_form.submit();
	}
}
function LoginCheck2() {
	
	if((document.login_form2['login_name'].value=='')||(document.login_form2['login_pass'].value=='')){
		window.alert("请输入用户名和密码");
	}else{
		document.login_form2.submit();
	}
}
function CheckInput() {
	
	if(document.form2['keyword'].value==''){
		window.alert("内容不能为空");
	}else{
		document.form2.submit();
	}
}
function CheckContent2() {
	
	if(document.form2['content'].value==''){
		window.alert("评论内容不能为空");
	}else{
		document.form2.submit();
	}	
}
function CheckContent() {
	
	var text=document.getElementById("content").value;
	if(text==""){
		window.alert("评论内容不能为空");
	}else{
		document.comment_form.submit();
	}
}
