// Publish Forms
function publish() {
	var rbg = document.publishForm.publish;
	for(i=0; i < rbg.length; i++) {
		if(rbg[i].checked) {
			if(rbg[i].value != "createprint") {
				location.href = location.href + "/" + rbg[i].value;
			} else {
				showHideWindow('PrintDisplay');
			}
		}
	}
}

// Save To Favorites Form
function checkFields() {
	if(document.savefavoritesform.save.checked) {
		document.createemailform.savetofavorites.value = true;
	}
	if(validateEmail()){
		document.createemailform.submit();
	}
}

//-- VALIDATE EMAIL --//
function validateEmail(){
	// get value of input
	var inStr = document.createemailform.emailto.value;	
	
	// make sure the field isn't empty
	if(inStr == ""){
		var oa = '\347';
		document.getElementById("errorDiv").innerHTML = "<b>Por favor, preencha o campo 'Para' com un endere" + oa + "o de e-mail.</b><br /><br />";
		return false;
	}else{
		/* Ultimately, we would want to check each of the substrings in the string to make sure they're all valid emails.
		   For now, we'll just make sure the string isn't empty.*/
		return true;
	}
}

//Images and Video Landing Form
function resetFields(which) {
	var form = document.getElementById("patedsearch");
    var DropDown = document.getElementById("topic");
    var pInput = document.getElementById("psearch");
    if(which == "topic") {
		// dropdown selected, clear the keywords & reset form action
		pInput.value = '';
		form.action = "/patienteducation/searchresults"; // in patient education
	} else if(which == "keyword") {
		// keywords selected, reset dropdown & reset form action
		if(form.length > 0) {
			DropDown.selectedIndex = 0;
		}
		form.action = "/search/patedsearch";
	} else if (form.action == "") {
        alert("Please select a topic or enter search terms.");
		return false;
	} else if ((pInput.value == "") && (DropDown.selectedIndex == 0)) {
        alert("Please select a topic or enter search terms.");
		return false;
	}
}

function clearDrop() {
    document.getElementById('psearch').value = "";
    if ((document.getElementById('psearch').value != "Enter keywords or search terms") || (document.getElementById('psearch').value != "")) {
	    document.getElementById('topic').selectedIndex = 0;
		resetFields('keyword');
	}
}

function genSearchCBXValidate(cbForm) {
	if ((cbForm.products.checked != true) && (cbForm.news.checked != true) && (cbForm.pated.checked != true) && (cbForm.profed.checked != true)) {
		var oa = '\363';
		alert("Por favor, escolha um t" + oa + "pico para refinar os resultados de sua busca ou realize uma nova busca");	
		return false;
	} 
	return true;
}

function genSearchINPTValidate(inptForm) {
	if ((inptForm.Search.value == "Search") || (inptForm.Search.value == " ")) {
		var oa = '\0363';
		alert("Por favor, selecione um t" + oa + "pico");	
		return false;
	}
	return true;
}





