function popwin(url, name, x, y) {
	if (x == null) x = 480;
	if (y == null) y = 500;
	var glossary = window.open(url, name, 'width=' + x + ',height=' + y + ',scrollbars=yes,resizable=yes,toolbar=no,status=yes,menubar=no');
}


function changeContent(id,shtml) {
   if (document.getElementById || document.all) {
      var el = document.getElementById? document.getElementById(id): document.all[id];
      if (el && typeof el.innerHTML != "undefined") el.innerHTML = shtml;
   }
}

function toggleLayer(whichLayer,stater) {
	var elem, vis;
	if( document.getElementById ) // this is the way the standards work
		elem = document.getElementById( whichLayer );
	else if( document.all ) // this is the way old msie versions work
		elem = document.all[whichLayer];
	else if( document.layers ) // this is the way nn4 works
		elem = document.layers[whichLayer];
	vis = elem.style;
	// if the style.display value is blank we try to figure it out here
	if (stater == 'show') {
		vis.display = 'block';
	} else {
		vis.display = 'none';
	}
	//if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
	//	vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
	//vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function changeClass(Elem, myClass) {
	var elem;
	if(document.getElementById) {
		var elem = document.getElementById(Elem);
	} else if (document.all){
		var elem = document.all[Elem];
	}
	elem.className = myClass;
}

function menu_goto( menuform ) {
	var selecteditem = menuform.newurl.selectedIndex ;
	var newesturl = menuform.newurl.options[ selecteditem ].value ;
	if (newesturl.length != 0) {
		menuform.newurl.options[0].selected=true;
		location.href = newesturl ;
	}
}

// Start tooltips code --------------------------------------------------------------
var offsetx = 12;
var offsety =  8;
var tiplocker;
function newelement(newid) { 
    if(document.createElement)
    { 
        var el = document.createElement('div'); 
        el.id = newid;     
        with(el.style)
        { 
            display = 'none';
            position = 'absolute';
        } 
        el.innerHTML = '&nbsp;'; 
        document.body.appendChild(el); 
    } 
} 
var ie5 = (document.getElementById && document.all); 
var ns6 = (document.getElementById && !document.all); 
var ua = navigator.userAgent.toLowerCase();
var isapple = (ua.indexOf('applewebkit') != -1 ? 1 : 0);
function getPosition(e) {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } 
    else {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
	var lixlpixel_tooltip = document.getElementById(tiplocker);
	if (tiplocker == 'calinsideroll') {
		offsetx = -215;
	}
	lixlpixel_tooltip.style.left = (cursor.x+offsetx) + 'px';
    lixlpixel_tooltip.style.top = (cursor.y+offsety) + 'px';
    //return cursor;
}
function tooltip(tip,tiploc) {
	tiplocker = tiploc;
    if(!document.getElementById(tiploc)) newelement(tiploc);
    var lixlpixel_tooltip = document.getElementById(tiploc);
    lixlpixel_tooltip.innerHTML = tip;
    lixlpixel_tooltip.style.display = 'block';
    document.onmousemove = getPosition;
}
function exit(tiploc) {
    document.getElementById(tiploc).style.display = 'none';
}
// End tooltips code ----------------------------------------------------------------



// Start div scroller code ----------------------------------------------------------
// gives up and down scroll buttons to images, spans, ... named up_name, down_name, respectively.
// will keep the default scroll_box's style overflow if it encounters errors (so make overflow: auto;)
// usage: put this after the scrollbox div:  var div_scroll1 = new TextScroll('div_scroll1', 'scroll_box');

function TextScroll(scrollname, div_name, up_name, down_name) {
    this.div_name = div_name;
    this.name = scrollname;
    this.scrollCursor = 0;
    this.speed = 10;
    this.timeoutID = 0;
    this.div_obj = null;
    this.up_name = up_name;
    this.dn_name = down_name;
	{
        if (document.getElementById) {
            var div_obj = document.getElementById(this.div_name);
            if (div_obj) {
                this.div_obj = div_obj;
                this.div_obj.style.overflow = 'hidden';
            }
            var div_up_obj = document.getElementById(this.up_name);
            var div_dn_obj = document.getElementById(this.dn_name);
            if (div_up_obj && div_dn_obj) {
                div_up_obj.onmouseover = function() { eval(scrollname + ".scrollUp();") };
				div_up_obj.onmouseout = function() { eval(scrollname + ".stopScroll();") };
				div_dn_obj.onmouseover = function() { eval(scrollname + ".scrollDown();") };
				div_dn_obj.onmouseout = function() { eval(scrollname + ".stopScroll();") };
            }
        }
    }
	this.stopScroll = function() {
        clearTimeout(this.timeoutID);
    }
	this.scrollUp = function() {
        if (this.div_obj) {
            this.scrollCursor = (this.scrollCursor - this.speed) < 0 ? 0 : this.scrollCursor - this.speed;
            this.div_obj.scrollTop = this.scrollCursor;
            this.timeoutID = setTimeout(this.name + ".scrollUp()", 60);
        }
    }
	this.scrollDown = function() {
        if (this.div_obj) {
            this.scrollCursor += this.speed;
            this.div_obj.scrollTop = this.scrollCursor;
            this.timeoutID = setTimeout(this.name + ".scrollDown()", 60);
        }
    }
	this.resetScroll = function() {
        if (this.div_obj) {
            this.div_obj.scrollTop = 0;
            this.scrollCursor = 0;
        }
    }
}
// end div scroller code ------------------------------------------------------------

// share with friend code -----------------------------------------------------------
function ajaxShare(formy){
	var formname = document.getElementById(formy);
	var ajaxRequest;  // The variable that makes Ajax possible!
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ni = document.getElementById('tabsharemessage');
			formname.to.value = '';
			formname.from.value = '';
			ni.innerHTML = ajaxRequest.responseText;
		}
	}
	var queryString = "?to=" + formname.to.value + "&from=" + formname.from.value + "&intro=" + formname.intro.value + "&subject=" + formname.subject.value + "&response=" + formname.response.value + "&dork=";
	ajaxRequest.open("GET", "/i/share.php" + queryString, true);
	ajaxRequest.send(null);
	var removethis = 1;
}
// end share with friend code -------------------------------------------------------

function clearMe(formfield){
	if (formfield.defaultValue==formfield.value)
	formfield.value = "";
 }

function doMail(theLink, key){

    //Get the HREF tag. This includes the anti-spam 'key'
    var before = theLink.getAttribute('href');

    //If the anti-spam key is not found in the link, exit the function without doing anything
    //If the link is clicked more than once, this prevents the Javascript from throwing an error
    if(before.indexOf(key) == -1) return false;

    //Our new variable "addy" is a combination of the text that
    //comes BEFORE the key [0] and AFTER the key [1]
    var addy = before.split(key)[0] + before.split(key)[1];

    //Substitute the original link with the new link ("addy")
    theLink.href = addy;
	return true;
}

function resetBottomPage(){
	// this attempts to fix an IE7 display issue
	var theCont = document.getElementById('lower');
	theCont.style.bottom = '';
	theCont.style.bottom = '0';
}

function frontpagenav(selectorChosen,selectorCount,selectorThumbs) {
	var iThumb=selectorThumbs.split(" ");
	for (a = 1; a < (selectorCount + 1); a++) {
		// change the image inside of the clicked on div
		var thisThumb = document.getElementById("slideselect" + a);
		if (a == selectorChosen) {
			// change style
			thisThumb.className = "frontslidethumblink";
			// change thumb to color
			thisThumb.innerHTML = '<img src="/images/thumb_' + iThumb[a - 1] + '.jpg" width="45" height="45" border="0" alt="change slide" />';
			thisThumb.blur();
		} else {
			thisThumb.className = "frontslidethumblink gray";
			thisThumb.innerHTML = '<img src="/images/thumbgray_' + iThumb[a - 1] + '.jpg" width="45" height="45" border="0" alt="change slide" />';
		}
	}
}
