// function doHelp() {
//	alert("The Help function is currently under construction.");
//}


function doSaveAs() {
var ret=document.execCommand("SaveAs",true,"myProfileSheet.htm");
	if (ret){
		alert("You have successfully saved the Profile Sheet to your computer. If you make corrections to your profile sheet you must then click the save button once again.");
	}
}

function onSubmitForm() {
	if(document.pressed == 'Save') {
		document.resSaveEdit.action ="http://ps.tampabayrealtor.com/residential/resSaveEdit.php";
		document.resSaveEdit.target ="_self";
	}
	
	else
	if(document.pressed == 'Help') {
		var popup=window.open('http://ps.tampabayrealtor.com/residential/config/loading.htm','popup','width=375,height=295,menubar=no,status=no,location=no,toolbar=no,scrollbars=no');
		document.resSaveEdit.action ="http://ps.tampabayrealtor.com/residential/resHelp.php";
		document.resSaveEdit.target ="popup";
	}
  
	else
	if(document.pressed == 'Email') {
		var popup=window.open('http://ps.tampabayrealtor.com/residential/config/loading.htm','popup','width=375,height=240,menubar=no,status=no,location=no,toolbar=no,scrollbars=no');
		document.resSaveEdit.action ="http://ps.tampabayrealtor.com/residential/resEmail.php";
		document.resSaveEdit.target ="popup";
	}
	
	else
	if(document.pressed == 'Reciprocal') {
		var popup=window.open('http://ps.tampabayrealtor.com/residential/config/loading.htm','popup','width=375,height=295,menubar=no,status=no,location=no,toolbar=no,scrollbars=no');
		document.resSaveEdit.action ="http://ps.tampabayrealtor.com/residential/resEmailReciprocal.php";
		document.resSaveEdit.target ="popup";
	}

	else
	if(document.pressed == 'Print Profile Sheet') {
		var popup=window.open('http://ps.tampabayrealtor.com/residential/config/loading.htm','popup','width=700,height=500,menubar=no,status=no,location=no,toolbar=yes,scrollbars=yes');
		document.resSaveEdit.action ="http://ps.tampabayrealtor.com/residential/resPrint.php";
		document.resSaveEdit.target ="popup";
	}
	return true;
}

function refSaveAsOnLoad() {
	if (document.referrer == 'http://ps.tampabayrealtor.com/residential/') {
		document.execCommand("SaveAs",true,"profilesheet.htm");
		alert("You have successfully saved the profile sheet to your computer. If" + '\n' + "you make corrections or additions to your profile sheet you must" + '\n' + "then click the Save button to save any changes.");
	}
	else
	{
		alert("It is reccomended that before you edit this profile sheet that you save it" + '\n' + "as different file name. This will enable you to keep an archive" + '\n' + "of the changes you have made to your online profile sheets.");
		document.execCommand("SaveAs",true,"profilesheet.htm");
	}
}


function formCheckEmail(formobj){
	// Enter name of mandatory fields
	var fieldRequired = Array("to", "from", "subject");
	// Enter field description to appear in the dialog box
	var fieldDescription = Array("Recipient Email Address", "From E-mail Address", "Email Subject");
	// dialog message
	var alertMsg = "Please complete the following fields:\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "file":
				if (obj.value == "" || obj.value ==null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}


function formCheckEmailReciprocal(formobj){
	// Enter name of mandatory fields
	var fieldRequired = Array("to", "from", "subject", "fileatt");
	// Enter field description to appear in the dialog box
	var fieldDescription = Array("Recipient Email Address", "From E-mail Address", "Email Subject", "Primary Photo");
	// dialog message
	var alertMsg = "Please complete the following fields:\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "file":
				if (obj.value == "" || obj.value ==null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}