/**
 * @author TimothyAlvis
 */

// Trunk for future max character check
function MaxCharacters(element, maxnum)
{
		
}

// Validates the clan information before sending off for actual DB save
function SaveCreatedClan()
{
	var bSave = true;
	var sBackstory = "";
	var sNotices = "";
	// do a few tests to make sure that the following is true
	// 1) Content is in at least the clan name and motto. We'll provide a default text for backstory
	// 2) No "! Violation" or "! Invalid URL" exists
	if(document.CreateClan.ClanName.value == "" ||  document.CreateClan.ClanMotto.value == "" || document.CreateClan.ClanTAG.value == "")
	{
		bSave = false;
	}
	if(document.CreateClan.ClanBackstory.value == "")
	{
		sBackstory = "Unknown"
	}
	else
	{
		sBackstory = document.CreateClan.ClanBackstory.value;
	}
	sNotices += document.getElementById('ClanAvatarNotice').innerHTML;
	sNotices += document.getElementById('ClanNameNotice').innerHTML;
	sNotices += document.getElementById('ClanMottoNotice').innerHTML;
	sNotices += document.getElementById('ClanBackstoryNotice').innerHTML;
	sNotices += document.getElementById('ClanRegionNotice').innerHTML;
	sNotices += document.getElementById('ClanTAGNotice').innerHTML;
	
	if(sNotices != "")
	{
		bSave = false;
	}
	if(!bSave)
	{
		alert('You must take care of all violations first!');
	}
	else
	{
		document.CreateClan.method = "POST";
		document.CreateClan.submit();
	}
}


// Checks to make sure they have a valid region selected
function ValidateRegion()
{
	if(document.CreateClan.CreateClanRegion.value == "-1")
	{
		document.getElementById('ClanRegionNotice').innerHTML = "! Invalid Region";
	}
	else
	{
		document.getElementById('ClanRegionNotice').innerHTML = "";
	}
}


