/* function GotoPage_post(iPage) {
	document.search_text.curPg.value = iPage;
	document.search_text.submit();
	}
*/

function GotoPage_post(iPage) {
		
	document.search_en.curPg.value = iPage;
	document.search_en.submit();
	}
function GotoPage_view(iPage) {
		
	document.view.curPg.value = iPage;
	document.view.submit();
	}

function GotoPage(iPage) {
	document.search_en.curPg.value = iPage;
	document.search_en.submit();
	}
function Goto(iPage) {
	document.show.curPg.value = iPage;
	document.show.submit();
	}

function Check_Input() {
	if (document.input.nhande.value=="")
	{
		alert("Bạn hãy nhập nhan đề");
		document.input.nhande.focus();
		return false;
	}
	if (document.input.tacgia.value=="")
	{
		alert("Bạn hãy nhập tác giả");
		document.input.tacgia.focus();
		return false;
	}
	if (document.input.sotrang.value=="")
	{
		alert("Bạn hãy nhập số trang");
		document.input.sotrang.focus();
		return false;
	}
	if (document.input.sheet.value=="")
	{
		alert("Bạn hãy nhập kích thước");
		document.input.sheet.focus();
		return false;
	}
	if (document.input.mahieu.value=="")
	{
		alert("Bạn hãy nhập mã hiệu");
		document.input.mahieu.focus();
		return false;
	}
	if (document.input.tukhoa.value=="")
	{
		alert("Bạn hãy nhập từ khoá");
		document.input.tukhoa.focus();
		return false;
	}
	if (document.input.vnpf.value != "")
	{
		var str1 = document.input.vnpf.value;
		if (str1.length > 3)
		{
		}else{
//			var str = "../nlvnpf/images_books/nlvnpf-";
//			str+= document.input.vnpf.value;
//			str+= "/nlvnpf-" + document.input.vnpf.value + ext;
//			document.write(str);
			alert("Bạn nhập mã số chưa đúng");
			document.input.vnpf.focus();
			return false;
		}				
		var dem = document.input.sheet.value;
		for(var i=1;i<=dem;i++)
		{
			var ext = "";
			var str = "./images_books/nlvnpf-";
			str+= document.input.vnpf.value;
			if (i < 10)
			{
				ext = "00" + i.toString();
			}else{
				if (i > 9 && i <100)
				{
					ext = "0" + i;
				}else{
					ext = i;
				}
			}
			str+= "/nlvnpf-" + document.input.vnpf.value + "-" + ext + ".jpg";
//			fs = new File(str);
//			if(isFile(str)){
//				alert("Thiếu file ảnh, bạn hãy kiểm tra lại.");
//			}else{
//				 alert("Thiếu file ảnh, bạn hãy kiểm tra lại.");
//			}
		}

//		if(!exists(str)){ alert("Chưa có thư mục ảnh cho sách này.");}
//		document.write(str);
	}
	
	if (document.input.width_.value=="")
	{
		alert("Bạn hãy nhập chiều rộng");
		document.input.width_.focus();
		return false;
	}else{
		var test = document.input.width_.value;		
		for(var i=0;i<test.length;i++){
			var j = test.charCodeAt(i);
			if (j > 58){
				alert("Bạn nhập chiều rộng không phải là dãy số. Hãy nhập lại");
				document.input.width_.focus();
				return false;
			}else{
			if (j < 48){
				if (j==44)
				{
				}else{
				alert("Bạn nhập chiều rộng không phải là dãy số. Hãy nhập lại");
				document.input.width_.focus();
				return false;
				}
				
			}
			}
		}
	}
	if (document.input.height_.value=="")
	{
		alert("Bạn hãy nhập chiều cao");
		document.input.height_.focus();
		return false;
	}else{
		var test = document.input.height_.value;		
		for(var i=0;i<test.length;i++){
			var j = test.charCodeAt(i);
			if (j > 58){
				alert("Bạn nhập chiều cao không phải là dãy số. Hãy nhập lại");
				document.input.height_.focus();
				return false;
			}else{
			if (j < 48){
				if (j==44)
				{
				}else{
				alert("Bạn nhập chiều cao không phải là dãy số. Hãy nhập lại");
				document.input.height_.focus();
				return false;
				}
			}
			}
		}
	}
	if (document.input.sheet.value=="")
	{
		alert("Bạn hãy nhập số tờ");
		document.input.sheet.focus();
		return false;
	}else{
		var test = document.input.sheet.value;		
		for(var i=0;i<test.length;i++){
			var j = test.charCodeAt(i);
			if (j > 58){
				alert("Bạn nhập số tờ không phải là dãy số. Hãy nhập lại");
				document.input.sheet.focus();
				return false;
			}else{
			if (j < 48){
				alert("Bạn nhập số tờ không phải là dãy số. Hãy nhập lại");
				document.input.sheet.focus();
				return false;
			}
			}
		}
	}
	if (document.input.nom.checked==true || document.input.han.checked==true || document.input.qn.checked==true)
	{}else{
		alert("Bạn hãy chọn ngôn ngữ viết Hán, Nôm");
		return false;
	}
	if (document.input.date_now.value=="")
	{
		alert("Bạn hãy nhập ngày");
		document.input.date_now.focus();
		return false;
	}	
	return true;
	}

function Check_update() {
	if (document.update.title_qn.value=="")
	{
		alert("Bạn hãy nhập nhan đề");
		document.update.title_qn.focus();
		return false;
	}
	if (document.update.title_hn.value=="")
	{
		alert("Bạn hãy nhập nhan đề");
		document.update.title_hn.focus();
		return false;
	}
	if (document.update.nlv.value=="")
	{
		alert("Bạn hãy nhập mã số");
		document.update.nlv.focus();
		return false;
	}
	if (document.update.vnpf.value=="")
	{
		alert("Bạn hãy nhập mã số");
		document.update.vnpf.focus();
		return false;
	}
	if (document.update.width_.value=="")
	{
		alert("Bạn hãy nhập chiều rộng");
		document.update.width_.focus();
		return false;
	}
	if (document.update.height_.value=="")
	{
		alert("Bạn hãy nhập chiều cao");
		document.update.height_.focus();
		return false;
	}
	if (document.update.sheet.value=="")
	{
		alert("Bạn hãy nhập số tờ");
		document.update.sheet.focus();
		return false;
	}
	if (document.update.date_now.value=="")
	{
		alert("Bạn hãy nhập ngày");
		document.update.date_now.focus();
		return false;
	}
	return true;
	}

//	function fileExists1(x) {
//		var str = "http://localhost/nlvnpf/images_books/nlvnpf-";
//		str+= document.input.vnpf.value;
/*		var dem = document.input.sheet.value;
		for(var i=1;i<=dem;i++)
		{
			var ext = "";
			var str = "http://localhost/images_books/nlvnpf-";
			str+= document.input.vnpf.value;
			if (i < 10)
			{
				ext = "00" + i.toString();
			}else{
				if (i > 9 && i <100)
				{
					ext = "0" + i;
				}else{
					ext = i;
				}
			}
			str+= "/nlvnpf-" + document.input.vnpf.value + "-" + ext + ".jpg";
//			var answer = '<?php return file_exists(file_name); ?>';
//			return answer;
		}
*/
//	}
