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

var userAgent = new Object();

/** 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
*/

function public_getAgentType() { 
	var result = "";
	if (navigator) {
		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.getType = public_getAgentType;

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

userAgent.getSystemType = 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;

/** 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;

/** setLocationTo

*/
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();
}

userAgent.setLocationTo = public_setLocationTo;

