$(document).ready(function(){

	var smalPict = new Array();
	var ind      = 0;
	var flag     = 0;

	$('.content').find('a').each( function() {
		if ( $(this).attr('rel') != "" ) {
			smalPict.push( $(this).attr('rel') );
		}
	});

	$('.product-photo:first').attr('style', 'position: relative; display: block;');
	
	function animat(){


		if ( flag == 0 ) {
			if ( ind == smalPict.length ) {
				ind = 0;
			}
	                $('#puper').attr('src', "/netcat/timthumb.php?src=" + smalPict[ind] + "&w=151&h=90" );

			
			ind++;
        	}


		current_id='#'+$('.main-photos .product-photo:visible').attr('id');
		next_id='#'+$('.main-photos .product-photo:visible').next('.product-photo').attr('id');

		if($(current_id).is(':last-child')){
			next_id='#'+$('.main-photos .product-photo:first-child').attr('id');
		}

		if ( $(document).find( next_id ).length != 0 ) {
		
			$(current_id).css('position','absolute');
			$(next_id).css('position','relative');

			$('.main-photos .product-photo').fadeOut(500,function(){$('.main-photos .product-photo .price').hide();});
			$(next_id).fadeIn(500,function(){$(next_id+' .price').show();});

			var s = $(next_id).find('.myPrice');
                        if ( $(s).html() == '' ) {
				$(s).parent().parent().hide();
			}
		}
	}

	var intervalID = setInterval(animat, 5000);

	$('.menu a').hover(
		function(){
			if ( $(this).attr('rel') != '' ) {
				flag = 1;
				$('#puper').attr( 'src', "/netcat/timthumb.php?src=" + $(this).attr('rel') +"&w=151&h=90" );
			}
		},
		function(){
			if($(this).attr('rel')!=''){
				flag = 0;
			}
		}
	);
});
