var ieX = (navigator.appName.indexOf("Microsoft") != -1);

var ns4 = (document.layers);
var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);

/* workaround for netscape 4 resize bug: http://www.webreference.com/dhtml/diner/resize/ */
if(ns4){origWidth=innerWidth;origHeight=innerHeight;onresize=function(){if(innerWidth!=origWidth||innerHeight!=origHeight)location.reload()}}

function pageload() {
	loaded = true;
}

function getElement(id,doc) {
	if (!doc) { doc = document; }
	if (ie5||ns6)
		return(doc.getElementById(id));
	else if (ie4)
		return(doc.all[id]);
	else if (ns4)
		return(doc.layers[id]);
	else
		return null;
}

function getDivDocument(d) {
	if (ns6)
		return d.ownerDocument;
	else
		return d.document;
}

function styleObject(e) {
	return (ns4 ? e : e.style);
}

function showElement(e,force) {
	so = styleObject(e);
	so.visibility = "visible";
	if (force) { so.zIndex = 999; }
}

function hideElement(e,force) {
	so = styleObject(e);
	so.visibility = "hidden";
	if (force) { so.zIndex = -999; }
}

function w(t) { document.write(t); }

function changeContent(e,t) {
	if (!ns4)
		e.innerHTML = t;
	else if (document.layers) {
		e.document.open();
		e.document.write(t);
		e.document.close();
	}
}

function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + '$' + num + '.' + cents);
}

// the following code adds dreamweaver rollover support
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// content scroller stuff
maxy=0;
miny=0;
contentTimer=false;
contentDirection=0;

function contentUp() {
	contentDirection = 1;
	contentTimer = setInterval("contentLogic()",50);
}

function contentDown() {
	contentDirection = -1;
	contentTimer = setInterval("contentLogic()",50);
}

function contentStop() {
	clearInterval(contentTimer);
}

function contentLogic() {
	slideContent(0,10*contentDirection);
}

function slideContent(x,y) {
	if (!loaded)
		return;
		
	if (ns4) {
		eContainer = getElement('contentContainer');
		e = getElement('contentText',eContainer)
	}
	else
		e = getElement('contentText');
	
	if (miny==0) {
		if (ns4) {
			miny = (e.clip.height*-1)+270;
		}
		else {
			miny = (e.offsetHeight*-1)+270;
		}
	}
			
	s = styleObject(e);
	if (!s.top)
		s.top = 0;

	//alert(parseInt(s.top) +" "+ miny +" "+ maxy);

	if (!(miny > maxy)) {
		s.top = parseInt(s.top) + y;
		if (parseInt(s.top) < miny)
			s.top = miny;
		else if (parseInt(s.top) > maxy)
			s.top = maxy;
	}
	
	//alert(parseInt(s.top) +" "+ miny +" "+ maxy);
}
