function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function get_adjustedWidth(w) {
    if (self.innerWidth) {
        w = w;
    } else if (document.documentElement && document.documentElement.clientWidth) {
        w = w + 17;
    } else if (document.body) {
        w = w + 17;
    }
    else return;

    return w;
}

function get_adjustedHeight(h) {
    if (self.innerWidth) {
        h = h + 3;
    } else if (document.documentElement && document.documentElement.clientWidth) {
        h = h;
    } else if (document.body) {
        h = h;
    }
    else return;

    return h;
}

function openPopUpDemo(target) {
	var windowwid = 920 + 30; //adding as some browsers add scrollbars otherwise, even if scrollbars=no
	var windowhei = 700 + 30;
	if ((windowwid + 40) > screen.availWidth) {
		windowwid = screen.availWidth - 40;
	}
	if ((windowhei + 100) > screen.availHeight) {
		windowhei = screen.availHeight - 100;
	}
	window.open(target, "qualyspopup","width="+windowwid+",height="+windowhei+",resizable=yes, location=yes, menubar=no, scrollbars=yes, toolbar=no, status=no");
}

function openPopUp(target, w, h) {
	var windowwid = get_adjustedWidth(w);
	var windowhei = get_adjustedHeight(h);
	if ((windowwid + 40) > screen.availWidth) {
		windowwid = screen.availWidth - 40;
	}
	if ((windowhei + 100) > screen.availHeight) {
		windowhei = screen.availHeight - 100;
	}

	window.open(target, "qualyspopup","width="+windowwid+",height="+windowhei+",resizable=yes, location=no, menubar=no, scrollbars=yes, toolbar=no, status=no");
}

function openPopUpScreen(target, w, h) {
//	openPopUp("http://www.qualys.com/products/screens/?screen="+escape(target), w, h);
	openPopUp("/products/screens/?screen="+escape(target), w, h);
}

function openPopUpImage(target, w, h, title, pageTitle) {
	var windowwid = w + 30;
	var windowhei = h + 30;
	if ((windowwid + 40) > screen.availWidth) {
		windowwid = screen.availWidth - 40;
	}
	if ((windowhei + 100) > screen.availHeight) {
		windowhei = screen.availHeight - 100;
	}
	newWind = window.open("", "qualyspopup","width="+windowwid+",height="+windowhei+",resizable=yes, location=no, menubar=no, scrollbars=yes, toolbar=no, status=no");
    newWind.document.write("<html><head><title>"+pageTitle+"</title></head><body><img src=\""+target+"\"></body></html>");
    newWind.document.close();
}

function openPopUpFile(target, w, h, pageTitle) {
	var windowwid = w + 30;
	var windowhei = h + 30;
	if ((windowwid + 40) > screen.availWidth) {
		windowwid = screen.availWidth - 40;
	}
	if ((windowhei + 100) > screen.availHeight) {
		windowhei = screen.availHeight - 100;
	}
//    newWind = window.open("", "qualyspopup","width="+windowwid+",height="+windowhei+",resizable=yes, location=no, menubar=no, scrollbars=yes, toolbar=no, status=no");
//    newWind.document.write("<html><head><title>"+pageTitle+"</title></head><body><img src=\""+target+"\"></body></html>");
//    newWind.document.close();
	newWind = window.open(target, "qualyspopup","width="+windowwid+",height="+windowhei+",resizable=yes, location=no, menubar=no, scrollbars=yes, toolbar=no, status=no");
}

function mouseOn(imageName, onSource) {
	if (document.images) {
		document[imageName].src = onSource;
  }
}

function mouseOff(imageName, outSource) {
	if (document.images) {
		document[imageName].src = outSource;
  }
}