//last_prod

jQuery.noConflict();

jQuery(document).ready(function() {

	  

		var prevText =  		"Previous";

		var prevId_last = 		"lastprod_prevBtn";

		var nextId_last =		"lastprod_nextBtn";	

		orientation_last=	orientation_last;

		var nextText = 		"Next";

		var speed_last = 			800;

		

			var obj_slide = jQuery("#vm_lastprod_slider");

			var s = jQuery("li", obj_slide).length;

			/*if(display_styles =="table"){

				s = ul_width;

			}

			*/

			var w_li = jQuery("li", obj_slide).width();

			var h_li = jQuery("li", obj_slide).height();

			var w = obj_slide.width(); 

			var h = obj_slide.height(); 

			var ts = s-num_per_slide_last;

			var t = 0;

			var f = 0;

			var vertical = ( orientation_last == 'vertical');

			//jQuery("ul", obj_slide).css('width',s*w);

			if(!vertical){

				jQuery("li", obj_slide).css('float','left');

				//jQuery("ul", obj_slide).css('width',s*w_li);

				jQuery("ul", obj_slide).css('width',s*w_li);

			}else{

				jQuery("li", obj_slide).css('clear','both');

				jQuery("ul", obj_slide).css('width',s*h_li);

			}

			

			jQuery('#lastprod_slider_pagination').html('<div class="pagination_button" style="float:right;"><span id="'+  prevId_last +'"><a href=\"javascript:void(0);\">'+  prevText +'</a></span> <span id="'+  nextId_last +'"><a href=\"javascript:void(0);\">'+  nextText +'</a></span></div>');	

			jQuery("a","#"+ prevId_last).hide();

			jQuery("a","#"+ nextId_last).hide();

			jQuery("a","#"+ nextId_last).click(function(){

				if(!vertical) {

					//p = (t*w*-1);

					t = (t>=ts) ? ts : t+num_per_slide_last;

					f = (f>=ts) ? ts : f+1;

					p = (f*num_per_slide_last*w_li*-1);

					//alert(p);

					if(p <= (-1*w_li*s + num_per_slide_last*w_li)){
						p = (-1*w_li*s + num_per_slide_last*w_li);
					}
					
					tmp = p;

					if(isIE6()){

						p = Math.floor(p/2);

					}

					jQuery("ul",obj_slide).animate(

						{ marginLeft: p },

						  speed_last

					);

				}else {

					p = (t*h_li*-1);

					//jQuery("ul",obj_slide).animate( 'margin-top', p);

					jQuery("ul",obj_slide).animate(

						{ marginTop: p },

						  speed_last

					);

						//options.speed			

				}				

				//--------------		

				//alert(t);

				if (t>=ts) { jQuery(this).fadeOut();
				}
				jQuery("a","#"+ prevId_last).fadeIn();

			});

			jQuery("a","#"+ prevId_last).click(function(){		

				//animate("prev",t,ts,options,h_li);

				t = (t<=0) ? 0 : t-num_per_slide_last;

				f = (f<=0) ? 0 : f-1;

				if(!vertical) {

					//p = (t*w*-1);
/*
					if(!tmp) {
						tmp = 0;
					}
					alert(tmp);
*/					
					p = (f*num_per_slide_last*w_li*-1);

					if(p <= (tmp + num_per_slide_last*w_li)){

						p = (tmp + num_per_slide_last*w_li);

						//alert(p);

					}

					if(isIE6()){

						p = Math.floor(p/2);

					}

					if( p>0 ){

						p = 0;

					}

					jQuery("ul",obj_slide).animate(

						{ marginLeft: p },

						  speed_last

					);	

				} else {

					p = (t*h_li*-1);

					jQuery("ul",obj_slide).animate(

						{ marginTop: p },

						  speed_last

					);				

				}

				//----------------------------

				

				if (t<=0){ jQuery(this).fadeOut();
				}
				jQuery("a","#"+ nextId_last).fadeIn();

			});	

	

			if(s>1) jQuery("a","#"+ nextId_last).fadeIn();	

//		});

	  

//	};

	

});



