function showhidediv(whichDiv) 
{
	if(document.getElementById(whichDiv).style.display == 'none')
	{
		document.getElementById(whichDiv).style.display = '';
	}else{
		document.getElementById(whichDiv).style.display = 'none';
	}
}

//Set a DIV's style to default
function showdiv(whichDiv,displayAs) 
{
	document.getElementById(whichDiv).style.display = displayAs;
}

//Set a DIV's style to display:none; 
function hidediv(whichDiv) 
{
	document.getElementById(whichDiv).style.display = 'none';
}

function hideallshowone(whichDiv,allChilds)
{
var array=allChilds.split(",");
for(i=0;i<array.length;i++) 
{
        hidediv(array[i]);
}
showdiv(whichDiv,'block');
//doit_opacity_aggressive(whichDiv,0,100,5,2);
}

//Unlike hideallshowone() this version does not require a unique id.
//This one simply hides every childNode. And then reveals the one.
//It has an opacity fade built in.
function hideallshowone2(whichDiv,whichDivSet)
{
for( var i = 0; i < document.getElementById(whichDivSet).childNodes.length; i++ )
{
document.getElementById(whichDivSet).childNodes[i].style.display='none';
}
var obj=document.getElementById(whichDivSet).childNodes[whichDiv];
doit_opacity(whichDivSet,0,100,80,20);
obj.style.display='block';
}

function clearalltagone(whichDiv,allChilds)
{
var array=allChilds.split(",");
for(i=0;i<array.length;i++) 
{
        document.getElementById(array[i]).className='none';
}
document.getElementById(whichDiv).className='hover';
}


function hideall(allChilds,ifTrue)
{
if(ifTrue)
{
var array=allChilds.split(",");
for(i=0;i<array.length;i++) 
{
        hidediv(array[i]);
}
}
}

function tagall(allChilds,ifTrue)
{
if(ifTrue)
{
var array=allChilds.split(",");
for(i=0;i<array.length;i++) 
{
        document.getElementById(array[i]).className='none';
}
}
}

function doit(id,attribute,unit,end,time,steps)
{
	var obj = document.getElementById(id);
	var start = parseInt(eval('obj.'+attribute));

	if((start<end && steps>0) || (start>end && steps<0))
	{
		eval('obj.'+attribute+'="'+(steps+start)+unit+'"');
		setTimeout((function(){ doit(id,attribute,unit,end,time,steps); }),time);
	}
	else
	{
		eval('obj.'+attribute+'="'+end+unit+'"');
	}
}

//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 + ")";
}

//My very simple script to change an objects opacity. Set the object's ID, Starting Opacity, Ending Opacity, The Time Between Steps, The Perentage Change Each Time.
function doit_opacity(id,start,end,time,steps)
{
	var obj = document.getElementById(id);
	changeOpac(start,id);
	if((start<=end && steps>0) || (start>=end && steps<0))
	{
		setTimeout((function(){ doit_opacity(id,start+steps,end,time,steps); }),time);
	}
}

//This more aggressively pursues opacity changes. More reliable, but more resource intense.
function doit_opacity_aggressive(id,start,end,time,steps)
{
	var obj = document.getElementById(id);
	var interval=setInterval((function(){ start=start+steps;opacity_aggressive_interval(id,start,end,time,steps,interval); }),time);
}
function opacity_aggressive_interval(id,start,end,time,steps,interval)
{
	if((start>=end && steps>0) || (start<=end && steps<0))
	{
	clearInterval(interval);
	}
	else
	{
	changeOpac(start,id);
	}
}


//Generic Cookie Functions
function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
  var cookie_string = name + "=" + escape ( value );

  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  
  if ( secure )
        cookie_string += "; secure";
  
  document.cookie = cookie_string;
}

function delete_cookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}
