active_pict = 0;
var myrules = {
'div.imageswitcht a' : function(el)
{
var id = el.id.split('_');
if(el.className == 'active first')
active_pict = id[1];
else
Element.hide('product_img_'+id[1]);
el.onclick = function()
{
var id = el.id.split('_');
var pict_id = id[1];
if(active_pict != pict_id)
{
$('product_img_'+pict_id).style.visibility = 'visible';
Element.hide('product_img_'+pict_id);
new Effect.Fade('product_img_'+active_pict, {
afterFinish: function()
{
new Effect.Appear('product_img_'+pict_id, { duration: 0.4 });
},
duration: 0.4
});
$('pict_'+active_pict).className = $('pict_'+active_pict).className.replace(/active/, '');
$('pict_'+pict_id).className += ' active';
active_pict = pict_id;
}
return false;
}
},
'#productlist_navi' : function(el)
{
$('productlist').style.overflow = "hidden";
$('productlist').style.width = "330px";
if($('productlist').scrollHeight - $('productlist').offsetHeight > 20)
el.style.display = "block";
},
'#productlist_navi a' : function(el)
{
el.onclick = function()
{
if(Element.hasClassName(el, 'top'))
{
var NewScrollpos = $('productlist').scrollTop - 110; //$('productlist').offsetHeight;
//$('productlist').scrollTop = NewScrollpos;
scroll_products(NewScrollpos, -1);
}
else
{
var NewScrollpos = $('productlist').scrollTop + 110; //$('productlist').offsetHeight;
//$('productlist').scrollTop = NewScrollpos;
scroll_products(NewScrollpos, 1);
}
}
}
};
function scroll_products(max, dir)
{
if( (dir == 1 && $('productlist').scrollTop < max && $('productlist').scrollTop < $('productlist').scrollHeight - $('productlist').offsetHeight) || (dir == -1 && $('productlist').scrollTop > max && $('productlist').scrollTop > 0 ) )
{
$('productlist').scrollTop = $('productlist').scrollTop + dir * 5;
setTimeout("scroll_products("+max+", "+dir+")", 1);
}
}
if( typeof Behaviour != "undefined")
Behaviour.register(myrules);
// function to change price when option is changed
function price_change(id)
{
var i = 0;
while($('price_'+i))
{
$('price_'+i).style.display="none";
i++;
}
$('price_'+id).style.display="block";
}
