cookiecheck = getcookie('infocookie')
if (cookiecheck != 'close'){
	window.onload = initbox;
}

var ie=document.all
var dom=document.getElementById
var ns4=document.layers
var ns6=document.getElementById&&!document.all
var calunits=document.layers? "" : "px"

var bouncelimit=32 //(must be divisible by 8)
var topoffset=15//上のオフセット
var dropinspeed=100 //スピード
var direction="up"
var lpos

function initbox(){
if (!dom&&!ie&&!ns4)
return
crossobj=(dom)?document.getElementById("dropin").style : ie? document.all.dropin : document.dropin
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
crossobj.top=scroll_top-250+calunits
crossobj.visibility=(dom||ie)? "visible" : "show"
dropstart=setInterval("dropin()",dropinspeed)
}

function dropin(){
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
if (parseInt(crossobj.top)<topoffset+scroll_top)
crossobj.top=parseInt(crossobj.top)+topoffset+calunits
else{
clearInterval(dropstart)
bouncestart=setInterval("bouncein()",50)
}
}

function bouncein(){
crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits
if (bouncelimit<0)
bouncelimit+=8
bouncelimit=bouncelimit*-1
if (bouncelimit==0){
clearInterval(bouncestart)
}
}

function dismissbox(){
if (window.bouncestart) clearInterval(bouncestart)
crossobj.visibility="hidden"
}

function truebody(){
return (document.compatMode!="BackCompat")? document.documentElement : document.body
}

function getcookie(CookieName){ 
	CookieName += '=';
	cookiestr = document.cookie + ';';
	checkstart = cookiestr.indexOf(CookieName)
	if (document.cookie.length>0) {
    	if (checkstart != -1){
			checkend = cookiestr.indexOf(";",checkstart);
			return unescape(cookiestr.substring(checkstart + CookieName.length , checkend));
		}
	}
	return false;  
}

function insertCookie( cnstr )
{
	document.cookie = cnstr + '=close;expires=Thu, 1-Jan-2020 00:00:00 GMT';

}

function delay(x)
{
	var d=new Date()
	d=d.getSeconds()+x
	if (d>=60) d=d-60
	while (true)
	{
		var d1=new Date()
		if(d==d1.getSeconds())
			break;
	}
}
function SetCooKie(name,value)
{
	var argv=SetCooKie.arguments;
	var argc=SetCooKie.arguments.length
	var expires=(argc>2) ? argv[2] : null
	var path=(argc>3) ? argv[3] : null
	var domain=(argc>4) ? argv[4] : null
	var secure=(argc>5) ? argv[5] : false
	document.cookie=name + "=" +escape(value) + 
	((expires==null) ? "" :( ";expires=" + expires.toGMTString())) +
	((path==null) ? "" :( ";path=" + path)) +
	((domain==null) ? "" :( ";domain=" + domain)) +
	((secure==true) ? "; secure " : "")
}
function GetCookie(name)
{
	var arg=name + "=" 
	var alen=arg.length
	var clen=document.cookie.length
	var i=0
	while(i<clen)
	{
		var j=i+alen
		if (document.cookie.substring(i,j)==arg)
		{
			//getCookieVal(j)
			return true;
		}
		i=document.cookie.indexOf(" ", i) + i;
		if ( i==0) break;
	}
	return false;
}
function getCookieVal(offset)
{
	var endstr=document.cookie.indexOf(";",offset)
	if(endstr==-1)
	{
		endstr=document.cookie.length;
	}
	return unescape(document.cookie.substring(offset,endstr));

}
function Delaynew()
{
	if (!ns4)
	{	
		document.getElementById("dropin").style.visibility="visible";

	}
	else
		document.dropin.visibility="show";

	return;
}


function DropIn(main_bgcolor,main_texttype,main_textcolor,textbar,height,width,top,left,bordercolor,borderstyle,borderwidth,sec,showeverytime)
{
	lpos = top
	ans="no"
	//delay(sec)
	var chkshow=false;
	if (!showeverytime)
	{
		chkshow=GetCookie('popDropin');
		if (chkshow)
		{
			SetCooKie('popDropin','added')
		}
	}

	if(!chkshow)
	{ 
		if (ns4)
		{
			templayer=document.layers[0]
			templayer.left=left
			templayer.top=top
			templayer.width=width
			templayer.height=height
		}
		else if (ns6)
		{
			document.getElementById("tbl").style.border = bordercolor+' '+borderwidth+'px '+borderstyle
			document.getElementById("dragtext").innerHTML=textbar

			document.getElementById("dropin").style.height=height +'px'
			document.getElementById("dropin").style.width =width +'px'
			document.getElementById("dropin").style.left =left +'px'
			document.getElementById("dropin").style.top =top +'px'
			document.getElementById("dragtext").style.backgroundColor=main_bgcolor
			document.getElementById("dragtext").style.color = main_textcolor
			document.getElementById("dragtext").style.fontFamily = main_texttype
		}
		else 
		{
			document.getElementById("tbl").style.border = bordercolor+' '+borderwidth+'px '+borderstyle
			document.getElementById("dragtext").innerHTML=textbar

			document.getElementById("dropin").style.height=height +'px'
			document.getElementById("dropin").style.width =width +'px'
			document.getElementById("dropin").style.left =left +'px'
			document.getElementById("dropin").style.top =top +'px'
			document.getElementById("dragtext").style.backgroundColor=main_bgcolor
			document.getElementById("dragtext").style.color = main_textcolor
			document.getElementById("dragtext").style.fontFamily = main_texttype
		}
		setTimeout("initbox()",(sec*1000));	
	}
}
//}


function Counter(){
	finTime = new Date(2008,3,4,0,0,0).getTime();	// 目標日
	nowTime = new Date();			// 現在の日時
	var outw = "";
	var temp = 0;
	var temp2 = 0;

	var s	=	1000;
	var m	=	1000 * 60;
	var h	=	1000 * 60 * 60;
	var d	=	1000 * 60 * 60 * 24;


	timew = Math.floor(finTime-nowTime.getTime());

	if (timew>0){

		/*** ミリ秒の表示 ***/
		temp = (timew % 1000); 		/* msec */
		outw = ((temp <100)&&(temp>=10) ? "0" : "")+((temp <10)&&(temp > 0) ? "00" : "")+temp+outw;

		/*** 秒の表示 ***/
		temp2 = Math.floor(timew/s);
		temp =(temp2 % 60); 		/* sec */
		outw = ((temp <10)&&(temp>=0) ? "0" : "")+temp+"秒 "+outw;

		/*** 分の表示 ***/
		temp2 = Math.floor(timew /m);
		temp = (temp2 % 60); 		/* min */ 
		outw = ((temp<10)&&(temp>=0) ? "0" :"")+temp+"分 "+outw;

		/*** 時間の表示 ***/
		temp2 = Math.floor(timew/h);
		temp = (temp2 % 24); 		/* hour */
		outw = ((temp<10)&&(temp>=0) ? "0" : "")+temp+"時間 "+outw;

		/*** 日の表示 ***/
		temp = Math.floor(timew/d);
		outw = " "+temp+"日 "+outw;

		document.cd1.disp.value=" ロスタイム終了まで、あと"+outw;
		document.cd2.disp.value=" ロスタイム終了まで、あと"+outw;
		document.cd3.disp.value=" ロスタイム終了まで、あと"+outw;
		document.cd4.disp.value=" ロスタイム終了まで、あと"+outw;

		temp = setTimeout("Counter()",1); 		// 1ミリ秒後に実行
	}
	else{		//期日を過ぎた場合の表示内容
		document.cd1.disp.value="　販売は終了しました。ありがとうございました。";
		document.cd2.disp.value="　販売は終了しました。ありがとうございました。";
		document.cd3.disp.value="　販売は終了しました。ありがとうございました。";
		document.cd4.disp.value="　販売は終了しました。ありがとうございました。";
	}
}

