function isEmailValid(emailAddress)
{
     var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
     var regex = new RegExp(emailReg);
     return regex.test(emailAddress);
}

function generatePassword()
{
	var allowedChars = "123456789ABCDEFGHJKLMNPQRSTUVWXYZ";
	var pwd = "";
	$([1,2,3,4,5,6]).each(function(i) {
		pwd += allowedChars.charAt((Math.round(Math.random() * (allowedChars.length-1)) )); 			
	});

	//console.log(pwd);	
	return pwd;
}

function closeModal(bReloadPage)
{
	//This is an override to Thick Box's close method.
	//using this method when closing all modals allows for easy future changes should we 
	//wish to perform additional actions.
		
	$('#TB_load').hide(); //EPK: Ensure loader image is hidden when closing thickbox.
	self.parent.tb_remove();	
	if(bReloadPage)	parent.window.location.reload();
}

function closeModalAndGoTo(link)
{
	//This method allows the link to be access from modals.
	closeModal(0);	
	if(link.length)	parent.window.location = link;
}

function changeModal(linkObj)
{
	//this method is useful when going from one modal straight to another.
	//especially useful when going to modals of varying sizes.
	//the link in the a tag should be the same as any regular thickbox link. 
	var t = linkObj.title || false;
	var a = linkObj.href;
	var g = linkObj.rel || false;
	
	parent.window.tb_show(t,a,g);
}

jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

$.preloadImages("/assets/common/css/images/navbar_home_over.gif", "/assets/common/css/images/navbar_gallery_over.gif", "/assets/common/css/images/navbar_discussions_over.gif", "/assets/common/css/images/navbar_communityNews_over.gif", "/assets/common/css/images/navbar_calendar_over.gif", "/assets/common/css/images/navbar_businessdirectory_over.gif");
