﻿﻿if( typeof(Clog) != 'undefined' && Clog.Debug ) Clog.Debug.write('loaded : file/js/Config.js',{color:'#882222'});
if( typeof(Clog) == "undefined" )
	Clog= {};

Clog.ServiceDomain= "clogger.jp";
Clog.ServiceURL= "http://"+Clog.ServiceDomain+"/";
Clog.SecureServiceURL= "https://"+Clog.ServiceDomain+"/";

Clog.UIDomain= Clog.ServiceDomain;
Clog.UIURL= "http://"+Clog.UIDomain+"/";
Clog.SecureUIURL= "https://"+Clog.UIDomain+"/";

Clog.Version= "1.6";


if( typeof(Clog) != 'undefined' && Clog.Debug ) Clog.Debug.write('loaded : file/js/Common2.js',{color:'#882222'});
if( typeof(Clog) == "undefined" )
	Clog= {};

if( typeof(Clog.Cookies) == "undefined" )
	Clog.Cookies= {};

Clog.Cookies.setData= function( _this, name, val, exp, ssl, callback )
{
	var domain= "";
	try { domain= document.URL.match(/^https?:\/\/([^/:]+)/)[1]; }
	catch(e) {}

	var data= "";
	data+= ";"+name+"=";
	if( val == null )
		exp= -1;
	else
		data+= encodeURIComponent(val);

	var flgCallAPI= domain != _this.info.domain;
	if( ! flgCallAPI )
	{
		var path= document.URL.split("/");
		path= path.length > 4 ? path[4] : "";
		flgCallAPI= path.toLowerCase() != _this.info.stateName.toLowerCase();
	}

	if( flgCallAPI )
	{
		if( typeof(exp) != "undefined" && exp != null )
			data+= ";*e="+ exp;
		if( typeof(ssl) != "undefined" && ! ssl )
			data+= ";*s";
		var img= document.createElement("img");
		img.onload= function()
		{
			if( typeof(callback) != "undefined" )
				callback()
			img.parentNode.removeChild(img);
		};
		img.width= img.height= 1;
		document.body.appendChild(img);
		img.src= _this.info.storeURL+ "?set="+data.substring(1);
	}
	else
	{
		data+= ";path=/"+ (_this.info.stateName == "" ? "" : _this.info.stateName + "/");
		if( typeof(exp) != "undefined" && exp != null )
			data+= ";expires="+(new Date((new Date()).getTime()+60000*exp)).toGMTString();
		if( typeof(ssl) != "undefined" && ! ssl )
			data+= ';secure';
		document.cookie= data.substring(1);
		if( typeof(callback) != "undefined" )
			callback()
	}
	try { if( val == null ) { delete _this[name]; } else { _this[name]= val; } }
	catch(e) {}
}

Clog.Common=
{
	chooseEmoji_targetID: null,

	backHistory: function(pos)
	{
		if( navigator.userAgent.indexOf("Safari") != -1 && Clog.Service.ImageUploadCount )
			history.go(Clog.Service.ImageUploadCount* -2- 1);
		else
			history.back();
	},

	getSymbolInfos: function()
	{
		SymbolInfos.DoCoMo.path= "i";
		SymbolInfos.DoCoMo.name= "DoCoMo";

		SymbolInfos.AU.path= "a";
		SymbolInfos.AU.name= "au";

		SymbolInfos.Softbank.path= "s";
		SymbolInfos.Softbank.name= "SoftBank";

		SymbolInfos.Recent= [ { code:[] } ];
		SymbolInfos.Recent.name= "最近使った絵文字";
		SymbolInfos.Recent[0].name= "";
		SymbolInfos.Recent[0].animation= "*";

		SymbolInfos.Search= [ { code:[] } ];
		SymbolInfos.Search.name= "検索";
		SymbolInfos.Search[0].name= "";
		SymbolInfos.Search[0].animation= "*";

		SymbolInfos.AU[0].animation= "E471,E5C3,EACD,EB80,EB64,EACF,EACE,EAC5,E5C4,E5C5,EAC0,EAC3,EB69,EACB,E473,E5C6,EAC2,E474,EAC6,E472,EB5D,EAC9,EABF,EAC1,E4E7,EB67,EAC4,EACA,EAC7,EAC8,EB61,EB7F,EB63,EB60,EB65,EB68,EB5E,EB6A,EB66,EAD9,EB86,EB85,EB87,EB88,E5BF,E4EF";
		SymbolInfos.AU[1].animation= "EAD6,EAD3,E477,E478,E5AF,EB75,EAA6,E5CA,EAAB,E479,E46C,E468,EA9C,E46F,EA98,E476,E475,EB5C,EB5B,E47B,E47A,EB73";
		SymbolInfos.AU[2].animation= "E5DB,E470,E5C7";
		SymbolInfos.AU[3].animation= "E5B4,EABE,EA97,EB35";
		SymbolInfos.AU[4].animation= "E469,E5CC,EAEB,E5BD,EAF4,EAF1,EB53";
		SymbolInfos.AU[5].animation= "E50B,E46B,EB72,E4B8,EB41,EB43,EADD,E46D,EB1C,E46E";
		SymbolInfos.AU[6].animation= "E5C8,E46A";
		SymbolInfos.AU[7].animation= "E47C";

		SymbolInfos.Softbank[1].animation= "E101,E102,E103,E104,E105,E106,E107,E108,E10D,E10F,E111,E113,E115,E117,E119,E11B,E11D,E12B,E12E,E130";
		SymbolInfos.Softbank[2].animation= "E201,E203,E206,E219,E255,E256,E257";
		SymbolInfos.Softbank[3].animation= "E30C,E310,E311,E312,E313,E317,E31E,E31F,E320,E325,E326,E327,E328,E329,E32E,E335,E336,E337,E34B";
		SymbolInfos.Softbank[4].animation= "E409,E40D,E412,E417,E41C,E41E,E41F,E422,E423,E424,E426,E427,E428,E429,E42D,E433,E437,E43E,E440,E442,E447";
		SymbolInfos.Softbank[5].animation= "E51F";

		var index= {};
		for( var group in {DoCoMo:1,AU:1,Softbank:1} )
		{
			var groups= SymbolInfos[group];
			for( var i= 0; i < groups.length; i++ )
			{
				var code= groups[i].code;
				for( var j= 0; j < code.length; j++ )
				{
					code[j].path= groups.path;
					index[groups.path+code[j][0]]= code[j];
				}
			}
		}
		SymbolInfos.index= index;

		SymbolInfos.getCodes= function(val)
		{
			var result= [];
			var codes= val.split(",");
			for( var i= 0; i < codes.length; i++ )
			{
				var code= index[codes[i]];
				if( code )
					result.push(code);
			}
			return result;
		}

		return SymbolInfos;
	},

	getInnerHTML: function(html)
	{
		if( (html= html.substring(html.indexOf(">")+ 1)) != "" )
			html= html.substring(0, html.lastIndexOf("<"));
		return html;
	},

	copyObject: function(obj)
	{
		var ret;
		if( obj.constructor == Array || (obj.constructor == "(Internal Function)" && typeof(obj.length) == "number" && typeof(obj.push) == "function") )
		{
			ret= [];
			for( var i= 0; i < obj.length; i++ )
			{
				if( obj[i].constructor == Object || obj[i].constructor == Array || (obj[i].constructor == "(Internal Function)" && typeof(obj[i]) == "object"))
					ret.push( Clog.Common.copyObject(obj[i]) );
				else
					ret.push( obj[i] );
			}
		}
		else
		{
			ret= {};
			for( var prop in obj )
			{
				var val= obj[prop];
				if( val != null && val.constructor != null && (val.constructor == Object || val.constructor == Array || (val.constructor == "(Internal Function)" && typeof(val) == "object")) )
					val= Clog.Common.copyObject(val);
				ret[prop]= val;
			}
		}
		return ret;
	},

	kanmaFormat: function( val )
	{
		var ret= ((val < 0 ? -val : val)+"").split(".");
		var digits= 3
		for( ; ret[0].length > digits; digits+= 4 )
			ret[0]= ret[0].substr(0,ret[0].length-digits)+ ","+ ret[0].substr(ret[0].length-digits);
		if( val < 0 ) ret[0]= "-"+ ret[0];
		return ret.join(".");
	},

	logError: function(message,url,line)
	{
		try { Clog.Service.call( { $callID:"ERR", LogError:{message:message+"\r\nClog.Version="+Clog.Version, agent:navigator.userAgent, url:url+", "+document.URL, line:line } }, function(){} ); }
		catch(e) {}
		return false;
	},

	initControls: function(funcs, obj)
	{
		if( typeof(obj) == "undefined" )
			obj= document.body;
		return Clog.Common.getControls(obj, "ctrl", funcs);
	},

	initFields: function(obj)
	{
		return Clog.Common.getControls(obj, "fld", null);
	},

	getControls: function(target, name, funcs)
	{
		if( typeof(funcs) == "undefined" )
			funcs= null;
		var ret= {}; //[]
		var err= false;
		var parseHierarchy= function(objs, data)
		{
			for( var i= 0; i < objs.length; i++ )
			{
				var obj= objs[i];
				var data2= data;
				try
				{
					var uid= obj.getAttribute("uid");
					if( uid && data )
					{
						obj.uid= uid;
						if( !(data2= data.ctrls[uid]) )
							data2= data;
						obj.$data= data2;
					}
					var ctrl= obj.getAttribute(name);
					if( ctrl )
					{
						ret[ctrl]= obj;
						if( funcs && funcs[ctrl] && typeof(funcs[ctrl]) == "function" )
						{
							if( Clog.Debug.on )
								Clog.Debug.write("getControls.init:"+ctrl, {color:"#666666"} );
							try { funcs[ctrl](obj); }
							catch(e)
							{
								if( ! err )
								{
									err= true;
									try { Clog.Common.logError(ctrl+"\n"+typeof(funcs[ctrl])+"\n"+(e.description ? e.description : e),"/js/Common.js","getControls"); }
									catch(e) {}
								}
							}
						}
					}
				}
				catch(e) {}
				if( obj.childNodes && obj.childNodes.length > 0 )
					parseHierarchy(obj.childNodes, data2);
			}
		};
		parseHierarchy(target.childNodes, target.$data);
		return ret;
	},

	replaceSupport: -1,

	replace: function(str, re, func)
	{
		if( Clog.Common.replaceSupport == -1 )
		{
			Clog.Common.replaceSupport= 0;
			"a".replace(/a/, function(){ Clog.Common.replaceSupport= 1 } );
		}
		var prms= func;
		if( typeof(func) != "function" )
			func= function(all, p1) { return typeof(prms[p1]) != "undefined" ? prms[p1] : "" };
		if( Clog.Common.replaceSupport == 1 )
			return str.replace(re, func);
		var ret= "";
		var pos= 0;
		var arr;
		while((arr= re.exec(str)) != null)
		{
			ret+= str.substring(pos, arr.index);
			var name= arr[1];
			ret+= func(arr[0], arr[1], arr[2], arr[3]);
			pos= arr.index+ arr[0].length;
		}
		return ret+ str.substring(pos);
	},

	createHtml: function(data, ctrls, uid)
	{
		var html= data.html;
		if( ctrls.$item )
		{
			var name= data[ctrls.$item];
			if( typeof(ctrls[name]) != "undefined" )
			{
				try { html= typeof(ctrls[name]) == "function" ? ctrls[name](data, uid) : ctrls[name]; }
				catch(e) { Clog.Common.logError(name+"\n"+(e.description ? e.description : e),"/js/Common.js","createHtml"); }
				if( html == null )
					html= data.html;
			}
		}

		html= Clog.Common.replace(html, /\x02(.+?)\x02/g, function(all, name) { return name+'="'+ data[name]+ '"'; } );
		
		return ! data.ctrls ? html : Clog.Common.replace(html, /\x01(.+?)\x01/g, function(all, name) { return Clog.Common.createHtml(data.ctrls[name], ctrls, name); } );
	},

	createStates: function(states)
	{
		var ret= {
			states: states,
			set: function(name, val)
			{
				if( typeof(this[name]) == "undefined" )
					return false;
				try
				{
					this.states[name].value= val;
					this[name]= val+ "";
				}
				catch(e)
				{
					//alert("createStatesで「"+name+"」に値を設定できません。");
					//Clog.Common.logError("createStatesで「"+name+"」に値を設定できません。","","") ;
					return false;
				}
				return true;
			}
		};
		var objs= Clog.Common.getElementsByTagName(states, "INPUT");
		for( var i= 0; i < objs.length; i++ )
			ret[objs[i].name]= states[objs[i].name].value;
		return ret;
	},

	updateHtml: function(ctrl, func, data)
	{
		if( typeof(data) == "undefined" )
			data= ctrl.$data;
		var html= typeof(func.$item) == "undefined" ? func(ctrl.$data) : Clog.Common.createHtml(data, func);
		if( (html= html.substring(html.indexOf(">")+ 1)) != "" )
			html= html.substring(0, html.lastIndexOf("<"));
		ctrl.innerHTML= html;
	},

	loadImage: function( obj, src, width, height, err, zoom )
	{
		if( typeof(src) == "undefined" )
			src= obj.getAttribute("url");
		if( typeof(width) == "undefined" )
			width= obj.width;
		if( typeof(height) == "undefined" )
			height= obj.height;
		if( typeof(err) == "undefined" )
			err= obj.getAttribute("noimage");
		if( typeof(zoom) == "undefined" )
			zoom= true;

		var documentOwn= document;
		var win= window.frames["safariScript"];
		doc= win && win.document ? win.document : document;

		var safari= navigator.userAgent.indexOf("Safari") != -1;
		var img= doc.createElement("img");
		if( safari || navigator.userAgent.indexOf("Opera") != -1 )
		{
			if( typeof(err) != "undefined" && err != null )
				obj.src= err;
			if( safari )
				img.style.visibility= "hidden";
		}

		if( width == -1 )
			width= obj.width;
		if( height == -1 )
			height= obj.height;

		img.onload= function()
		{
			if( ! img )
				return;
			img.loaded= true;
			var imgWidth= img.width;
			var imgHeight= img.height;
			if( img.parentNode && safari)
				img.parentNode.removeChild( img );
			img= null;

			//var obj= documentOwn.getElementById(id);
			if( obj )
			{
				//obj.src= "";
				obj.src= "/images/dot.gif";
				obj.removeAttribute("width");
				obj.removeAttribute("height");
				if( zoom || imgWidth > width || imgHeight > height )
				{
					var newWidth, newHeight;
					if( width / height < imgWidth / imgHeight )
					{
						obj.width= newWidth= width;
						obj.height= newHeight= imgHeight* width/ imgWidth;
					}
					else
					{
						obj.height= newWidth= height;
						obj.width= newHeight= imgWidth* height/ imgHeight;
					}
					/*
					newWidth= Math.round(newWidth);
					newHeight= Math.round(newHeight);
					obj.setAttribute("width",newWidth);
					obj.setAttribute("height",newHeight);
					*/
				}

				if( obj.getAttribute("setMargin") == 1 )
				{
					if( obj.height < height )
						obj.style.marginTop= Math.round((height-obj.height)/2)+ "px";
					else
						obj.style.marginTop= "0px";
				}
				obj.src= src;
				if( navigator.userAgent.indexOf("Opera") != -1 )
				{
					setTimeout(
						function()
						{
							obj.width--;
							obj.width++;
						}, 10
					);
				}
			}
		};
		img.onerror= function()
		{
			img.loaded= true;
			if( img.parentNode && safari)
				img.parentNode.removeChild( img );
			img= null;
			if( typeof(err) != "undefined" && err != null )
				Clog.Common.loadImage( obj, err, width, height, err, zoom );
		};
		if( safari )
			doc.body.appendChild(img);
		img.src= src;
		return img;
	},

	getElementsByTagName: function(obj, tag, nest)
	{
		tag= tag.toLowerCase();
		var ret= [];
		for( var i= 0; i < obj.childNodes.length; i++ )
		{
			if( obj.childNodes[i].tagName && obj.childNodes[i].tagName.toLowerCase() == tag )
				ret.push(obj.childNodes[i]);
			if( nest )
			{
				var items= this.getElementsByTagName(obj.childNodes[i],tag,nest)
				for( var j= 0; j < items.length; j++ )
					ret.push(items[j]);
			}
		}
		return ret;
	},

	setURLs: function(ctrl)
	{
		var objs= ctrl.getElementsByTagName("IMG");
		for( var i= 0; i < objs.length; i++ )
		{
			var url= objs[i].getAttribute("url");
			if( url )
				Clog.Common.loadImage( objs[i] );
		}
	},

	getPageSize: function()
	{
		var xScroll, yScroll;
		if( document.documentElement && document.documentElement.scrollHeight)
		{
			xScroll = document.documentElement.scrollWidth;
			yScroll = document.documentElement.scrollHeight;
		}
		else if (window.innerHeight && window.scrollMaxY)
		{
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		}
		else if (document.body.scrollHeight > document.body.offsetHeight)
		{
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		}
		else 
		{
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}

		var windowWidth, windowHeight;
		if (self.innerHeight)
		{
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
		{
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		}
		else if (document.body)
		{
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}    

		if(yScroll < windowHeight)
			pageHeight = windowHeight;
		else
			pageHeight = yScroll;

		if(xScroll < windowWidth)
			pageWidth = windowWidth;
		else
			pageWidth = xScroll;

		return {width:pageWidth,height:pageHeight};
	},

	replaceAll: function(val)
	{
		return Clog.Common.replaceSymbol(Clog.Common.replaceLink(Clog.Common.replaceAcceptHTML(val)));
	},

	replaceSymbol: function(val)
	{
		return Clog.Common.replace(val+"", /\[[iasc]:[0-9a-z]{4}\]/gi,
			function( p0 )
			{
				return '<img src=/symbols/'+p0.substring(1,2)+'/'+p0.substring(3,7)+'.gif border=0 style="vertical-align:top;">';
			}
		);
	},

	replaceLink: function(val)
	{
		if( typeof(val) == "undefined" )
			val= "";
		return Clog.Common.replace(val, /(|href=['"]?|src=['"]?)(http(s)?:\/\/[a-z0-9.$,;:&=?!*~@#_()/\-+%]+)/gi, 
			function( p0, p2, p1 )
			{
				if( p2 )
					return p0;
				var domain= p1.match(/:\/\/([^/:]+)/);
				return '<span class="Link-Blue"> <a href="'+p1+'" target=_blank title="'+p1+'"><img src="'+Clog.ServiceURL+domain[1]+'.icon.clog" width=16 border=0 onerror="this.src=\'/favicon/favicon.png\'" style="vertical-align:top;"> '+domain[1]+'</a> </span>';
//				return Clog.Common.StringtoHTML(p1).replace(/^[^>)]+/,
//					function(p0)
//					{
//						var domain= p0.match(/:\/\/([^/:]+)/);
//						//return '<span class="Link-Blue"> <a href="'+p0+'" target=_blank title="'+p0+'"><img src="http://'+domain[1]+'/favicon.ico" width=16 border=0 onerror="this.src=\'/favicon/favicon.png\'" style="vertical-align:top;"> '+domain[1]+'</a> </span>';
//						return '<span class="Link-Blue"> <a href="'+p0+'" target=_blank title="'+p0+'"><img src="'+Clog.ServiceURL+domain[1]+'.icon.clog" width=16 border=0 onerror="this.src=\'/favicon/favicon.png\'" style="vertical-align:top;"> '+domain[1]+'</a> </span>';
//					}
//				);
			}
		).replace(/\[id:([0-9a-z]{16})\]/ig, Clog.UIURL+"ClogInfo.html?$1");
	},

	replaceAcceptHTML: function(html, flgErase)
	{
		if( typeof(flgErase) == "undefined" )
			flgErase= false;
		var safari= navigator.userAgent.indexOf("Safari") != -1;

		html= Clog.Common.replace(html+"", /&lt;(FONT|DIV|A|IMG)(.*?)&gt;/ig,
			function(p0,p1,p2,p3)
			{
				if( flgErase )
					return "";
				var item= "<"+p1;
				var m= (p2+" ").match(/ (COLOR|SIZE|ALIGN|HREF|SRC|BORDER|TARGET|WIDTH|HEIGHT)=([^ ]*)/ig );
				if( m )
				{
					for( var i= 0; i < m.length; i++ )
						item+= " "+Clog.Common.StringtoHTML(m[i]);
				}
				item+= ">";
				return item;
			}
		);

		html= Clog.Common.replace(html, /(&lt;(B|I|U|S|STRIKE|SUP|SUB|RUBY|RB|RP|RT|OL|UL|LI)&gt;|&lt;\/(B|I|U|S|STRIKE|SUP|SUB|RUBY|RB|RP|RT|OL|UL|LI|FONT|DIV|A|IMG)&gt;)/ig,
			function(p0,p1,p2,p3)
			{
				if( flgErase )
					return "";
				if( safari )
				{
					if( p2 && p2.toUpperCase() == "RUBY" )
						return "<span id=ruby><ruby>";
					if( p3 && p3.toUpperCase() == "RUBY" )
						return "</ruby></span>";
				}
				return Clog.Common.StringtoHTML(p0);
			}
		);
		return html;
	},

	HTMLtoString: function(val)
	{
		if( typeof(val) != "string" )
			return val;
		return Clog.Common.replace(val, /[ "&<>]/g,
			function(chr)
			{
				switch(chr)
				{
					//case ' ': return "&nbsp;";
					case '"': return "&quot;";
					case "&": return "&amp;";
					case "<": return "&lt;";
					case ">": return "&gt;";
				}
				return chr;
			}
		);
	},

	StringtoHTML: function(val)
	{
		if( typeof(val) != "string" )
			return val;
		return Clog.Common.replace(val, /&#?[a-z0-9]+;/ig,
			function(html)
			{
				var code= html.match(/[a-z0-9]+/)+"";
				if( html.charAt(1) == "#" )
					return String.fromCharCode(code);
				switch(code.toLowerCase())
				{
					case "nbsp": return ' ';
					case "quot": return '"';
					case "amp": return "&";
					case "lt": return "<";
					case "gt": return ">";
				}
				return html;
			}
		);
	},

	trimTag: function(val)
	{
		return val.replace(/<.+?>/g,"").replace(/(^[ 　\r\n\t]+|[ 　\r\n\t]+$)/g,"");
	},

	trimSpace: function(val)
	{
		return val.replace(/(^[ 　\r\n\t]+|[ 　\r\n\t]+$)/g,"");
	},

	OpenEmoji: function(id)
	{
		Clog.Common.ChooseEmoji( id, "/Emoji.aspx" );
	},

	ChooseEmoji: function(id, url)
	{
		Clog.Common.chooseEmoji_targetID= id;
		var win= window.open( url, "emozi", "width=480,height=530,scrollbars=yes, menubar=no, toolbar=no, location=no, status=yes, resizable=no" );
		win.focus();
		return win;
	},

	showProcessPanel: function( flg, msg )
	{
		if( ! flg && Clog.Common.objProcessPanel1 )
		{
			document.body.removeChild(Clog.Common.objProcessPanel1);
			document.body.removeChild(Clog.Common.objProcessPanel2);
			Clog.Common.objProcessPanel1= null;
		}
		else if( flg && ! Clog.Common.objProcessPanel1 )
		{
			if( typeof(msg) == "undefined" )
				msg= "処理中･･･";
			var page= Clog.Common.getPageSize();
//alert(dump(page));
			var obj= document.createElement("div");
			obj.style.position= "absolute";
			obj.style.padding= obj.style.margin= obj.style.left= obj.style.top= "0px";
			obj.style.width= "100%";
			obj.style.height= page.height+"px";
			obj.style.backgroundColor= "#888888";
			obj.style.border= "none";
			obj.style.display= "block";
			obj.style.zIndex= 32765;
			obj.style.filter = "alpha(opacity=50)";
			obj.style.MozOpacity = 0.5;
			obj.style.opacity = 0.5;
			document.body.appendChild(obj);
			Clog.Common.objProcessPanel1= obj;

			var top= document.documentElement.scrollTop || window.pageXOffset || window.scrollY || 0;
			var obj= document.createElement("div");
			obj.style.position= "absolute";
			obj.style.padding= obj.style.margin= obj.style.left= obj.style.top= "0px";
			obj.style.width= "100%";
			obj.style.height= page.height- top+"px";
			obj.style.display= "block";
			obj.style.zIndex= 32766;
			obj.style.top= top+ "px";
			document.body.appendChild(obj);
			obj.innerHTML= '<center style="margin-top:20%; margin-bottom:30px;"><span style="background:#ffeedd; padding:20px; font-size:small; border:solid 5px #FF864B; "><img src=/images/ajax-loader.gif style="vertical-align:middle;"> '+msg+'</span></center>';
			Clog.Common.objProcessPanel2= obj;

			//obj.scrollIntoView();
		}
	}
}


window.onload= function()
{
	window.onerror= Clog.Common.logError;

	if( typeof(App) == "undefined" || ! App.init )
		return;
	if( navigator.userAgent.indexOf("Safari") != -1 )
		window.onunload= function() { }
	if( navigator.userAgent.indexOf("Firefox") != -1 )
		window.onpageshow= function() { App.init(); }
	else
		App.init();
}

function $(id) { return document.getElementById(id); }

function chooseEmoji_callback( ch, targetID )
{
	var obj= $(typeof(targetID) != "undefined" ? targetID : Clog.Common.chooseEmoji_targetID);
	if( ! obj )
		return;
	var posStart= 0, posEnd= 0;
	var isIE = (navigator.appName.toLowerCase().indexOf('internet explorer')+1?1:0);
	if( isIE )
	{
		obj.focus();
		var range = document.selection.createRange();
		if( obj.tagName == "TEXTAREA" )
		{
			var clone = range.duplicate();
			clone.moveToElementText(obj);
			clone.setEndPoint( 'EndToEnd', range );
			posStart= clone.text.length - range.text.length;
			posEnd= clone.text.length - range.text.length + range.text.length;
			if( posStart == posEnd && (range.boundingTop+range.boundingHeight) != (clone.boundingTop+clone.boundingHeight) )
			{
				posStart+= 2;
				posEnd+= 2;
			}
		}
		else
		{
			var range2= obj.createTextRange();
			range2.setEndPoint('EndToStart', range);
			posStart= range2.text.length;
			range2= obj.createTextRange();
			range2.setEndPoint('EndToEnd', range);
			posEnd= range2.text.length;
		}
	}
	else
	{
		posStart= obj.selectionStart;
		posEnd= obj.selectionEnd ;
	}
   
	obj.value = obj.value.substring(0, posStart) + ch + obj.value.substring(posEnd, obj.value.length);
	posStart+= ch.length;

	if( isIE )
	{
		var m= obj.value.substring(0, posStart).match(/\n/g);
		if( m )
			posStart-= m.length;
		var len= obj.value.length;
		var m= obj.value.match(/\n/g);
		if( m )
			len-= m.length;
		var range = obj.createTextRange();
		range.moveStart( "character", posStart);
		range.moveEnd( "character", -len+ posStart );
		range.select();
	}
	else
	{
		obj.selectionEnd= obj.selectionStart= posStart;
	}
}










function dump( obj, spc )
{
	if( spc == undefined )
		spc= "";
	var msg= "";
	if( obj == null )
	{
		msg= "null";
	}
	else if( obj.constructor == Array )
	{
		for( var i= 0; i < obj.length; i++ )
		{
			msg+= "\n"+spc+i+"=";
			if( obj[i] != null && (obj[i].constructor == Object || obj[i].constructor == Array) )
				msg+= dump(obj[i],spc+" ");
			else
				msg+= obj[i];
		}
	}
	else
	{
		for( var prop in obj )
		{
			var val= obj[prop];
			if( val == null || val.constructor == null )
			{
				msg+= "\n"+spc+prop+"=null";
				continue;
			}
			msg+= "\n"+spc+prop+(val.constructor == Array ? "["+val.length+"]" : "")+"=";
			if( val != null && (val.constructor == Object || val.constructor == Array || typeof(val) == "object") )
				msg+= "{"+dump(val,spc+" ")+"\n"+spc+"}";
			else
				msg+= val;
		}
	}
	return msg;
}

function dummy() {}

if( typeof(Clog) != 'undefined' && Clog.Debug ) Clog.Debug.write('loaded : file/js/Service.js',{color:'#882222'});
if( typeof(Clog) == "undefined" )
	Clog= {};

Clog.Scripts= {};

Clog.Service=
{
	id: (new Date()).getTime(),
	cantUseOCX: false,
	pools: [],
	funcsURL: "API.aspx",
	loadFiles: [],
	flgFirstCall: true,
	chkCookie: false,

	makeParam: function(param, func)
	{
		var ret= "";
		var prm= param[func];
		for( var prop in prm )
		{
			if( prop.substring(0,1) == "$" )
				continue;
			ret+= "\x01"+ prop+ "=";
			if( typeof(prm[prop]) == "undefined" )
				ret+= "";
			else
			{
				if( prm[prop].constructor == Object )
				{
					for( var prop2 in prm[prop] )
						ret+= "\x0f"+ param[prop2].$funcNo+ "."+ prm[prop][prop2];
				}
				else if( prm[prop].constructor == Array )
					ret+= prm[prop].join("\x02");
				else
					ret+= prm[prop];
			}
		}
		return ret == "" ? "" : encodeURIComponent(ret.substring(1));
	},

	createHttpRequest: function()
	{
		if( window.XMLHttpRequest )
		{
			return new XMLHttpRequest();
		}
		else if( window.ActiveXObject )
		{
			//MSXML2以降用
			try { return new ActiveXObject("Msxml2.XMLHTTP"); }
			catch(e) {
				//旧MSXML用
				try { return new ActiveXObject("Microsoft.XMLHTTP"); }
				catch(e) { return null; }
			}
		}
		else
		{
			return null
		}
	},

	call: function( param, callBack, secure )
	{
		if( typeof(secure) == "undefined" )
			secure= false;
		if( ! Clog.Service.chkCookie && secure )
		{
			Clog.Service.chkCookie= true;
			//if( ! (";"+document.cookie).match(/; *chk=/) )
			//	alert("Cookieの設定が無効になっています。\nCookieを有効にしてからもう一度ページを読み込んでください。");
		}

		for( var prop in param )
		{
			if( param[prop].tagName == "FORM" )
			{
				var newParam= {};
				for( var tag in {INPUT:0,SELECT:0,TEXTAREA:0} )
				{
					var elements= param[prop].getElementsByTagName(tag);
					for( var i= 0; i < elements.length; i++ )
					{
						var element= elements[i];
						if( ! element.name || element.name == "" )
							continue;
						if( (element.type == "checkbox" || element.type == "radio") && ! element.checked )
							continue;
						var vals= newParam[element.name];
						if( ! vals )
							vals= newParam[element.name]= [];
						vals.push(element.value);
					}
				}
				param[prop]= newParam;
			}
		}

		var prms= "";
		var funcNo= 0;
		var callMethod= null;
		var ci= "";
		var funcs= "";

		for( var prop in param )
		{
			if( prop.substring(0,1) == "$" )
			{
				if( prop == "$method" )
					callMethod= param[prop];
				if( prop == "$callID" )
					ci= param[prop];
				if( prop == "$debug" )
					ci= "debug";
				continue;
			}
			var p= param[prop];
			if( p.result )
				delete p.result;
			if( prop == "LoadParts" || prop == "LoadScript" )
			{
				var flnm= p.flnm.toLowerCase().replace(".","_");
				if( Clog.Service.loadFiles[flnm] )
				{
					p.result= Clog.Service.loadFiles[flnm];
					continue;
				}
				callMethod= "callByScript2";
			}
			if( ! p.$func )
				p.$func= prop;
			if( ! p.$func )
				continue;
			p.$funcNo= ++funcNo;
			prms+= "&f"+funcNo+"="+p.$func+","+Clog.Service.makeParam(param, prop);
			funcs+= ","+p.$func;
		}
		if( ci == "" )
			ci= funcs.substring(1);

		if( funcNo == 0 )
		{
			callBack(param);
			return;
		}

		if( Clog.Service.flgFirstCall )
		{
			if( ! Clog.APIToken )
			{
				var apiToken= document.getElementsByName("apiToken");
				if( apiToken.length == 1 )
					Clog.APIToken= apiToken[0].getAttribute("value");
			}
			Clog.Service.flgFirstCall= false;
			param.GetServerTime= { $funcNo:0 };
			prms= "&f0=GetServerTime,"+Clog.Service.makeParam(param, "GetServerTime")+ prms;
		}
		if( Clog.APIToken )
			prms= "&api="+Clog.APIToken+ prms;

		// 同じドメインならcallByHttpでコールを試す
		if( ! secure )
			secure= document.URL.indexOf("https://") == 0;
		var url= (secure ? Clog.SecureServiceURL : Clog.ServiceURL)+ Clog.Service.funcsURL;
		var domain1= document.URL.match(/^https?:\/\/([^\/]+)/);
		var domain2= url.match(/^https?:\/\/([^\/]+)/);

		if( callMethod == null )
		{
			if( Clog.Service.cantUseOCX )
				domain1= null;
			if( secure && document.URL.indexOf("https://") != 0 )
				domain1= null;
			if( secure && navigator.userAgent.indexOf("Safari") != -1 )
				domain1= null;
			if( domain1 != null && domain1[1] == domain2[1] )
			{
				var httpoj= null;
				try { httpoj= Clog.Service.createHttpRequest(); }
				catch(e) {}
				if( httpoj == null )
					Clog.Service.cantUseOCX= true;
				else
					callMethod= "callByHttp";
			}
			if( callMethod == null )
				callMethod= "callByScript";
		}

		var callID= Clog.Service.id++;
		prms= "callID="+callID+ prms;

		Clog.Service.pools[callID]= { callBack:callBack, param:param, time:(new Date()).getTime() };
		var sts= Clog.Service[callMethod]( prms, callID, url+"?ci="+ci );
		if( sts )
			Clog.Service.notifyResponse( { result:-1, alert:sts, callID:callID } );
	},

	callByScript: function( prms, callID, url )
	{
		if( prms.length > 1500 )
			return Clog.Service.callByFrame(prms, callID, url);

		var win= null;
		if( ! document.URL.match(/^https:/i) )
		{
			win= window.frames["safariScript"];
			if( win && ! win.document.body )
			{
				setTimeout( function(){Clog.Service.callByScript(prms, callID, url);}, 1 );
				return;
			}
			if( win )
			{
				win.Clog.Service.notifyResponse= function(ret)
				{
					var Scripts= window.frames["safariScript"].Clog.Scripts;
					for( var prop in Scripts )
					{
						Clog.Scripts[prop]= Scripts[prop];
						delete Scripts[prop];
					}
					Clog.Service.notifyResponse(ret);
				};
			}
		}

		return Clog.Service.callByScript2(prms, callID, url, win ? win.document : document);
	},

	callByScript2: function( prms, callID, url, doc )
	{
		if( typeof(doc) == "undefined" )
			doc= document;
		if( ! doc.body )
		{
			//alert(prms);
			//setTimeout( function() { Clog.Service.callByScript2( prms, callID, url, doc ); }, 1000 );
			return null;
		}

		var s = doc.createElement("script");
		s.type = "text/javascript";
		s.charset = "utf-8";
		s.src= url+ "&"+prms;
		//s.onerror= function(){alert("err");};

		if( Clog.Debug.on && url.indexOf("ci=debug") == -1 )
		{
			Clog.Debug.write("<b>callByScript</b>:"+ url);
			Clog.Debug.write(prms, {color:"#999922"});
			Clog.Debug.write("Calling ...", {id:"call_"+callID, color:"#ff0000"});
		}

		doc.body.appendChild(s);
		Clog.Service.pools[callID].$script= s;

		return null;
	},

	callByHttp: function( prms, callID, url )
	{
		if( ! document.URL.match(/^https:/i) )
		{
			var win= window.frames["safariScript"];
			if( win && ! win.document.body )
			{
				setTimeout( function(){Clog.Service.callByHttp(prms,callID,url);}, 1 );
				return;
			}
			if( win )
			{
				win.onunload= function()
				{
					try { win.document.getElementById("state").reload.value= 1; }
					catch(e) {}
				}
				if( win.document.getElementById("state").reload.value == 1 )
					return Clog.Service.callByScript(prms, callID, url);
			}
		}

		var httpoj= null;
		try
		{
			if( Clog.Debug.on && url.indexOf("ci=debug") == -1 )
			{
				Clog.Debug.write("<b>callByHttp</b>:"+ url);
				Clog.Debug.write(prms, {color:"#999922"});
				Clog.Debug.write("Calling ...", {id:"call_"+callID, color:"#ff0000"});
			}

			httpoj= Clog.Service.createHttpRequest();
			httpoj.open( "POST", url, true );
			httpoj.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
			httpoj.setRequestHeader('If-Modified-Since', 'Wed, 15 Nov 1995 00:00:00 GMT');
			httpoj.onreadystatechange= function()
			{
				if( httpoj.readyState == 4 )
				{
					eval(httpoj.responseText);
//					try { eval(httpoj.responseText); }
//					catch(e)
//					{
//						if( httpoj.responseText == "" )
//							return;
//						var callInfo= Clog.Service.pools[callID];
//						if( callInfo && ! callInfo.param.LogError )
//						{
//							try { Clog.Service.call( { $callID:"ERR", LogError:{message:"prms = "+prms+"\r\nresponseText = "+httpoj.responseText, agent:navigator.userAgent, url:"Service.js.js, "+document.URL, line:"00295" } }, function(){} ); }
//							catch(e) {}
//						}
//						Clog.Service.notifyResponse({result:-1,alert:"サービスの呼び出しに失敗しました。",callID:callID});
//					}
				}
				else if( httpoj.readyState != 1 && httpoj.readyState != 2 && httpoj.readyState != 3 )
					Clog.Service.notifyResponse({result:-1,alert:"サービスの呼び出しに失敗しました。",callID:callID});
			}
			httpoj.send( prms );
		}
		catch(e) { return httpoj == null ? "DisableActiveX" : "HttpRequestError"; }

		return null;
	},

	callByFrame: function( prms, callID, url )
	{
		var prmCreateCacheID= { $method:"callByScript", CreateCacheID:{} };
		if( url.indexOf("ci=debug") != -1 )
			prmCreateCacheID.$debug= 1;
		if( Clog.Debug.on && ! prmCreateCacheID.$debug )
		{
			Clog.Debug.write("<b>callByFrame</b>:"+ url);
			Clog.Debug.write(prms, {color:"#999922"});
			Clog.Debug.write("Calling ...", {id:"call_"+callID, color:"#ff0000"});
		}

		Clog.Service.call( prmCreateCacheID,
			function(ret)
			{
				var doc2= document;
				var win2= window;
				if( ! document.URL.match(/^https:/i) )
				{
					win2= window.frames["safariScript"];
					if( win2 )
						doc2= win2.document;
					else
						win2= window;
				}

				var obj= doc2.createElement("span");
				obj.id= "frame_span_"+callID;
				obj.style.position= "absolute";
				obj.style.overflow= "hidden";
				obj.style.left= obj.style.top= obj.style.width= obj.style.height= "0px";
				doc2.body.appendChild(obj);
				obj.innerHTML= "<iframe id=frame_"+callID+" name=frame_"+callID+" style='border:solid 1 black;'></iframe>";

				var html= "";
				html+= '<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"></head><body>\n';
				html+= "<form id=form"+callID+" action='"+url+"' method=post accept-charset=UTF-8>\n";
				html+= '<input type=hidden name=$cacheID>\n';
				var vals= prms.split(/&/g);
				for( var i= 0; i < vals.length; i++ )
				{
					var pos= vals[i].indexOf("=");
					vals[i]= { name:vals[i].substring(0,pos), value:vals[i].substring(pos+1) };
					html+= '<input type=hidden name='+vals[i].name+'>\n';
				}
				html+= "</form>\n";
				html+= "</body></html>\n";

				var chkCreateFrame= function()
				{
					var doc= null;
					try { doc= win2.frames["frame_"+callID].document; } catch(e) {}
					if( doc == null )
					{
						setTimeout( chkCreateFrame, 1 );
						return;
					}
					doc.write( html );
					doc.close();

					var form= doc.getElementById("form"+callID);
					form["$cacheID"].value= ret.CreateCacheID.result.cacheID;
					for( var i= 0; i < vals.length; i++ )
						form[vals[i].name].value= decodeURIComponent(vals[i].value);

					setTimeout(
						function()
						{
							var prmGetCache= { $method:"callByScript", GetCache:{ remove:1, cacheID:ret.CreateCacheID.result.cacheID } };
							if( prmCreateCacheID.$debug )
								prmGetCache.$debug= 1;
            				Clog.Service.call( prmGetCache, function() {} );
						} ,1
					);

					form.submit();
				}
				chkCreateFrame();
			}
		);
	},

	notifyResponse: function(ret)
	{
		var callInfo= Clog.Service.pools[ret.callID];
		if( callInfo )
		{
			if( Clog.Debug.on && ! callInfo.param.$debug )
				Clog.Debug.write("Response: "+((new Date()).getTime()-callInfo.time)+" ms", {id:"call_"+ret.callID, color:"#008800"});

			if( callInfo.$script )
				callInfo.$script.parentNode.removeChild( callInfo.$script );
			var param= callInfo.param;
			for( var prop in param )
			{
				var result= ret["f"+param[prop].$funcNo];
				delete param[prop].$funcNo;
				if( result )
				{
					param[prop].result= result;
					if( prop == "LoadParts" || prop == "LoadScript" )
					{
						var flnm= param[prop].flnm.toLowerCase().replace(".","_");
						Clog.Service.loadFiles[flnm]= result;
					}
				}
			}
			if( ret.result )
			{
				param.result= ret.result;
				param.alert= ret.alert;
				param.func= ret.func;
			}

			if( param.GetServerTime && param.GetServerTime.result )
			{
				if( Math.abs(param.GetServerTime.result.clog_server_time.getTime()- (new Date()).getTime()) > 8*3600*1000 )
					alert("お使いのコンピュータの時計がずれている可能性があります。\n時計を合わせる事をお勧めいたします。");
			}

			callInfo.callBack(param);
//setTimeout( function() {
//			delete Clog.Service.pools[ret.callID];
//}, 1 );
		}

		var doc2= document;
		var win2= window;
		if( ! document.URL.match(/^https:/i) )
		{
			win2= window.frames["safariScript"];
			if( win2 )
				doc2= win2.document;
			else
				win2= window;
		}

		var frame= doc2.getElementById("frame_"+ret.callID);
		var frame_span= doc2.getElementById("frame_span_"+ret.callID);
	
		if( frame )
			frame.parentNode.removeChild( frame );
		if( frame_span )
			frame_span.parentNode.removeChild( frame_span );
//		if( frame )
//			Clog.Service.backFrameControl();
	},

	backFrameControl: function()
	{
		if( navigator.userAgent.indexOf("Safari") == -1 )
			return;
		var pnlBackFrameControl= document.getElementById("pnlBackFrameControl");
		if( ! pnlBackFrameControl )
		{
			pnlBackFrameControl= document.createElement("span");
			pnlBackFrameControl.id= "pnlBackFrameControl";
			pnlBackFrameControl.style.position= "absolute";
			pnlBackFrameControl.style.overflow= "hidden";
			pnlBackFrameControl.style.left= pnlBackFrameControl.style.top= pnlBackFrameControl.style.width= pnlBackFrameControl.style.height= "0px";
			document.body.appendChild(pnlBackFrameControl);
		}
		Clog.Service.callFrameCount++;
		pnlBackFrameControl.innerHTML= "<iframe src="+Clog.UIURL+"BackFrameControl.html?1&"+(Clog.Service.callFrameCount*3)+" width=640 height=30></iframe>";
	},
	
	callFrameCount: 0,
	initUploadCount: 0,
	ImageUploadCount: 0,

	initUpload: function( id, id2 )
	{
		if( typeof(id2) != "undefined" )
		{
			var place= document.getElementById(id);
			place.placeID= id2;
			place.newType= 1;
			place.getForm= function()
			{
				var ret= null;
				try { ret= window.frames[place.placeID].document.getElementById(place.placeID); }
				catch(e) { }
				return ret;
			};
			return;	
		}

		Clog.Service.initUploadCount++;
		var place= document.getElementById(id);
		if( ! place.orgHTML )
		{
			place.orgHTML= place.innerHTML;
			place.getForm= function()
			{
				var ret= null;
				try { ret= window.frames[place.placeID].document.getElementById(place.placeID); }
				catch(e) { }
				return ret;
			};
			place.clear= function()
			{
				place.innerHTML= "";
			};
		}
		
		place.placeID= "frmUpload"+(Clog.Service.id++);
		var src= "";
		if( navigator.userAgent.indexOf("MSIE") != -1 && document.URL.indexOf("https://") == 0 )
			src= "src=/blank.htm";
		//place.innerHTML= '<iframe src="blank.htm" name='+place.placeID+' style="overflow:hidden; border:none; width:'+place.style.width+'; height:'+place.style.height+';"></iframe>';
		place.innerHTML= '<iframe '+src+' name='+place.placeID+' style="overflow:hidden; border:none; width:'+place.style.width+'; height:'+place.style.height+';"></iframe>';
		var chkFrame= function()
		{
			if( ! window.frames[place.placeID] )
			{
				setTimeout( chkFrame, 1 );
				return;
			}
			var frmUpload= window.frames[place.placeID].document;
			if( frmUpload.getElementById(place.placeID) )
			{
				setTimeout( chkFrame, 1 );
				return;
			}
			var html= "";
			html=  "<body scroll=no style='border:none; margin:0px; padding:0px; overflow:hidden;'>";
			html+= "<form id="+place.placeID+" action='' method=post enctype='multipart/form-data'>";
			html+= place.orgHTML;
			html+= "</form>";
			html+= "</body>"
			frmUpload.write(html);
			frmUpload.close();
		};
		setTimeout( chkFrame, 1 );
	},

	ImageUpload: function(id, callBack)
	{
		var obj= $(id);
		if( obj.getForm )
		{
			//obj.getForm().action= Clog.ServiceURL+ "Funcs.aspx?func="+ "ImageUpload";
			Clog.Service.call( { CreateCacheID:{ objectID:"token" } },
				function(ret)
				{
					var form= obj.getForm();
					//form.action= Clog.ServiceURL+ "Funcs.aspx?func=ImageUpload&cacheID="+ret.CreateCacheID.result.cacheID;
					form.action= Clog.ServiceURL+ "API.aspx?$func=ImageUpload&cacheID="+ret.CreateCacheID.result.cacheID+"&newType="+(obj.newType ? 1 : 0);
					var html= form.ownerDocument.documentElement.innerHTML;
					var frame= document.getElementsByName(form.id)[0];
					var errSubmit= false;
	                setTimeout(
	                    function()
	                    {
							if( errSubmit )
							{
								callBack({ alert:"アップロード出来ません！" });
								return;
							}
        	                Clog.Service.call( { CheckCache:{ cacheID:ret.CreateCacheID.result.cacheID, mode:"ImageUpload" } },
								function(ret)
								{
									if( ! obj.newType )
									{
										Clog.Service.backFrameControl();
										Clog.Service.initUpload(id);
									}
									ret.cacheID= ret.CheckCache.cacheID;
									callBack(ret);
								}
							);
						} ,1
					);
					
					Clog.Service.ImageUploadCount++;
					try { form.submit(); }
					catch(e) { errSubmit= true; }
				}
			);
		}
	}
};

Clog.Debug=
{
	on: true,
	msgPool: [],
	cacheID: null,
	timer: null,

	write: function(msg, prms)
	{
		if( ! Clog.Debug.on )
			return;
		if( typeof(prms) == "undefined" )
			prms= {};
		var id= "";
		var style= "";
		for( var name in prms )
		{
			if( name == "id" )
				id= prms[name];
			else
				style+= name+ ":"+ prms[name]+ ";";
		}
		if( style != "" )
			msg= '<div style="'+ style+ '">'+ msg+ '</div>';
		msg= id+ ":"+ msg;

		var flgFirst= Clog.Debug.cacheID == null;

		if( Clog.Cookies && Clog.Cookies.$root && Clog.Cookies.$root.debug )
			Clog.Debug.cacheID= Clog.Cookies.$root.debug;
		else
		{
			var m= (";"+document.cookie+";").match(/; *debug=([^;]+);/);
			Clog.Debug.cacheID= m != null ? m[1] : null;
		}

		Clog.Debug.on= true && Clog.Debug.cacheID;
		if( Clog.Debug.on )
		{
			if( flgFirst )
			{
				Clog.Debug.write("&nbsp;");
				Clog.Debug.write("Start : "+document.URL, {"background-color":"#ff8888"} );
			}

			var flgOutput= false;
			try
			{
				if( window.opener && Clog.Debug.msgPool.length == 0 && ! window.opener.App.relay )
				{
					window.opener.App.Ctrls.Output.write(msg);
					flgOutput= true;
				}
			}
			catch(e) {}

			if( ! flgOutput )
			{
				Clog.Debug.msgPool.push(msg);
				if( Clog.Debug.timer == null )
					Clog.Debug.timer= setTimeout( Clog.Debug.writePool, 100 );
			}
		}
	},

	writePool: function()
	{
		if( Clog.Debug.msgPool.length == 0 )
			return;
		var lines= Clog.Debug.msgPool.join("\n");
		Clog.Debug.msgPool= [];
		Clog.Service.call( { $debug:1, WriteCache: { cid:Clog.Debug.cacheID, lines:lines } },
			function()
			{
				if( Clog.Debug.msgPool.length > 0 )
					Clog.Debug.timer= setTimeout( Clog.Debug.writePool, 100 );
				else
					Clog.Debug.timer= null;
			}
		);
	}
};

try { Clog.Parse.LoadedService(); } catch(e) {}

if( typeof(Clog) != 'undefined' && Clog.Debug ) Clog.Debug.write('loaded : file/js/AccessControl.js',{color:'#882222'});
if( typeof(Clog) == "undefined" )
	Clog= {};

Clog.AccessControl=
{
	companyID: "",
	flgCheckAccount: false,
	resultCheckLogin: null,
	urlAfterLogin: Clog.UIURL+ "Clogs.aspx",
	urlAfterLogout: Clog.UIURL+ "Top.aspx",

	init: function(ctrl)
	{
		if( typeof(ctrl) == "undefined" )
			ctrl= $("frmLogin");
		if( ! ctrl )
			return;

		ctrl.onsubmit= function() { return false; }
		ctrl.user_id.onkeypress= ctrl.password.onkeypress= function(event)
		{
			if( typeof(event) == "undefined" )
				event= window.event;
			if( event.keyCode == 13 )
				Clog.AccessControl.login(ctrl);
		};
		if( Clog.AccessControl.resultCheckLogin && Clog.AccessControl.resultCheckLogin.user_id )
		{
			ctrl.user_id.value= Clog.AccessControl.resultCheckLogin.user_id;
			ctrl.save_user_id.checked= true;
		}
	},

	login: function(frm)
	{
		if( typeof(frm) == "undefined" )
			frm= $("frmLogin");
		if( typeof(AppData) != "undefined" && !AppData.supportAjax )
		{
			frm.url.value= Clog.AccessControl.urlAfterLogin ? Clog.AccessControl.urlAfterLogin : document.URL;
			frm.submit();
		}
		else
		{
			if( frm.mode && frm.mode.value == "openid" )
			{
				frm.open_id.value= Clog.Common.trimSpace(frm.open_id.value);
				if( frm.open_id.value == "" )
				{
					alert("OpenIDを入力してください。");
					return;
				}
				Clog.Common.showProcessPanel(true, "接続中･･･");
				Clog.Service.call( { AssociateOpenID:{ open_id:frm.open_id.value, close:AppData.popup ? 1 : 0 } },
					function(ret)
					{
						result= ret.AssociateOpenID.result;
						if( ! ret.alert && ! result.openid_server )
							ret.alert= "接続できるOpenIDサーバーが見つかりませんでした。";
						if( ret.alert )
						{
							Clog.Common.showProcessPanel(false);
							alert(ret.alert);
							return;
						}
						var submitOpenID= function()
						{
							var keys= result.parameterKeys.split(",");
							var html= '<form id=frmOpenID action="'+ result.openid_server+ '" method='+ result.method+ '>\n';
							for( var i= 0; i < keys.length; i++ )
							{
								if( keys[i].indexOf("$op_") == 0 )
									document.cookie= keys[i].substring(1)+ "="+ result.parameter[keys[i]]+ ";path=/";
								else
									html+= '<input type=hidden name="openid.'+ keys[i]+ '">\n';
							}
							$("ConnetOpenID").innerHTML= html+ '</form>';
							document.cookie= "op_mode="+ AppData.mode+ ";path=/";

							var frmOpenID= $("frmOpenID");
							for( var i= 0; i < keys.length; i++ )
							{
								if( keys[i].indexOf("$op_") != 0 )
									frmOpenID["openid."+keys[i]].value= result.parameter[keys[i]];
							}
							frmOpenID.submit();
						}
						if( Clog.Cookies && Clog.Cookies.State1 )
							Clog.Cookies.State1.set("open_id", $("save_open_id").checked ? ret.AssociateOpenID.result.open_id : null, 3600*24*365, false, submitOpenID );
						else
							submitOpenID();
						
					}, true
				);
				return;
			}
			Clog.Common.showProcessPanel(true, "ログイン中･･･");
			Clog.Service.call( { Login:{ companyID:Clog.AccessControl.companyID, user_id:frm.user_id.value, password:frm.password.value, save_user_id:frm.save_user_id.checked ? 1 : 0 } },
				function(ret)
				{
					if( ret.alert )
					{
						Clog.Common.showProcessPanel(false);
						alert(ret.alert);
						return;
					}
					var pageMove= function()
					{
						if( AppData.popup )
						{
							Clog.Common.showProcessPanel(false);
							App.Login.closeLogin();
						}
						else if( Clog.AccessControl.urlAfterLogin )
							window.location= Clog.AccessControl.urlAfterLogin;
						else if( frm.back_url && frm.back_url.value )
							history.back();
						else
							location.reload();
					}
					if( Clog.Cookies && Clog.Cookies.State1 )
						Clog.Cookies.State1.set("user_id", ret.Login.result.user_id == "" ? null : ret.Login.result.user_id, 3600*24*365, false, pageMove );
					else
						pageMove();
				}, true
			);
		}
	},
	logout: function()
	{
		if( typeof(AppData) != "undefined" && !AppData.supportAjax )
		{
			var frmLogout= $("frmLogout");
			frmLogout.url.value= document.URL;
			frmLogout.submit();
		}
		else
		{
			Clog.Service.call( { Logoff:{} },
				function(ret)
				{
					if( Clog.AccessControl.urlAfterLogout )
						window.location= Clog.AccessControl.urlAfterLogout;
					else
						location.reload();
				}, true
			);
		}
	}
}

if( typeof(Clog) != 'undefined' && Clog.Debug ) Clog.Debug.write('loaded : file/js/Profile2.js',{color:'#882222'});
if( typeof(Clog) == "undefined" )
	Clog= {};

Clog.Profile=
{
	mode: "friend",
	filter: "friend",
	display: false,
	site1: [],
	site2: [],
	site3: [],
	accountIDs: {},
	groupIDs: {},
	groups: {},
	friends: {},
	pageNo: 0,
	pageCnt: 0,
	itemPerPage: 10,
	selectedGroup: "all",

	Group:
	{
		selectMode: function(mode)
		{
			Clog.Profile.pageNo= 0;
			Clog.Profile.selectedGroup= "";
			Clog.Profile.filter= Clog.Profile.mode= mode;
			Clog.Profile.Group.paging("top");
		},
		select: function(obj)
		{
			if( obj.value == "" )
				return;
			else if( obj.value == "manage" )
				window.location= Clog.UIURL+ "FriendList.html?"+ (Clog.Profile.mode == "friend" ? "FriendGroup" : "WatchGroup");
			
			Clog.Profile.pageNo= 0;
			Clog.Profile.selectedGroup= obj.value;
			Clog.Profile.filter= obj.value == "all" ? Clog.Profile.mode : obj.value;
			Clog.Profile.Group.paging("top");
		},
		paging: function(page)
		{
			if( ! Clog.Profile.accountIDs[Clog.Profile.filter] )
			{
				Clog.Profile.accountIDs[Clog.Profile.filter]= [];
				var prms= { SearchFriends: {getAccountID:1, account_id:AppData.profile.account_id, friendType:Clog.Profile.mode == "friend" ? 1 : 2} };
				if( Clog.Profile.filter != Clog.Profile.mode )
					prms.SearchFriends.group_id= Clog.Profile.filter;
				if( ! Clog.Profile.groupIDs[Clog.Profile.mode] && AppData.profile.own )
					prms.SearchGroup= {account_id:AppData.profile.account_id, group_type:prms.SearchFriends.friendType};
				Clog.Service.call(prms,
					function(ret)
					{
						if( ret.alert )
						{
							alert(ret.alert);
							return;
						}
						Clog.Profile.accountIDs[Clog.Profile.filter]= ret.SearchFriends.result.account_id;
						if( ret.SearchGroup )
						{
							var groupIDs= Clog.Profile.groupIDs[Clog.Profile.mode]= [];
							var groups= ret.SearchGroup.result.groups;
							for( var i= 0; i < groups.length; i++ )
							{
								Clog.Profile.groups[groups[i].group_id]= groups[i];
								groupIDs.push(groups[i].group_id);
							}
						}
						Clog.Profile.Group.paging(page);
					}
				);
				return;
			}
			Clog.Profile.pageCnt= Math.floor((Clog.Profile.accountIDs[Clog.Profile.filter].length+ Clog.Profile.itemPerPage- 1)/ Clog.Profile.itemPerPage);

			var pageNo= Clog.Profile.pageNo;
			if( page == "top" )
				pageNo= 0;
			else
			{
				if( page == "next" )
					pageNo++;
				else if( page == "prev" )
					pageNo--;
				if( pageNo < 0 || pageNo >= Clog.Profile.pageCnt )
					return;
			}
			Clog.Profile.pageNo= pageNo;
			var ids= Clog.Profile.accountIDs[Clog.Profile.filter];
			var spos= Clog.Profile.pageNo* Clog.Profile.itemPerPage;
			var epos= spos+ Clog.Profile.itemPerPage;
			var account_ids= [];
			for( var i= spos; i < epos && i < ids.length; i++ )
			{
				if( ! Clog.Profile.friends[ids[i]] )
					account_ids.push(ids[i]);
			}
			if( account_ids.length > 0 )
			{
				Clog.Service.call({
					GetFriendInfos: {friend_id:account_ids, account_id:AppData.profile.account_id, friendType:Clog.Profile.mode == "friend" ? 1 : 2, fields:"clog_count,unread_clog"}
					}, function(ret)
					{
						if( ret.alert )
						{
							alert(ret.alert);
							return;
						}
						var friends= ret.GetFriendInfos.result.friends;
						for( var i= 0; i < friends.length; i++ )
							Clog.Profile.friends[friends[i].friend_account_id]= friends[i];
						Clog.Profile.Group.update();
					}
				);
				return;
			}
			Clog.Profile.Group.update();
		},
		update: function()
		{
			$("ProfileArea_group").innerHTML= Clog.Common.createHtml(AppHtml.Profile_group, Clog.Profile.Group);
			Clog.Common.setURLs($("ProfileArea_group"));
		},

		modeFriend: function(data) { return Clog.Profile.mode == "friend" ? null : "" },
		modeWatch: function(data) { return Clog.Profile.mode != "friend" ? null : "" },
		manageGroup: function(data)
		{
			if( ! AppData.profile.own )
				return "";
			return Clog.Common.createHtml(data, {
				iconFriend: Clog.Profile.mode == "friend" ? null : "",
				iconWatch: Clog.Profile.mode != "friend" ? null : "",
				groupItem: function(data)
				{
					var html= "";
					var groupIDs= Clog.Profile.groupIDs[Clog.Profile.mode];
					for( var i= 0; i < groupIDs.length; i++ )
					{
						var group= Clog.Profile.groups[groupIDs[i]];
						html+= Clog.Common.replace(data.html, /@(.+?)@/g, {
							value:		group.group_id,
							text:		group.group_name,
							selected:	Clog.Profile.selectedGroup == group.group_id ? "selected" : ""
						});
					}
					return html;
				},
				$item: "item"
			});
		},
		friendList: function(data)
		{
			var html= "";
			var ids= Clog.Profile.accountIDs[Clog.Profile.filter];
			var spos= Clog.Profile.pageNo* Clog.Profile.itemPerPage;
			var epos= spos+ Clog.Profile.itemPerPage;
			for( var i= spos; i < epos && i < ids.length; i++ )
			{
				var friend= Clog.Profile.friends[ids[i]];
				html+= Clog.Common.replace( Clog.Common.createHtml(data, {
					up: friend.unread_clog ? null : "",
					removed: "",
					active: friend.status == 1 ? null : "",
					negotiating: friend.status != 1 ? null : "",
					$item: "item"
				}), /@(.+?)@/g, {
					nick_name:		friend.friendly_name,
					image:			"/images/dot.gif",
					image_url:		Clog.ServiceURL+ friend.friend_account_id+ ".image.0.clog",
					width:			24,
					height:			24,
					clog_count:		friend.clog_count,
					link:			Clog.UIURL+ "Clogs.aspx?" + friend.friend_account_id,
					link2:			friend.status == 10 ? Clog.UIURL+ "FriendAgree.html?"+ friend.friend_id : friend.status == 2 ? Clog.UIURL+ "FriendApply.html?"+ friend.friend_account_id : ""
				});
			}
			return html;
		},
		notRegist: function(data) { return Clog.Profile.accountIDs[Clog.Profile.filter].length == 0 ? null : "" },
		notFound: "",
		manageFriend: function(data)
		{
			if( Clog.Profile.accountIDs[Clog.Profile.filter].length < 10 && ! AppData.profile.own )
				return "";
			return Clog.Common.createHtml(data, {
				prev: Clog.Profile.pageNo == 0 ? "" : null,
				manage: AppData.profile.own ? null : "",
				next: Clog.Profile.pageCnt > Clog.Profile.pageNo+ 1 ? null : "",
				$item: "item"
			}).replace("@UIURL@", Clog.UIURL).replace("@mode@", Clog.Profile.mode == "friend" ? "Friend" : "Watch");
		},

		$item: "fld"
	},

	init: function(ctrl)
	{
		if( Clog.Profile.accountIDs.watch )
			Clog.Profile.accountIDs.watch= undefined;
		if( Clog.Profile.groupIDs.watch )
			Clog.Profile.groupIDs.watch= undefined;
		var groupIDs= Clog.Profile.groupIDs[Clog.Profile.mode]= [];
		var groups= AppData.groups;
		for( var i= 0; i < groups.length; i++ )
		{
			groupIDs.push(groups[i].group_id);
			Clog.Profile.groups[groups[i].group_id]= groups[i];
		}
	},

	show: function(obj)
	{
		Clog.Profile.display= ! Clog.Profile.display;
		var ProfileArea_profile= $("ProfileArea_profile");
		ProfileArea_profile.style.display= Clog.Profile.display ? "block" : "none";
		if( Clog.Profile.display && ! ProfileArea_profile.init )
		{
			ProfileArea_profile.init= 1;
			if( AppData.profile.mysite )
			{
				var sites= AppData.profile.mysite.split("\n");
				for( var i= 0; i < sites.length; i++ )
				{
					var vals= sites[i].split("\t");
					(vals[0] == 256 ? Clog.Profile.site1 : vals[0] == 257 ? Clog.Profile.site2 : Clog.Profile.site3).push(vals);
				}
			}
			ProfileArea_profile.innerHTML= Clog.Common.createHtml(AppHtml.Profile_profile, Clog.Profile);
		}
		obj.innerHTML= Clog.Profile.display ? "閉じる" : "確認";
		return false;
	},

	location: function(data) { return AppData.profile.public_field & Clog.Value.PublicField.Location ? data.html.replace("@text@", Clog.Value.LocationNames[AppData.profile.user_location]) : "" },
	age: function(data) { return AppData.profile.public_field & Clog.Value.PublicField.Age ? data.html.replace("@text@", AppData.profile.age) : "" },
	birthday: function(data) { return AppData.profile.public_field & Clog.Value.PublicField.Birthday ? data.html.replace("@text@", AppData.profile.bday_m+"月"+AppData.profile.bday_d+"日") : "" },
	constellation: function(data) { return AppData.profile.public_field & Clog.Value.PublicField.Constellation ? data.html.replace("@text@", Clog.Value.ConstellationNames[AppData.profile.constellation]) : "" },
	blood: function(data) { return AppData.profile.public_field & Clog.Value.PublicField.Blood ? data.html.replace("@text@", Clog.Value.BloodNames[AppData.profile.blood]) : "" },
	job: function(data) { return AppData.profile.public_field & Clog.Value.PublicField.Job ? data.html.replace("@text@", Clog.Value.JobNames[AppData.profile.job]) : "" },
	sendai: "",
	comment: function(data) { return data.html.replace("@title@","自己紹介").replace("@text@", AppData.profile.comment.replace(/\n/g,"<br>")) },

	mySiteMain: function(data)
	{
		if( ! AppData.profile.mysite )
			return "";
		return Clog.Common.createHtml(data, {
			siteList: function(data)
			{
				var createItem= function(data, sites)
				{
					var html= "";
					for( var i= 0; i < sites.length; i++ )
					{
						var icon= sites[i][1].match(/:\/\/([^/:]+)/);
						html+= Clog.Common.replace(data.html, /@(.+?)@/g, {
							link:	sites[i][1],
							icon:	icon ? Clog.ServiceURL+icon[1]+".icon.clog" : "",
							title:	sites[i][2]
						});
					}
					return html;
				}
			
				return Clog.Common.createHtml(data, {
					titleWeb: Clog.Profile.site1.length == 0 ? "" : null,
					itemWeb: function(data) { return createItem(data, Clog.Profile.site1) },
					titleBlog: Clog.Profile.site2.length == 0 ? "" : null,
					itemBlog: function(data) { return createItem(data, Clog.Profile.site2) },
					$item: "item"
				});
			},
			$item: "item"
		});
	},

	mySiteSub: function(data)
	{
		if( Clog.Profile.site3.length == 0 )
			return ""
		return Clog.Common.createHtml(data, {
			itemSite: function(data)
			{
				var sites= Clog.Profile.site3;
				var html= "";
				for( var i= 0; i < sites.length; i++ )
				{
					html+= Clog.Common.replace(data.html, /@(.+?)@/g, {
						link:	Clog.Value.MySite[sites[i][0]].url.replace("@id@",sites[i][1]),
						icon:	Clog.UIURL+"favicon/"+Clog.Value.MySite[sites[i][0]].icon,
						site:	Clog.Value.MySite[sites[i][0]].title
					});
				}
				return html;
			},
			$item: "item"
		});
	},

	$item: "item"
}

if( typeof(Clog) != 'undefined' && Clog.Debug ) Clog.Debug.write('loaded : file/js/script.js',{color:'#882222'});
<!--
function popJumpSW(selOBJ)
{
	n = selOBJ.selectedIndex;
	window.open(selOBJ.options[n].value,"clogit","width=480,height=330,scrollbars=yes,menubar=yes,toolbar=yes,location=yes,status=yes,resizable=yes");
}
// -->
function OpenWindow( url, width, height, options, name ){
  if(!width) width = 0;
  if(!height) height = 0;
  if(!options) options = "scrollbars=yes,menubar=yes,toolbar=yes,location=yes,status=yes,resizable=yes";
  if(!name) name = "outsideSiteWindow";

  var newWin = window.open( url, name, "width=" + width + ",height=" + height + "," + options );
}

function popJump(selOBJ)
{
	document.body.focus();
	n = selOBJ.selectedIndex;
	if( selOBJ.options[n].value != "" )
	{
		if( selOBJ.options[n].getAttribute("nopopup") )
			window.location= selOBJ.options[n].value;
		else if( ! window.open(selOBJ.options[n].value) )
			window.location= selOBJ.options[n].value;
	}
	selOBJ.selectedIndex= 0;
}

//プレロード＆マウスオーバー（メニュー）
function newImage(arg) {
if (document.images) {
rslt = new Image();
rslt.src = arg;
return rslt;
}
}

function changeImages() {
if (document.images && (preloadFlag == true)) {
for (var i=0; i<changeImages.arguments.length; i+=2) {
document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
}
}
}
// -->

var preloadFlag = false;
function preloadImages() {
if (document.images) {
nice_gallery_over = newImage("/gallery-images/but-nice-gallery-over.gif");

preloadFlag = true;
}
}

//レイヤーセレクタ
function layer_sellector(targetLayer,nextStyle){

  if (document.all){
  document.all[targetLayer].style.visibility = nextStyle;
  
  }else if (document.layers){
  document.layers[targetLayer].visibility = nextStyle;

  }else if (document.getElementById){
  document.getElementById(targetLayer).style.visibility = nextStyle;   
  
  }
}
//レイヤーセレクタ
function layer_pop(targetLayer,nextStyle){

  if (document.all){
  document.all[targetLayer].style.display = nextStyle;
  
  }else if (document.layers){
  document.layers[targetLayer].display  = nextStyle;

  }else if (document.getElementById){
  document.getElementById(targetLayer).style.display  = nextStyle;   
  
  }
}
//オンマウス
function myChgPic(myPicURL){
   document.images["myBigImage"].src = myPicURL;
}

//サンプル用
var target = "";

// 設定終了


function jump(){
var url = document.select.options[document.select.selectedIndex].value;
if(url != "" ){
if(target == 'top'){
top.location.href = url;}
else if(target == 'blank'){
window.open(url, 'window_name');
}
else if(target != ""){
eval('parent.' + target + '.location.href = url');
}
else{
location.href = url;
}
}
}

//CSSの振り分け
var css_browser_selector = function() {
	var 
		ua=navigator.userAgent.toLowerCase(),
		is=function(t){ return ua.indexOf(t) != -1; },
		h=document.getElementsByTagName('html')[0],
		b=(!(/opera|webtv/i.test(ua))&&/msie (\d)/.test(ua))?('ie ie'+RegExp.$1):is('gecko/')? 'gecko':is('opera/9')?'opera opera9':/opera (\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',
		os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';
	var c=b+os+' js';
	h.className += h.className?' '+c:c;
}();
// -->

