//Hide the div..
function hideDiv(divName){
	tempDiv = document.getElementById(divName);
	if (!tempDiv) {
		return;
	}
	if (tempDiv.style.display=="block"){
	    tempDiv.style.display="none";
	}
}

//Show the div..
function showDiv(divName){
	tempDiv = document.getElementById(divName);
	if (!tempDiv) {
	    return;
    }
	if (tempDiv.style.display=="none"){
	    tempDiv.style.display="block";
	}
}

//Checking that all fields are filled in on the form..
function formCheck(formobj){
    // name of mandatory fields
    var fieldRequired = Array("name", "email", "comments");
    // field description to appear in the dialog box
    var fieldDescription = Array("Name", "Email", "Comments");
    // 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){
            if (obj.type == null){
                var blnchecked = false;
                for (var j = 0; j < obj.length; j++){
                    if (obj[j].checked){
						blnchecked = true;
                    }
                }
                if (!blnchecked){
                    alertMsg += " - " + fieldDescription[i] + "\n";
                }
                continue;
            }

            switch(obj.type){
            case "select-one":
                if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
                    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 (alertMsg.length == l_Msg){
        return true;
    }else{
        alert(alertMsg);
        return false;
    }
}