var Prototype = {
  Version: '1.6.0',

  Browser: {
    IE:     !!(window.attachEvent && !window.opera),
    Opera:  !!window.opera,
    WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
    Gecko:  navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1,
    MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
  },

  BrowserFeatures: {
    XPath: !!document.evaluate,
    ElementExtensions: !!window.HTMLElement,
    SpecificElementExtensions:
      document.createElement('div').__proto__ &&
      document.createElement('div').__proto__ !==
        document.createElement('form').__proto__
  },

  ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
  JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/,

  emptyFunction: function() { },
  K: function(x) { return x }
};

function addOpacity(id,step,currentValue,targetValue)
{
    if(step <0 && currentValue<=targetValue || step >0 && currentValue >= targetValue)
        return;
    currentValue = currentValue + step;
    setOpacity(id,currentValue/100);
    setTimeout(function(){addOpacity(id,step,currentValue,targetValue);},
        50);
}

function setOpacity(id,value)
{
    if(Prototype.Browser.IE) {
         id.filters.alpha.opacity = value*100;
    }
    if(Prototype.Browser.Opera) {
         id.filters.alpha.opacity = value*100;
    }
    if(Prototype.Browser.WebKit) {
        id.style.MozOpacity = value;
        id.style.Opacity = value;
    }
    if(Prototype.Browser.Gecko) {
        id.style.MozOpacity = value;
        id.style.Opacity = value;
    }
    if(Prototype.Browser.MobileSafari) {
        id.style.MozOpacity = value;
        id.style.Opacity = value;
    }
}

function switchImage(adimages,curentpos,nextDiv,prevDiv,timespan)
{
    if(adimages && adimages.length == 0) return;
    if(curentpos >= adimages.length)
        curentpos = 0;

    nextDiv.innerHTML = "<img src='" + adimages[curentpos].imgUrl + "' />";

    addOpacity(prevDiv,-5,100,0);
    addOpacity(nextDiv,5,0,100);

    var temp = prevDiv;prevDiv = nextDiv;nextDiv = temp;

    curentpos++;
    setTimeout(function(){switchImage(adimages,curentpos,nextDiv,prevDiv,timespan);},
        timespan);
}
