Effect.DelayedAppear = Class.create();
Object.extend(Effect.DelayedAppear.prototype, {
    initialize: function(elements, options, timeout){
        this.elements = elements;
        this.elements.each(function(element){ element.hide();});
        this.effect = 'Appear';
        this.timeout = timeout || 100;
        this.options = Object.extend({}, options || {});

        this.afterFinish = this.options.afterFinish || Prototype.emptyFunction;
        this.options.afterFinish = Prototype.emptyFunction;
        setTimeout(this.action.bind(this),1);
    },
    action: function() {
        if(this.elements.length){
            new Effect[this.effect](this.elements.shift(), this.options);
            setTimeout(this.action.bind(this), this.timeout);
        } else {
            if(this.afterFinish) this.afterFinish();
        }
    }
});


Effect.DelayedChain = Class.create();
Object.extend(Effect.DelayedChain.prototype, {
    initialize: function(effect, elements, options, timeout){
        this.elements = elements;
        this.effect = effect;
        this.timeout = timeout || 100;
        this.options = Object.extend({}, options || {});

        this.afterFinish = this.options.afterFinish || Prototype.emptyFunction;
        this.options.afterFinish = Prototype.emptyFunction;
        setTimeout(this.action.bind(this),1);
    },
    action: function() {
        if(this.elements.length){
            new Effect[this.effect](this.elements.shift(), this.options);
            setTimeout(this.action.bind(this), this.timeout);
        } else {
            if(this.afterFinish) this.afterFinish();
        }
    }
});

Effect.Chain = Class.create();
Object.extend(Effect.Chain.prototype, {
    initialize: function(effect, elements, options){
        this.elements = elements || [];
        this.effect = effect;
        this.options = options || {};
        this.afterFinish = this.options.afterFinish || Prototype.emptyFunction;
        this.options.afterFinish = this.nextEffect.bind(this);
        setTimeout(this.nextEffect.bind(this), 1);
    },
    nextEffect: function(){
        if(this.elements.length)
            new Effect[this.effect](this.elements.shift(), this.options);
        else
            this.afterFinish();
    }
});

// raplaces PNGs for internet explorer boring bug
function replacePng(){
  // html attribute helper
  function htmlAttribute(attributeName, value){return ' '+attributeName+'="'+value+'" ';}

  version = parseFloat(navigator.appVersion.split("MSIE")[1]);
  if (version >= 5.5 && document.body.filters) {
      $$('img').each(function(image){
      name = image.src.split('?')[0];
      if ( name.substring(name.length-3, name.length).toLowerCase() == "png" ) {
        new_style = "display:inline-block;"
                    + image.style.cssText+";"
                    //+ (image.align.length)?";float:"+image.align+";":""
                    + (image.parentElement.href ? "cursor:hand;":"" )
                    + "width:"+image.width+"px; height:"+image.height+"px;"
                    + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                    + "(src=\'" + image.src + "\', sizingMethod='scale');";
        new_style = htmlAttribute('style', new_style);
        new_class = htmlAttribute('class',image.className);//singular, but gets all the classes
        new_id = htmlAttribute('id',image.id);
        new_title = htmlAttribute('title', image.title);
        new_alt = htmlAttribute('alt', image.alt);

        new_html = '<span '+new_style+new_class+new_id+new_title+new_alt+'></span>';
  //      alert(new_html);
        Element.replace(image, new_html);
      }
    });
  }
}

function switchBackground() {
  ie = /MSIE/.test(navigator.userAgent);
  element = $('body');
  element.addClassName('white');
  if (ie) {
    new Effect.Fade("logo", {duration:0.2});
    setTimeout(function(){element.setStyle( {backgroundColor:'#ffffff'} );}, 600);
    setTimeout(function(){element.setStyle( {backgroundColor:'#cc6699'} );}, 500);
    setTimeout(function(){element.setStyle( {backgroundColor:'#99ccff'} );}, 400);
    setTimeout(function(){element.setStyle( {backgroundColor:'#006699'} );}, 300);
    setTimeout(function(){element.setStyle( {backgroundColor:'#003366'} );}, 200);
    setTimeout(function(){element.setStyle( {backgroundColor:'#000033'} );}, 100);
  } else {
    element.setStyle( {backgroundColor:'#000000'} );
    new Effect.Morph('body', {style:'background:#ffffff;'} );
  }
//  return false;
}

/*
Add a new smooth transition with Effect.
Transitions.slowstop. This transition starts very quickly,
but comes to a gradual stop. Great for scrolling somewhere
on a page with a duration of 2. sunsean
* /

Effect.Transitions.slowstop = function(pos) {
  return 1-Math.pow(0.5,20*pos);
}
/*
Here is a custom effect that I made. It allows you to scroll
inside an element that’s overflow is set to auto or scroll.
Usage:
new Effetc.Scroll(‘element-id’, {x: 10, y: 100});
*/
Effect.Scroll = Class.create();
Object.extend(Object.extend(Effect.Scroll.prototype, Effect.Base.prototype), {
  initialize: function(element) {
    this.element = $(element);
    var options = Object.extend({
      x:    0,
      y:    0,
      mode: 'absolute'
    } , arguments[1] || {}  );
    this.start(options);
  },
  setup: function() {
    if (this.options.continuous && !this.element._ext ) {
      this.element.cleanWhitespace();
      this.element._ext=true;
      this.element.appendChild(this.element.firstChild);
    }

    this.originalLeft=this.element.scrollLeft;
    this.originalTop=this.element.scrollTop;

    if(this.options.mode == 'absolute') {
      this.options.x -= this.originalLeft;
      this.options.y -= this.originalTop;
    } else {

    }
  },
  update: function(position) {
    this.element.scrollLeft = this.options.x * position + this.originalLeft;
    this.element.scrollTop  = this.options.y * position + this.originalTop;
  }
});

function moveLeft(container){
  Position.prepare();
  container_y = document.getElementById('hcontentscroll').scrollLeft;
  new Effect.Scroll(container, {x:(container_y - 250), y:0});
  return false;
}

function moveRight(container){
  Position.prepare();
  container_y = document.getElementById('hcontentscroll').scrollLeft;
  new Effect.Scroll(container, {x:(container_y + 250), y:0});
  return false;
}

function moveLefts(container){
  Position.prepare();
  container_y = document.getElementById('hcontentscroll').scrollLeft;
  new Effect.Scroll(container, {x:(container_y - 125), y:0});
  return false;
}

function moveRights(container){
  Position.prepare();
  container_y = document.getElementById('hcontentscroll').scrollLeft;
  new Effect.Scroll(container, {x:(container_y + 125), y:0});
  return false;
}

function moveLx(container){
  Position.prepare();
  container_y = document.getElementById('hcontentscroll').scrollTop;
  new Effect.Scroll(container, {x:0, y:0});
  return false;
}

function moveRx(container){
  Position.prepare();
  container_y = document.getElementById('hcontentscroll').scrollTop;
  new Effect.Scroll(container, {x:1000, y:0});
  return false;
}



function moveUp(container){
  Position.prepare();
  container_y = document.getElementById('main').scrollTop;
  new Effect.Scroll(container, {x:0, y:(container_y - 90)});
  return false;
}

function moveDown(container){
  Position.prepare();
  container_y = document.getElementById('main').scrollTop;
  new Effect.Scroll(container, {x:0, y:(container_y + 90)});
  return false;
}



function moveUpx(container){
  Position.prepare();
  container_y = document.getElementById('main').scrollTop;
  new Effect.Scroll(container, {x:0, y:0});
  return false;
}

function moveDownx(container){
  Position.prepare();
  container_y = document.getElementById('main').scrollTop;
  new Effect.Scroll(container, {x:0, y:1000});
  return false;
}

function chimg(ceva, nrphoto){
  document.getElementById('main-gimage').src = ceva;
  document.getElementById('pno').innerHTML = nrphoto;
  document.getElementById('loading').style.display = 'block';
}
function chimgR(ceva, nrphoto){
  document.getElementById('main-gimage').src = ceva;
  document.getElementById('pno').innerHTML = nrphoto;
  document.getElementById('loading2').style.display = 'block';
}
function chimgFEED(ceva, nrphoto){
  document.getElementById('main-gimage').src = ceva;
  document.getElementById('pno').innerHTML = nrphoto;
  document.getElementById('pno2').innerHTML = nrphoto;
  document.getElementById('loading').style.display = 'block';
}
function remove_loading2(){
        document.getElementById('loading2').style.display = 'none';
}
function remove_loading(obj){
        document.getElementById('loading').style.display = 'none';
}

 
