
// showing and hiding divs...
function toggleImages( whichLayer )
{
  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(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';
}

// cookie functions from http://www.quirksmode.org/js/cookies.html
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name.toLowerCase()+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name.toLowerCase() + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i].toLowerCase();
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


// things that should happen on all pages with cookies...
// remove obsolete cookies
if (readCookie('WT_FPC')!="") {
	createCookie('WT_FPC',"",-1);
}
if (readCookie('UAID')!="") {
	createCookie('UAID',"",-1);
}

// set referrer cookie, if not already set
function checkReferrer() {
	if (document.referrer=='') {}
	else if (document.referrer=='-') {}
	else if (document.referrer.indexOf ('netterimages.com') > 0) {}
	else if (readCookie('sr')!=null) {}
	else { createCookie ('sr',document.referrer); }
}

function dynamicLogout() {
	if((window.location.href.indexOf('customer')!=-1)||window.location.href.indexOf('admin'))
		window.location="/";
	else
		window.location.reload();
}

function startNewReg() {
	pageTracker._trackPageview('/customer/newuser');
	ntptEventTag('ev=newuser');	
}

