// JavaScript Document

(function() {
  var ie = Prototype.Browser.IE,
  action = $w(ie ? 'enter leave' : 'over out').map(function(v){ return 'mouse' + v }),
  respond = function(eventName){
    return ie ? function(e) {
      e.element().fire(eventName)
    } : function(e) {
      var target = e.element();
      if (e.relatedTarget && !e.relatedTarget.descendantOf(target))
        target.fire(eventName);
    }
  };

  document.observe(action[0], respond('mouse:enter'))
    .observe(action[1], respond('mouse:leave'));
})();


function respondToMouseOver(event){
	var element = Event.element(event);
	window.setTimeout(function(){$('L3'+element.id).fade({duration: 0.2 },{ position: 'end', scope: 'L3q'+element.id, limit: 2 });}, 250 );
	window.setTimeout(function(){$('L3'+element.id).appear({duration: 0.2 },{ position: 'end', scope: 'L3q'+element.id, limit: 2 });}, 5000 );
}

function respondToMouseOut(event){
	var element = Event.element(event);
	window.setTimeout(function(){$('L3'+element.id).appear({duration: 0.2 },{ position: 'end', scope: 'L3q'+element.id, limit: 2 });}, 250 );
	window.setTimeout(function(){$('L3'+element.id).appear({duration: 0.2 },{ position: 'end', scope: 'L3q'+element.id, limit: 2 });}, 5000 );
}
	
function respondToMouseClick(event){
	var element = Event.element(event);
	var ItemNum = $(element).readAttribute('ItemNum');
	var a = document.createElement('img');
	a.setAttribute('src', $('Img'+element.id).src);
	
	$('flyerView').innerHTML='';
	
	if (ItemNum<2){
		a.observe('mouse:leave', function(){window.setTimeout(function(){$('flyerView').shrink({duration: 0.2 ,direction: 'top-left'});}, 250 )});
		a.observe('click', function(){window.setTimeout(function(){$('flyerView').shrink({duration: 0.2 ,direction: 'top-left'});}, 250 )});
	}else{
		a.observe('mouse:leave', function(){window.setTimeout(function(){$('flyerView').shrink({duration: 0.2 ,direction: 'top-right'});}, 250 )});
		a.observe('click', function(){window.setTimeout(function(){$('flyerView').shrink({duration: 0.2 ,direction: 'top-right'});}, 250 )});
	}
	
	//$('flyerView').setStyle({width: 'auto', height: 'auto'});
	var dimensions = a.getDimensions();
	$('flyerView').setStyle({width: a.width, height: a.height});
	
	
	$('flyerView').insert(a);
	//$('flyerView').clonePosition($(a),{setLeft: false, setTop: false});
	
	
	if (ItemNum<2){
		$('flyerView').clonePosition($(element),{setWidth: false, setHeight: false, offsetTop: -1, offsetLeft: -1});
		$('flyerView').grow({duration: 0.2 ,direction: 'top-left'});
	}else{
		$('flyerView').clonePosition($(element),{setWidth: false, setHeight: false, offsetTop: -1, offsetLeft: 189 - a.width});
		//$('flyerView').setStyle({left: $(element).getStyle('Left')+192 });
		$('flyerView').grow({duration: 0.2 ,direction: 'top-right'});
	}
	//queue.each(function(effect) { effect.cancel(); }); 192 - a.getWidth() 
	
	//new Effect.Appear(element,{ queue: { position: 'end', scope: 'sp'+oID,limit: 1 } });
}
	


