function preLoadImages(images)
{
	var cache = [];
	var len = images.length;

	for (var i = len; i--;)
	{
		var cacheImage = document.createElement('img');
		cacheImage.src = arguments[i];
		cache.push(cacheImage);
    }
}

var searchDefault = 'Code/Description';

var textAd = { 

    position : 0,
    element : null,
    speed : 1200,
    fadeSpeed : 800,
    startDelay : 2000,

    text : [
        'Over 2000 different fixing and fastening products',
        'Next day delivery, anywhere on the UK mainland',
        'Exemplary service',
        'Exceptional support',
        'You\'re never in a fix with ForgeFix'
    ],

    init : function()
    {
        this.element = $('#adcontent');
        this.element.html(this.text[0]);
        this.start(1);
    },

    start : function(pos)
    {
        var scope = this;
        this.position = 0;
        if(pos) { this.position = pos; }
        setTimeout(function(){ scope.step() }, this.startDelay);
    },
    
    step : function()
    {
        var scope = this;
        this.element.fadeOut(this.fadeSpeed, function() 
        {
            $(this).empty().append(scope.text[scope.position]).fadeIn(scope.fadeSpeed, function()
            {
                scope.position += 1;
                if (scope.position >= scope.text.length) { scope.start(); }
                else { setTimeout(function() { scope.step() }, scope.speed); }
            });
        });
    }
}

function replaceimg(id,imgsrc,alt) {
	oldimg=document.getElementById(id);
                                newimg=oldimg.cloneNode(false);
                                newimg.setAttribute('src',imgsrc);
                                newimg.setAttribute('alt',alt);
                                oldimg.parentNode.replaceChild(newimg, oldimg);
                }
                function enlargeImage(id) {
                                img=document.getElementById(id);
                                filename=img.src;
                                filepos=filename.indexOf('filename=');
                                if ( filepos == -1 ) { return true; }
                                filename=filename.substring(filepos+9);
                                filepos=filename.indexOf('&');
                                if ( filepos > 0 ) { filename=filename.substring(0,filepos); }
                                window.open('".IMAGE_SCRIPT."?filename='+filename+'&width=450&category=".urlencode($Cat->getCategoryCode())."','_blank','directories=no,height=500,width=470,menubar=no,status=no,titlebar=no');
                }


