
// Opacity and Fade in script.
// Script copyright (C) 2008 http://www.cryer.co.uk/.
// Script is free to use provided this copyright header is included.
function SetOpacity(object,opacityPct)
{
  // IE.
  object.style.filter = 'alpha(opacity=' + opacityPct + ')';
  // Old mozilla and firefox
  object.style.MozOpacity = opacityPct/100;
  // Everything else.
  object.style.opacity = opacityPct/100;
}
function ChangeOpacity(id,msDuration,msStart,fromO,toO)
{
  var element=document.getElementById(id);
  var opacity = element.style.opacity * 100;
  var msNow = (new Date()).getTime();
  opacity = fromO + (toO - fromO) * (msNow - msStart) / msDuration;
  if (opacity<0)
    SetOpacity(element,0)
  else if (opacity>100)
    SetOpacity(element,100)
  else
  {
    SetOpacity(element,opacity);
    element.timer = window.setTimeout("ChangeOpacity('" + id + "'," + msDuration + "," + msStart + "," + fromO + "," + toO + ")",1);
  }
}
function FadeIn(id)
{  
  var element=document.getElementById(id);
  if (element.timer) window.clearTimeout(element.timer);
  var startMS = (new Date()).getTime();
  element.timer = window.setTimeout("ChangeOpacity('" + id + "',1000," + startMS + ",0,100)",1);
}
function FadeOut(id)
{
  var element=document.getElementById(id);
  if (element.timer) window.clearTimeout(element.timer);
  var startMS = (new Date()).getTime();
  element.timer = window.setTimeout("ChangeOpacity('" + id + "',1000," + startMS + ",100,0)",1);
}
function FadeInImage(foregroundID,newImage,backgroundID)
{
   //alert("itt");
  var foreground=document.getElementById(foregroundID);
  if (backgroundID)
  {
    var background=document.getElementById(backgroundID);
    if (background)
    {
      background.style.backgroundImage = 'url(' + foreground.src + ')';
      background.style.backgroundRepeat = 'no-repeat';
    }
  }
  SetOpacity(foreground,0);
  foreground.src = newImage;
  if (foreground.timer) window.clearTimeout(foreground.timer);
  var startMS = (new Date()).getTime();
  foreground.timer = window.setTimeout("ChangeOpacity('" + foregroundID + "',1000," + startMS + ",0,100)",10);
}
function ShowSubmenu(id_sub)
{
    document.getElementById(id_sub).style.visibility='visible';
}
function HideSubmenu(id_subh)
{
    document.getElementById(id_subh).style.visibility='hidden';
}
function GchangeTextColor_din(dinid,gcolor)
                {
                    document.getElementById(dinid).style.color=gcolor;
                }
function GchangeTextColor_din_b(dinidb,gcolor)
                {
                    document.getElementById(dinidb).style.color=gcolor;
                }
                function changeTextColor(idd)
                {
                    document.getElementById(idd).style.color = '#FF0505';
                }
                 function changeTextColor_2(idd)
                {
                    document.getElementById(idd).style.color = '#000000';
                }
//                function showImageGallery(index, name)
//{
//    //alert(index);
//    var dark = document.getElementById("sitecontainer");
//    dark.style.opacity=opaque;
//    dark.style.MozOpacity=opaque;
//    dark.style.filter='alpha(opacity='+opacity+')';
//    dark.style.zIndex=zindex;
//    dark.style.backgroundColor=bgcolor;
//    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
//        pageWidth = document.body.scrollWidth+'px';
//        pageHeight = document.body.scrollHeight+'px';
//    } else if( document.body.offsetWidth ) {
//        pageWidth = document.body.offsetWidth+'px';
//        pageHeight = document.body.offsetHeight+'px';
//    }
//    dark.style.width= pageWidth;
//    dark.style.height= pageHeight;
//    dark.style.display='block';
//    var album = document.getElementById("galery_java");
//    album.style.display = "block";
//    //document.getElementById("image_here").innerHTML = '<img src="/images/nagy_kep.png" alt="duma" />';
//    if (index<0)
//    {
//        index_container = array.length-1;
//        document.getElementById("image_here").innerHTML = '<img src="/'+array[array.length-1]+'" alt="imagini despre produs" />';
//    }
//    if (index>=array.length)
//    {
//        index_container = 0;
//        document.getElementById("image_here").innerHTML = '<img src="/'+array[0]+'" alt="imagini despre produs" />';
//    }
//    if (index>=0 && index<array.length)
//    {
//        index_container = index;
//        document.getElementById("image_here").innerHTML = '<img src="/'+array[index]+'" alt="imagini despre produs" />';
//    }
//    //document.getElementById("image_counter").innerHTML = '<span style="font-family: Trebuchet MS, sans-serif;">'+(index_container+1)+'/'+array.length+'</span>';
//    document.getElementById("produs_name").innerHTML = '<span style="font-family: Trebuchet MS, sans-serif;">'+name+'</span>';
//    album.style.background = "red";
//    album.style.zIndex=1000;
//
//    //==============================================================================
//    var scrolledX, scrolledY;
//    if( self.pageYOffset ) {
//        scrolledX = self.pageXOffset;
//        scrolledY = self.pageYOffset;
//    } else if( document.documentElement && document.documentElement.scrollTop ) {
//        scrolledX = document.documentElement.scrollLeft;
//        scrolledY = document.documentElement.scrollTop;
//    } else if( document.body ) {
//        scrolledX = document.body.scrollLeft;
//        scrolledY = document.body.scrollTop;
//    }
//
//    // Next, determine the coordinates of the center of browser's window
//
//    var centerX, centerY;
//    if( self.innerHeight ) {
//        centerX = self.innerWidth;
//        centerY = self.innerHeight;
//    } else if( document.documentElement && document.documentElement.clientHeight ) {
//        centerX = document.documentElement.clientWidth;
//        centerY = document.documentElement.clientHeight;
//    } else if( document.body ) {
//        centerX = document.body.clientWidth;
//        centerY = document.body.clientHeight;
//    }
//    var xwidth = album.offsetWidth;
//    var xheight = album.offsetHeight;
//    //alert(xwidth+" "+xheight);
//    var leftOffset = scrolledX + (centerX - xwidth) / 2;
//    var topOffset = scrolledY + (centerY - xheight) / 2;
////==============================================================================
//    album.style.top = topOffset+"px";
//    album.style.left = leftOffset+"px";
//}
