
$(document).ready(function(){
    // VALIDATE DRUG SEARCH
    $("#aphabeticalSearchForm").validate({
        rules: {
            name: {
				required: true,
				minlength: 3
            }
        },
        messages: {
            name: {
                required: "Enter a drug name",
                minlength: "You must use least 3 characters"
            }
        }
    });
    $("#HeadSearch").submit(function() {
		var searchWord = $("input#name").val();
			if (searchWord.length < 3) {
				alert('You must enter at least 3 characters to do a search.');
				return false;
				}				
	});
    
    $('#orderOnlineLink').click(function(){
        $('#showOnlineInstructions').load('orderonline.php').toggle();
    });
    
    $('#orderPhoneLink').click(function(){
        //$('#showPhoneInstructions').load('orderbyphone.php').toggle();
		$('#showphoneInstructions').load('orderbyphone.cfm').toggle();
    });
    
    $('#orderMailLink').click(function(){
        $('#showMailInstructions').load('orderbymail.cfm').toggle();
    });
    $('#showGeneric').mouseover(function(){
		$('#wiag').show();
	});
    $('#showGeneric').mouseout(function(){
		$('#wiag').hide();
	});
// ToolTips	
	$(".tipShipping img").jHelperTip({
		 trigger: "hover",
		 source: "ajax",
		 topOff: 10,
		 leftOff: 20,
		 type: "GET", 
		 url: 'includes/tips.cfm',
		 data: 'tip=shipping2',
		 loadingText: 'loading...',
		 autoClose: true
	});
	$(".tipPrescription img").jHelperTip({
		 trigger: "hover",
		 source: "ajax",
		 topOff: 10,
		 leftOff: 20,
		 type: "GET", 
		 url: 'includes/tips.cfm',
		 data: 'tip=prescription',
		 loadingText: 'loading...',
		 autoClose: true
	});
			  
	$(".tipOTC img").jHelperTip({
		 trigger: "hover",
		 source: "ajax",
		 topOff: 10,
		 leftOff: 20,
		 type: "GET", 
		 url: 'includes/tips.cfm',
		 data: 'tip=otc',
		 loadingText: 'loading...',
		 autoClose: true
	});
});

function phone_focus(current_element, next_element, max_length) {
	var oCurrent = document.getElementById(current_element);
	var oNext = document.getElementById(next_element);
	
	if (!isDefined(oCurrent)) {
		return;
	}
	if (!isDefined(oNext)) {
		return;
	}
	
	var currentLength = oCurrent.value.length;
	
	if (currentLength == max_length) {
		oNext.focus();
	}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
