var snowflakes = 200;
var snowflakeslow = 50;
var level = 2;
var wind = 1;
var w3c = (document.getElementById)?true:false;
var ns4 = (document.layers)?true:false;
var ie4 = (document.all && !w3c)?true:false;
var ie5 = (document.all && w3c)?true:false;
var ns6 = (w3c && navigator.appName.indexOf("Netscape") >= 0)?true:false;
var t = '';
var w_x,w_y;
var dropstart = 1;
var snowmode = 0;
var snow = new Array();
var spacefromrightborder = 140;
for(i = 1;i <= snowflakes;i++)t += "<div id='snow" + i + "' class='snow'>&nbsp;&nbsp;</div>";
t += "<div id='snowswitch' style='position: absolute; top: 29px; left: -300'><img src='images/SNOW_OFF.GIF' onclick='snow_change(this);'></div>";

//var btn = new Array("ATOMFEED","BLOG","FLICKR","GEO","MOBILE","OPML","PDA","PODCAST","RSS","SYNDICATION","TRACKBACK",
//		         "UMTS","XML","FFVII","LOOOL","RFC2616","WOW",
//		         "AJAX","HDMI","HDTV","MBUDGET","MP3","WSXGA");
//for(i = 1;i <= snowflakes;i++)t += "<div id='snow" + i + "' class='snow'><img src=\"images/COOLBTN/"+btn[Math.floor(Math.random()*btn.length)]+".PNG\"></div>";

//if (Math.random() < 0.5) { t += "<div id='snowswitch' style='position: absolute; top: 29px; left: -400; border: 3px ridge #0088AA;'><EMBED src=\"http://www.nintendo.co.jp/mario20th/download/banner/chara.swf\" quality=high bgcolor=#CCCCCC swLiveConnect=FALSE WIDTH=\"150\" HEIGHT=\"60\" NAME=\"movie\" ALIGN=\"\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"/></div>"; }
//else { t += "<div id='snowswitch' style='position: absolute; top: 29px; left: -400; border: 3px ridge #AA8855;'><EMBED src=\"http://www.nintendo.co.jp/mario20th/download/banner/coin.swf\" quality=high bgcolor=#CCCCCC swLiveConnect=FALSE WIDTH=\"150\" HEIGHT=\"60\" NAME=\"movie\" ALIGN=\"\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"/></div>"; }
//spacefromrightborder = 180;

//t += "<div id='megain' style='position: fixed; top: 50px; left: 50;' onclick=\"var mega = (ns4)?document.layers['megain']:(ie4)?document.all['megain']:document.getElementById('megain'); mega.style.display = 'none';\"><img src=\"images/GOEISTIN.PNG\" width=\"1024\" height=\"768\"></div>";
//spacefromrightborder = 1080;
//snowflakes = 0;

document.write(t);
function snow_change(imgobj)
{
	var imgpref = imgobj.src.substring(0,imgobj.src.lastIndexOf("_")+1);
	if      (snowmode == 0) { imgobj.src = imgpref+"LOW.GIF"; snowmode = 1; }
	else if (snowmode == 1) { imgobj.src = imgpref+"HIGH.GIF"; snowmode = 2; }
	else if (snowmode == 2) { imgobj.src = imgpref+"OFF.GIF"; snowmode = 0; }
	clear();
}
function getstartpos(obj)
{
    obj.size = 1;
    //obj.size = Math.floor(Math.random() * 3) + 1;
    obj.ystep = obj.size * level;
    obj.xstep = (Math.abs(wind) / 2) + (Math.floor(Math.random() * 3) / 2); 
    //if (ns4)obj.clip.width = obj.clip.height = obj.size;
    //else obj.style.width = obj.style.height = obj.size;
    moveidto(obj, Math.floor(Math.random() * (w_x-20)) - obj.size - 60, 0);
} 
function movedrop()
{
	var numflakes = 0;
	if (snowmode == 0) return; 
	if (snowmode == 1) numflakes = snowflakeslow;
	if (snowmode == 2) numflakes = snowflakes;
	var pxo = (ie4 || ie5)?document.body.scrollLeft:pageXOffset;
	var pyo = (ie4 || ie5)?document.body.scrollTop:pageYOffset;
	for(i = dropstart;i <= numflakes;i+=3)
	{
		var l = (ns4)?snow[i].left:parseInt(snow[i].style.left);
		var t = (ns4)?snow[i].top:parseInt(snow[i].style.top);
		if ((t + snow[i].ystep + snow[i].size >= w_y + pyo - 20) || (l <= pxo)) getstartpos(snow[i]);
		else moveidto(snow[i], l - snow[i].xstep, t + snow[i].ystep);
	} 
	dropstart++;
	if (dropstart > 3) dropstart = 1;
} 
function getwindowdims()
{
    w_x = (ie4 || ie5)? document.body.clientWidth:window.innerWidth;
    w_y = (ie4 || ie5)? document.body.clientHeight:window.innerHeight;
} 
function moveidto(id, x, y)
{
    if (ns4)id.moveTo(x, y);
    else
    {
        id.style.left = x; // + 'px';
        id.style.top = y; // + 'px';
    } 
}
function clear()
{
    for(i = 1;i <= snowflakes;i++)
    {
      if ((snowmode == 0) || ((snowmode == 1) && (i > snowflakeslow)))
      {
            moveidto(snow[i], Math.floor(Math.random() * (w_x-20)) - 60, -50);
      }
      if (((snowmode == 1) && (i <= snowflakeslow)) || ( (snowmode == 2) && (i > snowflakeslow) ) )
      {
        getstartpos(snow[i]);
        moveidto(snow[i], Math.floor(Math.random() * (w_x-20)) - 60, Math.floor(Math.random() * (w_y-20)));
      }
    } 
}

window.onresize = function()
{
    if (ns4)setTimeout('history.go(0)', 400);
    else getwindowdims();
    if (!ns4)
	{
		var sswitch = (ns4)?document.layers['snowswitch']:(ie4)?document.all['snowswitch']:document.getElementById('snowswitch');
		sswitch.style.left = w_x-spacefromrightborder;
	}
} 
window.onload = function()
{
    level = Math.max(Math.min(5, level), 1)
    getwindowdims();
    for(i = 1;i <= snowflakes;i++)
    {
        snow[i] = (ns4)?document.layers['snow' + i]:(ie4)?document.all['snow' + i]:document.getElementById('snow' + i);
	}
	var sswitch = (ns4)?document.layers['snowswitch']:(ie4)?document.all['snowswitch']:document.getElementById('snowswitch');
	sswitch.style.left = w_x-spacefromrightborder;
	clear();
    setInterval('movedrop()', 50);
} 