function form_send(url,id){
	new Ajax.Updater(
		id,
		url,{
			method:"post",
			postBody:Form.serialize(id+'_form')
		}
	);
}
function form_back(url,id){
	$(id+'_form').mode.value='back';
	new Ajax.Updater(
		id,
		url,{
			method:"",
			postBody:Form.serialize(id+'_form')
		}
	);
}
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 onetime_script(page_id,jump,hour,type){
	page = getCookie("page"+page_id);
	if(page != ''){
		if(type==1){
			hour=parseInt(hour);
			time=parseInt(getCookie("time"+page_id));
			dd = new Date();
			now=dd.getTime();
			limit=Math.floor(time+hour*3600000);
			if(now-limit > 0){
				location.href=jump;
				return;
			}
			else{
				return(limit);
			}
		}
		else if(type==2){
			dd = new Date();
			now=dd.getTime();
			y=hour.substr(0,4);
			m=hour.substr(5,2);
			d=hour.substr(8,2);
			h=hour.substr(11,2);
			mi=hour.substr(14,2);
			dd2 = new Date(y,m-1,d,h,mi,0);
			limit=dd2.getTime();
			if(now > limit){
				location.href=jump;
				return;
			}
			else{
				return(limit);
			}
		}
		else{
			hour=parseInt(hour);
			if(page >= hour){
				location.href=jump;
				return;
			}
			else{
				page=parseInt(page)+1;
				setCookie("page"+page_id,page);
				return;
			}
		}
	}
	else{
		dd = new Date();
		time=dd.getTime();
		setCookie("page"+page_id,1);
		setCookie("time"+page_id,time);
		return;
	}
	location.href=jump;
}

function countdown(id,type) {
	today = new Date()
	myMsec= limit-today.getTime();
	time0 = Math.floor(myMsec/(1000*60*60*24));
	myMsec -= (time0*(1000*60*60*24));
	time1 = Math.floor(myMsec/(1000*60*60));
	myMsec -= (time1*(1000*60*60));
	time2 = Math.floor(myMsec/(1000*60));
	myMsec -= (time2*(1000*60));
	time3 = Math.floor(myMsec/1000);
	myMsec -= (time3*(1000));
	time4 = Math.floor(myMsec/10);

	if(time2<10){time2='0'+time2;}
	if(time3<10){time3='0'+time3;}
	if(time4<10){time4='0'+time4;}

	if((limit - today) > 0){
		hyouji=""+time1+"時間 "+time2+"分 ";
		if(time0 > 0){
			hyouji=""+time0+"日 "+hyouji;
		}
		if(type<=1){
			hyouji=hyouji+time3+"秒 ";
		}
		if(type==0){
			hyouji=hyouji+time4;
		}
		$('countdown_area'+id).innerHTML = hyouji;
	}
	else{
		location.reload(true);
	}
	tid = setTimeout('countdown('+id+','+type+')', 10);
}
function firsttime(id,page_id){
	time=getCookie("time"+page_id);
	dd=new Date();
	dd.setTime(time);

	y=dd.getYear();
	m=dd.getMonth()+1;
	d=dd.getDate();
	h=dd.getHours();
	if(h < 10){h='0'+h;}
	i=dd.getMinutes();
	if(i < 10){i='0'+i;}

	hyouji=''+y+'年 '+m+'月 '+d+'日 '+h+'時 '+i+'分 ';
	$('firsttime_area'+id).innerHTML = hyouji;
}
function limittime(id,hour){
	y=hour.substr(0,4);
	m=hour.substr(5,2);
	d=hour.substr(8,2);
	h=hour.substr(11,2);
	mi=hour.substr(14,2);
	hyouji=''+y+'年 '+m+'月 '+d+'日 '+h+'時 '+mi+'分 ';
	$('limittime_area'+id).innerHTML = hyouji;
}


function splitrun_script(list){
	l=new Array(5);
	l=list.split(',');
	rnd=Math.floor(Math.random()*100);
	t=0;
	for(i=0;i<5;i++){
		pr=l[i].split(':');
		t+=parseInt(pr[1]);
		if(rnd <= t){
			location.href=pr[0];
			return;
		}
		if(pr[0] != ''){pr_last=pr[0];}
	}
	location.href=pr_last;
	return;
}
function preload(id){
	filename=id.src;
	filename=filename.replace('\.gif','_.gif');
	filename=filename.replace('\.jpg','_.jpg');
	document.primg=new Image;
	document.primg.src=filename;
}
function rollover(id){
	filename=id.src;
	filename=filename.replace('\.gif','_.gif');
	filename=filename.replace('\.jpg','_.jpg');
	id.src=filename;
}
function rollover_out(id){
	filename=id.src;
	filename=filename.replace('_\.gif','.gif');
	filename=filename.replace('_\.jpg','.jpg');
	id.src=filename;
}

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';
	$$('body').each(function(ele){body_size=ele.getDimensions();});
	body_height=Math.max(body_size.height,1000);
	body_width=body_size.width+50;
	$(area_name).style.display='block';
}
