
/*  ----  Partner Code Setting  ----  */
/*  ----  JWord floating ad js  (encoding:  Shift_JIS)     ----  */
/*  ----  copyright (C) 2004 AccessPort Inc.       ----  */
	
/*  ----  default values  ----  */
	
		var jwdflt_actptnr = 'AP';			// 01 partner
		var jwdflt_actagnt = '';				// 02 agent 
		var jwdflt_acttype = '001';			// 03 flttype 
		var jwdflt_actbyps = '0';				// 04 bypass 
		var jwdflt_actcode = 'fltad';		// 05 logcode 
		var jwdflt_actchkp = '';				// 06 chkpartner / parent partner 
		var jwdflt_actichk = '';				// 07 cookie check flag 
		var jwdflt_actintv = '';				// 08 intv for cookie check 
		var jwdflt_actintk = '';				// 09 intkey for cookie check 
		var jwdflt_actiact = '';				// 10 iactppptype - to open after installation

		var chk_flashplugin;
		var chk_cnsmin = 0;
		var chk_Jwd2 = 0;
		var chk_browzer = 0;
		
		
		var jwdflt_type = "flt";
		var jwdflt_code = "";
		var jwdflt_ChkTimes = 2;

/*  ----  setting the actual values  ----  */

		if (jwdflt_setting[0]  == '1')
		{
			if (jwdflt_setting[1])
			{
				jwdflt_actptnr = jwdflt_setting[1];
			}
			if (jwdflt_setting[2])
			{
				jwdflt_actagnt = jwdflt_setting[2];
			}
			if (jwdflt_setting[3])
			{
				jwdflt_acttype = jwdflt_setting[3];
			}
			if (jwdflt_setting[4])
			{
				jwdflt_actbyps = jwdflt_setting[4];
			}
			if (jwdflt_setting[5])
			{
				jwdflt_actcode = jwdflt_setting[5];
			}
			if (jwdflt_setting[6])
			{
				jwdflt_actchkp = jwdflt_setting[6];
			}
			if (jwdflt_setting[7])
			{
				jwdflt_actichk = jwdflt_setting[7];
			}
			if (jwdflt_setting[8])
			{
				jwdflt_actintv = jwdflt_setting[8];
			}
			if (jwdflt_setting[9])
			{
				jwdflt_actintk = jwdflt_setting[9];
			}
			if (jwdflt_setting[10])
			{
				jwdflt_actiact = jwdflt_setting[10];
			}

		}
		
		var jwdflt_LimitCookieName = jwdflt_actptnr + "_" + jwdflt_acttype + "_JWDFLT_C";


		function errexit() { return true; }
		window.onerror = errexit;


/*  ----  check. SP2 & IE7 Upper for Windows IE  ----  */
		var g_fIsSP2 = false;
		var g_fIsIE7 = false;
		var g_fIsIE8 = false;
		function checkSP2()
		{
			var sp_flag;
			g_fIsSP2 = (window.navigator.userAgent.indexOf("SV1") != -1);
			g_fIsIE7 = (window.navigator.userAgent.indexOf("MSIE 7") != -1);
			g_fIsIE8 = (window.navigator.userAgent.indexOf("MSIE 8") != -1);
			(g_fIsSP2 || g_fIsIE7 || g_fIsIE8) ? sp_flag = 1 : sp_flag = 0;
			return sp_flag;
		}

/*  ----  for kks  ----  */
		function jwdfltGetNameVal( adtype, code, chk )
		{
			var nameVal;
			nameVal = "flt:" + adtype + ":" + code + ":" + chk;
			return nameVal;
		}
		
		function jwdfltKKSIFrameUrl( ptnr, adtype, code, chk )
		{
			var nameVal;
			nameVal = jwdfltGetNameVal( adtype, code, chk );
			document.write('<iframe src="http://download.jword.jp/pub/kks/jwd_ad_kks.htm?type=kks&partner=' + ptnr + '&name=' + nameVal + '" id="jwdfltkks" name="jwdfltkks" width="1" height="1" border="0" frameborder="0" marginheight="0" marginwidth="0"><\/iframe>');
		}
		
		function jwdfltKKSImgUrl( ptnr, adtype, code, chk )
		{
			var nameVal;
			nameVal = jwdfltGetNameVal( adtype, code, chk );

			tmp_image = new Image();
			tmp_image.src = 'http://download.jword.jp/pub/kks/jwd_ad_kks.htm?type=kks&partner=' + ptnr + '&name=' + nameVal;
		}
		

		function jwdfltForSP2SetCookieLimit( days )
		{
			setDay = new Date();
			expDay = new Date();
			expDay.setTime(expDay.getTime() + (days*1000*60));
			return expDay;
		}

		function jwdfltForSP2SetCookie( CName )
		{
			if(navigator.cookieEnabled)
			{
				ExpiresDays = jwdfltForSP2SetCookieLimit(jwdflt_ChkTimes);
				Item = CName + "=" + escape( ExpiresDays ) + "; ";
				SetExpiresDays = ExpiresDays.toGMTString();
				Expires = "expires=" + SetExpiresDays;
				document.cookie =  Item + Expires;
			}
		}

		function jwdfltForSP2GetCookie( CName )
		{
			theCookieValue = "";
			theName   = CName + "=";
			if( document.cookie.length > 0 )
			{
				offset = document.cookie.indexOf(theName)
				if(offset != -1)
				{
					offset += theName.length;
					end = document.cookie.indexOf(';', offset );
					if( end == -1 ){ end = document.cookie.length; }
					theCookieValue = unescape( document.cookie.substring( offset, end ));
				}
			}
			if (theCookieValue == "")
			{
				return null;
			}else{
				return true;
			}
		}

/*  ----  check. flash Plugin !  ----  */
	
		function checkFlash()
		{
			plugin = null;
			flashVersionFlag = null;
			flashPluginFlag = null;
			
			if(navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.userAgent.indexOf("Windows 95") >=0 || navigator.userAgent.indexOf("Windows 98") >=0 || navigator.userAgent.indexOf("Windows NT") >=0 ))
			{
					document.write('<script type="text/vbscript" language="VBScript"><!--//\n');
					document.write('on error resume next \n');
					document.write('plugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5")))\n');
					document.write('//--></script>\n');
			}

			if( plugin == true )
			{
				flashVersionFlag = checkFlashVersion();
				if(flashVersionFlag == true )
				{
					flashPluginFlag = true;
				}else{
					flashPluginFlag = false;
				}
				
			}else{
				
				flashPluginFlag = false;
			}
			return flashPluginFlag;

		}
	
/*  ----  check. flash Plugin Version !  ----  */
/*  ----  flash Plugin Version 5.0 over        */

		function checkFlashVersion()
		{
		
			document.write('<script type="text/vbscript" language="VBScript"><!--//\n');
			document.write('Private i, x, JWD_FlashControlVersion \n');
			document.write('On Error Resume Next\n');
			document.write('x = null\n');
			document.write('JWD_FlashControlVersion = 0\n');
			document.write('var Flashmode\n');
			document.write('FlashMode = False\n');
			document.write('For i = 9 To 1 Step -1\n');
			document.write('	Set x = CreateObject("ShockwaveFlash.ShockwaveFlash." & i)\n');
			document.write('	JWD_FlashControlInstalled = IsObject(x)\n');
			document.write('	If JWD_FlashControlInstalled Then\n');
			document.write('		JWD_FlashControlVersion = CStr(i)\n');
			document.write('		Exit For\n');
			document.write('	End If\n');
			document.write('Next\n');
			document.write('FlashMode = (JWD_FlashControlVersion >= 5)\n');
			document.write('//--></script>\n');
			
			return FlashMode;
		
		}
	
		function jwdfltWriteJSFile( ptnr, agnt, type, byps, code, chkp, intvchk, intv, intkey, iact, flt_type, flt_code, os )
		{
            rnd = Math.floor(Math.random()*1000)+1;
			document.write('<script type="text/javascript" language="JavaScript" src="http://download.jword.jp/pub/flt/jwd_flt_sub_xpsp2.js?partner=' + ptnr + '&agent=' + agnt + '&flttype=' + type + '&bypass=' + byps + '&logcode=' + code + '&intvchk=' + intvchk + '&intv=' + intv + '&intkey=' + intkey + '&iactflttype=' + iact + '&flt_adv_type=' + flt_type + '&flt_adv_code=' + flt_code + '&flt_os=' + os + '&rnd=' + rnd + '" charset="Shift_JIS"></script>');
		}

	/*  ----  check. CnsMin !!!  ----  */
		
		
		if ( document.getElementById && document.all && (navigator.userAgent.indexOf('Win') != -1)
			&& (navigator.userAgent.toLowerCase().indexOf('msie') != -1) && (navigator.userAgent.toLowerCase().indexOf('opera') == -1) && (navigator.userAgent.toLowerCase().indexOf('aol') == -1))
		{
				document.write('<script type="text/vbscript" language="VBScript"><!--//\n');
				document.write('function CHECK_INSTALL() \n');
				document.write('on error resume next \n');
				document.write('Set cns=CreateObject("CnsHelper.CH")\n');
				document.write('if IsObject(cns) then \n');
				document.write('chk_cnsmin = 1 \n');
				document.write('end if \n');
				document.write('Set jwd2=CreateObject("JWord.Update")\n');
				document.write('if IsObject(jwd2) then \n');
				document.write('chk_Jwd2 = 1 \n');
				document.write('end if \n');
				document.write('End Function \n');
				document.write('//--></script>\n');
				
				CHECK_INSTALL();
				chk_browzer = 1;
		}
		
	/*  ----  check. Windows Vista  ----  */
		function jwdfltisVista()
		{
			/*@cc_on
			appVer  = navigator.userAgent;
			if(appVer.indexOf('NT 6.') != -1) {
				return true;
			}
			@*/
			return false;
		}

	/*  ----  check. Windows 9x  ----  */
		function jwdfltinstisWin9x()
		{
			/*@cc_on
			appVer  = navigator.userAgent;
			if(appVer.indexOf('Windows 9') != -1) {
				return true;
			}
			@*/
			return false;
		}

	/*  ----  check. Windows 64bit  ----  */
		function jwdfltinstisWin64bit()
		{
			/*@cc_on
			appVer  = navigator.userAgent;
			if (appVer.indexOf(' Win64') != -1 || appVer.indexOf(' WOW64') != -1) {
				return true;
			}
			@*/
			return false;
		}

		chk_flashplugin = checkFlash();
		
		/*  ----  ready. kks !!!  ----  */
		if( chk_browzer == 0 )
		{
			jwdfltKKSImgUrl( jwdflt_actptnr, jwdflt_acttype, jwdflt_actcode, "nowie" );
		}
		else if( chk_browzer == 1 && jwdfltForSP2GetCookie(jwdflt_LimitCookieName) == null )
		{
			if( chk_cnsmin == 0 && chk_Jwd2 == 0 )
			{
                if (jwdfltisVista()) {
                    jwdfltKKSImgUrl( jwdflt_actptnr, jwdflt_acttype, jwdflt_actcode, "outjwd_vista" );
                } else {
                    jwdfltKKSImgUrl( jwdflt_actptnr, jwdflt_acttype, jwdflt_actcode, "outjwd" );
                }
			}
			else
			{
                if (chk_cnsmin == 1) {
                    if (jwdfltisVista()) {
                        jwdfltKKSImgUrl( jwdflt_actptnr, jwdflt_acttype, jwdflt_actcode, "injwd_vista" );
                    } else {
                        jwdfltKKSImgUrl( jwdflt_actptnr, jwdflt_acttype, jwdflt_actcode, "injwd" );
                    }
                }
                if (chk_Jwd2 == 1) {
                    if (jwdfltisVista()) {
                        jwdfltKKSImgUrl( jwdflt_actptnr, jwdflt_acttype, jwdflt_actcode, "injwd2_vista" );
                    } else {
                        jwdfltKKSImgUrl( jwdflt_actptnr, jwdflt_acttype, jwdflt_actcode, "injwd2" );
                    }
                }
			}
		}

		/*  ----  ready. floating !!!  ----  */
		if(chk_cnsmin == 0 && chk_Jwd2 == 0 && chk_flashplugin == true && chk_browzer == 1 && !jwdfltisVista() && !jwdfltinstisWin9x() && !jwdfltinstisWin64bit())
		{
			jwdflt_os = checkSP2();
			if( jwdflt_os == 1 ){ jwdfltForSP2SetCookie(jwdflt_LimitCookieName); }
			jwdfltWriteJSFile( jwdflt_actptnr, jwdflt_actagnt, jwdflt_acttype, jwdflt_actbyps, jwdflt_actcode, jwdflt_actchkp, jwdflt_actichk, jwdflt_actintv, jwdflt_actintk, jwdflt_actiact, jwdflt_type, jwdflt_code, jwdflt_os );

		}
	
	
	