// Snow Effect Javascript
// copyright 19th November 2004, 20th July 2006 by Stephen Chapman
// permission to use this Javascript on your web page is granted
// provided that all of the code in this script (including these
// comments) is used without any alteration
// you can change the number of snow flakes if you like

var num_flakes = 10;
var snowflakes = new Array("../../img/snowflake.gif", "../../img/snowflake2.gif", "../../img/snowflake3.gif", "../../img/snowflake4.gif");

// DOM test
var aDOM = 0, ieDOM = 0, nsDOM = 0; var stdDOM = document.getElementById;
if (stdDOM) aDOM = 1; else {ieDOM = document.all; if (ieDOM) aDOM = 1; else {
var nsDOM = ((navigator.appName.indexOf('Netscape') != -1)
&& (parseInt(navigator.appVersion) ==4)); if (nsDOM) aDOM = 1;}}
function findDOM(objectId, wS) {
if (stdDOM) return wS ? document.getElementById(objectId).style:
document.getElementById(objectId);
if (ieDOM) return wS ? document.all[objectId].style: document.all[objectId];
if (nsDOM) return document.layers[objectId];
}

// window size tests
function findLivePageWidth() {
	/*
	return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth :700;
	*/
	return 150;
}
function findLivePageHeight() {
	return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight :500;
}
function posX() {
	return typeof window.pageXOffset != 'undefined' ? window.pageXOffset:document.documentElement.scrollLeft? document.documentElement.scrollLeft:document.body.scrollLeft? document.body.scrollLeft:0;
}
function posY() {return typeof window.pageYOffset != 'undefined' ? window.pageYOffset:document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop?document.body.scrollTop:0;}

// make it snow
var speed = 250;var movw = new Array();var movh = new Array();var move = new Array();var stepw = new Array();var steph = new Array();var posw = new Array();var posh = new Array();var dir = new Array();var winWidth;var winHeight;
function startSnow() {
	winWidth = 200;
	winHeight = findLivePageHeight()-100;
	for (var i = 0; i < num_flakes; i++){
		move[i] = 0;movh[i] = 12+ Math.random()*2;
		movw[i] = 11+ Math.random()*4;
		posw[i] = Math.random()*(winWidth-35)+12;
		posh[i] = Math.random()*winHeight;
		stepw[i] = 0.3 + Math.random()/10;
		steph[i] = 0.7 + Math.random();
		dir[i] = (Math.random()>0.5)?1:-1;
		document.write('<div id="snow'+ i +'" style="position: absolute; z-index: '+ i +'; visibility:hidden; "><img src="'+snowflakes[Math.floor(Math.random()*snowflakes.length)]+ '" border="0"></div>');
	}
	setTimeout("moreSnow()", speed);
}

function moreSnow() {
	for (var i = 0; i < num_flakes; i++) {
		if (posh[i] > winHeight-50) {
			posw[i] = 10+ Math.random()*(winWidth-movw[i]-30);
			posh[i] = 0;
			dir[i]=(Math.random()<0.5)?1:-1;
			stepw[i] = 0.3 + Math.random()/9;
			steph[i] = 1.3 + Math.random();
		}
		move[i] += stepw[i] *dir[i];
		if (Math.abs(move[i]) > 3) {
			dir[i]=-dir[i];
			posh[i]+=Math.abs(movh[i]*move[i]);
			posw[i]+=movw[i]*move[i];
			move[i]=0;
		}
		objstyle = findDOM('snow'+i,1);
		objstyle.left = (posX()+posw[i] + movw[i]*move[i])+'px';
		//objstyle.top = (posY()+posh[i] + movh[i]*(Math.abs(Math.cos(move[i])+move[i])))+'px';
		objstyle.top = (posY()+posh[i] + movh[i]*(Math.abs(move[i])))+'px';
		objstyle.visibility = 'visible';
	}
	setTimeout("moreSnow()", speed);
}

//startSnow();


////// SCROLLER CONFIGURATION ///////
scrollerWidth = "810";
//Scroller Links On MouseOver
scrollerDivider = "&nbsp;|&nbsp;";

//Browser Sniffer
var isIE = (document.getElementById && document.all)?true:false;
var isNS4 = (document.layers)?true:false;
var isNS6 = (document.getElementById && !document.all)?true:false;

// Build the scroller and place it on the page
function buildScroller(){
	if(isNS4){
		scroller='';
	}else{
		scroller='<div id="div1" style="position:relative; left:0; z-index:1">';
		scroller+='<table border="0" name="table0" id="table0"><tr>';
		y=0;
		while (y<4) {
			for (x=0; x<(Article.length); x++) {
				scroller+='<td nowrap>';
				if(Article[x][1].toLowerCase()!="none"){
					scroller+='<a class="rcScroller" href="'+Article[x][1]+'" target="'+Article[x][2]+'" >'+Article[x][0]+'<\/a>';
				}else{
					scroller+=Article[x][0];
				}
				//scroller+=Article[x][0];
				scroller+='<\/td>';
				if(scrollerDivider.toLowerCase() != "none"){
					scroller+='<td nowrap>'+scrollerDivider+'<\/td>';
				}
			}
			y++;
		}
		scroller+='<\/tr><\/table><\/div>';
	}
	document.writeln(scroller);
}
// Ensure the width of the scroller is divisible by 2. This allows smooth flowing of the scrolled content
function setWidth(){
	tableObj=(isIE)?document.all("table0"):document.getElementById("table0");
	obj=(isIE)?document.all("div1"):document.getElementById("div1");
	objWidth=getOffset(tableObj,"width");
	HalfWidth=Math.floor(objWidth/2);
	newWidth = (HalfWidth*2)+2;
	obj.style.width=newWidth+"px";
	moveLayer(obj, newWidth);
}
// Move the layer by one pixel to the left
function moveLayer(obj, width){
	maxLeft = (0-(width/2)+2)/2;
	obj.style.left=(parseInt(obj.style.left) <= maxLeft)?0+"px":(parseInt(obj.style.left)-1)+"px";
	timer = setTimeout ("moveLayer(obj, "+width+");", 25);
}
// Get width and height of layer
function getOffset(obj, dim) {
	oWidth = obj.offsetWidth;
	return oWidth;
}
function stopScroller(){
	clearTimeout(timer)  ;
}
function runScroller(){
	if(!isNS4){
		setWidth()
	}
}

