function updateTopMenu(n){
	if(document.images['a'+n])
		document.images['a'+n].src='/images/arrow.gif';
	if(document.getElementById('l'+n))
		document.getElementById('l'+n).style.color='#0099cc';
}

var currentSubnav=-1;
function setSubnav(n){
	var im=document.images['subA'+n];
	var style=document.getElementById('subL'+n).style;
	if(im && style){
		im.src=im.src.substr(0, im.src.length-4)+'A.gif';
		style.color='#0099cc';
		currentSubnav=n;
	}
}
function overSubnav(n){
	if(n!=currentSubnav){
		var im=document.images['subA'+n];
		var style=document.getElementById('subL'+n).style;
		if(im && style){
			im.src=im.src.substr(0, im.src.length-4)+'A.gif';
			style.color='#0099cc';
		}
	}
}
function outSubnav(n){
	if(n!=currentSubnav){
		var im=document.images['subA'+n];
		var style=document.getElementById('subL'+n).style;
		if(im && style){
			im.src=im.src.substr(0, im.src.length-5)+'.gif';
			style.color='#505050';
		}
	}
}
function overWhiteArrow(n){
	if(document.images['wArrow'+n])
		document.images['wArrow'+n].src='../images/subnav/whiteArrowA.gif';
}
function outWhiteArrow(n){
	if(document.images['wArrow'+n])
		document.images['wArrow'+n].src='../images/subnav/whiteArrow.gif';
}
var increment=1;
function scrollingText(numberOfDivisions, w, h){
	
	var height=h;
	var totalLength=-1;
	this.divisions=new Array();

	for(var i=0;i<numberOfDivisions;i++)
		this.divisions[i]=new scrollingDivision();
	
	for(var i=0;i<numberOfDivisions;i++)
		this.divisions[i].init(i);
	
	this.move=function(){
		checkTotalLength();//ie hack
		for(var i=0,l=divisions.length;i<l;i++)
			this.divisions[i].moveDiv();
		setTimeout('this.move()',70);
	}

	function setTotalLength(){
		totalLength=0;
		for(var i=0,l=divisions.length;i<l;i++){
			this.divisions[i].initStartPos(totalLength);
			totalLength=totalLength+this.divisions[i].getHeight();
		}
		if(totalLength<height)
			totalLength=height;
	}
	function checkTotalLength(){
		var tmpLength=0;
		for(var i=0,l=divisions.length;i<l;i++){
			tmpLength=tmpLength+this.divisions[i].getHeight();
		}
		if(tmpLength!=totalLength){
			setTotalLength();
		}
	}
	function scrollingDivision(){
		this.currY=h;
		this.txtDiv;
		this.style;

		this.writeHtml=function(n){
			var htm=new Array();
			htm.push('<div id=d'+n+' style="position:absolute;top:-500px;width:100%;">');
			htm.push(this.txt);
			htm.push('</div>');
			return htm.join('');
		}
		this.init=function(n){
			this.txtDiv=document.getElementById('d'+n);
			this.style=this.txtDiv.style;
		}
		this.initStartPos=function(n){
			this.currY=n
			this.style.top=n
		}
		this.reset=function(){
			this.currY=totalLength-this.getHeight();
			if(this.currY<height)
				this.currY=height;
		}
		this.getHeight=function(){
			return this.txtDiv.offsetHeight;
		}
		this.moveDiv=function(){
			this.currY=this.currY-increment;
			if(this.currY<this.getHeight()*-1)
				this.reset();
			this.style.top=this.currY+'px';
		}
	}
	this.move();
}

function popupMsg(companyName, xPos, yPos, n){
	var html= new Array();
	html.push('<div id=dBox'+n+' style="position:absolute;top:'+yPos+'px;left:'+xPos+'px;display:none;">');
	html.push('<table style="border: 2 solid #0099cc;" width=250 height=100 bgcolor=#C3E6F6>');
	html.push('<tr>');
	html.push('	<td>');
	html.push('		<b>Please note:</b> Stauff Pumps is the official distributor for '+companyName+' in Australia and New Zealand.<br>To make a purchase or to request more information, please contact Stauff Pumps through our <b>\'Contact Us\'</b> page.');
	html.push('	</td>');
	html.push('</tr>');
	html.push('</table>');
	html.push('</div>');
	document.write(html.join(''));
}
function openBox(n){
	var b=document.getElementById('dBox'+n)
	b.style.display='block'
}
function closeBox(n){
	var b=document.getElementById('dBox'+n)
	b.style.display='none'
}
function check(){
	var uName = document.form1.usrname.value;
	var pWord = document.form1.passwrd.value;
	if(uName && pWord){
		setCookie('usrname', uName+pWord);
		window.location.reload();
	}
}
function setCookie(name, value, expires, path, domain, secure){
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

//-FUNCTION ORIGIN UNKNOWN
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
//-FUNCTION ORIGIN UNKNOWN
function MM_findObj(n, d) { //v4.01
	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);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}
//-FUNCTION ORIGIN UNKNOWN
function MM_jumpMenu(targ,selObj,restore){ //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}
//-FUNCTION ORIGIN UNKNOWN
function MM_jumpMenu(targ,selObj,restore){ //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}
