function DivLoad(showDiv, textDiv, url){
	$('#' + showDiv).fadeIn(300);		
	if(showDiv == 'EventForm'){
//		$('#EventForm').removeShadow();
	}
	if(showDiv == 'ContactForm'){
//		$('#EventForm').removeShadow();
	}
	$.ajax({
		url: "/include/" + url,
		cache: false,
		dataType: "html",
		success: function(msg){
			$('#' + textDiv).html(msg);
		}
	});	
}
function DivShow(showDiv){
	$('#' + showDiv).fadeIn(300);		
}
function DivHide(showDiv){
	$('#' + showDiv).fadeOut(100);	
}

function PreparePost(thisform){
	var formdata = "";
    // Loop through form fields
   for (i=0; i < thisform.length; i++)
    {
         //Build Send String
         if(thisform.elements[i].type == "text"){ //Handle Textbox's
                  formdata = formdata + thisform.elements[i].name + "=" + escape(thisform.elements[i].value) + "&";
         }else if(thisform.elements[i].type == "textarea"){ //Handle textareas
                  formdata = formdata + thisform.elements[i].name + "=" + escape(thisform.elements[i].value) + "&";
         }else if(thisform.elements[i].type == "checkbox"){ //Handle checkbox's
                 formdata = formdata + thisform.elements[i].name + "=" + thisform.elements[i].checked + "&";
         }else if(thisform.elements[i].type == "radio"){ //Handle Radio buttons
                  if(thisform.elements[i].checked==true){
                     formdata = formdata + thisform.elements[i].name + "=" + thisform.elements[i].value + "&";
                  }
         }else{
                  //finally, this should theoretically this is a select box.
                  formdata = formdata + thisform.elements[i].name + "=" + escape(thisform.elements[i].value) + "&";
         }
    }
	//	  	alert(formdata);
	return formdata;	
}
function sendEmail(){
	var thisform = document.contactForm;
	var formdata = PreparePost(thisform);

	$.ajax({
		type: "POST",   
		url: "/includes/contactSend.php",
	    data: formdata,
		success: function(msg){
			$('#ContactFormText').show(500);
			$('#ContactFormText').html(msg);
			if(msg == 'Message Sent Successfully'){
				thisform.reset();
				setTimeout(function(){ $('#ContactFormText').hide(500) },2500);
			}
		}
	});	
	return false;	
}

function sendSignup(){
	var thisform = document.emailSignup;
	var formdata = PreparePost(thisform);
	
	var submitform = 'yes';
	var errorMsg = '';
	var theemail = thisform.email.value;
	
	if(thisform.email.value == ''){
		submitform = 'no';
		errorMsg += 'Enter your email address\n';
	}
	
	if(thisform.deli_menu.checked){
		//shadowbox
		Shadowbox.init({
			// let's skip the automatic setup because we don't have any
			// properly configured link elements on the page
			skipSetup: true
		});
		
		//window.onload = function() {
		
			// open a welcome message as soon as the window loads
			Shadowbox.open({
				content:    "http://hurleys.ky/includes/emailSignup_deli.php?email="+theemail,
				title:      "Deli Menu Options",
				player: 	"iframe",
				height:     300,
				width:      275
			});
		
		//};
	}
	
	

	if(submitform == 'yes'){
		$('#emailSignup').css('color','#CC0000');
		thisform.email.value = 'sending...';
		//alert(formdata);
		$.ajax({
			type: "POST",   
			url: "/includes/signupSend.php",
			data: formdata,
			success: function(msg){
				thisform.email.value = msg;
				setTimeout(function(){thisform.reset(); $('#emailSignup').css('color','#666666');},3000);
				return false;
			}
		});	
	}
	else
		alert(errorMsg);
	return false;	
}


$(document).ready( function(){
//    $(document).pngFix(); 
	
	$("#loadSlide").fadeOut(600);
//	$(".deptSlide #features").dropShadow();

	$('.mainLI').hover(
		 function(){
	        $('.subNav',this).slideDown(300);
		 },
		 function(){
	        $('.subNav').slideUp(100);
		 }
	);
	
	// facebook
	window.fbAsyncInit = function() {
		FB.init({appId: '256671251024678', status: true, cookie: true, xfbml: true});
	};
	
	(function() {
		var e = document.createElement('script');
		e.type = 'text/javascript';
		e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
		e.async = true;
		document.getElementById('fb-root').appendChild(e);
	}());
		

	
});


function HideDiv(targetdiv){
	$('#' + targetdiv).slideUp(50);		
}
function ShowDiv(targetdiv){
	$('#' + targetdiv).slideDown(250);		
}
