
var ColumnExpand =
{
	init: function()
	{
		$("#primaryContent").animate({left:"-1000px"},"fast");
		$("#primaryContent").animate({width:"450px"},"fast");
		$("#primaryContent").hide();
		$("#viewScripture2").hide();
		idHeight3 = $("#secondaryContent").css("height");	
		
		var viewScripture1 = $("#viewScripture1");
		var viewScripture2 = $("#viewScripture2");
		
		for (var i = 0, ii = viewScripture1.length; i < ii; i++)
		{			
			$(viewScripture1[i]).bind("click", function()
			{				
				// Make Changes	
				$("#viewScripture2").toggle(200);
				$("#viewScripture1").toggle(200);
				
				$("#secondaryContent").animate({width:"335px"},"slow");	
				$("#secondaryContent").animate({marginLeft:"490px"},"slow");
				$("#primaryContent").animate({left:"0px"},"slow");
				$("#primaryContent").animate({width:"450px"},"fast");
				$("#primaryContent").show(1200);
				$("#viewScripture2").animate({left:"470px"},"slow");
				$("#viewScripture1").animate({left:"470px"},"slow");	
				
				// Calculations
				idHeight = $("#primaryContent").css("height");
				var idHeight2 = idHeight3;				
				var heightLen = idHeight.length;
				var heightLen2 = idHeight2.length;
				
					if (heightLen == 6)
					{
						idHeight = idHeight.slice(0,4);
					} else
					{
						idHeight = idHeight.slice(0,3);
					}
						
					if (heightLen2 == 6)
					{
						idHeight2 = idHeight2.slice(0,4);
					} else
					{
						idHeight2 = idHeight2.slice(0,3);
					}
					
					idHeight = Number(idHeight);
					idHeight2 = Number(idHeight2);
					
					if (idHeight < idHeight2) 
					{
						idHeight = idHeight2+"px";	
					} else
					{
						idHeight = idHeight+"px";	
					}
				
				// Another Change
				$("#secondaryContent").animate({minHeight:idHeight},"fast");
			});
		}
		for (var i = 0, ii = viewScripture2.length; i < ii; i++)
		{
			$(viewScripture2[i]).bind("click", function()
			{
				var idWidth = $("#secondaryContent").css("width");
				$("#viewScripture2").toggle(200);
				$("#viewScripture1").toggle(200);
				
				$("#secondaryContent").animate({marginLeft:"15px"},"slow");
				$("#secondaryContent").animate({width:"810px"},"fast");
				$("#secondaryContent").animate({minHeight:idHeight3},"fast");	
				$("#primaryContent").animate({left:"-1000px"},"slow");
				$("#primaryContent").animate({width:"450px"},"fast");
				$("#primaryContent").hide(1200);
				$("#viewScripture2").animate({left:"1px"},"slow");
				$("#viewScripture1").animate({left:"1px"},"slow"); 
			});
		}
		
	}
};

ColumnExpand.init();

var FormValidation =
{
	init: function()
	{
		var forms = document.getElementsByTagName("form");
		
		for (var i = 0; i < forms.length; i++)
		{
			$(forms[i]).bind("submit", FormValidation.submitListener);
		}
	},

	rules:
	{
		message: /./,
		confirm: /JTKCS/		
	},

	errors:
	{
		message: "Please write a message.",
		confirm: "Please enter correct confirmation code!"
	},
	
	submitListener: function(event)
	{
		var fields = this.elements;
		
		for (var i = 0, ii = fields.length; i < ii; i++)
		{
			var className = fields[i].className;
			var classes = className.split(" ");
			
			for (var j = 0, jj = classes.length; j < jj; j++)
			{
				var oneClass = classes[j];
				var rule = FormValidation.rules[oneClass];
				if (rule)
				{
					if (!rule.test(fields[i].value))
					{
						fields[i].focus();
						alert(FormValidation.errors[oneClass]);
						event.preventDefault();
						return;
					}
				}
			}
		}
	}
};

FormValidation.init();
