function addAddressbookContacts(current)
{
	var str_emails='';
	for(i=0; document.getElementById('contactsArr['+i+']'); i++)
	{
		if(document.getElementById('contactsArr['+i+']').type == "checkbox") {
			if(document.getElementById('contactsArr['+i+']').checked) {
				str_emails += (document.getElementById('contactsArr['+i+']').value+';\n').replace(/,/, '');
			}
		}
	}
	if(str_emails.length > 0) {
		document.getElementById('txt_emails').value += str_emails;
		return hs.close(current);
	} else {
		alert('Please select Contacts to add.');
	}
}

function addAccountContacts(current)
{
	var str_emails='';
	for(i=0; document.getElementById('contactsArr['+i+']'); i++)
	{
		if(document.getElementById('contactsArr['+i+']').type == "checkbox") {
			if(document.getElementById('contactsArr['+i+']').checked) {
				str_emails += (document.getElementById('contactsArr['+i+']').value+';\n').replace(/,/, '');
			}
		}
	}
	if(str_emails.length > 0) {
		window.opener.document.getElementById('txt_emails').value += str_emails;
		//document.getElementById('txt_emails').value += str_emails;
		if(confirm('Do you want to close this popup window?')) {
			self.close();
		}
	} else {
		alert('Please select contants to add.');
	}
}

function checkAll()
{
	for(i=0; document.getElementById('contactsArr['+i+']'); i++)
	{
		if(document.getElementById('contactsArr['+i+']').type == "checkbox") {
			if(document.getElementById('cbCheckAll').checked) {
				document.getElementById('contactsArr['+i+']').checked = true;
			} else {
				document.getElementById('contactsArr['+i+']').checked = false;
			}
		}
	}
}

function validateImport()
{
	if(document.getElementById('rbImportOption_account').checked) {
		if(trim(document.getElementById('username').value) == "") {
			alert("Enter User Name");
			document.getElementById('username').focus();
			return false;
		}
		if(trim(document.getElementById('acc_password').value) == "") {
			alert("Enter Password");
			document.getElementById('acc_password').focus();
			return false;
		}
	} else {
		if(trim(document.getElementById('fileCSV').value) == "") {
			alert("Please select CSV file.");
			document.getElementById('fileCSV').focus();
			return false;
		}
	}
	return true;
}

function disableEnterKey(e)
{
     var key;

     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox
     if(key == 13)
          return false;
     else
          return true;
}

function openContactGrabberPopup()
{
	window.open('include/grabber/index.php','ImportContacts', 'width=600,scrollbars=1,resizable=1');
	return false;
}

function previewInvite(evt_id,mode)
{
	if(evt_id==undefined)
		evt_id	=	'';
	if(mode==undefined)
		mode	=	'preview';
	var theGetVars	=	'?event_id='+evt_id+'&mode='+mode;
	var theUrl;
	theUrl	=	'template_preview.php'+theGetVars;
	window.open(theUrl,'Preview', 'scrollbars=1,resizable=1,width='+screen.width+',height='+screen.height);
	return false;
}