// gives up and down scroll buttons to images, spans, ... named up_name, down_name, respectively.
// will keep the default scroll_box's style overflow if it encounters errors (so make overflow: auto;)

// usage: put this after the scrollbox div:  var div_scroll1 = new TextScroll('div_scroll1', 'scroll_box');
function TextScroll(scrollname, div_name, up_name, down_name)
{
    this.div_name = div_name;
    this.name = scrollname;
    this.scrollCursor = 0;
    this.speed = 25;
    this.timeoutID = 0;
    this.div_obj = null;
    this.up_name = up_name;
    this.dn_name = down_name;

{
        if (document.getElementById) {
            div_obj = document.getElementById(this.div_name);
            if (div_obj) {
                this.div_obj = div_obj;
                this.div_obj.style.overflow = 'hidden';
            }
            div_up_obj = document.getElementById(this.up_name);
            div_dn_obj = document.getElementById(this.dn_name);
            if (div_up_obj && div_dn_obj) {
                div_up_obj.setAttribute("onClick", scrollname + ".scrollUp();")
                div_up_obj.setAttribute("onmouseout", scrollname + ".stopScroll();")

div_dn_obj.setAttribute("onClick", scrollname + ".scrollDown();")
                div_dn_obj.setAttribute("onmouseout", scrollname + ".stopScroll();")
            }
        }
    }

this.stopScroll = function() {
        clearTimeout(this.timeoutID);
    }

this.scrollUp = function() {
        if (this.div_obj) {
            this.scrollCursor = (this.scrollCursor - this.speed) < 0 ? 0 : this.scrollCursor - this.speed;
            this.div_obj.scrollTop = this.scrollCursor;
            this.timeoutID = setTimeout(this.name + ".scrollUp()", 60);
        }
    }

this.scrollDown = function() {
        if (this.div_obj) {
            this.scrollCursor += this.speed;
            this.div_obj.scrollTop = this.scrollCursor;
            this.timeoutID = setTimeout(this.name + ".scrollDown()", 60);
        }
    }

this.resetScroll = function() {
        if (this.div_obj) {
            this.div_obj.scrollTop = 0;
            this.scrollCursor = 0;
        }
    }
}

// CHANGEOUT OF PRODUCTS
function showprods(itemname,prefix,added) {
	$("#showprod").fadeOut('fast');
	//$("#showprod").html('<table width="100%" height="350" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle"><img src="'+prefix+'imgs/ajax-loader.gif" /></td></tr></table>');
	$.ajax({ 
	  type: "POST", 
	  url: prefix+"FCKincludes/fck_changeprod.php", 
	  data: "showitem="+itemname+"&pre="+prefix+"&added="+added, 
	  success: function(msg){
		$("#showprod").html(msg);
		$("#showprod").fadeIn('fast');
		
			$("#sizeselect").change(function(){
				$("#showprice").fadeOut('fast');					 							 
				sizevalue = $(this).val();
				sizeid = $(this).siblings('.add_id').val();
				
				$.ajax({ 
				  type: "POST", 
				  url: prefix+"FCKincludes/fck_changesize.php", 
				  data: "price="+sizevalue+"&id="+sizeid, 
				  success: function(msg){
					$("#showprice").html('<span style="font-size: 11px;">NZD </span>'+msg+' incl GST');
					$("#showprice").fadeIn('fast')
				  } 
				});
				
			});
		
	  } 
	});
	return false;
}