/// common.js must be included before this script

/// USAGE
/// To the tag element put this attribute: onmouseover="SetOpacity(this)"
/// USAGE
/// If opacity doesnt work for ex. in IE for DIV, add width to it.

//for configuration \
var opacType = false;
var opacToStart = true;
var startOpac=100;
var flashingTime = 1;
var flashingStep = 2;
//for configuration /

var oOpac,si,bC=false,bD=false,isIEorMoz;
var iOpacGlob=startOpac;
var opacMask="progid:DXImageTransform.Microsoft.Alpha(Opacity='{M}')";

function InitializeOpac(){isIEorMoz = IEorMoz();}
function SetOpacity(obj)
{  
   if (obj.style.cursor!='pointer') obj.style.cursor = 'pointer';
   if (bD)ClearLogc();
   bD=false;oOpac=obj;si=setInterval(DoOpac,flashingTime);
  obj.onmouseout = function s(){ClearOpac();}   
}
function DoOpac(){
  if (iOpacGlob<=0 && !bC) if (opacType) iOpacGlob=startOpac; else bC=true;
  if (iOpacGlob>=startOpac && bC) {bC=false;if(bD)ClearLogc();}
  MainOpac(iOpacGlob);
  if (!bC) iOpacGlob = iOpacGlob - flashingStep;
  else iOpacGlob = iOpacGlob + flashingStep;
}
function MainOpac(iVal){
if (isIEorMoz) oOpac.style.filter=opacMask.replace('{M}',iVal);
else oOpac.style.MozOpacity=iVal/100;
}
function ClearOpac(){if(opacType)ClearLogc();else if (opacToStart) bD=true;else ClearLogc();}
function ClearLogc(){clearInterval(si);MainOpac(startOpac);iOpacGlob=startOpac;}
AddEventHandling(window,'load',InitializeOpac);
