$(document).ready(function(){

	if (typeof search_st != "undefined") {
		var search_start = search_st - 1;
	} else {
		var search_start = 0;
	}

	if (typeof search_count != "undefined") {
		if (search_count <= 2) { 
			$("#last_search .box_next img").attr("src", "images/arrow_next_off.gif");
			$("#last_search .box_next img").css({ cursor: "default"});
		}
		if (search_count > 1) {
			if (search_start == search_count-1) {
				var search_start = search_start - 1;
			} else {
				var search_start = search_start;
			}
		}
		if (search_start == 0) {
			$("#last_search .box_prev img").attr("src", "images/arrow_prev_off.gif");
			$("#last_search .box_prev img").css({ cursor: "default"});
		}
	}
	
	if (typeof fittings_count != "undefined") {
		if (fittings_count <= 2) { 
			$("#fittings .box_next img").attr("src", "images/arrow_next_off.gif");
			$("#fittings .box_next img").css({ cursor: "default"});
		}
	}
//	$("#last_search .box_prev img").css({ cursor: "default"});
//	$("#fittings .box_prev img").css({ cursor: "default"});
	
	function change_buttons(button_prev, button_next, counter, array) {
		var first = array[0].id.substring(1,(array[0].id.length));
		var end = array[1].id.substring(1,(array[1].id.length));
		if (first > 1) {
			$(button_prev+" img").attr("src", "images/arrow_prev.gif");
			$(button_prev+" img").css({ cursor: "pointer"});
		} else {
			$(button_prev+" img").attr("src", "images/arrow_prev_off.gif");
			$(button_prev+" img").css({ cursor: "default"});
		}					
		if (end < counter) {
			$(button_next+" img").attr("src", "images/arrow_next.gif");
			$(button_next+" img").css({ cursor: "pointer"});
		} else {
			$(button_next+" img").attr("src", "images/arrow_next_off.gif");
			$(button_next+" img").css({ cursor: "default"});
		}
	}
	$("#box_fittings").jCarouselLite({
		btnNext: "#fittings .box_next",
		btnPrev: "#fittings .box_prev",
		visible: 3,
		easing: "easeinout",
		speed: 1000,
		scroll: 3,
		circular: true,
		afterEnd: function(a) {
			change_buttons('#fittings .box_prev', '#fittings .box_next', fittings_count, a);
		}
	});					

});
var firstTime = true;

function thisMovie(movieName) 
{
	return ($.browser.msie) ? window[movieName] : document[movieName];
}
function getOffset(o) {
    var top = 0, left = 0;

	while (o.offsetParent) {
        top += o.offsetTop  || 0;
        left += o.offsetLeft || 0;
        o = o.offsetParent;
    };

	return [left, top];
//	return [o.offsetTop, o.offsetLeft]
}

