/********************************

	Scrolling/Expanding List
	Version 1.0
	last revision: 04.26.2004
	steve@slayeroffice.com

	http://slayeroffice.com/code/scroll_menu/

	Please notify me of any improvments you make on this
	code so that I can update the version hosted on
	slayeroffice

	please leave this notice intact.

********************************/


window.onload=init;


//********************** NEWS SECTION *************************/

var doc=document;
//var expander; 			// object reference for the plus/minus div
var lContainer_news; 			// object reference for the UL

var currentTop_news=0;			// the current Y position of the UL
var zInterval_news = null;		// animation thread interval
var direction_news;			// direction_news we're scrolling the UL. 0==up, 1==down
var startTop_news=0;			// the starting top of the UL

var scrollRate_news=6;			// initNewsial rate of scrolling //length of the scroll
var scrollTick_news=0;			// keeps track of long we've scrolled so we can slow it down accordingly

var listExpand_news=true;		// boolean to tell us if we're expanding or contracting the list
var listHeight_news=60;			// the current height of the UL
var isExpanded_news=false;		// boolean to denote if the list is expanded or not. initNewsiliazed to true as it will be set to false as soon as the expand control is clicked.

var MAX_SCROLL_TICK_news=4;		// the maximum value of scrollTick_news before it's reset
var LI_PADDING_news=2;		// the LI's padding value. used to compensate for overall dimensions
var LI_HEIGHT_news=10;		// the height of the LI
var MAX_LIST_HEIGHT_news=300;		// maximum height of the list when fully expanded
var MIN_LIST_HEIGHT_news=240;		// contracted height of the list
var REBOUND_news = -4;		// the value of scrollRate_news when we stop scrolling //efect when scrolling back a little
var FAST_EXPAND_news=5;		// the initNewsial rate of list expansion
var SLOW_EXPAND_news=1;		// the end rate of expansion
var SPEED_TRANSITION_news=20;	// when this value + the MAX or MIN list height is reached, we set scrollRate_news to its slower rate

//********************** END NEWS SECTION *************************/

function init() {
	
	
	//********************** NEWS SECTION *************************/
	
	if(!doc.getElementById)return; // bail out if this is an older browser
	
	up_news=doc.getElementById("upArrow_news");
	down_news=doc.getElementById("downArrow_news");

	// apply onclick behaviors to the up arrow, down arrow and expansion control elements
	down_news.onclick=function(){scrollObjectsNews(0);}
	up_news.onclick=function(){scrollObjectsNews(1);}
	down_news.onmouseover=function(){scrollObjectsNews(0);}
	up_news.onmouseover=function(){scrollObjectsNews(1);}
	//expander=d.getElementById("changeSize");
	//expander.onclick=function(){if(!isExpanded_news)isExpanded_news=true;changeListSizeNews(); }

	lContainer_news = doc.getElementById("textContainer_news");

	doc.getElementById("nContainer_news").style.height=MIN_LIST_HEIGHT_news+"px";
	
	test.load()
	
	//********************** END NEWS SECTION *************************/
}


//********************** NEWS SECTION *************************/

function initNews() {
	if(!doc.getElementById)return; // bail out if this is an older browser
	
	up_news=doc.getElementById("upArrow_news");
	down_news=doc.getElementById("downArrow_news");

	// apply onclick behaviors to the up arrow, down arrow and expansion control elements
	down_news.onclick=function(){scrollObjectsNews(0);}
	up_news.onclick=function(){scrollObjectsNews(1);}
	//expander=d.getElementById("changeSize");
	//expander.onclick=function(){if(!isExpanded_news)isExpanded_news=true;changeListSizeNews(); }

	lContainer_news = doc.getElementById("textContainer_news");

	doc.getElementById("nContainer_news").style.height=MIN_LIST_HEIGHT_news+"px";
}

function scrollObjectsNews(direction) {
	if(zInterval_news)return; // already scrolling.
	if(isExpanded_news)return; // list is expanded. no need to scroll.
	if((!direction && currentTop_news<=-1600) || (direction && currentTop_news==0))return; // dont scroll up if we're at the top or down if at the bottom of the list
	direction_news=direction;
	zInterval_news=setInterval("animateNews()",20);
}

function animateNews() {
	// increment or decrement currentTop_news based on direction_news
	if(!direction_news) {
		currentTop_news-=scrollRate_news;
	} else {
		currentTop_news+=scrollRate_news;
	}
	scrollTick_news++;	
	if(scrollTick_news>=MAX_SCROLL_TICK_news) {
		scrollRate_news--; // slow the scroll rate down for a little style
		scrollTick_news=0;
	}

	lContainer_news.style.top=currentTop_news+"px";
	if(scrollRate_news<=REBOUND_news) {
		// scroll is finished. clear the interval and reset vars for the next scroll
		clearInterval(zInterval_news);
		zInterval_news=null;
		startTop_news=currentTop_news;
		scrollTick_news=0;
		scrollRate_news=6;
	}
}

function changeListSizeNews() {
	listExpand_news=listExpand_news?false:true;
	clearInterval(zInterval_news);
	zInterval_news=setInterval("expandListNews()",20);
}

function expandListNews() {
	//if(zInterval_news)return; // already expanding or contracting.
	if(!listExpand_news) {
		if(listHeight_news<MAX_LIST_HEIGHT_news-SPEED_TRANSITION_news) {
			listHeight_news+=FAST_EXPAND_news;
		} else {
			listHeight_news+=SLOW_EXPAND_news;
		}
		if(currentTop_news<0) {
			currentTop_news+=3;
			lContainer_news.style.top=currentTop_news+"px";
		}
		if(listHeight_news<MAX_LIST_HEIGHT_news)document.getElementById("nContainer_news").style.height=listHeight_news+"px";

		if(listHeight_news>=MAX_LIST_HEIGHT_news && currentTop_news>=0) {
			clearInterval(zInterval_news);
			zInterval_news=null;
			expander.style.backgroundImage="url(minus.gif)";
			currentTop_news=0;
			isExpanded_news=true;
		}
	} else {
		if(listHeight_news>MIN_LIST_HEIGHT_news+SPEED_TRANSITION_news) {
			listHeight_news-=FAST_EXPAND_news;
		} else {
			listHeight_news-=SLOW_EXPAND_news;
		}
		document.getElementById("nContainer_news").style.height=listHeight_news+"px";
		if(listHeight_news<=MIN_LIST_HEIGHT_news) {
			clearInterval(zInterval_news);
			zInterval_news=null;
			expander.style.backgroundImage="url(plus.gif)";
			isExpanded_news=false;
		}
	}
}

//********************** END NEWS SECTION *************************/


//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
  lContainer_news.style.top=0+"px";
  currentTop_news=0;
  clearInterval(zInterval_news);
  zInterval_news=null;
  startTop_news=currentTop_news;
  scrollTick_news=0;
  scrollRate_news=6;
  
}

function MM_showHideLayersWim() { //v6.0
  var i,p,v,m,obj,args=MM_showHideLayersWim.arguments;
  for (i=0; i<(args.length-2); i+=4) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2]; m=args[i+3];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
  lContainer_news.style.top=0+"px";
  currentTop_news=0;
  clearInterval(zInterval_news);
  zInterval_news=null;
  startTop_news=currentTop_news;
  scrollTick_news=0;
  scrollRate_news=6;
  //alert(m);
  cleanActiveMenuWim();
  var active_menu = document.getElementById(m);
  active_menu.style.textDecoration = 'underline';
  active_menu.style.background = 'url(images/indent_mo.gif) no-repeat left center';
  
}

function cleanActiveMenuWim(){
	
	for (i=1; i<=6; i+=1){
		var nm = 'nm'+i;
		//alert(nm);
		if(document.getElementById(nm)){
			menuItem = document.getElementById(nm);
			menuItem.style.textDecoration = 'none';
			menuItem.style.background = 'url(images/indent.gif) no-repeat left center';
		}
	}
}
