//------------------------------------------------------//
//------------------------------------------------------//
var O_date =new Date();
var V_now  =Math.floor(O_date.getTime()/1000);
var V_pre  =V_now;
var V_left =0;

var obj = new wrapScroll('float_menu','container');
obj.marginTop=15;
obj.Interval =50;
obj.Duration =30;

window.onresize=float_menu_adjust;

//------------------------------------------------------//
function float_menu_adjust(){
	var float_block=document.getElementById("float_menu");

	if(document.documentElement && document.documentElement.clientHeight){
		var cw=document.documentElement.clientWidth;
		//var ch=document.documentElement.clientHeight;
	}else if(document.body && document.body.clientWidth){
		var cw=document.body.clientWidth;
		//var ch=document.body.clientHeight;
	}

	var menu_pos=Math.floor(cw/2)+380;
	var bg_pos=Math.floor(cw/2)-390;
	float_block.style.left=menu_pos+"px";
	document.body.style.backgroundPosition=bg_pos+"px";

}
//------------------------------------------------------//
function timer_start(lim){
	O_timer=setInterval("timer_count("+lim+")",100);
}
//------------------------------------------------------//
function timer_count(lim){
	var lim_sec=lim*60;
	V_now  =Math.round(new Date().getTime()/1000);
	if(V_now!=V_pre){
		V_left++;
		V_pre=V_now;
		var rt=lim_sec-V_left;

		var rm=0;
		var rs=0;
		if(rt>=0){
			rm=Math.floor(rt/60);
			rs=rt-(rm*60);
		}else{
			clearInterval(O_timer);
			rm="--";
			rs="--";
		}
		set_timer_strings(rm,rs);
	}
}
//------------------------------------------------------//
function set_timer_strings(rm,rs){
	if(rs=="--"){s="[--:"+rm+":"+rs+"]";}
	else{
		if(rm<10){rm="0"+rm;}
		if(rs<10){rs="0"+rs;}
		var s="[00:"+rm+":"+rs+"]";
	}

	var e=document.getElementById("session_time_left");
	if(e){
		if(navigator.userAgent.indexOf("Firefox")>-1){e.textContent=s;}
		else                                         {e.innerText=s;}
	}

	e=document.getElementById("session_time_left_in_float");
	if(e){
		if(navigator.userAgent.indexOf("Firefox")>-1){e.textContent=s;}
		else                                         {e.innerText=s;}
	}
}
//------------------------------------------------------//
//------------------------------------------------------//
function output_url(date){
	var entry=document.forms[0].thumb_url.value;

	var u=entry;
	date=date.replace('%INS_DATE%',date)
	var ww="100";
	var hh="90";

	var m=date.match(/\(.*\)/);
	date=date.replace(m,"");
	date=date.replace("----","（日付の書式を選択してください）");

	u=u.replace('%INS_DATE%',date);
	u=u.replace('%WIDTH%'   ,ww);
	u=u.replace('%HEIGHT%'  ,hh);

	var e=document.getElementById("thumb_url_sample");
	if(e){
		if(navigator.userAgent.indexOf("Firefox")>-1){e.textContent=u;}
		else                                         {e.innerText=u;}
	}
}
//------------------------------------------------------//
//------------------------------------------------------//
function strlen_count(parts,lim){
	var len=parts.value.length;
	if(len>lim && lim!=0){parts.style.cssText='border:1px solid #A90122; color:#A90122;';}
	else                 {parts.style.cssText='border:1px solid #666; color:#333;';}

	var e=document.getElementById("len_"+parts.name);
	if(e){
		if(navigator.userAgent.indexOf("Firefox")>-1){e.textContent=len+" 文字";}
		else                                         {e.innerText=len+" 文字";}
		if(len>lim && lim!=0){e.style.cssText='border:1px solid #A90122; background:#FFF3F5; color:#A90122;';}
		else                 {e.style.cssText='border:1px solid #0D389D; background:#DDE6FD; color:#0D389D;';}
//e.setAttribute('style','border:1px solid #A90122; background:#FFF3F5; color:#A90122;');
	}
}
//------------------------------------------------------//
function copy_previous_text(from,to,lim){
	to.value=from.value;
	strlen_count(to,lim)
}
//------------------------------------------------------//
function update_thumbnail(opt,format,date,root){
	var o=opt.value;

	var imgs=document.getElementsByTagName("img");
	for(var i=0; i<imgs.length;i++){
		var sid=imgs[i].getAttribute("id");

		if(sid && sid.match(/^thumb_[0-9]+_[0-9]/)){
			var ww=sid.split("_")[1];
			var hh=sid.split("_")[2];

			var e=document.getElementById(sid);

			var u=format;
			u=u.replace('%INS_DATE%',date);
			u=u.replace('%WIDTH%'   ,ww);
			u=u.replace('%HEIGHT%'  ,hh);
			u=u.replace('%OPTION%'  ,o);

			check_request(e,u,root+"/_no.gif");
		}
	}
}
//------------------------------------------------------//
function check_request(e,u,no){
	e.setAttribute("src",u);
}
//------------------------------------------------------//
function check_all_dest(){
	var elms=document.forms[0].elements;
	for(var i=0; i<elms.length; i++){
		if(elms[i].type!="checkbox"){continue;}
		elms[i].checked=true;
	}
}
//------------------------------------------------------//
function uncheck_all_dest(){
	var elms=document.forms[0].elements;
	for(var i=0; i<elms.length; i++){
		if(elms[i].type!="checkbox"){continue;}
		elms[i].checked=false;
	}
}
//------------------------------------------------------//
//------------------------------------------------------//
function confirm_fromsite_del(s){
	is_ok=confirm("更新サイト設定「"+s+"」を削除します。\n\rいったん削除すると取り消せません。\n\rよろしいですか？");
	return is_ok;
}
//------------------------------------------------------//
function confirm_destsite_del(s,f){
	if(f){
		is_ok=confirm("更新情報登録先サイト「"+s+"」を設定から削除します。\n\rよろしいですか？");
	}else{
		is_ok=confirm("更新情報登録先サイト「"+s+"」を設定から削除します。\n\r個別設定なども一緒に削除されます。\n\rよろしいですか？");
	}

	return is_ok;
}
//------------------------------------------------------//





/*
			if(){e.setAttribute("src",u);}
			else                {e.setAttribute("src",root+"/_no.gif");}


			if(e.tagName=="SPAN"){
				var n=document.createElement("img");
				n.setAttribute("src",u);
				n.setAttribute("width",ww);
				n.setAttribute("height",hh);
				n.setAttribute("id",e.id);
				//e.parentNode.replaceChild(n,e);
			}


//------------------------------------------------------//
function check_request(e,u,no){
	var xmlhttp=createXmlHttp();

	if(xmlhttp){
		xmlhttp.onreadystatechange = function() {
			if(xmlhttp.readyState==4 && xmlhttp.status==200){
				e.setAttribute("src",u);
			}else{
				e.setAttribute("src",no);
			}
		}

		xmlhttp.open("GET",u,true);
		xmlhttp.setRequestHeader("Content-Type" , "application/x-www-form-urlencoded");
		xmlhttp.send(null);
	}
}
//------------------------------------------------------//
function createXmlHttp(){
	if (window.XMLHttpRequest) {             // Mozilla, Firefox, Safari, IE7
		return new XMLHttpRequest();
	} else if (window.ActiveXObject) {       // IE5, IE6
		try {
			return new ActiveXObject("Msxml2.XMLHTTP");    // MSXML3
		} catch(e) {
			return new ActiveXObject("Microsoft.XMLHTTP"); // MSXML2まで
		}
	} else {
		return null;
	}
}
//------------------------------------------------------//
//------------------------------------------------------//
*/
