function popup(mylink, windowname)
{
	if (! window.focus)
		return true;
	
	var href;
	if (typeof(mylink) == 'string')
	{
   		href=mylink;   
	}
	else
	{
		href=mylink.href;
		if (windowname == "picture")
		{
			window.open(href, windowname, 'width=750,height=750,scrollbars=yes');
			return false;
		}
		else
		{
			window.open(href, windowname, 'width=500,height=350,scrollbars=yes');
			return false;
		}
	}	
}

// check for join form

function checkjoinform()
{
	
	if (document.joinform.username.value == "")
	{
		alert("Username must be entered\n");
		document.joinform.username.focus;
		return false;
	}
	
	var ss=new RegExp("@");
   	if ((!ss.test(document.joinform.email.value)) || (document.joinform.email.value.indexOf(".") == -1)||(document.joinform.email.value ==""))
  	{
   		alert("Enter the Email in proper format \n");
  		document.joinform.email.value.focus;
  		return false;
   	} 
	
	if (document.joinform.password.value == "")
	{
		alert("Enter a Password\n");
		document.joinform.password.focus;
		return false;
	}
	if (document.joinform.verify_password.value == "")
	{
		alert("Enter the Verify Password\n");
		document.joinform.verify_password.focus;
		return false;
	}
	
	if (!(document.joinform.verify_password.value == document.joinform.password.value))
	{
		alert("Passwords must be the same\n");
		document.joinform.password.focus;
		return false;
	}
		
	if(document.joinform.tos.checked == false)
	{
		alert("Monoleader Terms of Agreement not checked\n");
		document.joinform.tos.focus;
		return false;
	}
	return true;
	
}

// checks for memberprofile
function checkmemberform()
{
	
	if (document.joinform.username.value == "")
	{
		alert("Username must be entered\n");
		document.joinform.username.focus;
		return false;
	}
	
	var ss=new RegExp("@");
   	if ((!ss.test(document.joinform.email.value)) || (document.joinform.email.value.indexOf(".") == -1)||(document.joinform.email.value ==""))
  	{
   		alert("Enter the Email in proper format \n");
  		document.joinform.email.focus;
  		return false;
   	} 
	
	if (document.joinform.firstname.value == "")
	{
		alert("Enter First Name\n");
		document.joinform.firstname.focus;
		return false;
	}
	if (document.joinform.lastname.value == "")
	{
		alert("Enter Last Name\n");
		document.joinform.lastname.focus;
		return false;
	}
	
	if (document.joinform.password.value == "")
	{
		alert("Enter Password\n");
		document.joinform.password.focus;
		return false;
	}
	
	return true;
	
}

// check for submitreport.
function checkreportform()
{
	if (document.reportform.fishdate.value == "")
	{
		alert("Enter a Date\n");		
		return false;
	} 
	
	// validate that date format is valid - mm/dd/yyyy
		
	var validformat=/^\d{2}\/\d{2}\/\d{4}$/ //Basic check for format validity
	if (!validformat.test(document.reportform.fishdate.value))
	{
		alert("Invalid Date Format. Please correct and submit again.");
		return false;
	}
	else{ //Detailed check for valid date ranges
		var monthfield=document.reportform.fishdate.value.split("/")[0];
		var dayfield=document.reportform.fishdate.value.split("/")[1];
		var yearfield=document.reportform.fishdate.value.split("/")[2];
		var dayobj = new Date(yearfield, monthfield-1, dayfield);
		if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
		{
			alert("Invalid Day, Month, or Year range detected. Please correct and submit again.");
			return false;		
		}
			
		if (yearfield < 2009)
		{
			alert("Year must be greater than 2008");
			return false;
		}	
		
		<!--- date must be less than today's date --->
		var thetime=new Date();		
		var date = thetime.getDay() + "/" + thetime.getMonth() + "/"  + thetime.getYear(); 
		if (dayobj > thetime)
		{
			alert("Date must be less than today");
			return false;
		}		
		
	}
	
	if (document.reportform.selectSpecies1.value == "0,0")
	{
		alert("You must enter at least 1 species/subspecies");
		return false;


	}
		
	if (document.reportform.region1.value == "0")
	{
		alert("Please select a region");
		return false;
	}
			
	if (document.reportform.location1.value == "0")
	{
		alert("Please select a location");
		return false;
	}
	
		
	if (document.reportform.report_details.value == "")
	{
		alert("Please enter the report details");		
		return false;
	} 
	
	return true;
	
}

// check for resources form
function checkresourceform()
{
	if (document.resourceform.resource_title.value == "")
	{
		alert("Please enter resource title\n");		
		return false;
	} 
	
	if (document.resourceform.link1.value == "")
	{
		alert("Please enter a website");
		return false;
	}
	
	return true;
	
}

// confirm deletion of fishing report
function confirmDelete() 
{       
	if(confirm("Do you want to delete this fishing report?"))
	{
		return true;
	}
	
	return false;
	
}

// confirm deletion of member profile 
function confirmProfileDelete() 
{       
	if(confirm("Do you want to delete this member's profile and any fishing reports they have submitted?"))
	{
		return true;
	}
	
	return false;
	
}

// check Contact Us fields
function checkcontactform()
{
	
	if (document.contactform.realname.value == "")
	{
		alert("Your name must be entered\n");
		document.contactform.username.focus;
		return false;
	}
	
	var ss=new RegExp("@");
   	if ((!ss.test(document.contactform.email.value)) || (document.contactform.email.value.indexOf(".") == -1)||(document.contactform.email.value ==""))
  	{
   		alert("Enter the Email in proper format \n");
  		document.contactform.email.focus;
  		return false;
   	} 
	
	
	if (document.contactform.comments.value == "")
	{
		alert("Enter your question or comment\n");
		document.contactform.comments.focus;
		return false;
	}
	
	return true;
}
