var isCSS, isW3C, isIE4, isNN4, isIE6CSS;

function getBrowserTypes() {
    if (document.images) {
        isCSS = (document.body && document.body.style) ? true : false;
        isW3C = (isCSS && document.getElementById) ? true : false;
        isIE4 = (isCSS && document.all) ? true : false;
        isNN4 = (document.layers) ? true : false;
        isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;
    }
}

function getElement(id) {
    if (typeof id == "string") {
        if (isW3C)
            return document.getElementById(id);
		else if (isIE4)
            return document.all(id);
        else if (isNN4)
            return seekLayer(document, id);
    }

    return id;
}


function getStyleValue(id, attr, attrAlt) {
	var x = document.getElementById(id);

	if (x.currentStyle) {
		return eval('x.currentStyle.' + attrAlt);
	}
	else if (document.defaultView.getComputedStyle) {
		return document.defaultView.getComputedStyle(x,null).getPropertyValue(attr);
	}
}



function openWindow(targetURL, windowName, width, height, scroll) {
	xpos=0;
	ypos=0;

	if (parseInt(navigator.appVersion) >= 4 ) {
		xpos = (screen.width - width) / 2 - 6;
		ypos = (screen.height - height) / 2;
	}

	args = "width=" + width + ",height=" + height + ",location=0,menubar=0,resizable=0,scrollbars=" + scroll + ",status=0,titlebar=0,toolbar=0,hotkeys=0,screenx=" + xpos + ",screeny=" + ypos + ",left=" + xpos + ",top=" + ypos;

	window.open(targetURL, windowName, args);
}


function setCookie(name, value, time, path, domain, secure) {
	var expires = "";

	if (time)
		expires = new Date(time);

	var curCookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");

	document.cookie = curCookie;
}


function changeCookie(name, value) {
	setCookie(name, value, '', '/', '', '');
}


function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);

	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	}
	else {
		begin += 2;
	}

	var end = document.cookie.indexOf(";", begin);

	if (end == -1) { end = dc.length; }

	return unescape(dc.substring(begin + prefix.length, end));
}


function deleteCookie(name, path, domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" + 
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}


getWindowWidth = function() {
	if( document.documentElement && document.documentElement.clientWidth )
		return document.documentElement.clientWidth;
	else if( document.body && document.body.clientWidth )
		return document.body.clientWidth;
	else if( window.innerWidth )
		return window.innerWidth - 18;
};


getWindowHeight = function() {
	if( document.documentElement && document.documentElement.clientHeight )
		return document.documentElement.clientHeight;
	else if( document.body && document.body.clientHeight )
		return document.body.clientHeight;
	else if( window.innerHeight )
		return window.innerHeight - 18;
};
