function init() {
var a = document.getElementById('img_small');
a.style.opacity=0;
a.style.filter = "alpha(opacity=0)";
a.style.display='block';
}

var z_factor=2;

var lock=0;
var zoomed=0;
var max_w='';
var current_img='';
var opac=0;
var move='';

function fadein(id) {

l=document.getElementById(id);
l.style.display='block';

if ( opac < 1.1 ) {

 	opac=opac+.05;
	l.style.opacity=opac;
	l.style.filter = "alpha(opacity=" + (opac*100) + ")";
  	timeo = setTimeout('fadein("'+id+'")',20);
	}

else {
  if (timeo) clearTimeout(timeo);

    }

}

function  move_left(id) {

l=document.getElementById(id);
f= document.getElementById('frame');

limit = 10-l.width  + parseInt(f.style.width) ;

if ( DomUtils.getX(l) > limit ) {

	l.style.left=DomUtils.getX(l)-10+'px';
	move = setTimeout('move_left("'+id+'")',50);
	}
else
	kill_move();

}


function  move_right(id) {

l=document.getElementById(id);
limit = -10 - l.offsetLeft ;

if ( l.offsetLeft < limit ) {
	l.style.left=l.offsetLeft+10+'px';
	move = setTimeout('move_right("'+id+'")',50);
}
else
	kill_move();

}


function  move_up(id) {

l=document.getElementById(id);
f= document.getElementById('frame');

limit = 10 - l.height + parseInt(f.style.height); ;

if ( l.offsetTop > limit ) {
	l.style.top=l.offsetTop-10+'px';
	move = setTimeout('move_up("'+id+'")',50);
	}
else
	kill_move();


}


function  move_down(id) {

l=document.getElementById(id);
limit =  -10 -l.offsetTop;

if ( l.offsetTop < limit ) {
	l.style.top=l.offsetTop+10+'px';
	move = setTimeout('move_down("'+id+'")',50);
	}
else
	kill_move();


}


function kill_move() {
 if (move) clearTimeout(move);

}




function  gal(i) {

current_img = i;
document.getElementById('frame').style.display='block';
document.getElementById('nav').style.display='none';

l=document.getElementById('img_small');


 l.src=images[i];

 opac=0;
 l.style.width='';
 l.style.height=document.getElementById('frame').style.height;
 
 l.style.top=0;
 l.style.left=0;
 l.style.position='relative';
 l.style.margin='auto';
 l.style.opacity=0;
 l.style.filter = "alpha(opacity=0)";
 max_w='';
 	zoomed = 0;
fadein('img_small');

}





function mm(evt) {

if ( !zoomed ) {
 			image = document.getElementById('img_small');
			c = document.getElementById("frame");
			image_width = image.width; 
			if(DomUtils.getWidth(c)>image_width) 
			abs_x  = (DomUtils.getWidth(c)-image_width)/2;
			else
			abs_x  = 0;

			image.style.position='absolute';	
			DomUtils.setX(image,abs_x);
			DomUtils.setWidth(image,image_width);


			evt = new Evt(evt);

			if ( !max_w ) {

			max_w=DomUtils.getWidth(image)*z_factor;

			
		
		xPos = c.offsetLeft;
		xtempEl = c.offsetParent;
		while (xtempEl != null) {
  			xPos += xtempEl.offsetLeft;
	  		xtempEl = xtempEl.offsetParent;
  		}

		yPos = c.offsetTop;
		tempEl = c.offsetParent;
		while (tempEl != null) {
  			yPos += tempEl.offsetTop;
	  		tempEl = tempEl.offsetParent;
  		}
			
			
			var xm = ( evt.getX()-xPos-abs_x )/DomUtils.getWidth(image);
			var ym = ( evt.getY()-yPos )/DomUtils.getHeight(image);
		
			
			zoom(xm,ym) 	;
			document.getElementById('nav').style.display='block';
			}
	}
	zoomed = 1;
}


	
		
		function zoom(xm,ym) {
		
			image = document.getElementById("img_small");

		    var actualWidth = DomUtils.getWidth(image);
			
			var actualHeight = DomUtils.getHeight(image);		
			var ratio = 1/0.9;
			var x = DomUtils.getX(image);
			var y = DomUtils.getY(image);
			var w = DomUtils.getWidth(image);
			var h = DomUtils.getHeight(image);
			var newW = w*ratio;
			var newH = h*ratio;
			x = x +  (w-newW)*xm  ;
			y = y + (h-newH)*ym ;
		
		
	
	if ( w < max_w) {	
			DomUtils.setX(image,x);
			DomUtils.setY(image,y);
			DomUtils.setWidth(image,newW);
			DomUtils.setHeight(image,newH);

			setTimeout('zoom('+xm+','+ym+')',25);
		}	
		}


function WindowOnload(f) {
    var prev=window.onload;
    window.onload=function(){ if(prev)prev(); f(); }
  }

WindowOnload(init);


function validate_newsletter() {

if ( document.getElementById('your_name').value.length < 2 ) {
    alert("Please provide a real name");
    return false;
    }

if (document.forms[0].your_email.value.indexOf('@')==-1  || document.forms[0].your_email.value.indexOf('.')==-1  || document.forms[0].your_email.value.length <= 7 )
    {
    alert("Please provide your email");
    return false;
    }
 return true;
}
