// JavaScript Document
function SetDivHeight() {
	//added by scott s
	document.getElementById('ModuleBottom').style.height = "";
	document.getElementById('moduleBottomleft').style.height = "";
	document.getElementById('moduleBottomcenter').style.height = "";
	document.getElementById('moduleBottomright').style.height = "";



	var divh1 = document.getElementById('moduleTopleft').offsetHeight+'px';
	var divh2 = document.getElementById('moduleTopcenter').offsetHeight+'px';
	var divh3 = document.getElementById('moduleTopright').offsetHeight+'px';
	var divh4 = document.getElementById('moduleBottomleft').offsetHeight+'px';
	var divh5 = document.getElementById('moduleBottomcenter').offsetHeight+'px';
	var divh6 = document.getElementById('moduleBottomright').offsetHeight+'px';
	
	/*alert(document.getElementById('moduleBottomleft').offsetHeight+'px');
	alert(document.getElementById('moduleBottomcenter').offsetHeight+'px');
	alert(document.getElementById('moduleBottomright').offsetHeight+'px');
	*/
	
	var divheightArray = new Array();
	divheightArray[0] = divh1;
	divheightArray[1] = divh2;
	divheightArray[2] = divh3;
	
	var divheightArray2 = new Array();
	divheightArray2[0] = divh4;
	divheightArray2[1] = divh5;
	divheightArray2[2] = divh6;
	
	var divheightSorted = divheightArray.sort();
	var divheight = divheightSorted.pop();
	
	var divheightSorted2 = divheightArray2.sort();
	var divheight2 = divheightSorted2.pop();
	
	//alert(divheight2 + "::");
	
	
	document.getElementById('ModuleTop').style.height = divheight;
	document.getElementById('moduleTopleft').style.height = divheight;
	document.getElementById('moduleTopcenter').style.height = divheight;
	document.getElementById('moduleTopcenter').style.height = divheight;
	
	document.getElementById('ModuleBottom').style.height = divheight2;
	document.getElementById('moduleBottomleft').style.height = divheight2;
	document.getElementById('moduleBottomcenter').style.height = divheight2;
	document.getElementById('moduleBottomright').style.height = divheight2;

}

function AddBullet() {	
	var bulletCount = parseInt(document.getElementById('bulletCnt').value);
	var newbulletID = bulletCount + 1;
	var textarea = '<textarea rows="3" cols="24" name="M6_Text' + newbulletID + '" id="M6_Text' + newbulletID + '"></textarea>';
	var html = document.getElementById('Module6Bullets').innerHTML;
						
	document.getElementById('Module6Bullets').innerHTML= html + textarea;
	document.getElementById('bulletCnt').value = newbulletID;
	//alert(document.getElementById('ModuleBottom').style.height);
	SetDivHeight();	
}

function RemoveBullet() {	
	var bulletCount = parseInt(document.getElementById('bulletCnt').value);
	var d = document.getElementById('Module6Bullets');
	var textareaID = 'M6_Text' + bulletCount;
  	var olddiv = document.getElementById(textareaID);
	var newheight = document.getElementById('moduleBottomright').offsetHeight - document.getElementById(textareaID).offsetHeight;
	//alert(document.getElementById('moduleBottomright').style.height);
	d.removeChild(olddiv);
	document.getElementById('moduleBottomright').style.height = newheight + "px";
	document.getElementById('bulletCnt').value = bulletCount - 1;
	//alert(document.getElementById('moduleBottomright').style.height);
	SetDivHeight();
	
}

function isAllEmpty(inputStr) {
	for (i=0; i<inputStr.length; i++){
		if (inputStr.charAt(i) != null && inputStr.charAt(i) != "" && inputStr.charAt(i) != " ")
		return false;
		}
	
	return true;
}

function validate(form)	{
	if  (isAllEmpty(form.M1_Title.value))
	{
		alert("Enter a value in the Module 1 Title text field.");
		form.M1_Title.focus();
		return(false);
	}
	
	if  (isAllEmpty(form.M2_Title.value))
	{
		alert("Enter a value in the Module 2 Title text field.");
		form.M2_Title.focus();
		return(false);
	}
	
	if  (isAllEmpty(form.M3_Title.value))
	{
		alert("Enter a value in the Module 3 Title text field.");
		form.M3_Title.focus();
		return(false);
	}
	
	if  (isAllEmpty(form.M4_Title.value))
	{
		alert("Enter a value in the Module 4 Title text field.");
		form.M4_Title.focus();
		return(false);
	}
	
	if  (isAllEmpty(form.M5_Title.value))
	{
		alert("Enter a value in the Module 5 Title text field.");
		form.M5_Title.focus();
		return(false);
	}
	
	if  (isAllEmpty(form.M6_Title.value))
	{
		alert("Enter a value in the Module 6 Title text field.");
		form.M6_Title.focus();
		return(false);
	}
	
	if  (isAllEmpty(form.M1_Text.value))
	{
		alert("Enter a value for the Module 1 Descriptive Text text area.");
		form.M1_Text.focus();
		return(false);
	}
	
	if  (isAllEmpty(form.M2_Text.value))
	{
		alert("Enter a value for the Module 2 Descriptive Text text area.");
		form.M2_Text.focus();
		return(false);
	}
	
	if  (isAllEmpty(form.M3_Text.value))
	{
		alert("Enter a value for the Module 3 Descriptive Text text area.");
		form.M3_Text.focus();
		return(false);
	}
	
	if  (isAllEmpty(form.M4_Text.value))
	{
		alert("Enter a value for the Module 4 Descriptive Text text area.");
		form.M4_Text.focus();
		return(false);
	}
	
	if  (isAllEmpty(form.M5_Text.value))
	{
		alert("Enter a value for the Module 5 Descriptive Text text area.");
		form.M5_Text.focus();
		return(false);
	}

	return true;
}