rising = {
	
	get: function(obj, optional) {
		
		if (!optional) optional = {}
		
		getElementPosition(obj)
		
		if (!$('p_'+obj.rel.replace(/\//g,'_')))
			{
			nImg = document.createElement('img');
			nImg.loaded = false;
			
			if (optional.className)
				nImg.className = optional.className;
				
			
			
			nImg.id = 'p_'+obj.rel.replace(/\//g,'_');
			nImg.src = obj.rel;
			nImg.style.position = 'absolute';
			nImg.style.top = '-2000px';
			nImg.style.left = '-2000px';
			nImg.style.zIndex = '1000';
			nImg.style.boxShadow = '0 0 10px #000';
			nImg.style.MozBoxShadow = '0 0 10px #000';
			nImg.style.WebkitBoxShadow = '0 0 10px #000';
//			nImg.style.filter = 'progid:DXImageTransform.Microsoft.dropShadow(color=#000, offX=0, offY=0);'
			nImg.style.visibility = 'hidden';
			nImg.style.cursor = 'pointer';
			nImg.onclick = function() { if (this.working) return; this.oot = this.offsetTop; this.ool = this.offsetLeft; this.timer = setInterval(function() { rising.close($('p_'+obj.rel.replace(/\//g,'_'))) }, 15) }
			document.getElementsByTagName('body')[0].appendChild(nImg);
			}	
		
		if ($('p_'+obj.rel.replace(/\//g,'_')).loaded)
			{
			$('p_'+obj.rel.replace(/\//g,'_')).style.top = obj.t + 'px';
			$('p_'+obj.rel.replace(/\//g,'_')).style.left = obj.l + 'px';
	
			$('p_'+obj.rel.replace(/\//g,'_')).ot = parseInt($('p_'+obj.rel.replace(/\//g,'_')).style.top);
			$('p_'+obj.rel.replace(/\//g,'_')).ol = parseInt($('p_'+obj.rel.replace(/\//g,'_')).style.left);
			}
			
		$('p_'+obj.rel.replace(/\//g,'_')).parentImg = obj
		$('p_'+obj.rel.replace(/\//g,'_')).t = 0;
		
		$('p_'+obj.rel.replace(/\//g,'_')).h = obj.offsetHeight;
		$('p_'+obj.rel.replace(/\//g,'_')).w = obj.offsetWidth;
		
		
		
		$('p_'+obj.rel.replace(/\//g,'_')).style.display = 'block';
		
		
		if (!$('p_'+obj.rel.replace(/\//g,'_')).loaded)
			{
			if (optional.preLoadFunction) optional.preLoadFunction();
			$('p_'+obj.rel.replace(/\//g,'_')).onload = function() {
							$('p_'+obj.rel.replace(/\//g,'_')).loaded = true;
							if (optional.onLoadFunction) 
								{
								optional.onLoadFunction();
								}
								
								if (!$('p_'+obj.rel.replace(/\//g,'_')).realWidth)
									{
									$('p_'+obj.rel.replace(/\//g,'_')).realWidth = nImg.offsetWidth;
									$('p_'+obj.rel.replace(/\//g,'_')).realHeight = nImg.offsetHeight;
									}
								
								$('p_'+obj.rel.replace(/\//g,'_')).style.top = obj.t + 'px';
								$('p_'+obj.rel.replace(/\//g,'_')).style.left = obj.l + 'px';

								$('p_'+obj.rel.replace(/\//g,'_')).ot = parseInt($('p_'+obj.rel.replace(/\//g,'_')).style.top);
								$('p_'+obj.rel.replace(/\//g,'_')).ol = parseInt($('p_'+obj.rel.replace(/\//g,'_')).style.left);
								
								$('p_'+obj.rel.replace(/\//g,'_')).style.width = obj.offsetWidth + 'px';
								$('p_'+obj.rel.replace(/\//g,'_')).style.height = obj.offsetHeight + 'px';
								
								$('p_'+obj.rel.replace(/\//g,'_')).style.visibility = 'visible';
								//nImg.style.display = 'none';
								
								$('p_'+obj.rel.replace(/\//g,'_')).timer = setInterval(function() { rising.open($('p_'+obj.rel.replace(/\//g,'_'))) }, 15) 
							}
			}
		else
			{
			$('p_'+obj.rel.replace(/\//g,'_')).style.height = obj.offsetHeight + 'px';
			$('p_'+obj.rel.replace(/\//g,'_')).style.width = obj.offsetWidth + 'px';
			$('p_'+obj.rel.replace(/\//g,'_')).timer = setInterval(function() { rising.open($('p_'+obj.rel.replace(/\//g,'_'))) }, 15)
			}
			
		if (optional.styles)
			{
			for (prop in optional.styles)
			    {
			    nImg.style[prop] = optional.styles[prop];
			    }
			}
		
		return false;
	},
	
	open: function(obj) {
		obj.working = true;
		
		obj.t++;
		obj.style.width = parseInt(Linear(obj.t, obj.w, obj.realWidth-obj.w, 10)) + 'px';
		obj.style.height = parseInt(Linear(obj.t, obj.h, obj.realHeight-obj.h, 10)) + 'px';
		
		if (parseInt(obj.style.top) <= 20)
			obj.style.top = '20px';
		else
			obj.style.top = parseInt(Linear(obj.t, obj.ot, -(obj.realHeight/2 - obj.parentImg.offsetHeight/2), 10)) + 'px';
			
		if (parseInt(obj.style.left) <= 20)
			obj.style.left = '20px';
		else
			obj.style.left = parseInt(Linear(obj.t, obj.ol, -(obj.realWidth/2 - obj.parentImg.offsetWidth/2), 10)) + 'px';
		
		if ((parseInt(obj.style.left)+obj.offsetWidth) >= document.getElementsByTagName('body')[0].offsetWidth - 20)
			{
			obj.style.left = 'auto';
			obj.style.right = '20px';
			}
		else
			{
			obj.style.right = 'auto';
			}
	
		if (obj.t == 10)
			{
			clearInterval(obj.timer);
			obj.working = false;
			obj.t = 0;
			obj.style.width = obj.realWidth + 'px';
			obj.style.height = obj.realHeight + 'px';
			}
		
	},
	
	close: function(obj) {
		obj.t++;
		obj.working = true;
		obj.style.width = parseInt(Linear(obj.t, obj.realWidth, obj.w-obj.realWidth, 10)) + 'px';
		obj.style.height = parseInt(Linear(obj.t, obj.realHeight, obj.h-obj.realHeight, 10)) + 'px';

		obj.style.top = parseInt(Linear(obj.t, obj.oot, obj.ot - obj.oot, 10)) + 'px';
		
		if (parseInt(obj.style.top) <= 20)
			obj.style.top = '20px';
		
		obj.style.left = parseInt(Linear(obj.t, obj.ool, obj.ol - obj.ool, 10)) + 'px';
		
		if (parseInt(obj.style.left) <= 20)
			obj.style.left = '20px';
		
		if ((parseInt(obj.style.left)+obj.offsetWidth) >= document.getElementsByTagName('body')[0].offsetWidth - 20)
			{
			obj.style.left = 'auto';
			obj.style.right = '20px';
			}
		else
			{
			obj.style.right = 'auto';
			}
		
		if (obj.t == 10)
			{
			clearInterval(obj.timer);
			obj.timer = null
			obj.working = false;
			obj.t = 0
			obj.style.display = 'none';
			obj.style.width = obj.w + 'px';
			obj.style.height = obj.h + 'px';
			}
	}
}

function getElementPosition(obj)
		{
		var elem = obj

    	var l = 0;
    	var t = 0;

    	while (elem)
	   		{
	       	l += elem.offsetLeft;
	      	t += elem.offsetTop;
	     	elem = elem.offsetParent;
	   		}
	   	obj.l = l;
	   	obj.t = t;
		}
		
Linear = function (t, b, c, d) {
			return c*t/d + b;
	}
