function SetSize(oWidth){
	//alert (oWidth)
	var oGallery = document.getElementById("gallery");
	oGallery.setAttribute("style", "width:"+oWidth+"px")
	oGallery.style.cssText ="width:"+oWidth+"px";
	//alert (oGallery.style.width)
}
function ClearDiv(oDiv){
	if ( oDiv.hasChildNodes() )
	{
		while ( oDiv.childNodes.length >= 1 )
		{
			oDiv.removeChild( oDiv.firstChild );       
		} 
	}
}
//###########################
//------------move the shadowbox close button-----
//###########################
function moveCloseLink(sWidth)
{
	oWrapper=document.getElementById( 'sb-wrapper' );
	
    oContent=document.getElementById( 'sb-body' );	
	oContent.setAttribute("style", "oveflow:hidden")
	oContent.style.cssText ="oveflow:hidden";
	
    oClose=document.getElementById( 'sb-nav-close' );
	oClose.innerHTML="CLOSE"
	oClose.setAttribute("style", "width:"+60+"px;background-position:right;position: absolute;top: 8px;right:0;display: block;color:white;cursor: pointer;")
	oClose.style.cssText ="width:"+60+"px;background-position:right;position: absolute;top: 8px;right:0;display: block;color:white;cursor: pointer;";
	disableSelection(oClose);
    if( oWrapper )
       oWrapper.appendChild(oClose);
}

//###########################
//------------Disable text selection----- ---------------
//###########################
function disableSelection(target){

if (typeof target.onselectstart!="undefined") //IE route

    target.onselectstart=function(){return false}

else if (typeof target.style.MozUserSelect!="undefined") //Firefox route

    target.style.MozUserSelect="none"

else //All other route (ie: Opera)

    target.onmousedown=function(){return false}
	target.style.cursor = "default"
}

//###########################
//-------------FADE OUT FUNCTIONS ---------------
//###########################
function fade(eid)
{

  var element = document.getElementById(eid);
  if(element == null)
    return;

  element.FadeState = 2;
  if(element.FadeState == 1 || element.FadeState == -1)
  {
    element.FadeState = element.FadeState == 1 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
  }
  else
  {
    element.FadeState = element.FadeState == 2 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade;
    element.style.display = element.FadeState == 2 ? 'none' : 'block';	
    setTimeout("animateFade(" + new Date().getTime() + ",'" + eid + "')", 33);
  }
}

function animateFade(lastTick, eid)
{  
  var curTick = new Date().getTime();
  var elapsedTicks = curTick - lastTick;
 
  var element = document.getElementById(eid);
 
  if(element.FadeTimeLeft <= elapsedTicks)
  {
    element.style.display = element.FadeState == 1 ? 'block' : 'none';  
    element.style.opacity = element.FadeState == 1 ? '1' : '0';
    element.style.filter = 'alpha(opacity = '
        + (element.FadeState == 1 ? '100' : '0') + ')';
    element.FadeState = element.FadeState == 1 ? 2 : -2;
    return;
  }
 
  element.FadeTimeLeft -= elapsedTicks;
  var newOpVal = element.FadeTimeLeft/TimeToFade;
  if(element.FadeState == 1)
    newOpVal = 1 - newOpVal;

  element.style.opacity = newOpVal;
  element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')';
 
  setTimeout("animateFade(" + curTick + ",'" + eid + "')", 33);
}