function popupImage(img, pname, W, H){
    var sitedomain = 'http://www.ostwest.travel';
    var winWidth = (W) ? W : 640;
    var winHeight = (H) ? H : 620;
    var winName = (pname) ? pname : 'window';
    var X = Math.round((screen.width - winWidth) / 2);
    var Y = Math.round((screen.height - winHeight) / 2);
    params = "scrollbars=yes, status=yes, resizable=1, width=" + winWidth + ",height=" + winHeight + ",left=" + X + ",top=" + Y;
    wID = window.open('/en/popup?img=' + img.toString().replace(sitedomain, ''), winName, params);
}
function popupImageHotel(img, pname, W, H){
    var winWidth = (W) ? W : 640;
    var winHeight = (H) ? H : 620;
    var winName = (pname) ? pname : 'window';
    var X = Math.round((screen.width - winWidth) / 2);
    var Y = Math.round((screen.height - winHeight) / 2);
    params = "scrollbars=yes, status=yes, resizable=1, width=" + winWidth + ",height=" + winHeight + ",left=" + X + ",top=" + Y;
    wID = window.open(img, winName, params);
}

function externalLinks(){
    if (!document.getElementsByTagName)
        return;
    var anchors = document.getElementsByTagName("a");
    for (var i = 0; i < anchors.length; i++) {
        if (anchors[i].getAttribute("href") && anchors[i].getAttribute("rel") == "external") {
            anchors[i].target = "_blank";
        }
    }
}

Array.prototype.push = function() {
    var n = this.length >>> 0;
    for (var i = 0; i < arguments.length; i++) {
        this[n] = arguments[i];
        n = n + 1 >>> 0;
    }
    this.length = n;
    return n;
};

Array.prototype.pop = function() {
    var n = this.length >>> 0, value;
    if (n) {
        value = this[--n];
        delete this[n];
    }
    this.length = n;
    return value;
};

function $()
{
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++)
  {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1)
      return element;

    elements.push(element);
  }

  return elements;
}

window.onload = externalLinks;

