function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function swpImg(currImg,repImg)
{
	document.getElementById(currImg).src = repImg;
}

function URLEncode(string)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = string;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '"
                        + ch
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
};


//http request call to go on product pages. brings back individual product or the product range page.

http = null;

function generateRequest() {
    http = null;
    try {
        http = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
            http = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
        }
    }
    if (!http && typeof XMLHttpRequest != 'undefined') {
        http = new XMLHttpRequest();
    }
    return http;
}
function returnPage(product,flareFile) {
    http = generateRequest();
    if (http && document.getElementById) {
        document.title = name;
	var stylistso = new SWFObject('/flash/products/' + flareFile + '.swf','products','665','460','6','#ffffff'); stylistso.addParam('wmode','transparent');
	stylistso.write('flare');
        http.onreadystatechange = loadPage;
        http.open ("GET",product);
        http.send(null);
        return false;
    } else {
        return true;
    }
}
function loadPage() {
    if (http.readyState == 4) {
        document.getElementById("mainContent").innerHTML = http.responseText;
        http = null;
    }
}

