/**
 * js/pageControl.js
 * @author J-SURF Co.,Inc. - S.Yoshidome
 * @since version 1.0.0
 */


/**
 * doReload Method
 * リロード
 */
function doReload() {

	window.location.reload();

}


/**
 * setIframeSrc Method
 * iframeの参照先を変更
 * @param	frameID		対象iframeのid属性
 * @param	frameSrc	対象iframeのsrc属性
 */
function setIframeSrc(frameID, frameSrc) {

	window.document.getElementById(frameID).src = frameSrc;

}


/**
 * openWindow Method
 * モニタ有効範囲サイズでウィンドウをオープン
 * @param	targetURL	対象URL
 */	
function openWindow(targetURL) {

	maxWin = window.open(targetURL, "", "toolbar=no,menubar=no,location=no,status=no,scrollbars=no,resizable=no");
	maxWin.moveTo(0, 0);
	maxWin.resizeTo(screen.availWidth, screen.availHeight);

}

/**
 * loadYouTube Method
 * YouTubeのムービーをエンベッドでオープン
 */	
function loadYouTube() {

	var width;
	var height;
	
	window.moveTo(0, 0);
	window.resizeTo(425, 350);
	width = 425 + (425 - window.document.body.clientWidth);
	height = 350 + (350 - window.document.body.clientHeight) - 10;
	window.resizeTo(width, height);

}


function setYouTube(id) {

	var tag;

	tag = '<object width="425" height="350">';
	tag += '<param name="movie" value="http://www.youtube.com/v/' + id + '"></param>';
	tag += '<param name="wmode" value="transparent"></param>';
	tag += '<embed src="http://www.youtube.com/v/' + id + '" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed>';
	tag += '</object>';
	
	document.write(tag);
	
}


/**
 * setFlash Method
 * Flash表示関連タグの出力
 * 「このコントロールをアクティブ化して使用するにはクリックしてください。」対策
 * @param	width	width属性
 * @param	height	height属性
 * @param	id		id属性、name属性
 * @param	align	align属性
 * @param	src		src属性、value属性
 * @param	bgcolor	bgcolor属性	
 */
function setFlash(width, height, id, align, src, bgcolor) {

	var tag;

	tag = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '" id="' + id + '" align="' + align + '">';
	tag += '<param name="movie" value="' + src + '">';
	tag += '<param name="quality" value="high">';
	tag += '<param name="bgcolor" value="' + bgcolor + '">';
	tag += '<embed src="' + src + '" quality="high" bgcolor="' + bgcolor + '" width="' + width + '" height="' + height + '" name="' + id + '" align="' + align + '" type="application/x-shockwave-flash" pluginspace="http://www.macromedia.com/go/getflashplayer"></embed>';
	tag += '</object>';
	
	document.write(tag);

}


/**
 * openDialog
 * ダイアログを表示
 * @author Dome
 * @since version 1.0.0
 * @param targetURL（対象ページURL）
 * 　　   targetID（対象オブジェクトID）
 * 　　   targetValue（対象オブジェクト値）
 */
function openDialog(targetURL, targetID, targetValue) {
	
	var ret;
	
	ret = window.showModalDialog(targetURL, targetValue, "status:no;dialogWidth:725px;dialogHeight:540px");
	
	if (ret != null) {
		if (ret.length > 0) {
			if (window.document.all) {
				window.document.all(targetID).value = ret;
			} else if (window.document.getElementById) {
				window.document.getElementById(targetID).value = ret;
			}
		}
	} else {
		if (window.document.all) {
			window.document.all(targetID).value = "";
		} else if (window.document.getElementById) {
			window.document.getElementById(targetID).value = "";
		}
	}

}


/**
 * requireCheck
 * 記入必須項目のチェック
 * @author Dome
 * @since version 1.0.0
 * @param INPUT（対象入力項目）
 */
function requireCheck(INPUT) {

	var requireFields;
	var fieldNames;
    var fieldCheck;
    var fieldsNeeded;

	requireFields = new Array("name", "mail", "message");
	fieldNames = new Array("name", "mail address", "message");
    fieldCheck   = true;
    fieldsNeeded = "";

    for (var fieldNum = 0; fieldNum < requireFields.length; fieldNum++) {
        if ((INPUT.elements[requireFields[fieldNum]].value == "") ||
            (INPUT.elements[requireFields[fieldNum]].value == " ")) {
			if (fieldsNeeded.length > 0) {
            	fieldsNeeded += ", ";
			}
			fieldsNeeded += fieldNames[fieldNum];
            fieldCheck = false;
        }
    }
	
    if (fieldCheck == true) {
		return true
    } else {
        alert ("\n以下の項目をご入力ください。\n\n" + fieldsNeeded);
        return false;
    }

}


/**
 * confirmDelete
 * 削除確認
 * @author Dome
 * @since version 1.0.0
 */
function confirmDelete() {

	if (confirm("削除しますか？")) {
		return true;
	} else {
		return false;
	}

}


/**
 * confirmReset
 * リセット確認
 * @author Dome
 * @since version 1.0.0
 */
function confirmReset() {

	if (confirm("リセットしますか？")) {
		return true;
	} else {
		return false;
	}

}


/**
 * borderOutset
 * borderStyleをoutsetへ
 * @author Dome
 * @since version 1.0.0
 * @param targetID（対象ID）
 */
function borderOutset(targetID) {

	if (window.document.all) {
		window.document.all(targetID).style.borderStyle = 'outset';
	} else if (window.document.getElementById) {
		window.document.getElementById(targetID).style.borderStyle = 'outset';
	}

}


/**
 * borderSolid
 * borderStyleをsolidへ
 * @author Dome
 * @since version 1.0.0
 * @param targetID（対象ID）
 */
function borderSolid(targetID) {

	if (window.document.all) {
		window.document.all(targetID).style.borderStyle = 'solid';
	} else if (window.document.getElementById) {
		window.document.getElementById(targetID).style.borderStyle = 'solid';
	}

}


/**
 * openImage
 * 画像を表示
 * @author Dome
 * @since version 1.0.0
 * @param targetURL（対象URL）
 * 　　   targetWidth（対象幅）
 * 　　   targetHeight（対象高さ）
 * 　　   targetTitle（対象タイトル）
 */
function openImage(targetURL, targetWidth, targetHeight, targetTitle) {

	var new1,win1p;
	var tag;
	
	if (win1p == "on") {
		if (new1.closed) {
		} else {
			new1.close();
		}
	}
	win1p = "on";

	new1 = window.open("", "newwin", "scrollbars=auto,resizable=1,width=" + targetWidth + ",height=" + targetHeight + "");
	if (navigator.appVersion.charAt(0) >= 3) {
		new1.focus()
	};
	new1.document.clear();
	
	tag = '<html>';
	tag += '<head>';
	tag += '<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">';
	tag += '<title>' + targetTitle + '</title>';
	tag += '</head>';
	tag += '<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">';
	tag += '<div align="center">';
	tag += '<img src="' + targetURL + '" width="' + targetWidth + '" height="' + targetHeight + '" onClick="window.close()">';
	tag += '<div>';
	tag += '</body>';
	tag += '</html>';
	new1.document.write(tag);
	
	new1.document.close();
	new1.moveTo(0, 0);

}


/**
 * MM_preloadImages Method
 */
function MM_preloadImages() {
	
	var d = document;
	
	if (d.images) {
		if (!d.MM_p) {
			d.MM_p = new Array();
		}
		
		var i, j = d.MM_p.length, a = MM_preloadImages.arguments;
		
		for (i = 0; i < a.length; i++) {
			if (a[i].indexOf("#") != 0) {
				d.MM_p[j] 		= new Image;
				d.MM_p[j++].src	= a[i];
			}
		}
	}
	
}


/**
 * MM_swapImgRestore Method
 */
function MM_swapImgRestore() {
	
	var i, x, a = document.MM_sr;
	
	for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) {
		x.src = x.oSrc;
	}

}


/**
 * MM_findObj Method
 * @param	n	
 * @param	d
 * @return	
 */
function MM_findObj(n, d) {

	var p, i, x;
	
	if (!d) {
		d = document;
	}
	if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
		d = parent.frames[n.substring(p + 1)].document;
		n = n.substring(0,p);
	}
	if (!(x = d[n]) && d.all) {
		x = d.all[n];
	}
	for (i = 0; !x && i < d.forms.length; i++) {
		x = d.forms[i][n];
	}
	for (i = 0; !x && d.layers && i < d.layers.length; i++) {
		x = MM_findObj(n,d.layers[i].document);
	}
	if (!x && d.getElementById) {
		x = d.getElementById(n);
	}
	
	return x;
	
}


/**
 * MM_swapImage Method
 */
function MM_swapImage() {
	
	var i, j = 0, x, a = MM_swapImage.arguments;
	
	document.MM_sr = new Array;
	
	for (i = 0; i < (a.length - 2); i += 3) {
		if ((x = MM_findObj(a[i])) != null) {
			document.MM_sr[j++] = x;
			if (!x.oSrc) {
				x.oSrc=x.src;
			}
			x.src = a[i + 2];
		}
	}
	
}