// 日付チェック(共通)
function DateCheck(years, months, days){
	var flag = true;
	
	if (years == "" || isNaN(years)) {
		return false;
	}
	
	if (months == "" || isNaN(months)) {
		return false;
	}
	
	if (days == "" || isNaN(days)) {
		return false;
	}
	
	years = parseInt(years, 10);
	months = parseInt(months, 10) - 1;
	days = parseInt(days, 10);
	if (years < 1900) {
		return false;
	}
	
	var dates = new Date(years,months,days);
	
	if (dates.getYear() < 1900) {
		if (years != dates.getYear() + 1900) {
			flag = false;
		}
	} else {
		if (years != dates.getYear()) {
			flag = false;
		}
	}
	
	if (months != dates.getMonth()) {
		flag = false;
	}
	
	if (days != dates.getDate()) {
		flag = false;
	}
	
	if (flag) {
		return true;
	} else {
		return false;
	}
}

// クレジット有効期限チェック
function ValidationCreditExpr(year, month) {
	var isvalid = true;
	var dates = new Date();
	if (year == "" && month == "")  {
	  return true;
	}
	
	if ((year != "" && month == "") || (year == "" && month != "")) {
	  return false;
	}

	var years = parseInt("20"+year);
	var months = parseInt(month, 10) - 1;
	
	if (months > 11) {
      isvalid = false;
	} else if (dates.getYear() > years ) {
      isvalid = false;
	} else if (dates.getYear() == years && dates.getMonth() > months) {
      isvalid = false;
	}
	return isvalid;
}

// ステータスバーにURLを表示しない
function noURL(){
	window.status = "";
	return true;
}

function PressKeyCheck(e){

	// Alt + ←
	if(window.event.altKey==true && event.keyCode == 37) {
		return false;
	}

	// Alt + →
	if(window.event.altKey==true && event.keyCode == 39) {
		return false;
	}

	// BackSpace
	if( event.keyCode == 8 ) {
			//テキストボックス、パスワードボックスは許す 
			for (i = 0; i < document.all.tags("INPUT").length; i++) { 
				if (document.all.tags("INPUT")(i).name == window.event.srcElement.name && 
					(document.all.tags("INPUT")(i).type == "text" || document.all.tags("INPUT")(i).type == "password") && 
					document.all.tags("INPUT")(i).readOnly == false){ 
					return true; 
				} 
			} 
			//テキストエリアは許す 
			for (i = 0; i < document.all.tags("TEXTAREA").length; i++) { 
				if (document.all.tags("TEXTAREA")(i).name == window.event.srcElement.name && 
					document.all.tags("TEXTAREA")(i).readOnly == false){ 
					return true; 
				} 
			}
			//参照エリアは許す
			for (i = 0; i < document.all.tags("INPUT").length; i++) { 
				if (document.all.tags("INPUT")(i).name == window.event.srcElement.name && 
					document.all.tags("INPUT")(i).type == "file" && 
					document.all.tags("INPUT")(i).readOnly == false){ 
					return true; 
				} 
			}        

		return false ; 
	}
	// ESC
	if( event.keyCode == 27 ) {
		return false ; 
	}
		  
	// F5（ファンクションキー）
	if( event.keyCode == 116 ) {
		event.keyCode = 0
		return false ; 
	}
	
	//■開発管理番号-08A10000 START h.yamazaki
	//対2008-00402
	// Ctrl + b（お気に入りの整理）
	if( window.event.ctrlKey == true && event.keyCode == 66 ) {
		event.keyCode = 0
		return false ; 
	}
	// Ctrl + d（お気に入りに追加）
	if( window.event.ctrlKey == true && event.keyCode == 68 ) {
		event.keyCode = 0
		return false ; 
	}
	// Ctrl + h（履歴の表示）
	if( window.event.ctrlKey == true && event.keyCode == 72 ) {
		event.keyCode = 0
		return false ; 
	}
	// Ctrl + i（リンクの表示）
	if( window.event.ctrlKey == true && event.keyCode == 73 ) {
		event.keyCode = 0
		return false ; 
	}
	// Ctrl + n（現在の画面を新規ウインドウで表示）
	if( window.event.ctrlKey == true && event.keyCode == 78 ) {
		event.keyCode = 0
		return false ; 
	}
	//■開発管理番号-08A10000 END   h.yamazaki

	// Ctrl + r（画面更新）
	if( window.event.ctrlKey == true && event.keyCode == 82 ) {
		event.keyCode = 0
		return false ; 
	}
}

function DisableOnContextMenu(ev) {
	//テキストボックス、パスワードボックスは許す 
	for (i = 0; i < document.all.tags("INPUT").length; i++) { 
		if (document.all.tags("INPUT")(i).name == window.event.srcElement.name && 
			(document.all.tags("INPUT")(i).type == "text" || document.all.tags("INPUT")(i).type == "password") && 
			document.all.tags("INPUT")(i).readOnly == false){ 
			return true; 
		}
	}
	return false;
}

function DisableContextMenu(ev) {
	if (ev) {
		if (ev.button && ev.button == 2) {  // W3C DOM2
			return false;
		} else if (!ev.button && ev.which == 3) {  // N4
			return false;
		} else if (navigator.platform.indexOf("Mac")!=-1
		&& navigator.appName == "Netscape") {
			return false;
		}
	} else {
		if (event && event.button && event.button == 2) {  // IE
			return false;
		}
	}
}

if (navigator.appName == "Netscape"
&& !(navigator.platform.indexOf("Mac")!=-1)) {
document.captureEvents(Event.MOUSEDOWN);
}


function CreditInfoCheck(valid_mm,valid_yy,credit_no){
	if ((valid_mm == "" && valid_yy == "" && credit_no == "") || (valid_mm != "" && valid_yy != "" && credit_no != "")){
		return true;
	}else{
		return false;
	}
}
