
var action_current = 0;
var action_content_len = 0;
var action_scroll = new Array();
var action_content = new Array();
var action_button = {url:'', title:''};

action_scroll[0] = {time:0, begin:0, change:0.0, duration:0.0, element:null, timer:null, sinechange:1};
action_scroll[1] = {time:0, begin:0, change:0.0, duration:0.0, element:null, timer:null, sinechange:1};

for (var z=0; z<7; z++){
	action_content[z] = {body:'', title:'', image:'', url:''};
}

function action_set_button(text, url)
{

	action_button.url = url;
	action_button.text = text;

}

function action_add_content(image, url, title, body)
{
	
	if(action_content_len < action_content.length){

		action_content[action_content_len].body = body;
		action_content[action_content_len].title = title;
		action_content[action_content_len].image = image;
		action_content[action_content_len].url = url;
		action_content_len++;

	}
	
}

function action_expand(num)
{


	if(action_current == num){
		var re = new RegExp('^http');
		if(re.test(action_content[num-1].url)){
			location.href=action_content[num-1].url;
		}
		else{
			location.href='http://'+location.hostname+''+action_content[num-1].url;
		}
	}
	else if(action_current > 0){
		action_start(document.getElementById('navTxt-'+action_current+''), 170, 1, 1);
		action_start(document.getElementById('navTxt-'+num+''), 1, 170, 0);
		action_current = num;
	}
	else{
		action_start(document.getElementById('navTxt-'+num+''), 1, 170, 0);
		action_current = num;
	}

}


function action_write_content(a1, a2, a3, a4, a5)
{

	if(a1) timerInterval = a1;
	if(a2) timerDelay = a2;

	no_end = ( a3 ? 1 : 0 );

	if(a4) autoDelay1 = a4*1000;
	if(a5) autoDelay2 = a5*1000;

	var k = 0;

	var str = '';


	str += "<div id=\"main\" class=\"actionMain\">\n";
	str += "\n";
	str += "<table width=\"216\" height=\"479\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"left\" valign=\"top\">\n";
	str += "<tr><td height=\"53\" align=\"left\" valign=\"top\">\n";
	str += "</td></tr>\n";
	str += "<tr><td height=\"30\" valign=\"middle\" align=\"center\">\n";
	str += "<div id=\"nav-0\" class=\"actionGButton\"><A HREF=\""+action_button.url+"\">"+action_button.text+"</A></div>\n";
	str += "</td></tr>\n";
	str += "<tr><td height=\"5\" align=\"left\" valign=\"top\">\n";
	str += "</td></tr>\n";
	str += "\n";
	str += "<tr><td height=\"391\" align=\"left\" valign=\"top\">\n";
	str += "\n";

	for (var i = 0; i < 7; i++) {
	
		var j = i+1;

		str += "\n";
		str += "<div id=\"nav-"+j+"\" class=\"actionNAV\" onMouseOver=\"action_rollover("+j+",1);\" onMouseOut=\"action_rollover("+j+",0);\" onClick=\"action_expand("+j+");\">";
		str += "<table height=\"20\"><tr><td valign=\"middle\" width=\"40\"><img src=\""+action_content[i].image+"\"></td><td valign=\"middle\"><font id=\"navFont-"+j+"\" class=\"actionNavText\">"+action_content[i].title+"</font></td></tr></table></div>\n";
		str += "<div id=\"navTxt-"+j+"\" class=\"actionTXT\">\n";
		str += "<!-----------------------------------------  Content (Start) ----------------------------------------->\n";
		str += "<table><tr><td width=\"40\"></td><td>";
		str += ""+action_content[i].body+"";
		str += "</td></tr></table>\n";
		str += "<!-----------------------------------------  Content ----------------------------------------->\n";
		str += "</div>\n";
		str += "\n";

	}

	str += "\n";
	str += "</td></tr></table>\n";
	str += "\n";
	str += "</div>\n";

	document.write(str);

	var myTimer = setTimeout("action_expand(1);", 100); 
}



function action_start(elem, start, end, id)
{

	if (action_scroll[id].timer != null) {
		clearInterval(action_scroll[id].timer);
		action_scroll[id].timer = null;
	}
	action_scroll[id].time = 0;
	action_scroll[id].begin = start;
	action_scroll[id].change = end - start;
	action_scroll[id].duration = 30;
	action_scroll[id].element = elem;

	action_scroll[id].change = ( start > end ? start - end : end - start );
	action_scroll[id].sinechange = ( start > end ? 1 : -1 );

	action_scroll[id].timer = setInterval("action_vert_scroll("+id+");", 15);
}

function action_vert_scroll(id)
{
	if (action_scroll[id].time > action_scroll[id].duration) {
		clearInterval(action_scroll[id].timer);
		action_scroll[id].timer = null;
	}
	else {
		height = sine_func(action_scroll[id].time, action_scroll[id].begin, action_scroll[id].change, action_scroll[id].duration, action_scroll[id].sinechange);
		action_scroll[id].element.style.height = height+'px';
		action_scroll[id].time++;
	}
}

function sine_func(t, b, c, d, x)
{
	return x * c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
}

function action_rollover(id, bool)
{

	if(bool){
		document.getElementById('navFont-'+id+'').style.color='#FFFFFF';
		document.getElementById('navFont-'+id+'').style.fontWeight='bold';
		document.getElementById('nav-'+id+'').style.backgroundColor='#003768';
	}
	else{
		document.getElementById('navFont-'+id+'').style.color='#003768';
		document.getElementById('navFont-'+id+'').style.fontWeight='normal';
		document.getElementById('nav-'+id+'').style.backgroundColor='';
	}

}
