function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

function loadPage(pageLoad,divClass){
	var pageLoad;
	var divClass;
	$(document).ready(function(){
		document.getElementById( 'header' ).style.background="url(images/pbar-ani.gif)";
		//$("#myProgress").show();
		$("#" + divClass).load(pageLoad,function(){
			document.getElementById( 'header' ).style.background="none";
		});
		
	});
}
function sermons(){
	loadPage('sermonmain.php','mainsite');
}
function dynamics(){
	loadPage('dynamicsmain.php','mainsite');
}

function database(){
	loadPage('database.php','mainsite');
}

function tutorials(){
	//database();
	loadPage('tutorials.php','views');
}
function newSermon(){
	loadPage('newsermon.php','mainsite');
}
function editSermon(myID){
	var myID;
	loadPage('editsermon.php?id='+myID,'mainsite');
}

function showBible(myID){
	var myID;
	loadPage('editBible.php?id='+myID,'mainsite');
}

function editDynamics(myID){
	var myID;
	loadPage('slot.php?slot='+myID,'mainsite');
}




function loadSermon(myID,myType){
	var myID;
	var myType;
	if(myType=='edit'){
		editSermon(myID);
	}
}

function loadPerson(myID){
	var myID;
	loadPage('view.php?id='+myID,'views');
	//database();
}

/*******

	***	Anchor Slider by Cedric Dugas   ***
	*** Http://www.position-absolute.com ***
	
	Never have an anchor jumping your content, slide it.

	Don't forget to put an id to your anchor !
	You can use and modify this script for any project you want, but please leave this comment as credit.
	
*****/
		


$(document).ready(function() {
	$("a.anchorLink").anchorAnimate()
});

jQuery.fn.anchorAnimate = function(settings) {

 	settings = jQuery.extend({
		speed : 1100
	}, settings);	
	
	return this.each(function(){
		var caller = this
		$(caller).click(function (event) {	
			event.preventDefault()
			var locationHref = window.location.href
			var elementClick = $(caller).attr("href")
			
			var destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
				window.location.hash = elementClick
			});
		  	return false;
		})
	})
}

function handleEnter (field, event) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			//return false;
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 
		else
		return true;
}      

var allDialogs = [];
var seq = 0;
function create_1(options,groupname) {
	options = $.extend({title: "Dialog"}, options || {});
	var dialog = new Boxy("<div><p>The '"+groupname+"' group has been added to the cart</p></div>", options);
	allDialogs.push(dialog);
	return false;
}//end of create

function create_2(options) {
	options = $.extend({title: "Dialog"}, options || {});
	var dialog = new Boxy("<div><p>Do not forget to set the date and any other settings<br>before you start recording attendance.</p></div>", options);
	allDialogs.push(dialog);
	return false;
}//end of create

function create_3(options) {
	options = $.extend({title: "Duplicate Entry"}, options || {});
	var dialog = new Boxy("<div><p>This name already exists in the database!<br>You must select 'Duplicate OK' in order to add this person.</p></div>", options);
	allDialogs.push(dialog);
	return false;
}//end of create

function create_4(options,myWhen) {
	options = $.extend({title: "Dialog"}, options || {});
	var dialog = new Boxy("<div><p>The message will be sent on " + myWhen + "</p></div>", options);
	allDialogs.push(dialog);
	return false;
}//end of create

function create_5(options) {
	options = $.extend({title: "Dialog"}, options || {});
	var dialog = new Boxy("<div><p>The group has been added.</p></div>", options);
	allDialogs.push(dialog);
	return false;
}//end of create

function recent() { return allDialogs[allDialogs.length-1]; }
function tweenUp() { recent().tween(400,400); }
function tweenDown() { recent().tween(100,100); }
function getTitle() { alert(recent().getTitle()); }
function setTitle() { recent().setTitle(prompt("Enter new title:")); }


function create(options) {
options = $.extend({title: "Dialog"}, options || {});
var dialog = new Boxy("<div><p>This is dialog " + (++seq) + ". <a href='index.html#' onclick='Boxy.get(this).hide(); return false'>Close me!</a></p></div>", options);
allDialogs.push(dialog);
return false;
}
