/*  ----  Partner Code Setting  ----  */
/*  ----  JWord floating ad js  (encoding:  Shift_JIS)     ----  */
/*  ----  copyright (C) 2004 AccessPort Inc.       ----  */
	
/*  ----  default values  ----  */
		var jwdflt2_actptnr = 'AP';			// 01 partner
		var jwdflt2_actagnt = '';				// 02 agent 
		var jwdflt2_acttype = '001';			// 03 flttype 
		var jwdflt2_actbyps = '0';				// 04 bypass 
		var jwdflt2_actcode = 'fltad';		// 05 logcode 
		var jwdflt2_actchkp = '';				// 06 chkpartner / parent partner 
		var jwdflt2_actichk = '';				// 07 cookie check flag 
		var jwdflt2_actintv = '';				// 08 intv for cookie check 
		var jwdflt2_actintk = '';				// 09 intkey for cookie check 
		var jwdflt2_actiact = '';				// 10 iactppptype - to open after installation

		var chk_cnsmin = 0;
		var chk_Jwd2 = 0;
		var chk_browser = 0;

		var jwdflt2_type = "flt";
		var jwdflt2_code = "";
		var jwdflt2_ChkTimes = 2;

/*  ----  setting the actual values  ----  */
		if (jwdflt2_setting[0]  == '1')
		{
			if (jwdflt2_setting[1])
			{
				jwdflt2_actptnr = jwdflt2_setting[1];
			}
			if (jwdflt2_setting[2])
			{
				jwdflt2_actagnt = jwdflt2_setting[2];
			}
			if (jwdflt2_setting[3])
			{
				jwdflt2_acttype = jwdflt2_setting[3];
			}
			if (jwdflt2_setting[4])
			{
				jwdflt2_actbyps = jwdflt2_setting[4];
			}
			if (jwdflt2_setting[5])
			{
				jwdflt2_actcode = jwdflt2_setting[5];
			}
			if (jwdflt2_setting[6])
			{
				jwdflt2_actchkp = jwdflt2_setting[6];
			}
			if (jwdflt2_setting[7])
			{
				jwdflt2_actichk = jwdflt2_setting[7];
			}
			if (jwdflt2_setting[8])
			{
				jwdflt2_actintv = jwdflt2_setting[8];
			}
			if (jwdflt2_setting[9])
			{
				jwdflt2_actintk = jwdflt2_setting[9];
			}
			if (jwdflt2_setting[10])
			{
				jwdflt2_actiact = jwdflt2_setting[10];
			}
		}

		var jwdflt2_LimitCookieName = jwdflt2_actptnr + "_" + jwdflt2_acttype + "_JWDFLT2_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 jwdflt2GetNameVal( adtype, code, chk )
		{
			var nameVal;
			nameVal = "flt2:" + adtype + ":" + code + ":" + chk;
			return nameVal;
		}
		
		function jwdflt2KKSIFrameUrl( ptnr, adtype, code, chk )
		{
			var nameVal;
			nameVal = jwdflt2GetNameVal( adtype, code, chk );
			document.write('<iframe src="http://download.jword.jp/pub/kks/jwd_ad_kks.htm?type=kks&partner=' + ptnr + '&name=' + nameVal + '" id="jwdflt2kks" name="jwdflt2kks" width="1" height="1" border="0" frameborder="0" marginheight="0" marginwidth="0"><\/iframe>');
		}
		
		function jwdflt2KKSImgUrl( ptnr, adtype, code, chk )
		{
			var nameVal;
			nameVal = jwdflt2GetNameVal( 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 jwdflt2ForSP2SetCookieLimit( days )
		{
			setDay = new Date();
			expDay = new Date();
			expDay.setTime(expDay.getTime() + (days*1000*60));
			return expDay;
		}

		function jwdflt2ForSP2SetCookie( CName )
		{
			if(navigator.cookieEnabled)
			{
				ExpiresDays = jwdflt2ForSP2SetCookieLimit(jwdflt2_ChkTimes);
				Item = CName + "=" + escape( ExpiresDays ) + "; ";
				SetExpiresDays = ExpiresDays.toGMTString();
				Expires = "expires=" + SetExpiresDays;
				document.cookie =  Item + Expires;
			}
		}

		function jwdflt2ForSP2GetCookie( 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 Version !  ----  */
		function jwdflt2WriteJSFile( 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/flt2/jwd_flt2__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 !!!  ----  */
		function jwdflt2BrowserVersion()
		{
			var browser = 0;
			appVer  = navigator.userAgent;
			s = appVer.indexOf("MSIE ",0) + 5;
			e = appVer.indexOf(";",s);
			version = appVer.substring(s,e);
			beta = version.indexOf("b");
			if(beta != -1) version = version.substring(0,beta);
			if( version >= 5 ) return browser = 1;
		}

	/*  ----  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_browser = jwdflt2BrowserVersion();
		}

	/*  ----  check. Windows Vista  ----  */
		function jwdflt2isVista()
		{
			/*@cc_on
			appVer  = navigator.userAgent;
			if(appVer.indexOf('NT 6.') != -1) {
				return true;
			}
			@*/
			return false;
		}

	/*  ----  check. Windows 9x  ----  */
		function jwdflt2instisWin9x()
		{
			/*@cc_on
			appVer  = navigator.userAgent;
			if(appVer.indexOf('Windows 9') != -1) {
				return true;
			}
			@*/
			return false;
		}

	/*  ----  check. Windows 64bit  ----  */
		function jwdflt2instisWin64bit()
		{
			/*@cc_on
			appVer  = navigator.userAgent;
			if (appVer.indexOf(' Win64') != -1 || appVer.indexOf(' WOW64') != -1) {
				return true;
			}
			@*/
			return false;
		}

		/*  ----  ready. kks !!!  ----  */
		if( chk_browser == 0 )
		{
			jwdflt2KKSImgUrl( jwdflt2_actptnr, jwdflt2_acttype, jwdflt2_actcode, "nowie" );
		}
		else if( chk_browser == 1 && jwdflt2ForSP2GetCookie(jwdflt2_LimitCookieName) == null )
		{
			if( chk_cnsmin == 0 && chk_Jwd2 == 0 )
			{
                if (jwdflt2isVista()) {
                    jwdflt2KKSImgUrl( jwdflt2_actptnr, jwdflt2_acttype, jwdflt2_actcode, "outjwd_vista" );
                } else {
                    jwdflt2KKSImgUrl( jwdflt2_actptnr, jwdflt2_acttype, jwdflt2_actcode, "outjwd" );
                }
			}
			else
			{
                if (chk_cnsmin == 1) {
                    if (jwdflt2isVista()) {
                        jwdflt2KKSImgUrl( jwdflt2_actptnr, jwdflt2_acttype, jwdflt2_actcode, "injwd_vista" );
                    } else {
                        jwdflt2KKSImgUrl( jwdflt2_actptnr, jwdflt2_acttype, jwdflt2_actcode, "injwd" );
                    }
                }
                if (chk_Jwd2 == 1) {
                    if (jwdflt2isVista()) {
                        jwdflt2KKSImgUrl( jwdflt2_actptnr, jwdflt2_acttype, jwdflt2_actcode, "injwd2_vista" );
                    } else {
                        jwdflt2KKSImgUrl( jwdflt2_actptnr, jwdflt2_acttype, jwdflt2_actcode, "injwd2" );
                    }
                }
			}
		}

		/*  ----  ready. floating !!!  ----  */
		if(chk_cnsmin == 0 && chk_Jwd2 == 0 && chk_browser == 1 && !jwdflt2isVista() && !jwdflt2instisWin9x() && !jwdflt2instisWin64bit())
		{
			jwdflt2_os = checkSP2();
			if( jwdflt2_os == 1 ){ jwdflt2ForSP2SetCookie(jwdflt2_LimitCookieName); }
			jwdflt2WriteJSFile( jwdflt2_actptnr, jwdflt2_actagnt, jwdflt2_acttype, jwdflt2_actbyps, jwdflt2_actcode, jwdflt2_actchkp, jwdflt2_actichk, jwdflt2_actintv, jwdflt2_actintk, jwdflt2_actiact, jwdflt2_type, jwdflt2_code, jwdflt2_os );

		}
