		
function getWindowHeight(){
	var h=0;
	if(document.body.clientHeight > h){
		h=document.body.clientHeight;
	} 
	if(document.documentElement && document.documentElement.clientHeight > h){
		h=document.documentElement.clientHeight;
	}
	return h;
}
	
function getWindowWidth(){
	var w=0;
	if(document.body.clientWidth > w){
		w=document.body.clientWidth;
	} 
	if(document.documentElement && document.documentElement.clientWidth > w){
		w=document.documentElement.clientWidth;
	}				
	return w;
}

function scrollTop(){
	if(document.getElementById("action")){
		self.scrollTo(0,0);
	}
}

function executeAction(component){
	var links=component.getElementsByTagName('a');
	if(links != null){
		links[0].onclick();
	}
}	

function changeClass(component, className){
	var links=component.getElementsByTagName('a');
	if(links != null){
		links[0].className=className;
	}
}

function startLoad(){
	startLoadByName('tableWrapper');
}

function startLoadByName(divName){
	var wrapper=document.getElementById(divName).getElementsByTagName("table")[0];
    var div=document.createElement("div");
    div.setAttribute("id", "statusDiv");
    div.className="updateListingStatusWrapper";
    div.innerHTML="<h2>Updating List...</h2><div class=\"updateListingStatus\" align=\"center\">&#160;</div>";
    document.getElementById(divName).insertBefore(div, wrapper);
	wrapper.style.visibility = "hidden";
    div.style.display = "block";
    div.style.width = wrapper.offsetWidth + "px";
	var height = wrapper.offsetHeight;
	if(height < 300){
		height = 300;
	}
    div.style.height =  height + "px";
}
        	
function stopLoad(){
	stopLoadByName('tableWrapper');
}

function stopLoadByName(divName){
	var wrapper=document.getElementById(divName).getElementsByTagName("table")[0];
	var div=document.getElementById("statusDiv");
	document.getElementById(divName).appendChild(div);
	wrapper.style.visibility = "visible";
}			

//These functions serve to hide flash components in IE because modal panels 
//do not display properly when they are visible.
function hideFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for(var i=0; i<=flashObjects.length-1; i++){
		flashObjects[i].style.visibility='hidden';
	}
}

function showFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for(var i=0; i<=flashObjects.length-1; i++){
		flashObjects[i].style.visibility='visible';
	}	
}

function hideFooter(){
	if(isIE()){
		var flashObjects = document.getElementById("footerwrapper");
		flashObjects.style.visibility='hidden';
	}
}

function showFooter(){
	if(isIE()){
		var flashObjects = document.getElementById("footerwrapper");
		flashObjects.style.visibility='visible';
	}
}



function toggleContextExpand(componentId){
    var menu = document.getElementById(componentId);
    var footer = document.getElementById("tableWrapper");
    var p = findPos(footer);
    var tableBottom = p[0] + footer.offsetHeight;
    var menuTop = parseInt(menu.style.top);
    var difference = (menuTop + 115) - tableBottom;
    if(difference > 0){
        alert(difference);
        var d=new String(difference + "px");
        footer.style.marginBottom = d;
    }
}

function toggleContextCollapse(componentId){
    var menu = document.getElementById(componentId);
    menu.style.marginBottom = '';
}

function findPos(obj) {
var curleft = curtop = 0;
if (obj.offsetParent) {
    do {
        curleft += obj.offsetLeft;
        curtop += obj.offsetTop;
    } while (obj = obj.offsetParent);
}
return [curleft,curtop];
}

function isIE(){
	return (navigator.userAgent.indexOf('MSIE') !=-1);
}

var BrowserDetect = {
		init: function () {
			this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
			this.version = this.searchVersion(navigator.userAgent)
				|| this.searchVersion(navigator.appVersion)
				|| "an unknown version";
			this.OS = this.searchString(this.dataOS) || "an unknown OS";
		},
		searchString: function (data) {
			for (var i=0;i<data.length;i++)	{
				var dataString = data[i].string;
				var dataProp = data[i].prop;
				this.versionSearchString = data[i].versionSearch || data[i].identity;
				if (dataString) {
					if (dataString.indexOf(data[i].subString) != -1)
						return data[i].identity;
				}
				else if (dataProp)
					return data[i].identity;
			}
		},
		searchVersion: function (dataString) {
			var index = dataString.indexOf(this.versionSearchString);
			if (index == -1) return;
			return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
		},
		dataBrowser: [
			{
				string: navigator.userAgent,
				subString: "Chrome",
				identity: "Chrome"
			},
			{ 	string: navigator.userAgent,
				subString: "OmniWeb",
				versionSearch: "OmniWeb/",
				identity: "OmniWeb"
			},
			{
				string: navigator.vendor,
				subString: "Apple",
				identity: "Safari",
				versionSearch: "Version"
			},
			{
				prop: window.opera,
				identity: "Opera"
			},
			{
				string: navigator.vendor,
				subString: "iCab",
				identity: "iCab"
			},
			{
				string: navigator.vendor,
				subString: "KDE",
				identity: "Konqueror"
			},
			{
				string: navigator.userAgent,
				subString: "Firefox",
				identity: "Firefox"
			},
			{
				string: navigator.vendor,
				subString: "Camino",
				identity: "Camino"
			},
			{		// for newer Netscapes (6+)
				string: navigator.userAgent,
				subString: "Netscape",
				identity: "Netscape"
			},
			{
				string: navigator.userAgent,
				subString: "MSIE",
				identity: "Explorer",
				versionSearch: "MSIE"
			},
			{
				string: navigator.userAgent,
				subString: "Gecko",
				identity: "Mozilla",
				versionSearch: "rv"
			},
			{ 		// for older Netscapes (4-)
				string: navigator.userAgent,
				subString: "Mozilla",
				identity: "Netscape",
				versionSearch: "Mozilla"
			}
		],
		dataOS : [
			{
				string: navigator.platform,
				subString: "Win",
				identity: "Windows"
			},
			{
				string: navigator.platform,
				subString: "Mac",
				identity: "Mac"
			},
			{
				   string: navigator.userAgent,
				   subString: "iPhone",
				   identity: "iPhone/iPod"
		    },
			{
				string: navigator.platform,
				subString: "Linux",
				identity: "Linux"
			}
		]

	};
	BrowserDetect.init();

	function browserCorrect(brand, version){
		var isGood = 0;
		if(brand == 'Explorer' || brand == 'Chrome' || brand == 'Firefox' || brand == 'Safari'){
			isGood = 1;
			if(brand == 'Explorer' && version >= 6){
				isGood = 2;
			}
			if(brand == 'Chrome' && version >= 1){
				isGood = 2;
			}
			if(brand == 'Firefox' && version >= 3){
				isGood = 2;
			}
			if(brand == 'Safari' && version >= 3){
				isGood = 2;
			}
		}
		return isGood;
	}