﻿function isNumber (x)
{ 
  return ((typeof x === typeof 1) && (null !== x) && isFinite(x)) ;
}

function isDate (x)
{ 
  return Object.prototype.toString.call (x) === "[object Date]" ;
}

function isString (x)
{
    return typeof (x) === typeof ("") ;
}

function EscapeHtml (html)
{
    var escaped = html;
    var findReplace = [[/&/g, "&amp;"], [/</g, "&lt;"], [/>/g, "&gt;"], [/"/g, "&quot;"]] ;
    for (idx in findReplace)
    {
        var item = findReplace[idx] ;
        escaped = escaped.replace (item[0], item[1]) ;
    }
    return escaped ;
}

function FromUnixTime (time)
{
    if (!isNumber (time))
        time = parseInt (time.toString ()) ;
    return new Date (time * 1000) ;
}
