// JavaScript Document

 var isNS = (navigator.appName == "Netscape") ? 1 : 0;
  if(navigator.appName == "Netscape") document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);
  function mischandler(){
   return false;
 }
  function mousehandler(e){
 	var myevent = (isNS) ? e : event;
 	var eventbutton = (isNS) ? myevent.which : myevent.button;
    if((eventbutton==2)||(eventbutton==3)) return false;
 }
 document.oncontextmenu = mischandler;
 document.onmousedown = mousehandler;
 document.onmouseup = mousehandler;

function showItem(num)
{
	var ancho = 900;
	var alto  = 460;
	var BodySize = window.getScrollSize();
	var posScroll = window.getScroll();
	var winAvailableSize = window.getSize();
	
	var shadow	= $('shadow');
	var win	= $('win');
	var winContent	= $('wincontent');		
	var winCaption	= $('wincaption');
	shadow.style.display='block';
	shadow.style.height=BodySize.y+'px';
	shadow.style.width=BodySize.x+'px';
	
	var myFx = new Fx.Tween( shadow, {'duration': 300});
	myFx.start('opacity',0,0.8);
	
	win.style.display = 'block';
	win.style.width = 1+'px';
	win.style.height = 20+'px';
	win.style.left = ( winAvailableSize.x/2)+'px';
	win.style.marginLeft = -(ancho/2)+'px';
	win.style.top = ( posScroll.y + ( winAvailableSize.y/2) - (alto/2)-15) +'px';		
	
	win.set('opacity',1);
	winContent.set('opacity',0); 
	
	$('winbody').innerHTML="";
	
	var myFx2 = new Fx.Tween( win, {'duration': 700});
	myFx2.start('width',4,ancho);
	myFx2.addEvent('complete', function(){
		var myFx3 = new Fx.Tween( win, {'duration': 700});
		myFx3.start('height',4,alto+30);
		myFx3.addEvent('complete', function(){
			winContent.setStyle('opacity', 0);
			winContent.setStyle('display', 'block');
			var myFx4 = new Fx.Tween( winContent,{'duration': 600});
			myFx4.start('opacity',0,1);
			myFx4.addEvent('complete', function(){
				//$('winbody').innerHTML = "Cargando...";
				var req = new Request({
					url: 'itemrequest.php?iditem='+ids[num]+'&itemnum='+num+'&total='+nitems,
					onSuccess: function(txt){
						$('winbody').set('html', txt);
						}
					});
				req.send();
			}); 
		});
	});
}


function nextItem( num ){
	//$('winbody').innerHTML = "Cargando...";
	var req = new Request({
		url: 'itemrequest.php?iditem='+ids[num]+'&itemnum='+num+'&total='+nitems,
		onSuccess: function(txt){
			$('winbody').set('html', txt);
		}
	});
	req.send();
}

window.addEvent("domready", function(){						 
	if (showinimessage){
		inimsg();
	}
	
	$("design").addEvent("click", function(e){
		e.stop();
		MiPopup( 400, 400 );
	});
	$('shadow').addEvent('click', function(){
		cerrar();
	});

});


function showNextItem( iditem, prev, next ){
	$('winbody').innerHTML = "Cargando...";
	var req = new Request({
		url: 'itemrequest9.php?iditem='+iditem+'&prev='+prev+'&next'+next,
		onSuccess: function(txt){
			$('winbody').set('html', txt);
			}
		});
	req.send();
}
function displayimage( num, source ){
	var nimg = $('n_images').value;
	for(i=1; i<=nimg; i++){
		if(num==i){ $('imgbullet'+i).set('class',"sel");}
		else { $('imgbullet'+i).set('class',"x");}
	}
	$('itemmainimg').src = source;
}
function cerrar(){
	//alert('close');
	var myFx = new Fx.Tween($('win'),{'duration': 500});
	myFx.start('opacity',1,0);
	myFx.addEvent('complete', function(){
		var myFx2 = new Fx.Tween( $('shadow'),{'duration': 500});
		myFx2.start('opacity',0.8,0);
		myFx2.addEvent('complete', function(){
			$('win').style.display='none';
			$('shadow').style.display='none';
			$('initmsg').style.display='none';
		});
	});
}




function inimsg(){
	var BodySize = window.getScrollSize();
	var shadow	= $('shadow');
	shadow.style.display='block';
	shadow.style.height=BodySize.y+'px';
	shadow.style.width=BodySize.x+'px';
	var myFx = new Fx.Tween( shadow, {'duration': 300});
	myFx.start('opacity',0,0.8);
	
	var ini	= $('initmsg');
	ini.style.display='block';
	ini.style.top = '100px';
	ini.style.left = ((BodySize.x / 2) -300 ) + 'px';
	var myFx2 = new Fx.Tween( ini, {'duration': 600});
	myFx2.start('opacity',0,1);
}
