/* ====================================================
   Author  : webmaster of Kohrong-island.com
   Created : 14/10/2008
   Email : admin@kohrong-island.com
   You have right to use the program of lightbox freely

you need :
==========
javascript file : lightbox_kohrong.js
css file 	: lightbox_kohrong.css
html file	:

1/ Initialize the lightBox parameter

	<body onload="init_lightbox()">

2/ add start_animation function

	<a href="javascript:start_animation()">
	<img src="...mini" border="no" />
	</a>

3/ Create two layers

	<div id="lb"></div>
	<div id="lb_img"><img src="...zoom" id="image" onclick="closeimage()" /></div>

   ==================================================== */

idtime = null ;
opacite = 0 ;
opacite_img = 0.5 ;

y = 0 ;  	// Height of window
l = 0 ;		// Width of window
yima = 0 ;  	// Height of zoom image 
lima = 0 ;	// Width of zoom image

function animation_opacity(popacity,pid,pidimg){
// pid : layer black
// pidimg : layer for zoom image
	
    _id = document.getElementById(pid);   
    _idimg = document.getElementById(pidimg);   
    opacite = opacite + 0.05 ;
    opacite_img = opacite_img + 0.05 ;
    _id.style.MozOpacity=opacite ;
    _idimg.style.MozOpacity=opacite_img ;

    if(opacite>popacity){
	clearTimeout(idtime);
    }
    else{
	idtime = setTimeout("animation_opacity(0.7,'lb','lb_img')",2);
	window.status = opacite ;
	}
}

function start_animation(){

	_idima = document.getElementById('lb_img');
	_ima = document.getElementById('image');
	yima = _ima.height ;
	lima = _ima.width ;	
	_ima.style.top = parseInt((y-yima)/2,10);
	_ima.style.left = parseInt((l-lima)/2,10);
	_idima.style.visibility="visible";

	_ima.style.position = "absolute" ;
	document.getElementById('lb').style.visibility="visible";
        idtime =  setTimeout("animation_opacity(0.7,'lb','lb_img')",2);

}

function closeimage(){
	_lb = document.getElementById('lb') ;	
	_lb.style.visibility='hidden';
	_lb.style.MozOpacity = 0 ;

	_lb_img = document.getElementById('lb_img')
	_lb_img.style.visibility='hidden';
	_lb_img.style.MozOpacity = 0 ;

	idtime = null ;
	opacite = 0 ;
	opacite_img = 0.5 ;
	yima = 0 ;
	lima = 0 ;
}

function init_lightbox(){
	y=document.body.clientHeight;
	l=document.body.clientWidth;
}


