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 incSwf(fName,w,h,bgColor) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + w + '" height="' + h +' ">\n');
	document.write('<param name="allowScriptAccess" value="sameDomain" />\n');
	document.write('<param name="movie" value="' + fName + '" />\n');
	document.write('<param name="quality" value="high" />\n');
	document.write('<param name="wmode" value="opaque" />\n');
	document.write('<param name="loop" value="false" />\n');
	document.write('<param name="menu" value="false" />\n');
	document.write('<param name="bgColor" value="'+ bgColor +'" />\n');
	document.write('<embed src="' + fName + '" width="' + w + '" height="' + h + '" loop="False" wmode="opaque" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" />\n');
	document.write('</embed>\n');
	document.write('</object>\n');
}

function NowYear() {
   var now = new Date();
   var year = now.getFullYear();
   document.write(year);
}

function openWin(){
  newWin = window.open('dd_limited.html','tsubasa','width=500,height=510,scrollbars=yes,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function openWin2(){
  newWin = window.open('dd_life2.html','life2','width=670,height=400,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function openWin3(){
  newWin = window.open('dd_life.html','life','width=670,height=400,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function openWin4(){
  newWin = window.open('dd_bestfriend.html','friend','width=670,height=400,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function openWin5(){
  newWin = window.open('dd_haikei.html','haikei','width=670,height=400,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function openWin6(){
  newWin = window.open('dd_jonetsu.html','jonetsu','width=670,height=400,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function openWin7(){
  newWin = window.open('dd_ichigo.html','ichigo','width=670,height=400,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function openWin8(){
  newWin = window.open('dd_shunka.html','shunka','width=670,height=400,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}


function Live(){
  newWin = window.open('img/report/thank01.html','thank01','width=600,height=450,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function Live2(){
  newWin = window.open('img/report/thank02.html','thank02','width=600,height=450,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function Live3(){
  newWin = window.open('img/report/thank03.html','thank03','width=600,height=450,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function Live4(){
  newWin = window.open('img/report/thank04.html','thank04','width=600,height=450,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function Live5(){
  newWin = window.open('img/report/thank05.html','thank05','width=600,height=450,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function Live6(){
  newWin = window.open('img/report/thank06.html','thank06','width=600,height=450,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function Live7(){
  newWin = window.open('img/report/thank07.html','thank07','width=600,height=450,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function Live8(){
  newWin = window.open('img/report/thank08.html','thank08','width=600,height=450,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function Live9(){
  newWin = window.open('img/report/thank09.html','thank09','width=600,height=450,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function Live10(){
  newWin = window.open('img/report/thank10.html','thank10','width=600,height=450,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function Live11(){
  newWin = window.open('img/report/thank11.html','thank11','width=600,height=450,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function Live12(){
  newWin = window.open('img/report/thank12.html','thank12','width=600,height=450,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function Live13(){
  newWin = window.open('img/report/thank13.html','thank13','width=600,height=450,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function Live14(){
  newWin = window.open('img/report/thank14.html','thank14','width=600,height=450,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function Live15(){
  newWin = window.open('img/report/thank15.html','thank15','width=600,height=450,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function Live16(){
  newWin = window.open('img/report/thank16.html','thank16','width=600,height=450,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function Live17(){
  newWin = window.open('img/report/thank17.html','thank17','width=600,height=450,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function Live18(){
  newWin = window.open('img/report/thank18.html','thank18','width=600,height=450,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function Live19(){
  newWin = window.open('img/report/thank19.html','thank19','width=600,height=450,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}
function Live20(){
  newWin = window.open('img/report/thank20.html','thank20','width=600,height=450,scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}

function Lyric1(){
  newWin = window.open('lyrics/tsubasa.html','smile','width=450,height=600,scrollbars=yes,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}

function Lyric2(){
  newWin = window.open('lyrics/smile.html','smile','width=450,height=600,scrollbars=yes,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}

function Lyric3(){
  newWin = window.open('lyrics/rainbow.html','smile','width=450,height=650,scrollbars=yes,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}

function Lyric4(){
  newWin = window.open('lyrics/nightrain.html','smile','width=450,height=650,scrollbars=yes,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}

function Lyric5(){
  newWin = window.open('lyrics/circlebet.html','smile','width=450,height=700,scrollbars=yes,status=no,toolbar=no,location=no,menubar=no,resizable=no');
  newWin.focus();
}


// main function to handle the mouse events //
function ddMenu(f,b){var a=document.getElementById(f+"-ddheader");var e=document.getElementById(f+"-ddcontent");clearInterval(e.timer);if(b==1){clearTimeout(a.timer);if(e.maxh&&e.maxh<=e.offsetHeight){return}else{if(!e.maxh){e.style.display="block";e.style.height="auto";e.maxh=e.offsetHeight;e.style.height="0px"}}e.timer=setInterval(function(){ddSlide(e,1)},DDTIMER)}else{a.timer=setTimeout(function(){ddCollapse(e)},50)}};function ddCollapse(c){c.timer=setInterval(function(){ddSlide(c,-1)},DDTIMER)}function cancelHide(id){var h=document.getElementById(id+'-ddheader');var c=document.getElementById(id+'-ddcontent');clearTimeout(h.timer);clearInterval(c.timer);if(c.offsetHeight<c.maxh){c.timer=setInterval(function(){ddSlide(c,1)},DDTIMER)}}function ddSlide(a,c){var b=a.offsetHeight;var d;if(c==1){d=(Math.round((a.maxh-b)/DDSPEED))}else{d=(Math.round(b/DDSPEED))}if(d<=1&&c==1){d=1}a.style.height=b+(d*c)+'px';a.style.opacity=b/a.maxh;a.style.filter='alpha(opacity='+(b*100/a.maxh)+')';if((b<2&&c!=1)||(b>(a.maxh-2)&&c==1)){clearInterval(a.timer)}}(function(){var rolloverImages = [];function setRollOver2(){if(!document.images){return;}var imgs = document.images;var insert = [];for(var i=0,len=imgs.length; i<len; i++){var splitname = imgs[i].src.split('_rollout.');if(splitname[1]){var rolloverImg = document.createElement('img');rolloverImages.push(rolloverImg);rolloverImg.src = splitname[0]+'_rollover.'+splitname[1];var alpha = 0;rolloverImg.currentAlpha = alpha;rolloverImg.style.opacity = alpha/100;rolloverImg.style.filter = 'alpha(opacity='+alpha+')';rolloverImg.style.position = 'absolute';addEvent(rolloverImg,'mouseover',function(){setFader(this,100);});addEvent(rolloverImg,'mouseout',function(){setFader(this,0);});insert[insert.length] = {position:imgs[i],element:rolloverImg};}}for(i=0,len=insert.length;i<len;i++){var parent=insert[i].position.parentNode;parent.insertBefore(insert[i].element,insert[i].position)}addEvent(window,'beforeunload', clearRollover);}function setFader(a,b){a.targetAlpha=b;if(a.currentAlpha==undefined){a.currentAlpha=100}if(a.currentAlpha==a.targetAlpha){return}if(!a.fading){if(!a.fader){a.fader=fader}a.fading=true;a.fader()}}function fader(){this.currentAlpha+=(this.targetAlpha-this.currentAlpha)*0.2;if(Math.abs(this.currentAlpha-this.targetAlpha)<1){this.currentAlpha=this.targetAlpha;this.fading=false}var a=parseInt(this.currentAlpha);this.style.opacity=a/100;this.style.filter='alpha(opacity='+a+')';if(this.fading){var b=this;setTimeout(function(){fader.apply(b)},30)}}function clearRollover(){for(var a=0,b=rolloverImages.length;a<b;a++){var c=rolloverImages[a];c.style.opacity=0;c.style.filter='alpha(opacity=0)'}}function addEvent(a,b,c){if(a.addEventListener){a.addEventListener(b,c,false)}else if(window.attachEvent){a.attachEvent('on'+b,function(){c.apply(a)})}}addEvent(window,'load',setRollOver2);})();

/* Scroll */

//Browser Property
function getBrowserInfo(){ 
	this.majorver = parseInt(navigator.appVersion) ;
	this.agent = navigator.userAgent.toLowerCase() ;
	this.platform = navigator.platform.toLowerCase() ;
	this.mac = ( this.platform.indexOf('mac') != -1 ) ? 1 : 0 ;
	this.win = ( this.platform.indexOf('win') != -1 ) ? 1 : 0 ;

	this.dom1 = ( document.getElementById ) ? 1 : 0 ;
	this.dom2event = ( document.addEventListener && document.removeEventListener ) ? 1 : 0 ;

	this.opera = ( ( this.agent.indexOf('opera') != -1 ) || window.opera ) ? 1 : 0 ; ;
	if ( this.opera ) {
		this.opera5 = this.agent.indexOf('opera 5') ? 1 : 0 ;
		this.opera6 = this.agent.indexOf('opera 6') ? 1 : 0 ;
		this.opera7 = this.agent.indexOf('opera 7') ? 1 : 0 ;
		return this ;
	}
	this.ie = ( ( this.agent.indexOf('msie') != -1 ) && !this.opera ) ? 1 : 0 ;;
	if ( this.ie ) {
		this.ie4 = ( ( this.agent.indexOf('msie 4') != -1 ) && !this.dom1 ) ? 1 :0 ;
		this.ie5 = ( ( this.agent.indexOf('msie 5') != -1 ) && this.dom1 ) ? 1 : 0 ;
		this.ie55 = ( this.ie5 && window.createPopup ) ? 1 : 0 ;
		this.ie6 = ( ( this.agent.indexOf('msie 6') != -1 ) && this.dom1 ) ? 1 : 0 ;
		this.ie6s = ( this.ie6 && ( document.compatMode == "CSS1Compat" ) ) ? 1 : 0 ;
		this.ie4up = ( this.majorver >= 4 ) ? 1 : 0 ;
		this.ie5up = ( ( this.majorver >= 4 ) && !this.ie4 ) ? 1 : 0 ;
		this.ie55up = ( ( this.majorver >= 4 ) && !this.ie4 && !this.ie5 ) ? 1 : 0 ;
		this.ie6up = ( ( this.majorver >= 4 ) && !this.ie4 && !this.ie55 ) ? 1 : 0 ;
		return this ;
	}
	this.net = 	( ( ( this.agent.indexOf('netscape') != -1 ) || 
		( this.agent.indexOf('mozilla') != -1 ) || ( this.agent.indexOf('gecko/') != -1 ) ) && !this.opera ) ? 1 : 0 ;
	if ( this.net ) {
		this.net4 = ( document.layers && !this.dom1 ) ? 1 : 0 ;
		this.net6 = ( ( this.majorver >= 5 ) && this.dom2event ) ? 1 : 0 ;
		this.net4up = ( this.majorver >= 4 ) ? 1 : 0 ;
		this.net6up = ( ( this.majorver >= 5 ) && !this.net4 ) ? 1 : 0 ;
		return this ;
	}
	return this ;
}

	var _bw = new getBrowserInfo;

function getScrollY() {
	if( _bw.net4up || _bw.opera ) { return window.pageYOffset }
	if( _bw.ie6s ) { return document.documentElement.scrollTop }
	if( _bw.ie4up ) { return document.body.scrollTop }
	return 0;
}


//UpScroll処理

var timeID01;
var position;
var upmemory;
var nowposition01;

function Upscroll_Y(){
	position -= position * 0.2;
	nowposition01 = getScrollY();
	if( position <= 1 || nowposition01 > upmemory){
		clearTimeout(timeID01);
		if(nowposition01 > upmemory){
			window.scrollTo(0,nowposition01);
		}else{
			window.scrollTo(0,0);
		}
	}else{
		window.scrollTo(0,position);
		upmemory = Math.ceil(position);
		time_SCLL01();
	}
}

function time_SCLL01() {
	timeID01=setTimeout("Upscroll_Y()",16);
}

function SCLL() {
	upmemory = getScrollY();
	position = getScrollY();
	time_SCLL01();
}


function loaded(){
// passage time(単位:H)
var pass1 = 336;

var content1 = '<img src="http://www.karutetto.com/img/new.gif" alt="NEW" width="26" height="12" />';
var content2 = '<img src="http://www.karutetto.com/img/new2.gif" />';

var currentDate = new Date();
var spans = document.getElementsByTagName('span');
for (i = 0; i < spans.length; i++) {

	if(spans[i].getAttribute('class') == 'new2' ||
       spans[i].getAttribute('className') == 'new2') {
        time = spans[i].childNodes[0].nodeValue.split(":");
        var entryDate = new Date(time[0], time[1]-1, time[2], time[3], time[4], time[5]); 
        var now = (entryDate.getTime() - currentDate.getTime())/(60*60*1000); 
        now = Math.ceil(now);
        if(-now <= pass1){
            spans[i].innerHTML = content1;
            spans[i].style.display = 'inline';
        }
		else {
			spans[i].innerHTML = content2;
            spans[i].style.display = 'inline';
        }
    }
}
}

// 一定期間Newマーク表示
function newUp(y, m, d, c) {
  delDay = 30; // 何日後に削除するか
  oldDay = new Date(y + "/" + m + "/" +d);
  newDay = new Date();
  d =(newDay - oldDay) / (1000 * 24 * 3600);
  if(d <= delDay) {
    // Newマーク
    if(c == "new") document.write('<img src="http://www.karutetto.com/img/new.gif" alt="NEW" width="26" height="12" />');
  }
}