function checkEmail(email_value) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email_value)){
		return (true)
	} else {
		return (false)
	}
}

function setAllCheckBoxes(FormName, FieldName, CheckValue) {
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}


function setCheckBoxes (FormName, MainCheckBox, FieldName) {
	if(!document.forms[FormName])
		return;
	var objMainCheckBox = document.forms[FormName].elements[MainCheckBox];
	if(!objMainCheckBox)
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;

	var countCheckBoxes = objCheckBoxes.length;
	
	if(!countCheckBoxes)
		objCheckBoxes.checked = objMainCheckBox.checked;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = objMainCheckBox.checked;
}

function confirmCheckedList (FormName, listElts, areYouSureStr, rejectStr) {
	if(!document.forms[FormName])
		return false;
	var objListElts = document.forms[FormName].elements[listElts];
	if (!objListElts)
		return false; 

	var countElements = objListElts.length;
	
	// if there is just one element in a list, listElts will be formed as a scalar
	// variable, not an array, and in that case objListElts.length will be false
	if (!countElements) {
	// objListElts is a scalar variable, not an array
		if (objListElts.checked) { 
			areYouSureStr += (objListElts.defaultValue + "\n\n");
			return confirm (areYouSureStr);
		}
		else { 
			alert (rejectStr);
			return false;
		}	
	}
	else {
	// objListElts is an array 
		var nmbrOfChkdItems = 0;
	  
		for (i = 0; i < countElements; i++)
			if (objListElts[i].checked) nmbrOfChkdItems++;

		if (nmbrOfChkdItems == 0) { 
	    	alert (rejectStr);
	    	return false;
		}
	 
	  	var limitToShow = 0;
	  	for (i = 0; i < countElements; i++)
	   		if (objListElts[i].checked) { 
		 		areYouSureStr += (objListElts[i].defaultValue + '\n');
	     		if (++limitToShow == 37) break;
			}
	  
		if (limitToShow < nmbrOfChkdItems)
			areYouSureStr += "...\n";
	
		return confirm (areYouSureStr);
	}
}

function moreElements (eltId, str) {
	var divId = document.getElementById(eltId);
	divId.innerHTML += str;
}

function showAsterisk (eltId, showIt) {
	var divId = document.getElementById(eltId);
	if (divId) { 
		if (showIt)
			divId.innerHTML = "*";
	  	else
			divId.innerHTML = " ";
	}
}


function addSubscriber() 
{
	jQuery.noConflict();

	myErr = '';	
	var f = document.mailform;
	
	f.submit.disabled = true;
	f.btn_mailsubmit.disabled = true;
	
	jQuery.ajax({
	   type: "POST",
	   url: f.site_url.value +"executables/add_subscriber.php",
	   data: "lang="+ f.lang.value +"&name="+ f.sub_name.value +"&email="+ f.sub_email.value,
	   success: function(msg){
			alert(msg);
			f.btn_mailsubmit.disabled = false;
			//f.reset();
	   }
	 });
	
	return false;
} 
