function OtriadFunctions() {
	var self = this;
	var param;
	var opacity;
	var elm;
	var obj;
	var imageobject;
	var filename;
	var filetype;
	var oldfilename;
	var newfilename;

	this.getBody = function() {
		return document.getElementsByTagName('body')[0];
	}
	this.screenSize = function() {
		var myWidth = 0, myHeight = 0;
		if(typeof( window.innerWidth ) == 'number') {
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		}
		else if(document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight )) {
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		}
		else if(document.body && ( document.body.clientWidth || document.body.clientHeight )) {
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}
		return [Number(myWidth),Number(myHeight)];
	}
	this.findPosX = function(fobj) {
		if (navigator.appName == 'Microsoft Internet Explorer' || navigator.appName == 'Opera' || navigator.appName == 'Netscape') {
			return fobj.offsetLeft;
		}
		if (navigator.userAgent.indexOf('Chrome') > -1) {
			return fobj.offsetLeft;
		}
		var curleft = 0;
		if(fobj.offsetParent)
		while(1) {
			curleft += fobj.offsetLeft;
			if(!fobj.offsetParent)
			break;
			fobj = fobj.offsetParent;
		}
		else if(fobj.x)
		curleft += fobj.x;
		return curleft;
	}
	this.findPosY = function(fobj) {
		if (navigator.appName == 'Microsoft Internet Explorer' || navigator.appName == 'Opera' || navigator.appName == 'Netscape') {
			return fobj.offsetTop;
		}
		if (navigator.userAgent.indexOf('Chrome') > -1) {
			return fobj.offsetTop;
		}
		var curtop = 0;
		if(fobj.offsetParent)
		while(1) {
			  curtop += fobj.offsetTop;
			  if(!fobj.offsetParent)
			  break;
			  fobj = fobj.offsetParent;
		}
		else if(fobj.y)
		curtop += fobj.y;
		return curtop;
	}
	this.mouseX = function(e) {
		if (!e) { e = event; }
		if (e.pageX) { return e.pageX; }
		else if (e.clientX)
		return e.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
		else return null;
	}
	this.mouseY = function(e) {
		if (!e) { e = event; }
		if (e.pageY) { return e.pageY; }
		else if (e.clientY)
		return e.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
		else return null;
	}
	this.changeopacity = function(imageobject, opacity) {
		if (imageobject) {
			if (navigator.appName.indexOf("Netscape")!=-1&&parseInt(navigator.appVersion)>=5) {
				imageobject.style.MozOpacity=opacity/100;
			}
			else if (navigator.appName.indexOf("Microsoft")!=-1&&parseInt(navigator.appVersion)>=4) {
				if (opacity < 100) {
					imageobject.style.filter = 'alpha(opacity='+opacity+')';
				}
				else { imageobject.style.filter = ''; }
			}
			imageobject.style.opacity = opacity/100;
		}
	}
	this.getopacity = function(imageobject) {
		if (imageobject) {
			if (navigator.appName.indexOf("Netscape")!=-1&&parseInt(navigator.appVersion)>=5) {
				return imageobject.style.MozOpacity;
			}
			else if (navigator.appName.indexOf("Microsoft")!=-1&&parseInt(navigator.appVersion)>=4) {
				return imageobject.filters.alpha.opacity;
			}
			return imageobject.style.opacity;
		}
	}
	this.createjscssfile = function(filename, filetype) {
		if (filetype=="js"){ //if filename is a external JavaScript file
			var fileref=document.createElement('script');
			fileref.setAttribute("type","text/javascript");
			fileref.setAttribute("src", filename);
		}
		else if (filetype=="css"){ //if filename is an external CSS file
			var fileref=document.createElement("link");
			fileref.setAttribute("rel", "stylesheet");
			fileref.setAttribute("type", "text/css");
			fileref.setAttribute("href", filename);
		}
		document.getElementsByTagName('head')[0].appendChild(fileref);
	}
	this.replacejscssfile = function(oldfilename, newfilename, filetype) {
		var targetelement=(filetype=="js")? "script" : (filetype=="css")? "link" : "none" //determine element type to create nodelist using
		var targetattr=(filetype=="js")? "src" : (filetype=="css")? "href" : "none" //determine corresponding attribute to test for
		var allsuspects=document.getElementsByTagName(targetelement)
		for (var i=allsuspects.length; i>=0; i--){ //search backwards within nodelist for matching elements to remove
			if (allsuspects[i] && allsuspects[i].getAttribute(targetattr)!=null && allsuspects[i].getAttribute(targetattr).indexOf(oldfilename)!=-1){
				var newelement=createjscssfile(newfilename, filetype)
				allsuspects[i].parentNode.replaceChild(newelement, allsuspects[i])
			}
		}
	}
	this.removejscssfile = function(filename, filetype) {
		var targetelement=(filetype=="js")? "script" : (filetype=="css")? "link" : "none" //determine element type to create nodelist from
		var targetattr=(filetype=="js")? "src" : (filetype=="css")? "href" : "none" //determine corresponding attribute to test for
		var allsuspects=document.getElementsByTagName(targetelement)
		for (var i=allsuspects.length; i>=0; i--){ //search backwards within nodelist for matching elements to remove
			if (allsuspects[i] && allsuspects[i].getAttribute(targetattr)!=null && allsuspects[i].getAttribute(targetattr).indexOf(filename)!=-1) {
				allsuspects[i].parentNode.removeChild(allsuspects[i]) //remove element by calling parentNode.removeChild()
			}
		}
	}
}
var func = new OtriadFunctions();
