
//image gallery slider
//russo

var col = 1

function roundUp(num) {

	if (num - Math.round(num, 2) != 0) {
		return ((Math.round(num, 0)) + 1);
	}
	else {
		return num;
	}
}

function slideFolio(direction) {

	//var totalProductsForJS = document.getElementById("<%= hdnTotalImages.ClientID %>");
	var totalProductsForJS = document.getElementById("ctl00_phContent_hdnTotalImages");
	var totalPage;
	var btn_left = document.getElementById("galleryleft");
	var btn_right = document.getElementById("galleryright");
	var btn_left_none = document.getElementById("galleryleft_none");
	var btn_right_none = document.getElementById("galleryright_none");

	//totalPage = roundUp((totalProductsForJS.value / 2) - 2);
	totalPage = roundUp(totalProductsForJS.value / 4);

	//col = col + direction;
	if (direction == 'p' && col > 0) { col = col - 1; }
	if (direction == 'n') { col = col + 1; }

	var x = ((col - 1) * -880);
	var folioChange = new Fx.Style('gallerycontent', 'marginLeft', { duration: 400 });

	folioChange.start(x);

	if (col > 1 || col <= totalPage) {
		btn_left.style.display = "block";
		btn_right.style.display = "block";
		btn_left_none.style.display = "none";
		btn_right_none.style.display = "none";
	}

	if (col == 1) {
		btn_left.style.display = "none";
		btn_left_none.style.display = "block";
	}

	if (col == totalPage) {
		btn_right.style.display = "none";
		btn_right_none.style.display = "block";
	}
}

window.addEvent("load", function() {

	//$(document).ready(function() {

	//var totalProductsForJS = document.getElementById("<%= hdnTotalImages.ClientID %>")
	var totalProductsForJS = document.getElementById("ctl00_phContent_hdnTotalImages");

	if ((totalProductsForJS.value / 4) <= 1) {
		$('galleryleft').setStyle('display', 'none');
		$('galleryright').setStyle('display', 'none');
		$('galleryleft_none').setStyle('display', 'block');
		$('galleryright_none').setStyle('display', 'block');
	}

	else {
		$('galleryleft').setStyle('display', 'none');
		$('galleryright').setStyle('display', 'block');
		$('galleryleft_none').setStyle('display', 'block');
		$('galleryright_none').setStyle('display', 'none');
	}

});
