/*
* Filename	: common.js
* Function	:
* Comment	:
* History		: 2003/05/09, jerry, setup
*									2006/04/13, litlhope, modify
*
* Version	: 1.0
* Author		: Copyright (c) 2005 by JcomTech Corp. All Rights Reserved.
*/

var IE = document.all;
var NS4 = document.layers;
var NS6 = !IE && document.getElementById != null ? true : false;
var doc = (IE ? document.all : document);

/* member login */
function __memSubmit(form, sslUrl) {
	if (!validData(form.memId.value, "memId", true, "", "100", "4", "会員ID", "")) {
		form.memId.focus();
		return false;
	}	else if (!validData(form.passwd.value, "", true, "", "15", "4", "パスワード", "")) {
		form.passwd.focus();
		return false;
	}
	
//	if (form.sslYn != null && form.sslYn.value == "Y") {
	if (form.sslYn != null && form.sslYn.checked) {
		form.action = sslUrl + "/~gate/hp_ssl.jsp";
	} else {
		form.action = "/login/";
	}

	return true;
}

/* open window */
function __openWindow(url, popupName, scrollFlag, resizeFlag, width, height, left, top) {
	popupName = popupName == null ? "popup" : popupName;
	scrollFlag = scrollFlag == null ? "no" : scrollFlag;
	resizeFlag = resizeFlag == null ? "no" : resizeFlag;
	width = width == null ? 300 : width;
	height = height == null ? 300 : height;
	left = left == null ? 50 : left;
	top = top == null ? 50 : top;
	
	window.open(url, popupName, "scrollbars=" + scrollFlag + ", resizable=" + resizeFlag + ", width=" + width + ", height=" + height + ", left=" + left + ", top=" + top);
}

function openWindow(url, width, height, popupName) {
	__openWindow(url, popupName, "no", "yes", width, height);
}

function openWindowFixed(url, width, height, popupName) {
	__openWindow(url, popupName, "no", "no", width, height);
}

function openWindowScroll(url, width, height, popupName) {
	__openWindow(url, popupName, "yes", "yes", width, height);
}

function openWindowPos(url, width, height, popupName, left, top) {
	__openWindow(url, popupName, "no", "yes", width, height, left, top);
}

function openWindowFixedPos(url, width, height, popupName, left, top) {
	__openWindow(url, popupName, "no", "no", width, height, left, top);
}

function openWindowScrollPos(url, width, height, popupName, left, top) {
	__openWindow(url, popupName, "yes", "yes", width, height, left, top);
}

/* get IE version */
function getIEVersion() {
	var IEVersion = 0;
//var browserName = navigator.appName;
	var idx = navigator.appVersion.indexOf("MSIE");

	if (idx > -1) {	IEVersion = parseFloat(navigator.appVersion.substr(idx + 4)); }

	return IEVersion;
}

/* get object */
function getObjectByName(objName) {
	var obj = null;
	if (IE) {obj = document.all[objName];}
	else {obj = document.getElementById(objName);}
	return obj;
}

/* make array SET(eliminate duplication) */
function makeSet(array){
	var arrayLength = array.length;
	var ary = new Array();
	var size = 0;
	ary[0] = array[0];
	var unique = true;
	for(i=0;i<arrayLength;i++){
		unique = true;
		size = ary.length;
		for(j=0;j<size;j++){
			if(array[i]==ary[j]){
				unique = false;
				break;
			}
		}
		if(unique){
			ary[size] = array[i];
		}
	}
	return ary;
}

/* Merge two Array (concatenate two array)*/
function mergeArray(iArray, jArray){
	var iSize = iArray.length;
	var jSize = jArray.length;
	var mArray = new Array();
	var mSize = 0;
	var unique = true;
	
	mArray[0] = iArray[0];
	for(i=0;i<iSize;i++){
		mSize = mArray.length;
		mArray[mSize] = iArray[i];
	}
	
	for(j=0;j<jSize;j++){
		mSize = mArray.length;
		mArray[mSize] = jArray[j];
	}
	var nArray = makeSet(mArray);
	
	return nArray;
}

/* Array to String with seperator */
function arrayToString(array, sep){
	var size = array.length;
	var str = "";
	for(i=0;i<size;i++){
		if(array[i].length > 0){
			str = str+array[i]+sep;
		}
	}
	return str;
}

/* We need sort Array */

/** Object tag write **/
function writeFlash(flashSrc, wd, ht, paramStr) {
	var objStr = "";
	objStr += "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='" + wd + "' height='" + ht + "'>";
	if (paramStr != null && paramStr.length > 0) {
		objStr += paramStr;
	}
	objStr += "	 <param name='movie' value='" + flashSrc + "'>";
	objStr += "	 <param name='quality' value='high'>";
	objStr += "	 <embed src='" + flashSrc + "' quality='high' pluginspage='https://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + wd + "' height='" + ht + "' wmode='transparent'></embed>";
	objStr += "	</object>";

	document.write(objStr);
}

function writeFlashEscape(flashSrc, wd, ht, templNo, fontSz, flashText1, flashText2) {
	var pStr = "";
	var flashText;
	pStr += "<param name='wmode' value='transparent'>";
	if(templNo == 3){
		var text1 = encodeURIComponent(flashText1);
		text1 = text1.replace(/\(/g, "%28");
		text1 = text1.replace(/\)/g, "%29");
		text1 = text1.replace(/'/g,  "%27");
		var text2 = encodeURIComponent(flashText2);
		text2 = text2.replace(/\(/g, "%28");
		text2 = text2.replace(/\)/g, "%29");
		text2 = text2.replace(/'/g,  "%27");
		flashText = "str=" + text1 + "&str1=" +text2;
	} else {
		var text = encodeURIComponent(flashText1);
		text = text.replace(/\(/g, "%28");
		text = text.replace(/\)/g, "%29");
		text = text.replace(/'/g,  "%27");
		flashText = "text=" + text + "&size=" + fontSz;
	}
	pStr += "<param name='flashvars' value='" + flashText + "'>";
	writeFlash(flashSrc + "?" + flashText, wd, ht, pStr);
}
