/*
___________________________________________________________

index:
	Detect
	Plugin Check
	Set Swf
	Open WIn
	change font size 14px to 16px
___________________________________________________________*/



/* Detect
____________________________________________________________*/
function BrowserCheck(){
		var b = navigator.appName;
		if (b == "Netscape") this.b = "NN";
		else if (b == "Microsoft Internet Explorer") this.b = "IE";
		else this.b = b;
		this.version = navigator.appVersion;
		this.vSub = navigator.vendorSub;
		this.userAgent = navigator.userAgent;
		this.appVersion = navigator.appVersion;
		this.v = parseInt(this.version);
		this.vs = parseFloat(this.vSub);
		
		this.NN = (this.b == "NN");
		this.NN3 = (this.b == "NN" && this.v == 3);
		this.NN4 = (this.b == "NN" && this.v == 4);
		this.NN6x = (this.b == "NN" && this.v == 5 && this.vs >= 6.01);
		this.NN6 = (this.b == "NN" && this.v == 5);
		this.NN7 = (this.b == "NN" && this.v == 5 && this.vs >= 7);
		
		this.IE = (this.b == "IE");
		this.IE3 = (this.userAgent.indexOf('MSIE 3')>0);
		this.IE45 = (this.userAgent.indexOf('MSIE 4.5')>0);
		this.IE401 = (this.userAgent.indexOf('MSIE 4.01')>0);
		this.IE4 = (this.userAgent.indexOf('MSIE 4')>0);
		this.IE51 = (this.userAgent.indexOf('MSIE 5.1')>0);
		this.IE512 = (this.userAgent.indexOf('MSIE 5.12')>0);
		this.IE514 = (this.userAgent.indexOf('MSIE 5.14')>0);
		this.IE52 = (this.userAgent.indexOf('MSIE 5.2')>0);
		this.IE5 = (this.userAgent.indexOf('MSIE 5')>0);		
		this.IE6 = (this.userAgent.indexOf('MSIE 6')>0);
		
		this.GEK = (this.userAgent.indexOf("Gecko") != -1);
		this.SAF = (this.userAgent.indexOf("Safari",0) != -1);
		this.FF = (this.userAgent.indexOf("Firefox") != -1);
		this.CAB = (this.userAgent.indexOf("iCab",0) != -1);
		this.OPE = (this.userAgent.indexOf("Opera",0) != -1);
		
		this.Win = (this.userAgent.indexOf('Win',0) != -1);
		this.Mac = (this.userAgent.indexOf('Mac',0) != -1);
		this.MacOSX = (this.userAgent.indexOf('Mac OS X',0) != -1);
		if(this.IE512 || this.IE52){
			this.MacOSX=true;
		}
		else if(this.IE514){
			if (navigator.plugins) {
				for (i=0; i < navigator.plugins.length; i++ ) {
					if (navigator.plugins[i].name.indexOf('QuickTime') >= 0 && navigator.plugins[i].filename.indexOf('.plugin')!=-1){
						this.MacOSX=true;
					}
				}
			}
		}
		this.Unix = (this.appVersion.indexOf('X11',0) != -1);
}

var checkB = new BrowserCheck();
/*window.alert(checkB.IE52);



/* Flash Plugin Check
____________________________________________________________*/
var flash_version = 8;
var FlashInstalled = false;
var pv = 6;

if (checkB.OPE) {
	var sp = navigator.plugins["Shockwave Flash"].description.indexOf("Flash");
	var ep = navigator.plugins["Shockwave Flash"].description.lastIndexOf(" ");
	var aver = parseFloat(navigator.plugins["Shockwave Flash"].description.substring(sp+pv,ep));
	if(aver >= flash_version){
		FlashInstalled = true;
	}
} else if(checkB.Win && checkB.IE){
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('contentVersion = 7 \n');
	document.write('FlashInstalled = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & contentVersion))) \n');
	document.write('</SCR' + 'IPT\> \n');
	if(checkB.IE4){
		FlashInstalled = false;
	}
}else if(checkB.Mac && checkB.IE){
	if(!checkB.IE4 && navigator.plugins["Shockwave Flash"]){
		var sp = navigator.plugins["Shockwave Flash"].description.indexOf("Flash");
		var ep = navigator.plugins["Shockwave Flash"].description.lastIndexOf(" ");
		var aver = parseFloat(navigator.plugins["Shockwave Flash"].description.substring(sp+pv,ep));
		if(aver >= flash_version){
			FlashInstalled = true;
		}
	}
}else if(checkB.NN && navigator.plugins["Shockwave Flash"]){
	if(checkB.NN7 || checkB.NN6 || checkB.NN6x || checkB.NN4){
		var sp = navigator.plugins["Shockwave Flash"].description.indexOf("Flash");
		var ep = navigator.plugins["Shockwave Flash"].description.lastIndexOf(" ");
		var aver = parseFloat(navigator.plugins["Shockwave Flash"].description.substring(sp+pv,ep));
		if(aver >= flash_version){
			FlashInstalled = true;
		}
	}
}



/* Set SWF
____________________________________________________________*/
function setSwf(swf, id, bc, w, h, flashvars) {
	document.write('<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0" width=\"' + w + '\" height=\"' + h + '\" id=\"' + id + '\">');
	document.write('<param name=\"movie\" value=\"' + swf + '\">');
	document.write('<param name=\"quality\" value=\"high\">');
	document.write('<param name=\"bgcolor\" value=\"' + bc + '\">');
	document.write('<param name=\"flashvars\" value=\"' + flashvars + '\">');
	document.write('<param name=\"wmode\" value=\"transparent\">'); // option:opaque
	document.write('<embed src=\"' + swf + '\" flashvars=\"' + flashvars +'\" wmode=\"transparent\"'+ '\" quality=\"high\" bgcolor=\"' + bc + '\" width=\"' + w + '\" height=\"' + h + '\" name=\"' + id + '\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer">');
	document.write('</object>');
}




/* openWin // From Flash
____________________________________________________________*/
function newWin(var_location, var_target, var_width, var_height, var_toolbar, var_scrollbars, var_resizable){
	var_style = "width="+var_width+",height="+var_height+",toolbar="+var_toolbar+",scrollbars="+var_scrollbars+",resizable="+var_resizable+",location=no";
	swin = window.open(var_location, var_target, var_style);
}



/* openWin // From HTML
____________________________________________________________*/
function subWin(var_location, var_target, var_w, var_h, var_toolbar){
	var_width = parseInt(var_w);
	var_height = parseInt(var_h);
	var_tbcenter = parseInt(screen.height - var_h) / 2;
	var_lrcenter = parseInt(screen.width - var_w) / 2;

	if(checkB.Mac) {
		if(checkB.IE52 || checkB.IE51 ) {
			var_width -= 16;
			var_height -= 5;
		} else if(checkB.FF) {
			var_width += 10;
			var_height += 10;
		} else if(checkB.NN7) {
			var_width += 15;
			var_height += 15;
		} else if(checkB.OPE) {
			var_width += 10;
			var_height -= 5;
		} else {
		}
	} else if(checkB.Win) {
		if(checkB.IE) {
			var_width += 17;
			var_height += 5;
		} else if(checkB.FF){
			var_width += 10;
			var_height -= 20;
		} else if(checkB.NN7){
			var_width += 15;
			var_height -= 15;
		} else {
			var_width += 25;
			var_height += 15;
		}
	} else {
	}
		
	var_style = "width="+var_width+",height="+var_height+",top="+var_tbcenter+",left="+var_lrcenter+",toolbar="+var_toolbar+",scrollbars=1,resizable=0,directories=0,menubar=0,status=0,location=0";
	window.open(var_location, var_target, var_style);
}


window.name = "mainWin"
function openWin(url,target){
	subWin = window.open(url,target);
}

/*
function opCh(url){
	window.opener.location.href=url;
}*/



/* closeWin // From HTML
____________________________________________________________*/
function closeWin(){
  var nvua = navigator.userAgent;
    if(nvua.indexOf('MSIE') >= 0){
      if(nvua.indexOf('MSIE 5.0') == -1) {
        top.opener = '';
      }
    }
    else if(nvua.indexOf('Gecko') >= 0){
      top.name = 'CLOSE_WINDOW';
      wid = window.open('','CLOSE_WINDOW');
    }
    top.blur();
    top.close();
}



/* change font size 14px to 16px // 基準フォントサイズが14pxなとき16pxにする 
____________________________________________________________*/
function fontPatch() {
	if ( document.defaultView.getComputedStyle(document.body,'"').getPropertyValue("font-size") == "14px") {
		document.body.style.fontSize='16px';
	}
}
if ( document.defaultView && document.styleSheets  ) window.onload = fontPatch;



/* 画像プリロード
____________________________________________________________*/
function prlimg_rep(){ //report用
var images = new Array('images/btn_home_over.gif','images/btn_movie_over.gif','images/btn_quiz_over.gif','images/rep1_q.jpg','images/rep2_q.jpg','images/rep3_q.jpg','images/rep4_q.jpg','images/rep5_q.jpg','images/rep6_q.jpg','images/rep7_q.jpg','images/rep8_q.jpg','images/rep9_q.jpg','images/tab_top_over.jpg','images/tab_rep1_over.jpg','images/tab_rep2_over.jpg','images/tab_rep3_over.jpg','images/tab_rep4_over.jpg','images/tab_rep5_over.jpg','images/tab_rep6_over.jpg','images/tab_rep7_over.jpg','images/tab_rep8_over.jpg','images/tab_rep9_over.jpg','images/tab_rep2_up_over.jpg','images/tab_rep3_up_over.jpg','images/tab_rep4_up_over.jpg','images/tab_rep5_up_over.jpg','images/tab_rep6_up_over.jpg','images/tab_rep7_up_over.jpg','images/tab_rep8_up_over.jpg');
cacheimages(images);
}

function prlimg_quiz(){ //Quiz用
var images = new Array('images/btn_quiztop_over.gif');
cacheimages(images);
}

function cacheimages(images_array){
for(cacheloop = 0, imageslength = images_array.length; cacheloop < imageslength; cacheloop++){
var images_cache = new Image();
images_cache.src = images_array[cacheloop];
}
}


/* 画像変化
____________________________________________________________*/

function btn_over_gif(btn_name) { //gif用
	document.getElementById(btn_name).src = 'images/' + btn_name + '_over.gif';
}

function btn_over_jpg(btn_name) { //jpg用
	document.getElementById(btn_name).src = 'images/' + btn_name + '_over.jpg';
}

function btn_out_gif(btn_name) { //gif用
	document.getElementById(btn_name).src = 'images/' + btn_name + '.gif';
}

function btn_out_jpg(btn_name) { //jpg用
	document.getElementById(btn_name).src = 'images/' + btn_name + '.jpg';
}

function btn_over_rep(btn_name,q_no) { //report用
	document.getElementById(btn_name).src = 'images/' + btn_name + '_over.jpg';
	document.getElementById('pola').src = 'images/' + q_no + '.jpg';
}

function btn_out_rep(btn_name) { //report用
	document.getElementById(btn_name).src = 'images/' + btn_name + '.jpg';
	document.getElementById('pola').src = 'images/spacer.gif';
}

function btn_over_rep_up(btn_name,q_no) { //report用up
	document.getElementById(btn_name).src = 'images/' + btn_name + '_up_over.jpg';
	document.getElementById('pola').src = 'images/' + q_no + '.jpg';
}

function btn_out_rep_up(btn_name) { //report用up
	document.getElementById(btn_name).src = 'images/' + btn_name + '_up.jpg';
	document.getElementById('pola').src = 'images/spacer.gif';
}

