
generic = {     
	init: function() { 
	},
	env: { 
		isIE : !!(typeof(ActiveXObject) == 'function'),
		isIE6 : !!(!!(typeof(ActiveXObject) == 'function') && (/MSIE\s6\.0/.test(navigator.appVersion))),
		isFF : Prototype.Browser.Gecko,
		isFF2 : !!(typeof(navigator.product) != 'undefined' && navigator.product == 'Gecko' && !((document.childNodes) && (!navigator.taintEnabled)) && navigator.userAgent.toLowerCase().split(' firefox/')[1].split('.')[0] == '2'),
		isFF3 : !!(typeof(navigator.product) != 'undefined' && navigator.product == 'Gecko' && !((document.childNodes) && (!navigator.taintEnabled)) && navigator.userAgent.toLowerCase().split(' firefox/')[1].split('.')[0] == '3'),
		isMac    : !!(/macppc|macintel/.test(navigator.platform.toLowerCase())),
		isSafari : !!(/Safari/.test(navigator.userAgent)),
		
		domain : window.location.protocol + "//" + window.location.hostname,
		
		debug: true, //JSTest check subdomain
		parsedQuery:  window.location.href.toQueryParams(),
		
		query: function(key) { 
			var result = generic.env.parsedQuery[key] || null;
			return result; 
		}
	},
	events: {
		target: document,
		fire: function(args) {
			//console.log("generic.events.fire: "+args.event + " / " + args.msg);  
			if (!args) return;
			var e = args.event; 
			var msg = args.msg || null;
			generic.events.target.fire(e, msg);
		},
		observe: function(evt, func) { 
			if (!evt || !func) return;
			generic.events.target.observe(evt, func);
		}	
	},
	// TODO: move to forms.js
    forms: {
        select : {
            addOption:  function(args) {
                 if (!args) return;
                 var val = args.value;
                 var label = args.label || val;
                 var opt = '<option value="' + val + '">' + label + '</option>';
                 args.menuNode.insert(opt);
            },
            setValue: function(args) { 
                var idx = 0;
                for (var i=0, len=args.menuNode.options.length; i<len; i++) { 
                    if (args.value == args.menuNode.options[i].value) {
                        idx = i;
                        break;
                    }
                }
                args.menuNode.selectedIndex = idx;
            }
        }
    }
} 



