﻿// JScript File
function htmlCreateElement(name, child, cssClass) {
    var elem = document.createElement(name);
    if (cssClass != null) {
        elem.className = cssClass;
    }
    if (typeof(child) == "string") {
        child = document.createTextNode(child);
    }
    if (child != null) {
        elem.appendChild(child);
    }
    return elem;
}

function htmlAddElement(parent, name, child, cssClass) {
    var elem = htmlCreateElement(name, child, cssClass);

    if (parent != null) {
        parent.appendChild(elem);
    }
    
    return elem;
}

function htmlGetId(id) {
    return document.getElementById(id);
}
function htmlCreateImage(src, alt, cssClass) {
    var elem = htmlCreateElement("img", null, cssClass);

    elem.src = src;
    elem.alt = alt;
    elem.title = alt;
    return elem;
} 
function utilBind(func, self) {
    return function() {
        func.apply(self, arguments);
    }
}
function isNumber(num){
    var testresult=false
    var anum=/(^\d+$)|(^\d+\.\d+$)/
    if (anum.test(num)) testresult=true
   
    return testresult
}
function openWin(_url, w, h, str){
    var winRef = window.open( _url, "Edit", "width="+w+", height="+h+str )
    return winRef;
}
function getWindowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
    var obj=new Object();
    obj._width=myWidth;
    obj._height=myHeight;
    return obj;
}
function myDeEncode(res){
while ( res.indexOf("aring;") > 0 || res.indexOf("auml;") > 0 || res.indexOf("ouml;") > 0 || res.indexOf("Aring;") > 0 || res.indexOf("Auml;") > 0 || res.indexOf("Ouml;") > 0){
        res = res.replace("aring;" , "å");
        res = res.replace("auml;", "ä");
        res = res.replace("ouml;", "ö");
 	    res = res.replace("Aring;" , "å");
        res = res.replace("Auml;", "ä");
        res = res.replace("Ouml;", "ö");
    } 
return res;
}

function myEncode(res){
while ( res.indexOf("å") > 0 || res.indexOf("ä") > 0 || res.indexOf("ö") > 0 || res.indexOf("Å") > 0 || res.indexOf("Ä") > 0 || res.indexOf("Ö") > 0){
        res = res.replace("å", "aring;");
        res = res.replace("ä", "auml;");
        res = res.replace("ö", "ouml;");
 	    res = res.replace("Å", "Aring;");
        res = res.replace("Ä", "Auml;");
        res = res.replace("Ö", "Ouml;");
    } 
return res;
}