// Here resides some javascript functions...

// Hide content 
function hideContent(id) {
    // DOM3 = IE5, NS6
    if (document.getElementById) { 
        document.getElementById(id).style.display = 'none';
    } else {
        // Netscape 4
        if (document.layers) { 
            document.id.display = 'none';
        // IE 4
        } else { 
            document.all.id.style.display = 'none';
        }
    }
}

// Show content 
function showContent(id) {
    // DOM3 = IE5, NS6
    if (document.getElementById) { 
        document.getElementById(id).style.display = 'block';
    } else {
        // Netscape 4
        if (document.layers) {
            document.id.display = 'block';
        // IE 4
        } else { 
            document.all.id.style.display = 'block';
        }
    }
}

// Show Form
function showForm(id) {
    showContent(id);
}

// Hide Form
function hideForm(id) {
    hideContent(id);
}

// Delete recipe photo
function deletePhoto(value) {
    // Delete photo
    document.frmSubmitRecipe.deletePhoto.value = value;
    document.frmSubmitRecipe.submit();
}

// Show edit comment form
function editComment(id_num, recipe_id, comment_id) {
    var cmnt_id = "c" + id_num;
    var edit_id = "e" + id_num;
    var comment = filterText(document.getElementById(cmnt_id).innerHTML);

    hideContent(cmnt_id);
    document.getElementById(edit_id).innerHTML = "<form action=\"/lib/class_comment_process.php\" name=\"frmEditComment\" method=\"post\">" +
        "   <textarea name=\"comment\" class=\"commentEditTextBox textBox\">"+ comment +"</textarea><br />" +
        "   <input class=\"button\" type=\"submit\" value=\"Save\" /> <input class=\"button\" type=\"button\" value=\"Cancel\" onclick=\"javascript:cancelEditComment('"+ cmnt_id +"', '"+ edit_id +"');\" />" +
        "   <input type=\"hidden\" name=\"edit_comment\" value=\"1\" />" +
        "   <input type=\"hidden\" name=\"rid\" value=\""+ recipe_id +"\" />" +
        "   <input type=\"hidden\" name=\"cid\" value=\""+ comment_id +"\" />" +
        "</form>";
    showContent(edit_id);
}

// Cancel edit by hiding the form
function cancelEditComment(cmnt_id, edit_id) {
    hideContent(edit_id);
    showContent(cmnt_id);
}

// Filter the text by removing some stuff
function filterText(text) {
    str = text;
    str = str.replace(/\n/gi, "");
    str = str.replace(/<br>/gi, "\n");
    str = str.replace(/<a href=\"/gi, "");
    str = str.replace(/\">.*?<\/a>/gi, "");
    return str;
}

// Show the loading animation
function showLoader(id) {
	if (id == "submitLoader") {
		document.getElementById("submitLoader").innerHTML = "<br /><img src=\"/img/loader_blank.gif\" border=\"0\" width=\"16\" height=\"16\" name=\"loader\" /><br /><br />Please wait...";
	} else {
		document.getElementById(id).innerHTML = "<img src=\"/img/loader_blank.gif\" border=\"0\" width=\"16\" height=\"16\" name=\"loader\" />";
    }
	setTimeout('document.images["loader"].src = "/img/loader.gif"', 100); 
}

// Show the loading animation
function showLoaderB(id) {

}
