function floqObj() {
	this.timestamp = (new Date()).getTime();
	this.base_url = "static.floq.jp/";
	this.org_base_url = "orgstatic.floq.jp/";
	this.middle_url = "floqdata/";
	this.middle_url2 = "myfloq/";
	this.log_path = "utils/log";       // log cgi
	this.xml_url = "xml/";
	this.protocol = "http://";
	this.common_swf = "myfloq/myfloqSWF.swf";
	this.bridge_swf = "bridge.swf";
	this.xml = "";                        // URL of XML data
	this.id = "";
};

function floqBrowserCheck(){
		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 floqCheckB = new floqBrowserCheck();

var floq_flash_version = 8;
var floqFlashInstalled = false;
var floqPv = 6;

if (floqCheckB.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+floqPv,ep));
	if(aver >= floq_flash_version){
		floqFlashInstalled = true;
	}
} else if(floqCheckB.Win && floqCheckB.IE){
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('contentVersion = 8 \n');
	document.write('floqFlashInstalled = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & contentVersion))) \n');
	document.write('</SCR' + 'IPT\> \n');
	if(floqCheckB.IE4){
		floqFlashInstalled = false;
	}
}else if(floqCheckB.Mac && floqCheckB.IE){
	if(!floqCheckB.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+floqPv,ep));
		if(aver >= floq_flash_version){
			floqFlashInstalled = true;
		}
	}
}else if(floqCheckB.NN && navigator.plugins["Shockwave Flash"]){
	if(floqCheckB.NN7 || floqCheckB.NN6 || floqCheckB.NN6x || floqCheckB.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+floqPv,ep));
		if(aver >= floq_flash_version){
			floqFlashInstalled = true;
		}
	}
}




floqObj.prototype.getTimeStamp = function() {
	return this.timestamp;
}

floqObj.prototype.getXMLurl = function() {
	var ran = Math.random();
	if (this.id.match(/^BU_/)) {
        var rightstr = this.id.substr(3);
		if (rightstr.match(/-UPL$/)) {
            var leftstr = rightstr.replace(/-UPL$/, '');
			this.xml_url = 'bu/' + floqGetInitial(leftstr) + '/' + leftstr + '/xml/';
		} else if((rightstr.match(/_99999991$/)) && this.preview == 1) {
			var leftstr = rightstr.replace(/_99999991$/, '');
			this.xml_url = 'bu/' + floqGetInitial(leftstr) + '/' + leftstr + '/xml/';			
		} else {
			this.xml_url = 'bu/' + floqGetInitial(rightstr) + '/' + rightstr + '/xml/';
		}
	} else if(this.id.match(/^FCC_/)) {
		this.xml_url = 'fcc/xml/';			
	} else if(this.id.match(/^GU_/)) {
		var rightstr = this.id.replace(/^GU_/, '');
	 	this.xml_url = 'gu/xml/' + ('00' + rightstr).slice(-3) + '/';
	}
	this.xml = this.protocol + this.base_url +  this.xml_url + this.id + "_gui.xml";
	//this.xml = this.protocol + this.base_url + this.xml_url + this.id + ".xml";

    this.xml = this.xml + "?" + ran;				// measures to cache XML data 
	return this.xml;
}

floqObj.prototype.getRkXMLurl = function() {
	var url = this.getXMLurl();
	url = url.replace('gui.xml', 'rk.xml');
	return url;
}

floqObj.prototype.getUserID = function() {
	return this.id;
}

floqObj.prototype.setUserID = function(id) {
	this.id = id;
}

floqObj.prototype.getUserID2 = function() {
	if(this.id.match('BU_')) return this.id.replace('BU_', '');
	else return this.id;
}

floqObj.prototype.getMode = function() {
	return this.mode;
}

floqObj.prototype.setMode = function(mode) {
	this.mode = mode;
}

floqObj.prototype.getCommonMode = function() {
	return this.cmode;
}

floqObj.prototype.setCommonMode = function(mode) {
	this.cmode = mode;
}

floqObj.prototype.setPreview = function(_preview) {
	this.preview = _preview;
}

floqObj.prototype.getSWFdir = function() {
	return this.protocol + this.base_url + this.middle_url;
}

floqObj.prototype.getSWFdir2 = function() {
	return this.protocol + this.base_url + this.middle_url + this.middle_url2;
}

floqObj.prototype.getSWF = function() {
	var swf = this.protocol + this.base_url + this.middle_url + this.mode + '.swf';
	var ran = Math.random();
	swf = swf + "?mode=player" + "&nfid=" + this.id + "&" + ran;
	return swf;
}

floqObj.prototype.getSWFLarge = function() {
	return this.protocol + this.base_url + this.middle_url + 'large_' + this.mode + '.swf';
}

floqObj.prototype.getSWFCommon = function() {
	return this.protocol + this.base_url + this.middle_url + this.common_swf;
}

floqObj.prototype.getSWFBridge = function() {
	return this.protocol + this.base_url + this.middle_url + this.bridge_swf+"?cache_killer="+Math.random()*20000;
}


floqObj.prototype.getWidth = function() {
	switch (this.mode) {
		case 'container':
			return 160;
			break;
		case 'container2':
			return 160;
			break;
		case 'container3':
			return 160;
			break;
		case 'container4':
			return 160;
			break;
		case 'container5':
			return 160;
			break;
		default:
			return 160;
			break;
	}
}

floqObj.prototype.getHeight = function() {
	switch (this.mode) {
		case 'container':
			return 369;
			break;
		case 'container2':
			return 387;
			breaki;
		case 'container3':
			return 359;
			breaki;
		case 'container4':
			return 359;
			breaki;
		case 'container5':
			return 359;
			breaki;
		default:
			return 360;
			break;
	}
}

floqObj.prototype.getWidthLarge = function() {
	switch (this.mode) {
		case 'container':
		case 'container2':
		case 'container3':
		case 'container4':
		case 'container5':
		default:
			return 0;
			break;
	}
}

floqObj.prototype.getHeightLarge = function() {
	switch (this.mode) {
		case 'container':
		case 'container2':
		case 'container3':
		case 'container4':
		case 'container5':
		default:
			return 0;
			break;
	}
}

floqObj.prototype.getWidthCommon = function() {
	return 800;	
}

floqObj.prototype.getHeightCommon = function() {
	return 560;	
}

function floqSetClass(target, cname) {
	if (document.all) {
		if (navigator.userAgent.indexOf("Opera") != -1) {
			target.setAttribute('class', cname);
		} else {
			target.setAttribute('className', cname);
		}
	} else {
		target.setAttribute('class', cname);
	}
}

function floqCheckBrowser() {
	var userAgent = navigator.userAgent;
	
	if (navigator.userAgent.indexOf('Win',0) != -1 && navigator.appName == "Microsoft Internet Explorer") {
		return 'winIE';
	}
	if (userAgent.indexOf('Netscape') != -1) {
		return 'NN';	
	}
	if (userAgent.indexOf('Firefox') != -1) {
		return 'Firefox';
	}
	if (userAgent.indexOf('Safari') != -1) {
		return 'Safari';
	}
	if (userAgent.indexOf('Opera') != -1) {
		return 'Opera';
	}
	
	return '';
}


var Floq;

function floqGetIndexById(s){
	for(var i=0; i<floqIdSet.length; i++){
		if(s == floqIdSet[i]){
			return i;
		}
	}
}
function floqSetByClassName(s){
	if(s.target!=undefined){
		currentFloq = floqGetIndexById(s.target.parentNode.className);
		if(currentFloq == undefined){
			currentFloq = floqGetIndexById(s.target.parentNode.parentNode.className);
		}
	}else{
		currentFloq = floqGetIndexById(s.srcElement.parentNode.className);
		if(currentFloq == undefined){
			currentFloq = floqGetIndexById(s.srcElement.parentNode.parentNode.className);
		}
	}
}

function doInsert(id, preview, floqType) {

//	if(id == 'yokokazu'){
//		return;
//	}
	switch(floqType){
		case 'audiovisual':
		case 'affiliate':
		case 'multi1':
		case 'multi2':
		case 'multi3':
			document.write('<a href="http://www.floq.jp/guide/blogparts/paste/index.html" target="_blank"><img src="http://simple.floq.jp/common/js/160_395_multi_end.jpg"></a>');
			return;
		default:
			break;
	}

	if(floqFlashInstalled){
		floqCurrentId = id;
		Floq = new floqObj();
		Floq.timestamp +=id;
		floqIdSet.push(id);
		floqObjSet.push(Floq);

		Floq.setUserID(id);
		Floq.setPreview(preview);
		Floq.setMode(floqType);

		if(preview == 1) {
			Floq.base_url = Floq.org_base_url;
		}
		document.write('<style type="text/css" media="all">');
		document.write('@import "http://simple.floq.jp/common/css/floq.css";');
		document.write('</style>');
		document.write("<div id='floqswf"+floqGetIndexById(id)+"'></div>");
		//document.write("<div id='floqswf'></div>");
		document.write('<script type="text/javascript" charset="utf-8" src="http://simple.floq.jp/common/js/prototype.js"></script>');
		document.write('<script type="text/javascript" charset="utf-8" src="http://simple.floq.jp/common/js/XYcoordinate.js"></script>');
		document.write('<script type="text/javascript" charset="utf-8" src="http://simple.floq.jp/common/js/floqAddEvent.js"></script>');

		switch (floqType) {
			case 'container':
			case 'container2':
			case 'container3':
			case 'container4':
			case 'container5':
				document.write('<script type="text/javascript" charset="utf-8" src="http://simple.floq.jp/common/js/floqbox2.js"></script>');
				break;
			default:
				break;
		}
	}else{
		document.write('<a href="http://www.adobe.com/go/getflashplayer" target="_blank"><img src="http://simple.floq.jp/common/image/require.jpg" width="160" height="200" border="0" style="margin:0px;" /></a>');
	}
}

if(floqCurrentId == undefined){
	var floqCurrentId;
}
if(floqIdSet == undefined){
	var floqIdSet = new Array();
}
if(floqObjSet == undefined){
	var floqObjSet = new Array();
}
if(floqFunctionSet == undefined){
	var floqFunctionSet = new Array();
}


var floqArray;
if(floqArray != undefined){
doInsert(floqArray[0], floqArray[1] ,floqArray[2]);
}

function floqGetInitial(iduser) {
	return iduser.substr(0,2);
}

doInsert("BU_senbatsu_1875", "0", "container");