function startNavList(menuid, menuclass) {

if (document.all&&document.getElementById) 
{
	//alert(menuid);
	navRoot = document.getElementById(menuid);
	for (i=0; i<navRoot.childNodes.length; i++) 
	{
	
		node = navRoot.childNodes[i];
		if (node.nodeName=="LI")
		{
			node.onmouseover=function() {
				this.className+=" "+menuclass;
				if(document.getElementById('titlespan'))
				{	
					//alert('here');
					var titlespan = document.getElementById('titlespan');
					titlespan.style.visibility = 'hidden';
				}//end if 
			  
			  }//end function
			  
			  node.onmouseout=function() {
				 this.className=this.className.replace(" "+menuclass, "");
				if(document.getElementById('titlespan'))
				{
					var titlespan = document.getElementById('titlespan');
					titlespan.style.visibility='visible';
				}//end if
			   }//end function
		   }
	  }
 }
}

function startNavMenus()
{
	//startNavList('navmenuhoriz','over');

	startNavList('leftnav','over');
}

function toggleOn( targetId, player){
   
   var new_target = targetId+'a';
     if (document.getElementById)
     {
        target = document.getElementById( new_target );
		if (player)
			var newClassName = 'active playerprofile';
		else
			var newClassName = 'active nextlast';
		
		if (targetId == 'table') 
		{
			if (player)
				newClassName = 'active playerprofilelast';
			else
				newClassName = 'active table';
		}
		//var newClassName = 'active ' + targetId;
        target.className  = newClassName;
		//alert(newClassName);
		
     }
 
}

function toggleOff( targetId, player){
    var new_target = targetId+'a';
     if (document.getElementById)
     {
        target = document.getElementById( new_target );
        if (player)
			var newClassName = 'playerprofile';
		else
			var newClassName = 'nextlast';
		
		if (targetId == 'table') 
		{
			if (player)
				newClassName = 'playerprofilelast';
			else
				newClassName = 'table';
		}
        target.className  = newClassName;

     }
 
    }


function turnOff( targetId ){
     if (document.getElementById){
        target = document.getElementById( targetId );
                target.style.display = "none";
            }
        }
        
function turnOn( targetId ){
     if (document.getElementById){
        target = document.getElementById( targetId );
                target.style.display = "block";
				
            }
        }


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

var running = 'false';
var intervalID;
var clickedtransform = 'false';
var image_array =  new Array();
function onClickBlendimage(divid, imageid, imagefile, millisec)
{
	window.clearInterval(intervalID);
	running = 'false';
	clickedtransform='true';
	blendimage(divid, imageid, imagefile, millisec);
	clickedtransform='false';
}
function basename (path) { return path.replace( /.*\//, "" ); }
   // note that we can't call it "short",
   //  because that's a reserved word in JS.

  function dir (d, subdirs) {
    var new_hash = {};
    for(var i = 0; i < subdirs.length; i++) {
      var subdir_name      = subdirs[i][0],
          subdir_structure = subdirs[i][1];
      new_hash[ subdir_name ] = subdir_structure;
    }
    return [ basename(d), new_hash ];
  }

function getNextImage(aImages, dir)
{
	if (aImages.length <= 1) return false;
	
	var curImage = basename(document.getElementById('clickimage').src);

	for (var n = 0; n < aImages.length; n++)
	{
		if (basename(aImages[n]) == curImage)
			break;
	}
	

	if (dir == 'last')
	{
		if (n==0) 
			n = aImages.length ;

		blendimage('clickdiv','clickimage',aImages[n-1],600, n);
	}
	else
	{
		if (n < 0) 
			n = aImages.length - 1;
		else if (n == (aImages.length-1)) 
			n = -1;
		blendimage('clickdiv','clickimage',aImages[n+1],600, n+2);
	}
		
}

function onClickBlendimageTest(divid, imageid, imagefile, millisec)
{
	window.clearInterval(intervalID);
	running = 'false';
	clickedtransform='true';
	blendimage(divid, imageid, imagefile, millisec);
	clickedtransform='false';
}


function blendimage(divid, imageid, imagefile, millisec, test) {

	//alert(imagefile);
	//if(running == 'true' || clickedtransform =='true')
	//{
			
		var tempimage = document.getElementById(imageid).src;
	//alert(tempimage);
		var speed = Math.round(millisec / 100);
		var timer = 0;
		
		//set the current image as background
		document.getElementById(divid).style.backgroundImage = "url(" + tempimage + ")";
		
		//make image transparent
		changeOpac(0, imageid);
		
		//make new image
		document.getElementById(imageid).src = imagefile;
document.getElementById('currentImage').innerHTML = test;
		//fade in image
		for(i = 0; i <= 99; i++) {
			setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
			timer++;
			//document.getElementById('currentImage').innerHTML = curImage;
		}
		
		//alert(tempimage +' : '+imagefile);
	//}


	
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}
	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}

function startImageRotation(div,image)
{
 //alert( image_array.length);
 for (var i = 0; i < image_array.length; i++)
 {	
	//alert(image_array[i]);
		//window.setTimeout("blendimage('clickdiv', 'clickimage', '"+image_array[i]+"', '500')", parseInt(i)*2000);
		var test = i+1;
		//alert(test);
		//window.setTimeout(alert(image_array[i]), parseInt(i)*2000);
		window.setTimeout("blendimage('"+div+"','"+ image+"', '"+image_array[i]+"', '500', '"+test+"')", parseInt(i)*2000);
		//document.getElementById('currentImage').innerHTML = i;
		
 }
}

function stopImageRotation()
{
 	window.clearInterval(intervalID);
	running = 'false';
	clickedtransform='false';
}

function mouseOverImage(id)
{
	changeOpac('70', id);

}

function mouseOutImage(id)
{
	changeOpac('100', id);
}

function clickStartRotation(div,image,passed_image_array)
{
	if (running == 'false')
	{
		
		running = 'true';
		image_array = passed_image_array;
		startImageRotation(div,image);
		
		intervalID = window.setInterval("startImageRotation('"+div+"','"+image+"')", ((image_array.length * 2) * 1000));
		
		if (document.getElementById('clickPlay'))
			document.getElementById('clickPlay').innerHTML = '<strong>Stop Slideshow</strong>';
		
		return true;
	}
	else
	{
		stopImageRotation();

		if (document.getElementById('clickPlay'))
			document.getElementById('clickPlay').innerHTML = '<strong>Play Slideshow</strong>';
	}
}

function selectJump(select_id)
{
	var newIndex = document.getElementById(select_id).selectedIndex; 
var cururl = document.getElementById(select_id).options[document.getElementById(select_id).selectedIndex].value; 
	window.location = cururl;
}

function commercialStartSlideShow()
{
	clickStartRotation('clickdiv','clickimage',image_array);
}

function clearLogin()
{
	if(document.getElementById('username').value=='Email Address') 
	{
			document.getElementById('username').value=''; 	
			document.getElementById('pass').value=''; 
	}
}

function unsetCheckBoxes()
{
	
	var inputs = document.getElementsByTagName("input");

	for (var i=0; i< inputs.length; i++)
	{
		if (inputs[i].type=='checkbox' && inputs[i].checked==false)
		{
			inputs[i].style="visibility: hidden;";
			inputs[i].checked=true;
			inputs[i].value="0";
			
		}
	}

}
