// Date Display Function
function displayDate(){
	var this_month = new Array(12);
	this_month[0]  = "January";
	this_month[1]  = "February";
	this_month[2]  = "March";
	this_month[3]  = "April";
	this_month[4]  = "May";
	this_month[5]  = "June";
	this_month[6]  = "July";
	this_month[7]  = "August";
	this_month[8]  = "September";
	this_month[9]  = "October";
	this_month[10] = "November";
	this_month[11] = "December";
	
	var today = new Date();
	var day   = today.getDate();
	var month = today.getMonth();
	var year  = today.getYear();
	if (year < 1900){
		year += 1900;
	}
	return(day+" "+this_month[month]+" " +year);
}

var MyZipArea1;
var MyZipArea2;
var MyAddressArea;

// 郵便番号から住所を検索して表示する
function zip_code(MyForm) {
	
	var code = MyForm.zip1.value +  MyForm.zip2.value;
	
	// 郵便番号が入力されていなければエラー
	if (code.length <= 0) {
		alert ("郵便番号を入力してください");
		MyForm.zip1.focus();
		return false;
	}
	// 郵便番号が 3桁＋4桁 の書式になっていなければエラー
	if (code.length != 7) {
		alert ("郵便番号が “000-0000” の書式になっていません");
		MyForm.zip1.focus();
		return false;
	}
	
	// 既に住所が入力されていれば、確認メッセージを表示する
	if (MyForm.address.value.length != 0) {
		var res = confirm("現在入力されている住所の内容がクリアされますが、よろしいですか？");
		if (res == false) {
			return false;
		}
	}
	
	
	MyZipArea1 = MyForm.zip1;
	MyZipArea2 = MyForm.zip2;
	MyAddressArea = MyForm.address;
	
	
	// 住所検索プログラムの場所とパラメータを指定する
	//var url   = 'http://localhost/veritas/php/zip/zip.php';
	var url   = 'http://veritas.bz/php/zip/zip.php';
	var param = 'zip=' + code;
	
	// 非同期通信を開始する
	var myAjax = new Ajax.Request (url, { method: 'get', parameters: param, onComplete: showResponse});
	
}

// 住所検索結果をテキストボックスに表示する
function showResponse (originalRequest) {
	var str = originalRequest.responseText;
	
	// 結果が返ってこなければエラーメッセージを表示する
	if (str.length == 0) {
		var code = MyZipArea1.value + "-" + MyZipArea2.value;
		alert ("郵便番号 " + code + " の住所が見つかりません");
		
	// 結果を住所入力エリアに表示する
	} else {
		
		// responseText を URLdecode してから再度 encode する
		// Safari 文字化け対策
		if ( navigator.appVersion.indexOf( "KHTML" ) > -1 ) {
			var str = escape(str);
			if ( str.indexOf("%u") < 0 && str.indexOf("%") > -1 ) {
				str = decodeURIComponent(str);
			}
		}
		
		MyAddressArea.value = str;
		MyAddressArea.focus();
	}
}


// ストリーミングムービーのウィンドウを開く
function show_moviewindow (name, target, type) {
	
	var flg = true;
	
	if (type != "wmv" && type != "rm") {
		flg = false;
	}
	
	if (target != "p" && target != "s") {
		flg = false;
	}
	
	if (name != "about_veritas" &&
		name != "veritas_info" &&
		name != "eibunpou" &&
		name != "center-L3" &&
		name != "center-lesson") {
		
		flg = false;
	}
	
	//var page_path = "http://localhost/veritas/movie/";
	var page_path = "http://veritas.bz/movie/";
	//var page_name = page_path + name + "_" + target + "_" + type + ".html";
	var page_name = page_path + 'movie.php?t=' + target + '&mt=' + type + '&mv=' + name;
	
	if (flg == true) {
		var url   = 'http://veritas.bz/php/data/data.php';
		var param = 'ref=' + document.referrer + '&req=' + document.URL + '&clk=' + name + '_' + target + '_' + type;
		var myAjax = new Ajax.Request (url, { method: 'get', parameters: param, onComplete: myResponseGet});
		
		// ムービーウィンドウを開く
		window.open(page_name, "samplewin", "height=680, width=700, location=no, menuber=no, scrollbars=no, toolbar=no, status=no");
	}
	
}

function myResponseGet (originalRequest) {
	;
}