// JavaScript Document


// CURRENCY TOOLS
var rate_interval = 4000;
var next_rate = 0;
function show_rate(){
	document.getElementById('stock_rate_c').innerHTML = currency_rates[next_rate];
	next_rate++;
	if(next_rate > currency_rates.length-1) next_rate = 0;
}
show_rate(); // for the first time display w/o delay
rate_timer = setInterval("show_rate()", rate_interval);



// WEATHER TOOLS
var c = document.getElementById('weather_marquee');

// table helps to place text in DIV element w/o wrapping and to fit 
// layer width to text length automatically 
marquee_str = "<table cellpadding='0' cellspacing='0' border='0'>"
+ "<tr><td nowrap='nowrap'><div class='marquee_t'>" + marquee_str + "</div></td></tr></table>";
c.innerHTML = marquee_str;

var timer;
clip_right = 0;
clip_maxright = 240;
clip_left = 0;
pos_maxleft = 345;
pos_left = pos_maxleft + clip_maxright;
var pace = 1;
var interval = 30;
var ow = 1000;

function set_clip(){
	if(pos_left < pos_maxleft) {
		clip_left = clip_left + pace;
	}
	clip_right = clip_right + pace;
	pos_left = pos_left - pace;
	
	// restore default settings to start marquee again
	if(clip_left > ow) {
	  clip_right = 0;
	  clip_maxright = 240;
	  clip_left = 0;
	  pos_maxleft = 345;
	  pos_left = pos_maxleft + clip_maxright;
	}
	c.style.clip = "rect(0px "+clip_right+"px 50px "+clip_left+"px)";
	c.style.left = pos_left+'px';
}
timer = setInterval("set_clip()", interval);
//set_clip();
