var r = CheckBackURL();
var site = r[0] ;
var furl = r[1] ;
var ftitle = r[2] ;
var match_url ;

if( site != '' && site != 'undefined' ){
	match_url = sblHash[site] ;
}

if( site != '' && site != 'undefined' && match_url != '' && match_url != 'undefined' && furl != '' && furl != 'undefined' ){
	var match_url = sblHash[site] ;
	var ocs = NWocs ;
	if( ocs == '' ){ ocs = 'utf-8' ; }
	var url = 'http://relart.fresheye.com/ra/wkpblk/wkpblk.cgi' ;


	url += '?site=' + site 
	url += '&match_url=' + match_url ;
	url += '&furl=' + furl ;
	url += '&ftitle=' + ftitle ;
	url += '&ocs=' + ocs ;
	document.write('<script type="text/javascript" charset="' + ocs + '" src="' + url + '" ></scr' + 'ipt>');
}


function getCookie(val) {
 if(typeof(val) == "undefined") return "" ;
 val = val + "=";
 retval = "";
 scookie = document.cookie + ";";
 start = scookie.indexOf(val);
 if (start != -1){
  end = scookie.indexOf(";", start);
  retval = scookie.substring(start + val.length, end); 
 }
 return retval;
}

function setCookie(val, name, eday) {
 if(!navigator.cookieEnabled){
  return;
 }
 sday = new Date();
 sday.setTime(sday.getTime() + (eday * 1000 * 60 * 60 * 24));
 s2day = sday.toGMTString();
 document.cookie = val + "=" + name ;
}

function delCookie(val){
  document.cookie = val + "=;expires=Thu,01-Jan-70 00:00:01 GMT";
}

function CheckBackURL() {
	var path ;
	path = location.href ;
	var pos ;
	var pos_b ;
	var pos_e ;
	pos = path.indexOf( '?' ) ;
	if( pos != -1 ){
		path = path.substring( pos+1 );

		/* site */
		var site ;
		pos_b = path.indexOf( 'site=' ) ;
		if( pos_b != -1 ) {
			pos_e = path.indexOf( '&', pos_b ) ;
			if( pos_e != -1 ){
				site  = path.substring( pos_b+5, pos_e ) ;
			}
			else{
				site  = path.substring( pos_b+5 ) ;
			}
			setCookie( 'site', site, 1 );
		}

		/* furl */
		var furl ;
		var is_cookie_write = 0 ;
		pos_b = path.indexOf( 'furl=' ) ;
		if( pos_b != -1 ) {
			pos_e = path.indexOf( '&', pos_b ) ;
			if( pos_e != -1 ){
				furl  = path.substring( pos_b+5, pos_e ) ;
			}
			else{
				furl  = path.substring( pos_b+5 ) ;
			}
			setCookie( 'furl', furl, 1 );
			is_cookie_write = 1 ;
		}

		/* ftitle */
		var ftitle ;
		pos_b = path.indexOf( 'ftitle=' ) ;
		if( pos_b != -1 ) {
			pos_e = path.indexOf( '&', pos_b ) ;
			if( pos_e != -1 ){
				ftitle  = path.substring( pos_b+7, pos_e ) ;
			}
			else{
				ftitle  = path.substring( pos_b+7 ) ;
			}
			setCookie( 'ftitle', ftitle, 1 );
		}else if( is_cookie_write == 1 ){
			setCookie( 'ftitle', '', 1 );
		}

	}else{
		site = getCookie( 'site' );
		furl = getCookie( 'furl' );
		ftitle = getCookie( 'ftitle' ) ;
	}
	return [ site, furl, ftitle ];
}
