function charsleft(feld,maxChar) 
{
var theForm = document.themessage;
var anz = feld.value.length;
//var maxChar = 160;
if (anz> maxChar ) 
	{
	feld.value = feld.value.substring(0,maxChar);
	frei = 0;
	} 
else 
	{
	frei = maxChar -anz;
	}
	//theForm.num.value = frei;
}

function switchVisibility(obj1)
{
	if(obj1.className == "hideme")
	{
		obj1.className = "showme"
	}
	else
	{
		obj1.className = "hideme";
	}
}

//used to select a contact from the address book into the address text of the form
function selectFromDropDown(selectItem, newValue)
{
	for(y=0; y!=selectItem.length; y++)
	{
		if(selectItem.options[y].value==newValue)
		{
			selectItem.selectedIndex=y;
			break;
		}
	}			
}

function addAddressToDatabase(strCardCd, strSendDirect, strAction) 
{

	if (document.frmAddress.address.value == "") 
	{
		alert("Please ensure you enter an address and country to send the card to. Thank you.")
				//return false
	}
	else if( (document.frmAddress.month.value == 02 && document.frmAddress.day.value < 25) || (document.frmAddress.month.value == 08) )
	{
		alert("Our next available postage date is Thursday 25th February 2010.\nDue to holidays we are unable to post any more cards until this date.\n\nWe apologies for any inconvenience and remind you that if you \nchange your requested postal date to 25th February or later\nwe can take your order now.");
	}
	else
	{


		var strPostValue = getFormValues(document.frmAddress);	//get form values in ajaxcd.js
		//add the card cd
		strPostValue += "&card_cd=" + strCardCd;
		//add selfwrite flag

		if(strSendDirect=="Y")
		{
			strPostValue += "&self_write=N";
		}
		else if(strSendDirect=="N")
		{
			strPostValue += "&self_write=Y";
		}
		else if(strSendDirect=="B")
		{
			strPostValue += "&self_write=B";
		}
		
		//add the action to the list
		strPostValue += "&action=" + strAction;
		strPostValue = encodeURI(strPostValue);
		//alert(strPostValue);
		sendAddressToServer( strPostValue );		
	}	
}
function addMessagesToDatabase()
{
	
	var strPostMessage = getFormValues(document.frmMessage);	//get form values in ajaxcd.js
	strPostMessage = encodeURI(strPostMessage);
	sendMessageToServer( strPostMessage );

}