jQuery(document).ready(function() {
  // hides the div as soon as the DOM is ready (a little sooner than page load)
  var bubbleInProgress = false;
  jQuery('.onYourSideBubble').hide();
  if (!bubbleInProgress) {
  bubbleInProgress = true;
	jQuery('img.onYourSideLink').hover(function() {
		jQuery(this).next('.onYourSideBubble').show('fast');	
	}, function() {
		bubbleInProgress = false;
		jQuery(this).next('.onYourSideBubble').hide('fast');	
	});
  }
});

	var isNN = (navigator.appName.indexOf("Netscape")!=-1);
	//The curser automatically goes to the next field when the specified number of digits are entered
	function autoTab(input,len, e) {
		var keyCode = (isNN) ? e.which : e.keyCode; 
		var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,35,36,37,38,39,40,45,46,144];
		if(input.value.length >= len && !containsElement(filter,keyCode)) {
			input.value = input.value.slice(0, len);
			input.form[(getIndex(input)+1) % input.form.length].focus();
		}

		function containsElement(arr, ele) {
			var found = false, index = 0;
			while(!found && index < arr.length)
				if(arr[index] == ele)
					found = true;
				else
					index++;
			return found;
		}
		
		function getIndex(input) {
			var index = -1, i = 0, found = false;
			while (i < input.form.length && index == -1)
				if (input.form[i] == input) //if they are the same object, this is it
					{
					index = i;
					}
				else i++;
				
			return index;
		}

		return true;
	}

function verify_length(contactForm) { //checks the length of the textarea
	maxLen = 4000;
	if (contactForm.message.value.length >= maxLen) {
		contactForm.message.value = contactForm.message.value.substring(0, maxLen);
		return false;
	}
}

function highlightRow(currentRadio){
	if(document.getElementById('selectedRow')){
		document.getElementById('selectedRow').id = '';
	}
	currentRadio.parentNode.parentNode.id = 'selectedRow';
	currentRadio.parentNode.parentNode.getElementsByTagName('input')[0].checked = 1;
}

function win_popup(URL, width, height) {
    window.open(URL,'_blank','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+width+',height='+height+',left=20,top=20');
}
