//<!--
// Ultimate client-side JavaScript client sniff. Version 3.03

    // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);

    // Note: Opera and WebTV spoof Navigator.  We do strict client detection.
    // If you want to allow spoofing, take out the tests for opera and webtv.
    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && (is_major >= 4));
    var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    var is_nav6 = (is_nav && (is_major == 5));
    var is_nav6up = (is_nav && (is_major >= 5));
    var is_gecko = (agt.indexOf('gecko') != -1);

    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie3    = (is_ie && (is_major < 4));
    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
    var is_ie4up  = (is_ie && (is_major >= 4));
    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
    var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

    // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
    // or if this is the first browser window opened.  Thus the
    // variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.
    var is_aol   = (agt.indexOf("aol") != -1);
    var is_aol3  = (is_aol && is_ie3);
    var is_aol4  = (is_aol && is_ie4);
    var is_aol5  = (agt.indexOf("aol 5") != -1);
    var is_aol6  = (agt.indexOf("aol 6") != -1);

//1k DHTML API
d=document;l=d.layers;op=navigator.userAgent.indexOf('Opera')!=-1;
function gE(e,f){if(l){f=(f)?f:self;var V=f.document.layers;if(V[e])return V[e];for(var W=0;W<V.length;)t=gE(e,V[W++]);return t;}if(d.all)return d.all[e];return d.getElementById(e);}
function sE(e){l?e.visibility='show':e.style.visibility='visible';}
function hE(e){l?e.visibility='hide':e.style.visibility='hidden';}
function sZ(e,z){l?e.zIndex=z:e.style.zIndex=z;}
function sX(e,x){l?e.left=x:op?e.style.pixelLeft=x:e.style.left=x;}
function sY(e,y){l?e.top=y:op?e.style.pixelTop=y:e.style.top=y;}
function sW(e,w){l?e.clip.width=w:op?e.style.pixelWidth=w:e.style.width=w;}
function sH(e,h){l?e.clip.height=h:op?e.style.pixelHeight=h:e.style.height=h;}
function sC(e,t,r,b,x){l?(X=e.clip,X.top=t,X.right=r,X.bottom=b,X.left=x):e.style.clip='rect('+t+' '+r+' '+b+' '+x+')';}
function wH(e,h){if(l){Y=e.document;Y.open();Y.write(h);Y.close();}else if(e.innerHTML)e.innerHTML=h;}

function tVisShow(eN){e=gE(eN);if(e.style.display=='block')e.style.display='none';else e.style.display='block';}

function resize()
{
	var header = gE('header');
	var content = gE('content');

	var miscVOffset = 0;
	var minContentHeight = 500;
	
	if (!is_nav6up) {
		// body height
		var newHeight = document.body.clientHeight - header.offsetHeight + miscVOffset;
		newHeight = (newHeight > minContentHeight) ? newHeight : minContentHeight;
		sH(content, newHeight);
	}
}

function init_echeng()
{
	if (is_nav3 || is_nav4 || is_ie4 || is_ie3 || is_aol) {
		nav('/browser_not_supported.html');
	} else {
		resize();
	}
}

function launchSlide(dir, imgNum) {
	launchSlideManual(dir, imgNum, null, null);
}

function launchSlideManual(dir, imgNum, width, height) {
	var defaultWidth=730;
	var defaultHeight=730;
	
	if (width == null) width = defaultWidth;
	if (height == null) height = defaultHeight;

	openWin = window.open("/output/slide.php?p=" + dir + "&c=" + imgNum, "photo","toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes, width=" + width + ", height=" + height);
	if (openWin) openWin.focus();	
}

function LaunchImagePageManual(page, width, height) {
	OpenWin = this.open(page, "photo","toolbar=no,menubar=no,location=yes,scrollbars=yes,resizable=yes, width=" + width + ", height=" + height);
	if (OpenWin) OpenWin.focus();
}

function LaunchEEPage(page) {
	LaunchImagePageManual(page, 820, 750);
}

function LaunchImagePage(page) {
	LaunchImagePageManual(page, 750, 705);
}

function LaunchImageSamePage(page) {
	window.location = page;
}

function LaunchSlidePage(page) {
	OpenWin = this.open(page, "slidepage","toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes, width=750, height=705");
	if (OpenWin) OpenWin.focus();
}

function showJournalImageManual(imgName, width, height) {
	OpenWin = this.open('/scripts/photo_close.php?url=journal/images/full/' + imgName, "photo","toolbar=no,menubar=no,location=yes,scrollbars=yes,resizable=yes, width=" + width + ", height=" + height);
	if (OpenWin) OpenWin.focus();
}

function showJournalImage(imgName) {
	showJournalImageManual(imgName, 750, 705);
}

function popReferrers() {
	OpenWin = this.open("/referrers.php", "referrers","toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes, width=390, height=550");
	if (OpenWin) OpenWin.focus();
}

function nav(url)
{
	window.location=url;
}

function emaileric()
{
	nav("/contact/");
}

function searchgoogle()
{
	// searchtextfield = gE('mysearchbox')    
	var searchtextfield = document.getElementById && document.getElementById ('mysearchbox');
	
	if (searchtextfield && searchtextfield.value.length > 0) {
 	  	nav('http://www.google.com/search?q=' + searchtextfield.value + '+site%3Aecheng.com');
		return true;
	} else {
		alert('Gotta enter something to search for to make this work!');
		return false;
	}
}

function searchformkeypress(e) {
	var unicode=e.keyCode? e.keyCode : e.charCode;
	if (unicode==13) {
		searchgoogle();
		return false;
	} else {
		return true;
	}
}
