// JavaScript Document
/**********Check browser*************/
var _w = window;
var _d = document;
_d.gtn_ = _d.getElementsByTagName;
_d.gid_ = _d.getElementById;
_d.ce_ = _d.createElement;
var is = new z1Browser();
/************************/

footergrass = MM_findObj('grass');

var intervalID;
function winresize(){
	var winHeight = 0;
	var content = _d.gid_("content")||null;
	/*
	if(is.ie){
		var contentH = content.offsetHeight;
		if(contentH + footergrass.offsetHeight < _d.body.scrollHeight){
			winHeight = contentH + 62;
		}else winHeight = _d.body.scrollHeight;
	}else*/ winHeight = _d.body.scrollHeight;
	
	footergrass.style.position = "absolute";
//	alert(content.offsetHeight + "/" + winHeight);
	if(parseInt(content.offsetHeight) == parseInt(winHeight) || parseInt(content.offsetHeight) > parseInt(winHeight - 10))
		footergrass.style.top = (winHeight - 100) + "px";
	else if(content.offsetHeight + 190 > winHeight || winHeight > 800){
		footergrass.style.top = (winHeight - 130) + "px";
	}else footergrass.style.top = (winHeight - 100) + "px";
	footergrass.style.left = "0px";
	/*
	getresize = false;
//	alert("scroll:"+footergrass.offsetHeight + "\nBody:"+document.body.scrollHeight);
	var winHeight = document.body.scrollHeight;
	footergrass.style.position = "absolute";
	footergrass.style.top = is.ie?(winHeight-6):(winHeight - footergrass.offsetHeight) + "px";
	footergrass.style.left = "0px";
	/*
	if(document.body.scrollHeight >= document.getElementById("main").offsetHeight){
		alert(0);
		footergrass.style.position = "absolute"
		//document.getElementById("grass").style.bottom = 0;
		footergrass.style.bottom = "0px";
		//alert(footergrass.style.position);
	} else {
		footergrass.style.position = "static";
		//footergrass.style.bottom = "0px";
		//footergrass.style.top = document.getElementById("main").offsetHeight
		//alert(footergrass.style.position);
	}
	*/
	//intervalID = setTimeout("recall",1000);
}
function recall(){
	if(document.body.clientHeight > (document.getElementById("main").offsetHeight)){
	footergrass.style.position = "absolute"
	footergrass.style.bottom = 0
	//alert(footergrass.style.position);
	} else {
	footergrass.style.position = "static"
	}
	clearTimeout(intervalID);
}
winresize();
window.onresize = winresize;

function z1Browser() {
	var b = navigator.appName;
	if (b.indexOf("Netscape") != -1) {
		this.b = "ns";
	} else {
		if (b == "Opera" || (navigator.userAgent.indexOf("Opera") > 0)) {
			this.b = "opera";
		} else {
			if (b == "Microsoft Internet Explorer") {
				this.b = "ie";
			}
		}
	}
	if (!b) {
		alert("Unidentified browser.\nThis browser is not supported!");
	}
	this.version = navigator.appVersion;
	this.fv = parseFloat(this.version);
	this.v = parseInt(this.version);
	this.ns = (this.b == "ns" && this.v >= 4);
	this.ns4 = (this.b == "ns" && this.v == 4);
	this.ns6 = (this.b == "ns" && this.v == 5);
	this.ns7 = (navigator.userAgent.indexOf("Netscape/7") > 0);
	this.ie = (this.b == "ie" && this.v >= 4);
	this.ie4 = (this.version.indexOf("MSIE 4") > 0);
	this.ie5 = (this.version.indexOf("MSIE 5") > 0);
	this.ie55 = (this.version.indexOf("MSIE 5.5") > 0);
	this.ie6 = (this.version.indexOf("MSIE 6.0") > 0);
	if (this.ie) {
		this.iev = parseInt(this.version.substring(this.version.indexOf("MSIE ") + 5));
		this.ieFixed = (navigator.appMinorVersion.split(";").length > 3) || (navigator.userAgent.indexOf("NT 5.1") > 0);
	}
	this.opera = (this.b == "opera");
	this.dom = (_d.ce_ && _d.appendChild && _d.gtn_) ? true : false;
	this.def = (this.ie || this.dom);
	this.dyn = (this.dom || this.ie || this.ns4);
	var ua = navigator.userAgent.toLowerCase();
	if (ua.indexOf("win") > -1) {
		this.platform = "win32";
	} else {
		if (ua.indexOf("mac") > -1) {
			this.platform = "mac";
		} else {
			this.platform = "other";
		}
	}
}
