function isValidEmailAddress(emailAddress) {
    var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    return pattern.test(emailAddress);
}

function isValidUSPhoneNumber(phone) {
    var pattern = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;
    return pattern.test(phone);
}

function validateInqueryForm() {
    var firstname = $('#txtFirstName').val();
    var lastname = $('#txtLastName').val();
    var email = $('#txtEmail').val();
    var homephone = $('#txtHomePhone').val();
    
    if (firstname.length == 0) {
         alert('Please input first name.');
         return false;  
    }
    
    if (lastname.length == 0) {
    	alert('Please input last name.');
    	return false;
    }
       
    if (email.length == 0) {
         alert('Please input email.');
         return false;  
    }

    if (homephone.length == 0) {
         alert('Please input home phone number.');
         return false;  
    }

    if (!isValidEmailAddress(email)) {
         alert('Email address is invalid.');
         return false;  
    }

    if (!isValidUSPhoneNumber(homephone)) {
         alert('Home phone number is invalid.');
         return false;
    }

    return true;
}

function printSelection(node){
    var content=node.innerHTML
    var pwin=window.open('','print_content','width=100,height=100');

    pwin.document.open();
    pwin.document.write('<html><body onload="window.print()">'+content+'</body></html>');
    pwin.document.close();

    setTimeout(function(){pwin.close();},1000);
}

var childMenuArray =['#sportsChildMenu','#youthSportChildMenu','#dayCampsChildMenu','#schoolPerformingArtChildMenu','#childFamilyServiceChildMenu','#earlyChildhoodServiceChildMenu'];  
        
$(document).ready(function() {
    //Bind Child Menu Element MouseLeave Event
    //When MouseLeave Event Triggers, Hide Child Menu Div
    $('#sportsChildMenu').bind("mouseleave",function() {
    	$(this).hide();
    });
    $('#youthSportChildMenu').bind("mouseleave",function() {
    	$(this).hide();
    });
    $('#dayCampsChildMenu').bind("mouseleave",function() {
    	$(this).hide();
    });
    $('#schoolPerformingArtChildMenu').bind("mouseleave",function() {
    	$(this).hide();
    }); 
    $('#childFamilyServiceChildMenu').bind("mouseleave",function() {
    	$(this).hide();
    }); 
    $('#earlyChildhoodServiceChildMenu').bind("mouseleave",function() {
    	$(this).hide();
    });            
    
    //Bind Child Menu Item mouseout and mouseover Event
    //In this event, Swicth the background image of child menu item
    $('.childMenu').hover(function() {
    		$(this).css("background-image","url(images/sub_menu_over.png)");
    	},function() {
    	$(this).css("background-image","url(images/sub_menu.png)");
    });

}
);
        
function showChildMenu(menuDivId) {
    //Iterate Child Menu Array, only show one child menu at the same time
    for(i = 0; i < childMenuArray.length; i++) {
        if (childMenuArray[i] == menuDivId) {
        	$(childMenuArray[i]).show();
        }
        else {
        	$(childMenuArray[i]).hide();
        }
    }
}

