// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

// Apply rounded corners
window.onload = function() {
	Nifty("dt.round","big transparent right");
	Nifty("td.round","big transparent right");
	Nifty("div.roundleft", "big transparent left");
	Nifty("div.roundright", "big transparent right");
	Nifty("div#basket_header", "big transparent right");
	Nifty("li.package h2", "big transparent right");
};

if(Prototype.Browser.IE) {
	TopUp.addPresets({
		"#images1 a": {
			fixed: 0,
			modal: 0,
			width: '300px',
			height: '300px',
			group: "images"
		}
	});}
else {
	TopUp.addPresets({
		"#images1 a": {
			fixed: 0,
			modal: 0,
			width: '300px',
			height: '300px',
			group: "images",
			layout: "quicklook"
		}
	});
}

function rebindTopUp() {
	TopUp.rebindTopUp();
}

function copy_checked_products() {
	var checked = $$('.product_check_box').findAll(function(n) { return n.checked; }).pluck('id');
	$('free_sample_product_ids').value = checked;
}

function refresh_calendar() {
	if (typeof(calendar) != "undefined" ) {
		calendar.refresh();
	}
}

Effect.ScrollTo = Class.create();
Object.extend(Object.extend(Effect.ScrollTo.prototype, Effect.Base.prototype), {
	initialize: function(scrollelement, delta_argument, options) {
		this.scrollelement = $(scrollelement);
		this.delta = null;
		this.element = null;
		
		if (typeof delta_argument == 'number')
			this.delta = delta_argument;
		else
			this.element = $(delta_argument);
		
		this.start(options || {});
	},

	setup: function() {
		this.origin = this.scrollelement.scrollLeft;

		if (this.element != null) {
			var destination = this.element.offsetLeft - this.scrollelement.offsetLeft;
			this.delta = destination - this.scrollelement.scrollLeft;

			if (destination > this.scrollelement.style.width.split('px')[0])
				this.delta = this.delta - (this.scrollelement.style.width.split('px')[0] - this.element.style.width.split('px')[0]);
		}
	},

	update: function(position) {
		var offset = position * this.delta;
		this.scrollelement.scrollLeft = this.origin + offset;
	},

	finish: function(position) {
		// call function to hide left and right arrows
	}
});