// prise_js_productslide.js -- PRISE JavaScript - Product Slide
// Copyright (C) 2007-2011 by Manfred Baumeister, Dublin, Ireland

var __slide_boxwidth = 145;

function slide_setboxwidth(w)
{
	__slide_boxwidth = w;
}
function slide_getboxwidth()
{
	if (__slide_boxwidth == null)
	{
		__slide_boxwidth = 145;
	}
	return __slide_boxwidth;
}

function xGetElementsByClassNameCount(obj, className, tagName)
{
	var slash = String.fromCharCode(92);
	var re = new RegExp(slash + "b" + className + slash + "b");
	if (!obj)
	{
		obj = document;
	}
	if (!tagName)
	{
		tagName = '*';
	}
	var found = [];
	var elements = obj.getElementsByTagName(tagName);
	if (elements)
	{
		for (var i = 0; i < elements.length; ++i)
		{
			if (elements[i].className.search(re) != -1)
			{
				found[found.length] = elements[i];
			}
		}
	}
	return found.length;
}
function slide_boxcount(obj)
{
	return xGetElementsByClassNameCount(obj, "slide_box", "DIV");
}
function slide_prev(id)
{
	var slide		= bmeDOM_getObject(id);
	if (parseInt(slide.style.top) < 0)
	{
		slide.style.top = parseInt(slide.style.top) + parseInt(slide.clientHeight) + 'px';
	}
	return false;
}
function slide_next(id)
{
	var slide		= bmeDOM_getObject(id);
	var boxcount	= slide_boxcount(slide);
	var boxheight	= parseInt(slide.style.height);
	var boxperrow	= Math.floor(slide.clientWidth / slide_getboxwidth());	//145);
	var boxrows		= Math.ceil(boxcount / boxperrow);
	var boxscrollh	= boxrows * boxheight;
	if (parseInt(slide.style.top) > boxheight - boxscrollh)
	{
		slide.style.top = parseInt(slide.style.top) - boxheight + 'px';
	}
	return false;
}

//____________________________________________________________________
// JavaScript code end

