function checkEnter(e){ //e is event object passed from function invocation
var characterCode;  //literal character code will be stored in this variable

	if(e && e.which){ //if which property of event object is supported (NN4)
		//e = e;
		characterCode = e.which; //character code is contained in NN4's which property
	}
	else{
		//e = event;
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}

	//alert("characterCode = "+characterCode);
	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
 		return false;
	}
	else{
		return true;
	}

}

function new_window(url,title,winWidth,winHeight,resize,scroll) {
	var toolBarParms = "toolbar=0,directories=0,status=0,menubar=0,scrollbars=" + scroll;
	toolBarParms = toolBarParms + ",resizable=" + resize + ",width=" + winWidth + ",height=" + winHeight;
	link = window.open(url, title, toolBarParms);
}

function topwindow(url,title,winWidth,winHeight,resize,scroll) {
	var toolBarParms = "top=0,left=0,screenX=0,screenY=0,toolbar=0,directories=0,status=0,menubar=0,scrollbars=" + scroll;
	toolBarParms = toolBarParms + ",resizable=" + resize + ",width=" + winWidth + ",height=" + winHeight;
	link = window.open(url, title, toolBarParms);
}

//popups

//Legend
function legend(newURL) { window.open(newURL, 'LEGEND', 'scrollbars=yes,resizable=yes,alwaysRaised=yes,width=400,height=400'); }

//Counts
function counts(newURL, width) { window.open(newURL, 'COUNTS', 'scrollbars=no,resizable=no,alwaysRaised=yes,width=' + width + ',height=150'); }

//highlight functions
var preEl;
var orgClass1;
var orgClass2;

// call: like <tr ... onClick="HighLightTR('rowhi',8);">
function HighlightTR(hiliteClass,class1Count) {
	//ignore clicks on buttons inside the row
	if(typeof(event.srcElement.name) != 'undefined')
		return;

	if(typeof(preEl)!='undefined') {
		try{ChangeClass(preEl,orgClass1,orgClass2,class1Count);}catch(e){;}
	} 

	var el = event.srcElement;
	el = el.parentElement;
	orgClass1 = el.cells(0).className;
	orgClass2 = el.cells(el.cells.length - 1).className;

	try{ChangeClass(el,hiliteClass,hiliteClass,class1Count);}catch(e){;}
	preEl = el; 
}

function ChangeClass(a_obj,a_class1,a_class2,a_count) {
	for (i=0;i<a_obj.cells.length;i++) {
		if (i < a_count)
			a_obj.cells(i).className = a_class1;
		else
			a_obj.cells(i).className = a_class2;
	}
}

//timer functions
function timeString(timeLeft) {
	days = parseInt(timeLeft / 86400000);
	if (isNaN(days))
		days = 0;

	timeLeft = parseInt(timeLeft % 86400000);
	hours = parseInt(timeLeft / 3600000);
	timeLeft = parseInt(timeLeft % 3600000);
	mins = parseInt(timeLeft / 60000);
	timeLeft = parseInt(timeLeft % 60000);
	secs = parseInt(timeLeft / 1000);

	d1 = parseInt(days / 10);
	if (isNaN(d1))
		d1 = 0;

	d2 = parseInt(days % 10);
	if (isNaN(d2))
		d2 = 0;

	h1 = parseInt(hours / 10);
	if (isNaN(h1))
		h1 = 0;

	h2 = parseInt(hours % 10);
	if (isNaN(h2))
		h2 = 0;

	m1 = parseInt(mins / 10);
	if (isNaN(m1))
		m1 = 0;

	m2 = parseInt(mins % 10);
	if (isNaN(m2))
		m2 = 0;
/*
	s1 = parseInt(secs / 10);
	if (isNaN(s1))
		s1 = 0;

	s2 = parseInt(secs % 10);
	if (isNaN(s2))
		s2 = 0;
*/
	return days+" day(s) "+h1+h2+":"+m1+m2;//+":"+s1+s2;
}

function countDown() {
	var el = document.all.timeLeft;
	var str = document.all.timeStr;
	
	if (el != null && str != null) {
		el.innerText -= 1000;
		
		if (60000<=el.innerText) {
			str.innerText = timeString(el.innerText);
			setTimeout("countDown()", 1000);
		}
		else if (-60000<=el.innerText) {
			str.innerText = "Less than 1 minute";
			setTimeout("countDown()", 1000);
	       }
	       else {
			str.innerHTML = "<font color=red>Auction closed</font>";
			showHide('auctionExpired','visible');
		}
	}
}

    //With nested layers for netscape, this function hides the layer if it's visible and visa versa
    function showHide(div, visibility){
            obj=document.getElementById(div).style;
			if (obj == null)
				obj=document.all[div].style;
			if (obj == null)
				obj=document[div];
        obj.visibility=visibility;
    }


