var lastId = 0;
var product_id = 0;
var pWidth = 0;
var pHeight = 0;
var temp;
var plus = 0;

$(document).ready(function(){

	Shadowbox.init({
		players:    ["img", "iframe"]
	});


	if (navigator.appName != 'Netscape')
		plus = 4;

	$(".product").hover(function() {
	
		product_id = $(this).attr('id');
		temp = product_id.split("_");
		product_id = temp[1];

		/*if (product_id != lastId) {
			//pWidth = parseInt($(this).find('img').css('width'));
			//pHeight = parseInt($(this).find('img').css('height'));
			pWidth = ($(this).find('img')).width();
			pHeight = ($(this).find('img')).height();
		} else {
			//lastId = 0;
			return;
		}*/
		
		pWidth = ($(this).find('img')).width()+plus;
		pHeight = ($(this).find('img')).height()+plus;

		changeBoxContent();

		$(this).css({'z-index' : '10' , 'width' : $(this).width()+"px"});
		$(this).find('img').addClass("product-hover").stop()
			.animate({
				//marginTop: '-100px', 
				//marginLeft: '-75px', 
				top: '-10%', 
				left: '-10%', 
				width: pWidth*1.15+'px', 
				height: pHeight*1.15+'px',
				padding: '5%'
			}, 200);
		
		} , function() {
		$(this).css({'z-index' : '0'});
		/*$(this).find('img').removeClass("product-hover").stop()
			.animate({
				//marginTop: '0', 
				//marginLeft: '0',
				top: '-5px', 
				left: '-5px', 
				width: pWidth+'px', 
				height: pHeight+'px', 
				padding: '5px'
			}, 200);*/
		$(this).find('img').removeClass("product-hover").stop().attr('style', '');
			
	});

	
 
});

function changeBoxContent() {
	
		/*$('#product-content-'+lastId).animate({ color : '#ffffff' }, 500);
		$('#product-content-'+lastId).css('display' , 'none');
	
		$('#product-content-'+product_id).css({'color' : '#ffffff', 'display' : 'block'});
		$('#product-content-'+product_id).animate({ color : '#000000' }, 500);*/
		
		$('#product-content-'+lastId).css('display' , 'none');
		$('#product-content-'+product_id).css('display' , 'block');
		
		lastId = product_id;
	
}

/*$(document).ready(function(){

	$(".product").bind("mouseenter", function(e){
	
		obj = $(this).find('img');

		product_id = $(obj).attr('id');
		
		if (product_id != lastId && product_id > 0) {
		
			// Change back last element
			reset();
		
			// Change this element
			change();
			
			// Change content in box
			changeBoxContent();
			
			// Set last element to this
			lastId = product_id;
		
		}
		
	});
	
	$(".product").bind("mouseleave", function(e){

			reset();
		
	});

});

function change() {

	width = parseInt($(obj).css('width'))*1.2;
	height = parseInt($(obj).css('height'))*1.2;
	$(obj).css({'width' : width+"px",
				'height' : height+"px",
				'z-index' : "10",
				'border' : "1px solid",
				'border-color' : "#ccc",
				'bottom' :  height/6+"px"});
						
}

function reset() {

	if (product_id != lastId && product_id > 0) {
		// Change back last element
		width = parseInt($('#'+lastId).css('width'))/1.25;
		height = parseInt($('#'+lastId).css('height'))/1.25;
		$('#'+lastId).css({	'width' : width+"px",
							'height' : height+"px",
							'z-index' : "1",
							'border' : "0",
							'bottom' :  "0px"});
	}
						
}*/