if(typeof(HTMLElement)!= 'undefined'){
	HTMLElement.prototype.__defineGetter__("parentElement", function() {return (this.parentNode == this.ownerDocument) ? null : this.parentNode;});
}

function changemenu(){
	url=location.href;
	if(url.length<22)url="http://dukechina.org/index.php";
	TagA=document.getElementById("mainmenu").getElementsByTagName("A");
	for(i=0;i<TagA.length;i++){
		if(url.indexOf(TagA[i].href)!=-1){
			tmp=TagA[i].parentElement;
			while(tmp){
				if(tmp.tagName=='LI') tmp.className='lion';
				tmp=tmp.parentElement;
			}
//		return;
		}

	}

}

sfHover = function() {
	if(!document.getElementById("mainmenu")) return;
	var sfEls = document.getElementById("mainmenu").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
window.onload=function(){
	changemenu();
	if(window.attachEvent) sfHover();
}


function showPoll(URL,form){
	newWindow=window.open(URL,"survey","toolbar,resizable,scrollbars,dependent,width=500,height=300,left=150,top=80");
	newWindow.focus();

	if(form){
		form.submit();
	}
//	newWindow=window.open(URL,"survey","toolbar,resizable,scrollbars,dependent,width=500,height=420,left=150,top=80");
//	newWindow.focus();
	return false;
}



function openURL(URL)
{
	newWindow=window.open(URL,"xixi","toolbar=no,menubar=no,location=no,status=no,resizable=yes,scrollbars=yes");
//	window.open(URL,"xixi","height=460,width=450,top=50,left=160,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no");
	newWindow.focus();
	return true;
}

function goURL(URL,msg)
{
//	if (event.button == 2 || event.button == 3) return true;
	if (msg&&msg!=''){
		if (!confirm(msg)) return true;
	}
	location = URL;
	return true;
}

function loadURL(URL,msg)
{
	if (msg&&msg!=''){
		if (!confirm(msg)) return false;
	}
	jsform.src=URL;
	return true;
}

function msout(){
	this.style.backgroundColor = "#F6F6F6";
	this.style.color = "#666666";
	return true;
}

function msover(){
	this.style.backgroundColor = "#CCCCCC";
	this.style.color = "#FFFFFF";
	return true;
}

function setPointer(theRow, theColor)
{
	var theCells = null;
//	theRow.style.cursor='hand';
	if (typeof(document.getElementsByTagName) != 'undefined') {
		theCells = theRow.getElementsByTagName('td');
	}
	else if (typeof(theRow.cells) != 'undefined') {
		theCells = theRow.cells;
	}
	else {
		return false;
	}
	var rowCellsCnt = theCells.length;
	var domDetect = null;
	if (typeof(window.opera) == 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') {
		domDetect = true;
	}
	else {
		domDetect = false;
	}
        var c = null;
	if (domDetect) {
		for (c = 0; c < rowCellsCnt; c++) {
			theCells[c].setAttribute('bgcolor', theColor, 0);
		}
	}
	else {
		for (c = 0; c < rowCellsCnt; c++) {
			theCells[c].style.backgroundColor = theColor;
		}
	}
	return true;
}

