﻿
var Site = 
{     	
	IsIE : function()
	{
		return (window.navigator.userAgent.indexOf("MSIE") > 0);
	},
	IsIE7 : function()
	{
		return (window.navigator.userAgent.indexOf("MSIE 7.0") > 0);
	},
	IsIE6 : function()
	{   
	    var regexIE6 = /MSIE ([0-6])/;
		return (regexIE6.test(window.navigator.userAgent));
	},
	FireEvent : function (element,event,KindOfEvents)
	{
        if (document.createEventObject)
        {
            // dispatch for IE
            var evt = document.createEventObject();
            element.fireEvent('on'+event,evt)
        }
        else{
            // dispatch for firefox + others
            var evt = document.createEvent(KindOfEvents);
            evt.initEvent(event, true, true );
            element.dispatchEvent(evt);
        }
    },
	AttachEvent : function(obj, eventName, delegate) 
	{
		if  (typeof( obj.addEventListener ) != 'undefined' ) 
		{
			obj.addEventListener(Site.GetEventName(eventName),delegate,false);
		} 
		else {
			obj.attachEvent(eventName,delegate);
		}
	},
	DetachEvent : function(obj,eventName,delegate)
	{
		if (obj.removeEventListener) {
			obj.removeEventListener(eventName,delegate, true);
		}
		else if (obj.detachEvent) {
			obj.detachEvent(eventName,delegate);
		}
	},
	GetEventName : function (name)
	{
		return (name.indexOf('on') == 0) ? name.substring(2,name.length) : name;
	},
	SelectInitInput : function (name)
	{
		Site.AttachEvent(window,'onload',new Function('Site.SelectInput("' + name + '")'));
	},
	SelectInput : function (name)
	{
		var input = document.getElementById(name);
		input.select();input.focus();
	},
	SrcElement : function(evt)
	{
		return (window.event) ? event.srcElement : evt.target;
	},
	GetElementText : function(element)
	{
	  return Site.IsIE() ? element.innerText : element.textContent;
	},
	SetElementText : function(element,text)
	{
	  if(Site.IsIE()){element.innerText = text;}
	  else{element.textContent = text;} 
	},
	HandleErrorGlobal : function(strErrorMsg,strUrl,iLineNumber)
	{
		window.status = strErrorMsg + ': Line:' + iLineNumber;
		return true;
	}
}
window.onerror = Site.HandleErrorGlobal;