/*
--------------------------------------------------------
JavaScript Library File // for HAYABSA LANDINGS (C) 2005

Script Name: common.js

                               Designed by Tatsuo TAMURA
                               yoidore@yoidoretenshi.com
                            http://www.yoidoretenshi.com
--------------------------------------------------------
*/

//--------------------
// Popup Window
// 引数: 
//--------------------
function new_win_pop(url) {

	wWidth  = 720;
	wHeight = 445; 
	WidthCenter  = screen.availWidth / 2;
	HeightCenter = screen.availHeight / 2; 

	option = 'resizable=no,scrollbars=yes,width=' + wWidth + ',height=' + wHeight + ',left=' + (WidthCenter - (wWidth / 2)) + ',top=' + (HeightCenter - (wHeight / 2));

	window.open(url,'',option);
}

//--------------------
// Call Confirm Message
// 引数: Words（出力メッセージ）
//--------------------
function message(Words) {
	f = confirm(Words);
	return f
}

//--------------------
// Check From
// 引数: 
//--------------------
function checkForm() {
	//ID 1
	if (document.f1.id1.value==""){
		alert("\n品番1を入力して下さい\n（※必須項目です。）");
		document.f1.id1.focus();
		return false;
	}
	//ID 1
	if (isHankaku(document.f1.id1.value) != true){
		alert("\n品番1は半角英数字で入力して下さい");
//		document.f1.id1.value = "";
		document.f1.id1.focus();
		return false;
	}
	//ID 2
	if (document.f1.id2.value==""){
		alert("\n品番2を入力して下さい\n（※必須項目です。）");
		document.f1.id2.focus();
		return false;
	}
	//ID 2
	if (isHankaku(document.f1.id2.value) != true){
		alert("\n品番2は半角英数字で入力して下さい");
//		document.f1.id2.value = "";
		document.f1.id2.focus();
		return false;
	}
	//ID 3
	if (isHankaku(document.f1.id3.value) != true){
		alert("\n品番3は半角英数字で入力して下さい");
//		document.f1.id3.value = "";
		document.f1.id3.focus();
		return false;
	}
	//ARTIST
	if (document.f1.artist.value==""){
		alert("\nアーティスト名を入力して下さい\n（※必須項目です。）");
		document.f1.artist.focus();
		return false;
	}
	//TITLE
	if (document.f1.title.value==""){
		alert("\nタイトル名を入力して下さい\n（※必須項目です。）");
		document.f1.title.focus();
		return false;
	}
/*
	//PRICE (半角英数字)
	if (isHankaku(document.f1.price.value) != true){
		alert("\n価格は半角英数字で入力して下さい");
//		document.f1.price.value = "";
		document.f1.price.focus();
		return false;
	}
*/
	//PRICE (半角数字)
	if (!isNumeric(document.f1.price.value)){
		alert("\n価格は半角数字で入力して下さい\n（※カンマ「,」は不要です。）");
//		document.f1.price.value = "";
		document.f1.price.focus();
		return false;
	}
	//WEBSITE
	if (isHankaku(document.f1.webiste.value) != true){
		alert("\nＵＲＬは半角英数字で入力して下さい");
//		document.f1.webiste.value = "";
		document.f1.webiste.focus();
		return false;
	}
}

//--------------------
//半角数字チェック
//--------------------
function isNumeric(strValue){
	for(i=0; i < strValue.length; i++){
		if (strValue.substring(i, i+1)<"0" || strValue.substring(i, i+1)>"9"){
			return false;
		}
	}
	return true;
}

//--------------------
// 全角文字チェック
//--------------------
function isZenkakuNN(c) {
	var str = escape(c);
	if (str.charAt(0) != "%") {
		return false;
	}
	if ((str.charAt(1) == "8") && (str.charAt(1) == "9") && (str.charAt(1) == "E") && (str.charAt(1) == "F")) {
		return true;
	} else {
		return false;
	}
}

//--------------------
// 半角文字チェック
//--------------------
function isHankaku(strValue) {
	unitlength = "あ".length;
	if(unitlength == 2){
		for(i = 0; i < strValue.length; i++){
			if(isZenkakuNN(strValue.charAt(i))){
				return false;
			}
		}
	} else {
		for(i = 0; i < strValue.length; i++){
			if (escape(strValue.charAt(i)).charAt(1) == "u"){
				return false;
			}
		}
	}
	return true;
}


