﻿var flashVersion=false;
var nn=(navigator.appName.charAt(0)=="N");
var n6=(document.getElementById && nn) || false;
var ie=(document.all && !nn) || false;
var mac=(navigator.userAgent.indexOf("Mac")!=-1) || false;
var ver=""+navigator.appVersion;
var fno=ver.indexOf(" ");
var macChecked=0;
var chk_macIE=false;
ver=eval(ver.substring(0,fno));

if (window.opera || mac) {
	if (navigator.userAgent.indexOf("MSIE") > 0 && mac) {
		chk_macIE = true;
	} else {
		for (i = 0; i < navigator.plugins.length; i++) {
			pName = navigator.plugins[i].description;
			if (pName.indexOf("Flash", 0) != -1) {
				flashVersion = pName.substr(pName.indexOf("Flash", 0)+6);
				flashVersion = flashVersion.substr(0, flashVersion.indexOf("."));
			}
		}
	}

} else {
	if (ie && !mac) {
		var flashVersion=new ActiveXObject("ShockwaveFlash.ShockwaveFlash").FlashVersion();
		flashVersion=Math.floor(flashVersion / 0x10000);
	}

}

if (!flashVersion) {
	if (nn && !document.plugins) {
		flashVersion=false;
	} else if ((nn || n6) && navigator.plugins) {
		var pos = navigator.plugins["Shockwave Flash"].description.indexOf(".");
		flashVersion=navigator.plugins["Shockwave Flash"].description.substring(0, pos).replace("Shockwave Flash ", "");

	} else { 
		flashVersion=false;
	}
}

/*
if (ie && mac) window.onload=chkMac;
	
function chkMac() {
	if (window["sample"]) flashVersion=((window["sample"].FlashVersion() & 0xffff0000) >> 16);
	macChecked=1;
	result();
}
*/


//********************************************************
// Flash のヴァージョンチェック
//********************************************************
function chkflash() {

//	if (mac && ie && macChecked==0) return "NG";
	if (chk_macIE == true) {
		return "MacIE";
	}

	if (!flashVersion) {
		return "NG";
	}

	if (flashVersion >= 8) {
		return "OK";
	} else {
		return "NG";
	}
}

//********************************************************
// 子ウィンドウを開く
//********************************************************
function openwin() {
//	window.open("./window.htm", "child_win", "width=" + screen.availWidth + ",height=" + screen.availHeight + ",resizable=yes,scrollbars=no,left=0,top=0");
	window.open("/about/csr/photostory/flash/index.htm", "child_win", "resizable=yes,scrollbars=no,left=0,top=0");
}

function newwin(target) {
	var subWin;
	var targeturl;

	if (target == "feature") {
		targeturl = "http://feature-nikon.jp/";
	} else if (target == "npci") {
		targeturl = "http://imaging.nikon.com/products/imaging/activity/npci/npci2006-2007/index.htm";
	}

	subWin = window.open( targeturl, "new_win", "location=yes, menubar=yes, resizable=yes, scrollbars=yes, status=yes, titlebar=yes, toolbar=yes, directories=yes");
	subWin.focus();

}
//********************************************************
// 親ウィンドウを操作する
//********************************************************
function parent_operation(goto_page) {
	var home_url = "http://nikon.com/";
	var cate_url = "http://www.nikon.com/about/csr/photostory/index.htm";
	var nn=(navigator.appName.charAt(0)=="N");
	var n6=(document.getElementById && nn) || false;
	var ie=(document.all && !nn) || false;

	// 親ウィンドウの遷移先を決める
	if (goto_page == "home") {
		parent_url = home_url;
	} else if (goto_page == "cate_top") {
		parent_url = cate_url;
	}
	
	if (window.opener == null || window.opener == "" | window.opener.closed == true) {
		// 親ウィンドウが閉じられていたら新しいウィンドウを開く
		window.open(parent_url, "parent");
	} else {
		// 親ウィンドウを操作する
		window.opener.location.href = parent_url;
		window.opener.focus();
	}
}

function win_close() {
	window.close();
}