﻿function $(id)
{
    return document.getElementById(id);
}
String.prototype.Trim = function () 
{
    return this.replace ( /^\s+|\s+$|(?:^&nbsp;)+|(?:&nbsp;$)+/g, "" );
}  

function addLoadEvent(func)
{	
    var oldonload = window.onload;
    if (typeof window.onload != 'function')
    {
	    window.onload = func;
    } 
    else 
    {
	    window.onload = function()
	    {
		    oldonload();
		    func();
	    }
    }
}
function getCookieValue(name)
{
    var cookie = new String(document.cookie);

    if (cookie != null && cookie.indexOf('comment=') > -1)
    {
        var start = cookie.indexOf(name + '=') + name.length + 1;
        var end = cookie.indexOf('&', start);
        if (end > start && start > -1)
          return cookie.substring(start, end);
    }

    return null;
}

function setCursorPos(x)
 {   
    if (window.navigator.userAgent.indexOf("MSIE")>=1){
      var txtRange   =   x.createTextRange();   
      txtRange.moveStart(   "character",   x.value.length);   
      txtRange.moveEnd(   "character",   0   );   
      txtRange.select();   
      }
}