
    function setFocus(aForm){
        if( aForm.elements[0]!=null) {
            var i;
            var max = aForm.length;
            for( i = 0; i < max; i++ ) {
                if( aForm.elements[ i ].type != "hidden"
                    && !aForm.elements[ i ].disabled
                    && !aForm.elements[ i ].readOnly ) {
                        aForm.elements[ i ].focus();
                        break;
                    }
            }
        }
    }



function showToolTip(e,text){
	if(document.all)e = event;
	
	var obj = document.getElementById('bubble_tooltip');
	var obj2 = document.getElementById('bubble_tooltip_content');
	obj2.innerHTML = text;
	obj.style.display = 'block';
	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
	if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 
	var leftPos = e.clientX - 100;
	if(leftPos<0)leftPos = 0;
	obj.style.left = leftPos + 'px';
	obj.style.top = e.clientY - obj.offsetHeight -1 + st + 'px';
}	

function hideToolTip()
{
	document.getElementById('bubble_tooltip').style.display = 'none';
	
}

NS4 = (document.layers) ? true : false;

function checkEnter(event){ 	
	var code = 0;
	if (NS4)
		code = event.which;
	else
		code = event.keyCode;
	if (code==13)
		document.CreateProfile.submit();
}

function confirmCustomSubmit(destination){
		document.confirm.action = destination;
		document.confirm.submit();
}


function fillIt(type,theForm) {
  if (type == 1) {
    theForm.elements['billingadd'].value = theForm.elements['add'].value;
    theForm.elements['billingadd2'].value = theForm.elements['add2'].value;
    theForm.elements['billingcity'].value = theForm.elements['city'].value;
    theForm.elements['billingstate'].value = theForm.elements['state'].value;
	//TOOLSTUDIOS JEFF SANK: 4/1707 - restated below line as above due to inexplicable error (probably due to the fact that these values span 2 pages now)
	//   document.userInfo.billingstate.selectedIndex = document.userInfo.state.selectedIndex
	theForm.elements['billingzip5'].value = theForm.elements['zip5'].value;
	theForm.elements['billingzip4'].value = theForm.elements['zip4'].value;
	//theForm.elements['billingphone13'].value = theForm.elements['phone13'].value;
	//theForm.elements['billingphone23'].value = theForm.elements['phone23'].value;
	//theForm.elements['billingphone4'].value = theForm.elements['phone4'].value;
  }
  else if (type == 2) {
    theForm.elements['nameoncard'].value = (theForm.elements['fname'].value+ " " +theForm.elements['lname'].value);
   }
}

function secondNotice(days,catid,orderID,catName,catDisplay){
	if (catDisplay == 1){
		if (days <= 75) {
			alert("It usually takes up to 75 days to have the catalog company process a stop request.  Currently it has only been " + days + ".  If, after 75 days have passed, you are still receiving catalogs from this company, please return to this page and click the Send Second Stop Notice link.");
		}else{
			if (confirm("IMPORTANT -- You Stopped the " + catName + "  "+days+" days ago, CLICK OK to submit stop or hit CANCEL"))
			//alert('send2notice');
			location.href="send2notice.cfm?catID="+catid+"&orderID="+orderID+"&catName="+escape(catName);
		}
	}else{
		alert("Your 2nd stop notice for " + catName + " can not be completed.  It is not active at this time.")
	}
}


function stopAddLimit(){
		alert("You may only select 10 stops at a time.  Please click the next button and process the stops you've already selected before adding more.");
}


function stopNextDisallow(){
		alert("Sorry but you may not proceed without any selected stops.");
}


function validateForm() {
	x = 0;
	if (document.CreateProfile.userID.value == "") {
		alert("You must enter your desired userID in the userID field.");
		x = 1;
	}
	if (document.CreateProfile.pass.value == "") {
		if (x != 1) {
			alert("You must enter a password in the password field.");
			x = 1;
		}	
	}
	if (x != 1) {
		document.CreateProfile.submit();
	}
}


