var pageLinkManufacturerSearch = '/products/productlist.aspx';

function writeSWFtag (strSWFFile, intWidth, intHeight) {
    document.write('<object type="application/x-shockwave-flash" data="' + strSWFFile + '" ');
    document.write('width="' + intWidth + '" height="' + intHeight + '">');
    document.write('<param name="movie" value="' + strSWFFile + '"></object>');
}
function clickAnchorOnCR(anchor, e) {
    if (e.keyCode == 13)
    {
        if (e.preventDefault)
            e.preventDefault();
        e.returnValue = false;
        e.cancel = true;
        if (e.stopPropagation)
            e.stopPropagation();
        if (anchor.getAttribute('onclick') == null) {
            if (anchor.getAttribute('href')) 
                if (anchor.getAttribute('href').indexOf('javascript:')==0)
                {
                    eval(anchor.getAttribute('href'));
                }
                else
                    document.location = anchor.getAttribute('href');
        }
        else anchor.onclick();
    }
}

function addLoadEvent(func) { 
  var oldonload = window.onload; 
  if (typeof window.onload != 'function') { 
    window.onload = func; 
  } else { 
    window.onload = function() { 
      if (oldonload) { 
        oldonload(); 
      } 
      func(); 
    } 
  } 
}

/*
* Håndtering af query string operationer.
*/
function PageQuery(q) {
    if (q.length > 1) this.q = q.substring(1, q.length);
    else this.q = null;
    this.keyValuePairs = new Array();
    if (q) {
        for (var i = 0; i < this.q.split("&").length; i++) {
            this.keyValuePairs[i] = this.q.split("&")[i];
        }
    }

    this.getKeyValuePairs = function () {
        return this.keyValuePairs;
    }

    this.getValue = function (s) {
        for (var j = 0; j < this.keyValuePairs.length; j++) {
            if (this.keyValuePairs[j].split("=")[0].toLowerCase() == s.toLowerCase())
                return this.keyValuePairs[j].split("=")[1];
        }
        return null;
    }

    this.getKeyValueIndex = function (s) {
        for (var j = 0; j < this.keyValuePairs.length; j++) {
            if (this.keyValuePairs[j].split("=")[0].toLowerCase() == s.toLowerCase())
                return j;
        }
        return -1;
    }

    this.getParameters = function () {
        var a = new Array(this.getLength());
        for (var j = 0; j < this.keyValuePairs.length; j++) {
            a[j] = this.keyValuePairs[j].split("=")[0];
        }
        return a;
    }

    this.getLength = function () {
        return this.keyValuePairs.length;
    }

    this.setValue = function (q, value) {
        if (this.getValue(q) == null) {
            this.keyValuePairs[this.keyValuePairs.length] = q + "=" + value;
        } else {
            this.keyValuePairs[this.getKeyValueIndex(q)] = q + "=" + value;
        }
    }
    this.toString = function () {
        var retval = '';
        for (var j = 0; j < this.keyValuePairs.length; j++) {
            if (j == 0) {
                retval = this.keyValuePairs[j]
            } else {
                retval = retval + '&' + this.keyValuePairs[j];
            }
        }
        return retval;
    }
}

// Create an instance of PageQuery to work on :)
var pageQuery = new PageQuery(location.search);

