


//******************************************************************************
//                       Select a Verse for Personalization
//******************************************************************************
function selectverse(verse)
{
	$("#dialog_box").load("/bible/services/verse.php?id="+verse, function()
		{
			$("#dialog_box").dialog(
					{
						modal: 		true,
						width: 		512,
						title: 		"Personalize Bible Verse", 
						resizable: 	false,
						draggable: 	true,
						buttons: 
						{
							'Save': function()
							{
								$("div.ui-dialog-buttonpane").hide();
								$("#verse_form").ajaxSubmit(
									{	dataType: "json",
										success: function(data)
										{
											$("#r"+verse+" span.note").html(data.note);
											$("#r"+verse).attr('bgcolor',data.color);
											$("#r"+verse).mouseout(
												function()
												{
													$("#r"+verse).attr('bgcolor',data.color);
												}
											);
											$("#dialog_box").dialog('destroy');
										}
									}
								);
							}
						},
						close: function()
						{
							$("#dialog_box").dialog('destroy');
						}
					}
			);
		}
	);
}



//******************************************************************************
//                       Verse Personalization Color Switch
//******************************************************************************
function switchcolor(color)
{
	//======================================================== Put Value in Form
	$('#color').val(color);

	//========================================================== Move Red Square
	$(".colorbox").removeClass("selected");
	$("#colorbox_"+color).addClass("selected");

	//======================================================= Change Verse Color
	if (color==0)	$("#selected_verse").css("background-color","#FFFFFF");
	if (color==1)	$("#selected_verse").css("background-color","#AAFFFF");
	if (color==2)	$("#selected_verse").css("background-color","#AAAAFF");
	if (color==3)	$("#selected_verse").css("background-color","#AAFFAA");
	if (color==4)	$("#selected_verse").css("background-color","#FFFFAA");
	if (color==5)	$("#selected_verse").css("background-color","#FFAAAA");
	if (color==6)	$("#selected_verse").css("background-color","#FFAAFF");
}




//******************************************************************************
//                             Create a New Verse List
//******************************************************************************
function vlist_create()
{
	var Title = "Create a New Verse List";
	var BoxWidth = 760;
	var ButtonText = "Create";
	var URL = "/bible/services/vlist_create.php";
	
	build_dialog_box(Title, BoxWidth, ButtonText, URL);
}



//******************************************************************************
//                             Display a Verse List
//******************************************************************************
function vlist_display(which)
{
	$("#right_content").html("Loading...");
	$("#right_content").load("/bible/services/vlist_single.php?id="+which);
}



//******************************************************************************
//                     Flip Share of a Verse List (Public/Private)
//******************************************************************************
function vlist_flipshare(which)
{
	$.get("/bible/services/flipshare.php",{id: which},function(data)
		{
			if (data=="Public")
			{
				$("#vlist_share_" + which).attr("src","/style/img/bible/vlist_public.png");
			}
			else if (data=="Private")
			{
				$("#vlist_share_" + which).attr("src","/style/img/bible/vlist_private.png");
			}
		}
	);
}



//******************************************************************************
//                             Delete a Verse List
//******************************************************************************
function vlist_delete(which)
{
	if (confirm("Are you sure you want to delete this Verse List. This can not be undone."))
	{
		$.get("/bible/services/vlist_delete.php",{id: which},function(data)
			{
				alert(data);
				window.location.reload();
			}
		);
	}
}



//******************************************************************************
//                    E-Mail a Verse List to a Friend
//******************************************************************************
function vlist_email(which)
{
	var Title = "Email a Verse List";
	var BoxWidth = 760;
	var ButtonText = "Send Email";
	var URL = "/bible/services/vlist_email.php?id="+which;
	
	build_dialog_box(Title, BoxWidth, ButtonText, URL);
}



//******************************************************************************
//                    Edit the Title/Description of a Verse List
//******************************************************************************
function vlist_edit_title(which)
{
	var Title = "Modify Title and Description";
	var BoxWidth = 760;
	var ButtonText = "Save";
	var URL = "/bible/services/vlist_edit_title.php?id="+which;
	
	build_dialog_box(Title, BoxWidth, ButtonText, URL);
}



//******************************************************************************
//                    Edit the Verse/Note of a Verse List
//******************************************************************************
function vlist_edit_verse(which)
{
	var Title = "Modify Verse and Note";
	var BoxWidth = 760;
	var ButtonText = "Save";
	var URL = "/bible/services/vlist_verse_edit.php?id="+which;
	
	build_dialog_box(Title, BoxWidth, ButtonText, URL);
}



//******************************************************************************
//                       Reorder Verses of a Verse List
//******************************************************************************
function vlist_movedown(which,which2)
{
	$("#right_content").load("/bible/services/vlist_move.php",{id1:which,id2:which2});
}

function vlist_moveup(which, which2)
{
	$("#right_content").load("/bible/services/vlist_move.php",{id1:which,id2:which2});
}



//******************************************************************************
//                       Delete a Verse of a Verse List
//******************************************************************************
function vlist_delete_verse(which)
{
	if (confirm("Are you sure you want to delete this verse? This can not be undone."))
	{
		$("#right_content").load("/bible/services/vlist_verse_delete.php",{id:which});
	}
}



//******************************************************************************
//                       Update From Verse Previous
//******************************************************************************
function vlist_from_prev()
{
	iFrom = parseInt($("#from_id").val());
	iFrom -= 1;
	$("#from_verse").load("/bible/services/verse_reference.php",{id:iFrom,which:"from"});
	iTo = parseInt($("#to_id").val());
	if (iTo<iFrom)
	{
		$("#to_verse").load("/bible/services/verse_reference.php",{id:iFrom,which:"to"});
	}
}
//******************************************************************************
//                       Update From Verse Next
//******************************************************************************
function vlist_from_next()
{
	iFrom = parseInt($("#from_id").val());
	iFrom += 1;
	$("#from_verse").load("/bible/services/verse_reference.php",{id:iFrom,which:"from"});
	iTo = parseInt($("#to_id").val());
	if (iTo<iFrom)
	{
		$("#to_verse").load("/bible/services/verse_reference.php",{id:iFrom,which:"to"});
	}
}
//******************************************************************************
//                       Update To Verse Previous
//******************************************************************************
function vlist_to_prev()
{
	iTo = parseInt($("#to_id").val());
	iTo -= 1;
	$("#to_verse").load("/bible/services/verse_reference.php",{id:iTo,which:"to"});
	iFrom = parseInt($("#from_id").val());
	if (iTo<iFrom)
	{
		$("#from_verse").load("/bible/services/verse_reference.php",{id:iTo,which:"from"});
	}
}
//******************************************************************************
//                       Update To Verse Next
//******************************************************************************
function vlist_to_next()
{
	iTo = parseInt($("#to_id").val());
	iTo += 1;
	$("#to_verse").load("/bible/services/verse_reference.php",{id:iTo,which:"to"});
	iFrom = parseInt($("#from_id").val());
	if (iTo<iFrom)
	{
		$("#from_verse").load("/bible/services/verse_reference.php",{id:iTo,which:"from"});
	}
}
