$(document).ready(function (){

});

function assignControlls(parent){
	/*---TIPS---*/
	var price_tip=$(document.createElement('div')).attr('id', 'price_tip').css({display: 'none', position: 'absolute'});
	$('body').append(price_tip);
	/*parent.find('.scroller ul li').mousemove(function (e){

		var x = e.pageX - $(this).offset().left;
		var y = e.pageY - $(this).offset().top;
		$(price)
  		$(this).find("#price").css({top: y, left: (x+10)});
	});*/
	parent.mousemove(function (e){

		var x = e.pageX;// - $(this).offset().left;
		var y = e.pageY;// - $(this).offset().top;
		price_tip.css({top: y, left: (x+10)});
	});

    parent.find('.scroller ul li').hover(
    	function (){
    		if ($(this).find("#price").get(0).innerHTML!=''){
    			price_tip.html($(this).find("#price").html());
	    		price_tip.css('display', 'block');//fadeIn('normal');
    		}

    	},
    	function (e){
    		price_tip.css({display: 'none'});

    	}
    );
    /*----------*/
	/*var chil = 	parent.find('.scroller ul').children().size();
   	var ul_width=0;
	parent.find('.scroller ul li').each(function(){
		var ml = $(this).css('margin-left');
		var mr = $(this).css('margin-right');
		ml = parseInt(ml.replace('px', ''));
		mr = parseInt(mr.replace('px', ''));
        ul_width+=$(this).width()+ml+mr;

	});
	parent.find('.scroller ul').width(ul_width);*/
	parent.find('.scroller ul').css('left',  '0');
	var ul_width = parent.find('.scroller ul').width();
//	parent.find('.scroller ul').width(chil*180);
	var d = parent.find('.scroller').width() - parent.find('.scroller ul').width();
	if (ul_width > parent.find('.scroller').width()){
		parent.find('.scroll-right').hover(function (){
			var distance = parent.find('.scroller ul').css('left');
			distance = parseInt(distance.replace('px', ''));
			distance-= d;
			var duration = distance * 5;

			parent.find('.scroller ul').animate({ 'left' : +  d + 'px' }, duration, 'linear');
		}, function (){
    	    parent.find('.scroller ul').stop();
		});

		parent.find('.scroll-left').hover(function (){
			var distance = parent.find('.scroller ul').css('left');
			distance = parseInt(distance.replace('px', ''));
			distance= -distance;
			duration = distance * 5;

			parent.find('.scroller ul').animate({ 'left' : +  0 + 'px' }, duration, 'linear');
		}, function (){
        	parent.find('.scroller ul').stop();
		});
	}

}


