/**
 *	System Extention Object; v.0.1.1;
 */

/** getAgentType
 *	windows: ms5_win,ms4_win,stnrd_win,nn4x_win,opera_win
 *	    mac: ms5_mac,ms4_mac,stnrd_mac,nn4x_mac,opera_mac
 *	 others: stnrd,nn4x,opera,else
 */

var userAgent = new Object();

function public_getAgentType() { 
	var result = "";
	if ( window.opera ) {
		if (navigator.appVersion.indexOf("Win") != -1) result = "opera_win";
		else if (navigator.appVersion.indexOf("Mac") != -1) result = "opera_mac";
		else result = "opera";
	} else if ( document.all && document.getElementById ) {
		if (navigator.appVersion.indexOf("Win") != -1) result = "ms5_win";
		else result = "ms5_mac";
	} else if ( document.all && !document.getElementById ) {
		if (navigator.appVersion.indexOf("Win") != -1) result = "ms4_win";
		else result = "ms4_mac";
	} else if ( document.getElementById && !document.all ) {
		if (navigator.appVersion.indexOf("Win") != -1) result = "stnrd_win";
		else if (navigator.appVersion.indexOf("Mac") != -1) result = "stnrd_mac";
		else result = "stnrd";
	} else if ( document.layers ) {
		if (navigator.appVersion.indexOf("Win") != -1) result = "nn4x_win";
		else if (navigator.appVersion.indexOf("Mac") != -1) result = "nn4x_mac";
		else result = "nn4x";
	} else {
		result = "else";
	}
	(!!arguments[0])? ( (arguments[0] == result)? result = true : result = false ) : void(0) ;
	return result;
}
userAgent.getAgentType = public_getAgentType;

/** getSystemType
 *	windows:win
 *	    mac:mac
 *	 others:els
 */
function public_getSystemType() {
	var result = "";
	if (navigator.platform.indexOf("Win") != -1) {
		result = "win";
	} else if (navigator.platform.indexOf("Mac") != -1) {
		result = "mac";
	} else {
		result = "els";
	}
	if (!!arguments[0]) {
		result = (arguments[0] == result)? true : false;
	}
	return result;
}
userAgent.getPlatform = public_getSystemType;

/** setLinkElement
 *
 */

function public_setLinkElement(rel,href) {
	var result = "";
	result = (rel=="stylesheet")? "<link rel=\"stylesheet\" type=\"text/css\"" : "<lin rel=\""+ rel +"\"";
	result = (!!href)? result +" href=\""+ href +"\" />" : "" ;
	(result!="")? document.write(result) : void(0) ;
}
userAgent.setLinkElement = public_setLinkElement;

/** getRUL
 *
 */

function public_setLocation(URL,TARGET) {
	TARGET = (!!!TARGET)? "top" : TARGET ;
	if (!!URL) eval(TARGET).location = eval(TARGET).location.protocol + "//" + eval(TARGET).location.host + URL;
}
userAgent.setLocation = public_setLocation;

/** alternate_window
 *
 */
function public_setLocationTo(TARGET,URL) {
	URL = (!!URL)? URL : new String("");
	newWindow = (userAgent.getPlatform('mac') && document.all)? window.open(URL, TARGET, 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,resizable=yes,favorites=yes') : window.open(URL, TARGET) ;
	if (!userAgent.getAgentType("ms4_win") && !userAgent.getAgentType("ms4_mac")) newWindow.focus();
	return true;
}
userAgent.setLocationTo = public_setLocationTo;

function public_virtual_setDocumentTo(TARGET,URL) {
	(!!TARGET && !!URL)? userAgent.setLocationTo(TARGET, URL) : void(0) ;
}
userAgent.setDocumentTo = public_virtual_setDocumentTo;

/** getRandomNUm
 *
 */
function public_getRandomNum(start,end) {
	return (start == 0)? Math.floor(Math.random()*(end)) : Math.floor(Math.random()*(end-start)) + start;
}
userAgent.getRandomNum = public_getRandomNum;

/** inherit
 *
 */
function public_inherit(subClass, superClass) {
	for (var item in superClass.prototype) {
		subClass.prototype[item] = superClass.prototype[item];
	}
} 
userAgent.inherit = public_inherit;
