/*
 * jQuery Ex_Img
 * Author: Osiris Ltd
 * http://osiris-studio.org
 * osiris-studio@mail.ru
 * tel. +7 (351) 248-57-57
 * Released under GPL licenses.
 */

var ex_img_h = Array(), ex_img_w = Array();			

function intval( mixed_var, base ) {    // Get the integer value of a variable
	// 
	// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
 
	var tmp;
 
	if( typeof( mixed_var ) == 'string' ){
		tmp = parseInt(mixed_var);
		if(isNaN(tmp)){
			return 0;
		} else{
			return tmp.toString(base || 10);
		}
	} else if( typeof( mixed_var ) == 'number' ){
		return Math.floor(mixed_var);
	} else{
		return 0;
	}
}

function ex_img_in(o, k, k2, op, t1, t2)
{
		k = k || 1;
		k2 = k2 || k;
		op = op || 1;
		t1 = t1 || 500;
		t2 = t2 || 200;
		
		$(o).stop();
		
		if ($(o).attr('exwidth') == null)
		{
		    $(o).attr('exwidth', intval($(o).css('width')) );
		    $(o).attr('exheight', intval($(o).css('height')) );
		    
		    ///alert( $(o).attr('exwidth') + ', ' + $(o).attr('exheight') );
		}
		
		w = $(o).attr('exwidth');
		h = $(o).attr('exheight');
		//if (ex_img_h[o] == null)
		//{
			//ex_img_h[o] = intval($(o).css('height'));
			//ex_img_w[o] = intval($(o).css('width'));
		//}

		$(o).animate({opacity: op, height : h * k, width : w * k}, t1).animate({height : h * k2, width : w * k2}, t2);
}

function ex_img_out(o, k1, op, t1, t2)
{
		k1 = k1 || 1;
		op = op || 1;
		t1 = t1 || 300;
		t2 = t2 || 300;
		
		$(o).stop();

		if ($(o).attr('exwidth') == null) return;
				
		w = $(o).attr('exwidth');
		h = $(o).attr('exheight');

		$(o).animate({opacity: op, height : h * k1, width : w * k1}, t1).animate({height : h, width : w}, t2);
}

