function logout(path){
	res = confirm('ログアウトしますか？');
	if(res==true){
		var url = path + 'index.php?lgo=out';
		var li = location.href=url;
		//var li = location.href = '/~naoki/spms/index.php?lgo=out';

	}
}

function chengepass(path){
	var popwin,w,h
	w = 500;
	h = 400;
	url = path+'userdata.php';
	popwin=window.open(url,"subwin","width=" + w + ",height=" + h + ",menubar=no,toolbar=no,location=yes,scrollbars=yes,status=yes,resizable=yes,fullscreen=no");
	popwin.focus();
}

function CheckDate(label){
	var str= document.forms[0].elements[label].value;
	if(str==""){
		//alert(label+"が入力されていません。");
		//return false;
	}else{
		var s=str.split("/");
		if(s.length!=3){
			alert("日付が yyyy/mm/dd 形式ではありません");
			return false;
		}
		var y=s[0];
		var m=s[1];
		var d=s[2];
		if(isNaN(y)||isNaN(m)||isNaN(d)){
			alert("数字以外の文字が含まれています");
			return false;
		}else{
			if(y.length!=4){
				alert("年は西暦４桁で入力してください");
				return false;
			}else{
				if(m<1||m>12){
					alert("月は１〜１２の数字を入力してください");
					return false;
				}else{
					if(d<=0 || d>30+((m==4||m==6||m==9||m==11)?0:1) || (m==2&&d>28+(((y%4==0&&y%100!=0)||y%400==0)?1:0)) ){
						alert(y+"年"+m+"月"+d+"日は不正な日付です");
						return false;
					}
					var id = new Date(y,m-1,d);
					var cd = new Date("January 31,2004");
					var fd = new Date("January 1,3001")
					if(id.getTime() <= cd.getTime()){
						alert('2004年1月31日以前は入力できません');
						return false;
					}
					if(id.getTime() >= fd.getTime()){
						alert('3000年12月31日以降は入力できません');
						return false;
					}
				}
			}
		}
	}
}

function CheckDateDiv(mm,dd,yy){
	var str = "tmp";
	var tm= document.forms[0].elements[mm].selectedIndex;
	var gm = document.forms[0].elements[mm][tm].text;
	var td= document.forms[0].elements[dd].selectedIndex;
	var gd = document.forms[0].elements[dd][td].text;
	var ty= document.forms[0].elements[yy].selectedIndex;
	var gy = document.forms[0].elements[yy][ty].text;
	if(tm==0 || td==0 || ty==0){
		alert('計上年月日が未入力です。');
		return false;
	}
	if(str==""){
		//alert(label+"が入力されていません。");
		//return false;
	}else{
		/*var s=str.split("/");
		if(s.length!=3){
			alert("日付が yyyy/mm/dd 形式ではありません");
			return false;
		}
		var y=s[0];
		var m=s[1];
		var d=s[2];*/
		var y=gy;
		var m=gm;
		var d=gd;
		if(isNaN(y)||isNaN(m)||isNaN(d)){
			alert("数字以外の文字が含まれています");
			return false;
		}else{
			if(y.length!=4){
				alert("年は西暦４桁で入力してください");
				return false;
			}else{
				if(m<1||m>12){
					alert("月は１〜１２の数字を入力してください");
					return false;
				}else{
					if(d<=0 || d>30+((m==4||m==6||m==9||m==11)?0:1) || (m==2&&d>28+(((y%4==0&&y%100!=0)||y%400==0)?1:0)) ){
						alert(y+"年"+m+"月"+d+"日は不正な日付です");
						return false;
					}
					var id = new Date(y,m-1,d);
					var cd = new Date("January 31,2004");
					var fd = new Date("January 1,3001")
					if(id.getTime() <= cd.getTime()){
						alert('2004年1月31日以前は入力できません');
						return false;
					}
					if(id.getTime() >= fd.getTime()){
						alert('3000年12月31日以降は入力できません');
						return false;
					}
					return datacheck_pljsub();
				}
			}
		}
	}
}

function setCategory(mode){
	var ctg = document.category.ctg.value;
	var ltmp = document.category.lctg.selectedIndex;
	if(ltmp<0 && mode=='lctg'){
		return false;	
	}else if(ltmp>=0){
		if(document.category.lctg[ltmp].value=='' && mode=='lctg'){
			return false;
		}else{
			if(document.category.lctg[ltmp].value!=''){
				var lctg = document.category.lctg[ltmp].value;
			}else{
				var lctg = '';	
			}
		}
	}
	var mtmp = document.category.mctg.selectedIndex;
	if(mtmp<0 && mode=='mctg'){
		return false;	
	}else if(mtmp>=0){
		if(document.category.mctg[mtmp].value=='' && mode=='mctg'){
			return false;
		}else{
			if(document.category.lctg[ltmp].value!=''){
				var mctg = document.category.mctg[mtmp].value;
			}else{
				var mctg = '';
			}
		}
	}
	var stmp = document.category.sctg.selectedIndex;
	if(stmp<0 && mode=='sctg'){
		return false;	
	}else if(stmp>=0){
		if(document.category.sctg[stmp].value=='' && mode=='sctg'){
			return false;
		}else{
			if(document.category.sctg[stmp].value!=''){
				var sctg = document.category.sctg[stmp].value;
			}else{
				var sctg = '';	
			}
		}
	}
	var gtmp = document.category.group.selectedIndex;
	if(gtmp<0 && mode=='group'){
		return false;	
	}else if(gtmp>0){
		if(document.category.group[gtmp].value=='' && mode=='group'){
			return false;
		}else{
			if(document.category.group[gtmp].value!=''){
				var group = document.category.group[gtmp].value;
			}else{
				var group = '';	
			}
		}
	}
	
	var url = 'index.php?mode='+mode+'&ctg='+ctg+'&lctg='+lctg+'&mctg='+mctg+'&sctg='+sctg;
	location.href=url;
	
	
}

function pricecall(group){
	var product,w,h,path
	w = 600;
	h = screen.height*0.8;
	url = 'index.php?mode=gprice&group='+group;
	prowin=window.open(url,"product","width=" + w + ",height=" + h + ",menubar=no,toolbar=no,location=yes,scrollbars=yes,status=yes,resizable=yes,fullscreen=no");
	prowin.focus();
}

function pagePrint(){
	window.print();	
}