function load_up(i){
	$('uv_layer').style.display='none';
	$('load_layer').style.display='none';
	if(i!=''){
		popup_center(i);
	}
}

function open_help(help_id){
	if(document.all){
		width=document.body.clientWidth;
	}else if(document.layers){
		width=innerWidth;
	}else{
		width=800;
	}
	document.all.help_window.style.left=(width-600)/2;
	document.all.help_window.style.top=document.documentElement.scrollTop +200;
	rnd=Math.random();
	new Ajax.Updater('help_window','help.php?help=1&help_id='+help_id+'&'+rnd,{method:'get'});
}
function help_window_open(){
	$$('select').each(function(ele){ele.style.display='none';});
	document.all.help_window.style.display='block';
}
function close_help(){
	$$('select').each(function(ele){ele.style.display='inline';});
	document.all.help_window.style.display='none';
}
function preview_window_open(user_id,koumoku_id){
	x=100;
	y=window.event.clientY + document.documentElement.scrollTop - 20;
	var win=new Window("preview_win",{
		url:"../preview/"+user_id+"/?parts_id=999&koumoku_id="+koumoku_id,
		className:"bluelighting",
		left:x,top:y,
		width:800,height:600
	});
	win.setDestroyOnClose();
	win.show();
}

function open_color_picker(target){
	$$('select').each(function(ele){ele.style.display='none';});
	document.all.color_picker_area.style.left=window.event.clientX + document.documentElement.scrollLeft - 100;
	document.all.color_picker_area.style.top=window.event.clientY + document.documentElement.scrollTop - 150;
	document.all.color_picker_area.style.display="block";
	start_color=document.getElementById(target).value;
	start_color=start_color.replace('#','');
	if(start_color==''){start_color='000000';}
	document.getElementById("color_target").value=target;
	document.getElementById("cp1_BrightnessRadio").click();
	document.getElementById("cp1_Hex").value=start_color;
}
function input_color_hex(){
	target=$("color_target").value;
	$(target).value='#'+$("cp1_Hex").value;
	$(target+'_icon').style.background='#'+$("cp1_Hex").value;
}
function close_color_picker(){
	$$('select').each(function(ele){ele.style.display='inline';});
	$('color_picker_area').style.display='none';
}
function icon_change(id){
	color=document.getElementById(id).value;
	if(color==''){
		document.getElementById(id+'_icon').style.background='url(./image/color_non.gif)';
	}
	else{
		document.getElementById(id+'_icon').style.background=color;
	}
}
function kensaku(reload,form_id,url){
	open_kensaku_chu();
	new Ajax.Updater(
		reload,
		url,{
			method:"post",
			postBody:Form.serialize(form_id)
		}
	);
}
function open_kensaku_chu(){
	$('load_layer').innerHTML='検索中です。しばらくお待ちください。<br /><br /><img src="image/load_bar.gif" />';
	$('load_layer').style.top=document.documentElement.scrollTop+300;
	$$('select').each(function(ele){ele.style.display='none';});
	$('load_layer').style.display='block';
}
function close_load_layer(){
	$$('select').each(function(ele){ele.style.display='inline';});
	$('load_layer').style.display='none';
}

function mouse_y(id){
	y=window.event.clientY+document.documentElement.scrollTop;
	if(id != ''){
		y=y-parseInt($(id).style.top);
	}
	return y;
}

function mouse_x(id){
	x=window.event.clientX+document.documentElement.scrollLeft;
	if(id != ''){
		x=x-parseInt($(id).style.left);
	}
	return x;
}
function path_copy(){
	path=$('file_path').value;
	clipboardData.setData("Text", path);
}
function site_change(){
	location.href="./index.php?user_id="+$('site_list').value;
}
function popup_center(area_name){
	var scrollTop  = document.body.scrollTop  || document.documentElement.scrollTop;
	size=$(area_name).getDimensions();
	width=size.width;
	margin_left=parseInt(width/2)*(-1);
	$(area_name).style.margin='0px 0px 0px '+margin_left+'px';
	$(area_name).style.left='50%';
	$(area_name).style.top=(scrollTop+100)+'px';
	$(area_name).style.zIndex='2';
	$$('select').each(function(ele){ele.style.display='none';});
	$$('#'+area_name+' select').each(function(ele){ele.style.display='inline';});
	$$('body').each(function(ele){body_size=ele.getDimensions();});
	body_height=Math.max(body_size.height,1000);
	body_width=body_size.width+50;
	$('hantomei_layer').style.height='5000px';
	$('hantomei_layer').style.width=body_width+'px';
	$('hantomei_layer').style.display='block';
	$(area_name).style.display='block';
	
}
function popup_center2(area_name){
	size=$(area_name).getDimensions();
	width=size.width;
	margin_left=parseInt(width/2)*(-1);
	$(area_name).style.margin='0px 0px 0px '+margin_left+'px';
	$(area_name).style.left='50%';
	$(area_name).style.top=$(area_name).offsetTop+'px';
	$('hantomei_layer2').style.zIndex='3';
	$(area_name).style.zIndex='10';
	$$('select').each(function(ele){ele.style.display='none';});
	$$('#'+area_name+' select').each(function(ele){ele.style.display='inline';});
	if($('hantomei_layer').style.display=='block'){
		$('hantomei_layer2').style.display='block';
	}
	else{
		$$('body').each(function(ele){body_size=ele.getDimensions();});
		body_height=Math.max(body_size.height,1000);
		body_width=body_size.width+50;
		$('hantomei_layer2').style.height=body_height+'px';
		$('hantomei_layer2').style.width=body_width+'px';
		$('hantomei_layer2').style.display='block';
	}
	$(area_name).style.display='block';
}

function popup_close(area_name){
	$$('select').each(function(ele){ele.style.display='inline';});
	$(area_name).style.display='none';
	$('hantomei_layer').style.display='none';
}
function popup_close2(area_name){
	$$('select').each(function(ele){ele.style.display='inline';});
	$(area_name).style.display='none';
	$('hantomei_layer2').style.display='none';
}

function getCookie(key,tmp1,tmp2,xx1,xx2,xx3) {
    tmp1 = " " + document.cookie + ";";
    xx1 = xx2 = 0;
    len = tmp1.length;
    while (xx1 < len) {
        xx2 = tmp1.indexOf(";", xx1);
        tmp2 = tmp1.substring(xx1 + 1, xx2);
        xx3 = tmp2.indexOf("=");
        if (tmp2.substring(0, xx3) == key) {
            return(unescape(tmp2.substring(xx3 + 1, xx2 - xx1 - 1)));
        }
        xx1 = xx2 + 1;
    }
    return("");
}
function setCookie(key, val, tmp) {
    tmp = key + "=" + escape(val) + "; ";
    tmp += "expires=Tue, 31-Dec-2030 23:59:59; ";
    document.cookie = tmp;
}
function clearCookie(key) {
    document.cookie = key + "=" + "xx; expires=Tue, 1-Jan-1980 00:00:00;";
}
function url_kakunin(){
	url=$('top_url').value+$('page_url').value+'.'+$('html_kakucho').value;
	window.open(url, "kakunin",'');
}

function objFix_bot(){
	size=$(fbox_id).getDimensions();
	height=size.height;
	$(fbox_id).style.top = document.documentElement.scrollTop + document.documentElement.clientHeight - height +'px';
}
function objFix_mid(id){
	$(id).style.top = document.documentElement.scrollTop+ 100 +'px';
}
function date_in(id){
	new DatePicker({
		relative : id,
		language : "ja",
		zindex:10,
		disableFutureDate : true,
		dateFormat : [ ["yyyy", "mm", "dd"], "-" ],
		enableShowEffect : false,
		enableCloseEffect : false
	});
}
function prv_modechange(mode){
	if(mode=='preview'){
		$('preview_area').innerHTML=$('editmode_content').value;
		$('preview_area').style.display='';
		$('code_area').style.display='none';
		$('preview_link').className='preview_mode2';
		$('code_link').className='preview_mode';
	}
	else if(mode=='code'){
		$('preview_area').style.display='none';
		$('code_area').style.display='';
		$('preview_link').className='preview_mode';
		$('code_link').className='preview_mode2';
	}
}
function send_now(id,plug_id,data_id){
	$('mes_area').innerHTML='現在、投稿中です<br /><img src="image/ajax-loader.gif" />';
	popup_center('mes_window');
	new Ajax.Updater('mes_area','post_test.php',{method:"post",postBody:Form.serialize('edit_form')});
}
function pageback(i,j){
	switch(i){
		case 0:
			location.href="index2.php";
			break;
		case 1:
			location.href="blog_setting.php";
			break;
		case 2:
			location.href="kiji_setting2.php?set_id="+j+"#plug_in";
			break;
	}
}
function mes_hyouji2(mes){
	$('mes_area2').innerHTML=mes;
	$('mes_window2').style.display='block';
	setTimeout("mes_del2()", 5000);
}
function mes_del2(){
	$('mes_window2').style.display='none';
}
