// last modified 26-02-08
// CONTENTS
// addLoadEvent
// addLoadsofEvents
// addResizeEvent
// ajaxInit
// checkFuncExists
// checkSupport
// getElementsByClassName
// insertAfter
// isDigit
// trimString


var coreFuncs = {

addLoadEvent:function(func) {

    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
},

addLoadsofEvents:function(funclist) {

    if (!coreFuncs.checkSupport()) { return false; }
    for (var i = 0; i < funclist.length; i++) {

        coreFuncs.addLoadEvent(funclist[i]);
    }
},

addResizeEvent:function(func) {

    var oldonresize = window.onresize;
    if (typeof window.onresize != 'function') {
        window.onresize = func;
    } else {
        window.onresize = function() {
            oldonresize();
            func();
        }
    }
},

ajaxInit:function() {

    var xmlHttp = false;
    try {
      // regular browsers
      xmlHttp = new XMLHttpRequest();
    }
    catch (e) {
      // Internet Explorer
      try {
        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (e) {
        try {
          xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e) { return false; }
      }
    }
    return xmlHttp;
},

checkFuncExists:function(func) {

    if (typeof func == 'string' && eval('typeof ' + func) == 'function') {

       return true;
    }
    return false;
},

checkSupport:function() {

    if (!document.getElementById || !document.getElementsByTagName || !document.createTextNode || !document.createElement) { return false; }
    return true;
},


getElementsByClassName:function(className, nodeName, container) {

    nodeName = nodeName == null ? '*' : nodeName;
    var allElms = container == null ? document.getElementsByTagName(nodeName) : container.getElementsByTagName(nodeName);
    var targetElms = new Array(); var j = 0;
    for (var i = 0; i < allElms.length; i++) {

        if (allElms[i].className == className) {

            targetElms[j] = allElms[i]; j++;
        }
    }
    return targetElms;
},

insertAfter:function(newElement, targetElement) {

    var parent = targetElement.parentNode;
    if (parent.lastChild == targetElement) {
        parent.appendChild(newElement);
    } else {
        parent.insertBefore(newElement, targetElement.nextSibling);
    }
},

isDigit:function(num) {
	if (num.length>1){return false;}
	var string="1234567890";
	if (string.indexOf(num)!=-1){return true;}
	return false;
},

trimString:function(str) {
// remove spaces from beginning & end of string - http://www.somacon.com/p355.php
    str = str.replace(/^\s+|\s+$/g,"");
    return str;
}

}
