// Get out of some idiot's frame
if( top != self ) {
	top.location = self.location;
}


// Redirect to page based on selection from a select menu
function selectRedirect( target, selObj, restore ) {
	eval( target + ".location='" + selObj.options[selObj.selectedIndex].value + "'" );
	if( restore ) selObj.selectedIndex = 0;
}


// Decode Email (if encoded, i = a, o = e, u = i, a = o, e = u, '_' = '-', ' ' = '_' )
function assembleEmail( prefix, suffix, domain, encoded ) {
	var email = prefix + '@' + suffix + '.' + domain;
	if( encoded ) {
		strSearch = new Array( /$/, /i(?!#)/g, /o(?!#)/g, /u(?!#)/g, /a(?!#)/g, /e(?!#)/g, /(#|!)/g, /_/g, / /g );
		strReplace = new Array( '!', "a#", "e#", "i#", "o#", "u#", '', '-', '_' );
		i = 0;
		while( strSearch[i] != null ) {
			email = email.replace( strSearch[i], strReplace[i] );
			i++;
		} // end while
	} // end if
	var mailto = 'mailto:' + email;
	window.location = mailto;
} // end function


// toggle visibility
function toggle( targetId ) {
	if( document.getElementById ) {
		target = document.getElementById( targetId );
		if( target.style.display == "" || target.style.display == "none" ) {
			target.style.display = "block";
		}
		else {
			target.style.display = "none";
		}
	}
}


// toggle visibility for multiple items
function toggle2x( targetId, selfId ) {
	if( document.getElementById ) {
		target1 = document.getElementById( targetId );
		toggle( target1 );
		target2 = document.getElementById( selfId );
		toggle( target2 );
	} // end if
}


// toggle visibility once
toggled = new Array()
function toggleOnce( targetId ) {
	if( targetId in toggled ) return false;
	toggle( targetId );
	toggled[targetId] = true;
}


// Navigation Menu
function buildArray() {
	var a = buildArray.arguments;
	for (i=0; i<a.length; i++) {
		this[i] = a[i];
	}
	this.length = a.length;
}

var urls1 = new buildArray("",
"/","http://the-scholars.com/","http://simrtk.net/","/sitemap/",
"/novel/","/games/","/email/","/games/three_kingdoms/",
"/11/","/10/","/9/","/8/","/7/","/games/three_kingdoms/",
"/games/dynasty_warriors/","/dw6/","/dw5/","/dw4/","/dw3/","/games/dynasty_warriors/",
"/games/dynasty_tactics/","/dt2/","/dt/","/games/kessen/",
"/kessen2/","/kessen/","/games/other/","/samurai_warriors/",
"/games/#fotd","/games/#borc","/doae/","/doae2/","/doae3/");

function go( which, num, win ) {
	n = which.selectedIndex;
	if (n != 0) {
		var url = eval("urls" + num + "[n]")
		if (win) {
			openWindow(url);
		} else {
			location.href = url;
		}
	}
}



// Image Viewer; version 1.1.3, 062604; (string, boolean, integer, integer )
function newWindow( image, expand, iwidth, iheight, igame, ipath, ivariables ) {
	if( !igame || !ipath ) {
		url = "/i/?game=" + game + "&path=" + path;
	}
	else {
		url = "/i/?game=" + igame + "&path=" + ipath;
	}
	url += "&image=" + image;
	if( iwidth && iheight ) {
		url += "&width=" + iwidth + "&height=" + iheight;
	}
	else {
		url += "&width=" + width + "&height=" + height;
	}
	if( ivariables ) {
		url += ivariables;
	}
	if( expand ) {
		url += "&expand=true";
		if( iheight && iwidth ) {
			iwidth += 30;
			iheight += 45;
		}
		else {
			iwidth = width + 30;
			iheight = height + 45;	  
		}
		viewer = window.open( url, "imageViewer", "toolbar=no,location=no,scrollbars=yes,resizable=yes,width=" + iwidth + ",height=" + iheight );
	}
	else {
		if( iheight && iwidth ) {
			iwidth = iwidth;
			iheight = iheight + 22;
		}
		else {
			iwidth = width;
			iheight = height + 22;	  
		}
		viewer = window.open( url, "imageViewer", "toolbar=no,location=no,scrollbars=no,resizable=no,width=" + iwidth + ",height=" + iheight );
	}
	viewer.focus();
}


////////////////////////////////
// OLD DREAMWEAVER JAVASCRIPT //
////////////////////////////////

// Select jump meus (redirect to new selectRedirect)
function MM_jumpMenu( targ, selObj, restore ) {
	selectRedirect( targ, selObj, restore );
}

// Used to specify attributes of popup windows (use new_window instead)
function MM_openBrWindow( theURL,winName,features ) {
	window.open(theURL,winName,features);
}

