// JavaScript Document
// Programming by Scott Dillon


function openSubmenu(divID) {
	$('.submenu').hide();
	$("#"+divID).slideDown(200);
}

currentTimeout='';	
function closeSubmenu() {
		currentTimeout=setTimeout('$(".submenu").fadeOut("slow");',400);
}

$(document).ready(function(){
    
    $(".hoverHighlight").hover(
      function () {
		$(this).css({ backgroundColor:"#abdcab"});
            }, 
      function () {
		$(this).css({ backgroundColor:""});
      }
    );
	
	 $(".audio_container").hover(
      function () {
		$(this).css('backgroundImage',"url(images/backgrounds/audioHighlight.jpg)");
            }, 
      function () {
		$(this).css('backgroundImage','none');
      }
    );
	
 });


$(function()
{
	Date.format = 'mm/dd/yyyy';
	$('.date-pick').datePicker({clickInput:true, startDate:'01/01/1993'})
});

function confirmDelete(url,msg) {
	
	if (confirm(msg)) {
		window.location = url;
	}
	
}

function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

annOpen=false;
function loadAnnouncement(annID) {
	$("#ann_container").css("background-color","white");
	
	if(!annOpen) {
		$('#rotator_container').fadeOut('slow',function (){
				$("#ann_container").load("rootinc/ajaxindex.php?id="+annID);
				$('#ann_container').slideDown("slow");
				});
		annOpen=true;
	} else {
		$('#ann_container').slideUp('medium',function (){
				
				$("#ann_container").html('');
				$("#ann_container").load("rootinc/ajaxindex.php?id="+annID);													 
				$('#ann_container').slideDown('slow');
			});
	}
	
	$("#ann_container").css("background-color","white");
	$("#ann_container").css("color","#000000");
	if ($.browser.msie) this.style.removeAttribute('filter');
	
}


function loadPlayer(audID) {
	
	window.open("audioplayer.php?id="+audID,"AudioPlayer","height=336,width=511,left=100,top=100,resizable=no,scrollbars=no,toolbar=no,status=no");


}

function playAudio(itemID) {
	var so = new SWFObject('http://www.crossroadsfamily.com/inc/player.swf','mpl','340','20','8');
	so.addParam('allowscriptaccess','always');
	so.addParam('allowfullscreen','true');
	so.addVariable('width','340');
	so.addVariable('autostart','true');
	so.addVariable('height','20');
	so.addParam('wmode','transparent');
	so.addVariable('file','/documents/media/'+itemID);
	so.write('player');
	}

function submitPrayer() {
	
	prayerName = $('#prayername').val();
	prayerEmail = $('#prayeremail').val();
	prayerPhone = $('#prayerphone').val();
	prayerRequest = $('#prayerrequest').val();
	prayerAnon = $('#prayeranon:checked').val();
	captchaLetters = $('#captcha').val();
	
		
	if (prayerRequest == '') {
		alert("You must include the details of your request");
		return;
	}
		
	if(prayerAnon == null) {
		
		if (prayerName == '' ||
			prayerEmail == '') {
			alert("Please include your name and email");
			return;
		}
		} else {
		prayerAnon = 1;
	}
	
	$("#prayer_submit_form").html("<em>Sending Request...</em><p>&nbsp;</p>");
	
	$.post("rootinc/ajaxprayer.php", { name: prayerName, email: prayerEmail, phone: prayerPhone, request: prayerRequest, anon: prayerAnon, captcha: captchaLetters }, function(data){
	  $("#prayer_submit_form").html(data);
	});
		
	
}
