function filter (imagename, objectsrc) {
	if (document.images) {
	document.images[imagename].src=eval(objectsrc+".src")
	}
}	

var sectionArray = new Array("browser","guide","avatars","village","site","city")

function setMouseSection(thisSec,curSec) {
	for (z = 0; z < sectionArray.length; z++) {
		if (thisSec==sectionArray[z]) {
			document.images["Stm0p0i"+z+"eIMG"].src="/graphics/icons/nav"+sectionArray[z]+"_on.gif";
		}
	}
	for (z = 0; z < sectionArray.length; z++) {
		if (curSec==sectionArray[z]) {
			document.images["Stm0p0i"+z+"eIMG"].src="/graphics/icons/nav"+sectionArray[z]+"_on.gif";
		}
	}
}

//var curSection=thisSection;

function navOn(idName) {
	// first we turn off all the main ids
	var x;
	for (x = 0; x < topnavArray.length; x++) {
//		document.getElementById(topnavArray[x]+"CurveLeft").src="./graphics/icons/blankCurveLeft.png";
//		document.getElementById(topnavArray[x]+"CurveRight").src="./graphics/icons/blankCurveRight.png";
//		document.getElementById(topnavArray[x]+"Cell").className="blankCurveSpacer "+topnavArray[x];
//		document.getElementById(topnavArray[x]+"Sub").style.display="none";
	}
	document.getElementById(idName+"CurveLeft").src="/graphics/icons/fullCurveLeft.png";
	document.getElementById(idName+"CurveRight").src="/graphics/icons/fullCurveRight.png";
	document.getElementById(idName+"Cell").className="fullCurveSpacer "+idName;
	
}

function navOff() {
	// first we turn off all the main ids
	var curveName = "blank";
	var x;
	for (x = 0; x < topnavArray.length; x++) {
		if (topnavArray[x]==hubName) {
			curveName = "full";
		} else {
			curveName = "blank";
		}
		document.getElementById(topnavArray[x]+"CurveLeft").src="/graphics/icons/"+curveName+"CurveLeft.png";
		document.getElementById(topnavArray[x]+"CurveRight").src="/graphics/icons/"+curveName+"CurveRight.png";
		document.getElementById(topnavArray[x]+"Cell").className=curveName+"CurveSpacer "+topnavArray[x];
	}
}

function subNavOn(idName) {
	if (document.getElementById(subIdName)) {
		document.getElementById(subIdName).className="subOn";
	}
	document.getElementById(idName+"Sub").style.display="inline";
	navOn(idName,true);
}

function subNavOff(idName) {
	var index = matchArray(idName,topnavArray,arrayIndex);
	for (p = 0; p < subnavArray.length; p++) {
		for (q = 0; q < subnavArray[p].length; q++) {
			document.getElementById(subnavArray[p][q]).className="sub";
		}
	}
	if (document.getElementById(subIdName)) {
		document.getElementById(subIdName).className="sub";
	}
	navOff(idName,true);
}


function showSub(idName) {
	if (document.getElementById(idName+"Sub")) {
		document.getElementById(idName+"Sub").style.display="inline";
	}
}

function hideSub(idName) {
	if (idName == "") { // does all of them
		for (x = 0; x < topnavArray.length; x++) {
			document.getElementById(topnavArray[x]+"Sub").style.display="none";
		}
	} else {
		if (document.getElementById(idName+"Sub")) {
		//	document.getElementById(idName+"Sub").style.display="none";
		}	
	}	
}


var vb_flash_check = 0;
function get_flash_version(flash_required) {
    var flash_version = 0;
    if (navigator.mimeTypes) {
			var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
			if (plugin)
	  	  flash_version = parseInt(plugin.description.substring(plugin.description.indexOf(".")-1));
		}

    if (navigator.userAgent && navigator.userAgent.indexOf("MSIE") >= 0 && navigator.userAgent.indexOf("Win") >= 0) {
			document.writeln("<scr" + "ipt language=\"VBScript\"\>");
			document.writeln("on error resume next");
			document.writeln("vb_flash_check = (IsObject(CreateObject(\"ShockwaveFlash.ShockwaveFlash."+ flash_required + "\")))");
			document.writeln("</scr" + "ipt>");
			if(vb_flash_check) // Should really check flash version
  		  flash_version = flash_required;
		}
  return flash_version;
}
		
function flashtry(version)
    {
    var flash_version = 0;

    if (parseInt(navigator.appVersion.substring(0,1)) > 2)
			flash_version = get_flash_version(version);

    if (flash_version >= version) {
	    return 1;
	} 
    return 0;
    }

function hasHref(theHref,str) {
	if (theHref!="") {
		return "<a href=\""+theHref+"\">"+str+"</a>";
	} else {
		return str;
	}
}

function matchArray(value,array1,array2) {
	var newValue = "";
	for (a = 0; a < array1.length; a++) {
		if (array1[a] == value) {
			newValue = array2[a];
			break;
		}
	}
	return newValue;
}

function checkMatch(thisValue,curValue,showThis,showThat) {
	if (thisValue==curValue) {
		return showThis;
	} else {
		return showThat;
	}
}

function flashVsImage(flashCheck,flashHref,flashPath,imagePath,fWidth,fHeight) {
	var flashHTML = "";
	var imageHTML = "";
	var html = "";
	
	if (flashPath != "") {
		flashHTML += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\""+fWidth+"\" height=\""+fHeight+"\">";
			flashHTML += "<param name=\"movie\" value=\""+flashPath+"?clickTAG="+flashHref+"\">";
			flashHTML += "<param name=\"quality\" value=\"high\">";
			flashHTML += "<param name=\"wmode\" value=\"transparent\">";
			flashHTML += "<embed src=\""+flashPath+"?clickTAG="+flashHref+"\" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+fWidth+"\" height=\""+fHeight+"\"></embed>";
		flashHTML += "</object>";
	}
	
	if (imagePath != "") {
		imageHTML += "<img src=\""+imagePath+"\" border=\"0\" width=\""+fWidth+"\" height=\""+fHeight+"\"/>";
	}
	if ((!flashtry(flashCheck)) || (flashCheck==0)) {
		html = imageHTML;
	} else {  // doesn't have flash version, so we show HTML version
		html = flashHTML;
	}		
	document.write(html);
}

function flashVsImageID(flashID,flashCheck,flashHref,flashPath,imagePath,fWidth,fHeight) {
	var flashHTML = "";
	var imageHTML = "";
	var html = "";
	
	if (flashPath != "") {
		flashHTML += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\""+fWidth+"\" height=\""+fHeight+"\">";
			flashHTML += "<param name=\"movie\" value=\""+flashPath+"?clickTAG="+flashHref+"\" />";
			flashHTML += "<param name=\"quality\" value=\"high\" />";
			flashHTML += "<param name=\"wmode\" value=\"transparent\" />";
			flashHTML += "<embed src=\""+flashPath+"?clickTAG="+flashHref+"\" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+fWidth+"\" height=\""+fHeight+"\"></embed>";
		flashHTML += "</object>";
	}
	
	if (imagePath != "") {
		imageHTML += "<img src=\""+imagePath+"\" border=\"0\" width=\""+fWidth+"\" height=\""+fHeight+"\"/>";
	}
	if ((!flashtry(flashCheck)) || (flashCheck==0)) {
		html = imageHTML;
	} else {  // doesn't have flash version, so we show HTML version
		html = flashHTML;
	}		
	if (document.getElementById(flashID)) {
		document.getElementById(flashID).innerHTML = html;
	}
}

function flashIfInstalled(flashID,flashCheck,flashHref,flashPath,fWidth,fHeight) {
	
	if ((!flashtry(flashCheck)) || (flashCheck==0)) {
		;
	} else {
	    var element = document.getElementById(flashID);
	    var flashHTML = "";
	    flashHTML += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\""+fWidth+"\" height=\""+fHeight+"\">";
	    flashHTML += "<param name=\"movie\" value=\""+flashPath+"?clickTAG="+flashHref+"\" />";
	    flashHTML += "<param name=\"quality\" value=\"high\" />";
	    flashHTML += "<param name=\"wmode\" value=\"transparent\" />";
	    flashHTML += "<embed src=\""+flashPath+"?clickTAG="+flashHref+"\" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+fWidth+"\" height=\""+fHeight+"\"></embed>";
	    flashHTML += "</object>";
	    element.innerHTML = flashHTML;
	}
}

function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}

