
$(function() {
 
	$(window).bind("load",function(){		
		if(pgesel==1)
		{
			$.post("media/scripts/newsevents.php",{func:'news'},function(data){
				$('#newssec').html(data);				  
			});
			
			$.post("media/scripts/newsevents.php",{func:'events'},function(data){
				$('#eventssec').html(data);				  
			});
		}
	});
 
	$('#image').simpleCycle({
		duration: 2000, 
		interval: 7000
	});
 
	
		maxWidth = 505;
		minWidth = 300;
		$("#expand").click(
		  function(){
			curHeight = $("#image").height();
			if(curHeight==300)
			{
				$("#image").animate({height: maxWidth+"px"}, { queue:false, duration:400 });
				$("#expand").html("Contract Images");
			}
			else
			{
				$("#image").animate({height: minWidth+"px"}, { queue:false, duration:400 });
				$("#expand").html("Expand Images");
			}
		  });
		
		$('#baf').submit(function(){
			emailVal=$('#baf .txtbox').val();
			if(CheckEmail(emailVal))
			{
				$.post("/newyork/media/scripts/baf.php",{emailadd:emailVal,resid:'new york'},function(data){
					
					$('#returnstring').AnimateMessage(data);
					$('#baf .txtbox').val("");
				});
			}
			else
			{
				$('#returnstring').AnimateMessage("Please enter a valid email address.");
			}
			return false;
		});
});

$(function(){
	$.fn.AnimateMessage = function(returnmessage){
		$(this).text(returnmessage).fadeIn(300,function(){
			$(this).animate({opacity:1},3000,function(){$(this).fadeOut(300);});
		});
	};
	
});
	
function CheckEmail(inputemail) {
	AtPos = inputemail.indexOf("@");
	StopPos = inputemail.lastIndexOf(".");

	if (AtPos == -1 || StopPos == -1)
	{
		return false;
	}
	else
	{
		return true;	
	}

}	
	
/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}
