﻿// JScript File

//	START CLEARS INPUT FIELD
function clearDefault(el) {
	if (el.defaultValue==el.value) el.value = ""
}
//	END CLEARS INPUT FIELD

// START DETECT BROWSER AND OS
var detect = navigator.userAgent.toLowerCase();
var OS,browser,total,thestring;
var version = 0;

if (checkIt('konqueror')) {
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
browser = "Netscape Navigator"
version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS){
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}

function checkIt(string) {
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
//	END DETECT BROWSER AND OS

//	BEGIN SCREEN SIZE
function WindowSize() {
	var winW = 800, winH = 600;
	var SizeArray = new Array ();
	if (parseInt(navigator.appVersion)>3) {
		if (browser=="Internet Explorer") {
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
			if (document.documentElement){
				winW = document.documentElement.offsetWidth;
				winH = document.documentElement.offsetHeight;
			}
		}else{
			winW = window.innerWidth;
			winH = window.innerHeight;
		}
	}
	SizeArray[0] = winW;
	SizeArray[1] = winH;
	return SizeArray;
}
//	END SCREEN SIZE

//	BEGIN ELEMENT X/Y POSITION
// X POSITION
function findPosX(Elem){
	var curleft = 0;
	if(document.getElementById) {
		var obj = document.getElementById(Elem);
	} else if (document.all){
		var obj = document.all[Elem];
	}
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}else if (obj.x){
		curleft += obj.x;
	}
	return curleft;
}
// Y POSITION
function findPosY(Elem){
	var curtop = 0;
	if(document.getElementById) {
		var obj = document.getElementById(Elem);
	} else if (document.all){
		var obj = document.all[Elem];
	}
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}else if (obj.y){
		curtop += obj.y;
	}
	return curtop;
}
//	END ELEMENT POSITION

//	BEGIN ELEMENT WIDTH/HEIGHT
// HEIGHT POSITION
function getElementHeight(Elem) {
	if(document.getElementById) {
		var elem = document.getElementById(Elem);
	} else if (document.all){
		var elem = document.all[Elem];
	}
	if (browser=="Opera") { 
		xPos = elem.style.pixelHeight;
	} else {
		xPos = elem.offsetHeight;
	}
	return xPos;
}
// WIDTH POSITION
function getElementWidth(Elem) {
	if(document.getElementById) {
		var elem = document.getElementById(Elem);
	} else if (document.all){
		var elem = document.all[Elem];
	}
	if (browser=="Opera") {
		yPos = elem.style.pixelWidth;
	} else {
		yPos = elem.offsetWidth;
	}
	return yPos;
}
//	END ELEMENT WIDTH/HEIGHT