function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function load_up(){
	$('uv_layer').style.display='none';
	$('load_layer').style.display='none';
}

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){
	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=document.documentElement.scrollTop+100;
	$(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=body_height+'px';
	$('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 bro_ch(br){
	
	
	if(br=='IE8'){
		text='このシステムは、Internet Explorer 8に完全対応できていません。<br />申し訳ございませんが、「互換表示」でご利用になられますよう、よろしくお願いいたします。<br /><br />Internet Explorer 8でご利用になる場合、アドレスバーの右側のアイコン「互換表示」をクリックしてください。<img src="image/ie8_gokan.gif" />';
	}
	else if(br=='FF'){
		text='このシステムは、FireFoxに完全対応できていません。<br />申し訳ございませんが、インターネットエクスプローラ等でご利用いただくか<br />アドオン「IE Tab」をインストールしてご利用ください。<br /><br />詳細は、<a href="http://www.be-cms.com/help/11arufa-goriyoukanky.html#ap_503">こちら</a>をご覧ください。';
	}
	else if(br=='other'){
		text='ご利用いただいているブラウザは、推奨ブラウザではありません。<br /><br />不具合などございましたら、<a href="message.php">サポート掲示板</a>よりお問い合わせください。<br /><br /><div align="center"><a href="javascript:popup_close(\'help_window\')"><img src="image/ok.gif" border="0" alt="ok"/></a></div>';
	}
	
	$('help_window').innerHTML='<div class="dark_cell_help"><div style="float:right"></div><strong>ブラウザをご確認ください。</strong></div><div class="help_window_body">'+text+'<br /><br /></div>';
	popup_center('help_window');

}