function SelectAll(sLOOKINGFA) {
		var aInput = document.forms("processFORM")
		for (i=0; i < aInput.length; i++) {
			
			if (aInput(i).name.indexOf(sLOOKINGFA) == 0) {
				aInput(i).checked = true
			}
		}
	}
	
	function DeSelectAll(sLOOKINGFA) {
		var aInput = document.forms("processFORM")
		for (i=0; i < aInput.length; i++) {
			
			if (aInput(i).name.indexOf(sLOOKINGFA) == 0) {
				aInput(i).checked = false
			}
		}
	}

 /*
     * changeClass functions (used for rollovers) etc.
     */
function formPayment()
{
	//alert("action here 2")
	//document.form.action = "figureselect.asp?Product_ID_PK=" + Pid
}
 
    function changeClass(obj, class_name) {
        original_class      = obj.className;
        original_class_obj  = obj;
        obj.className       = class_name;
        obj.onmouseout      = restoreClass;

    }

    function restoreClass(e) {
        if((typeof(original_class_obj) != 'undefined') && (typeof(original_class_obj.className) != 'undefined')) {
            original_class_obj.className = original_class;
           
        }
    }

    function overButton(e, obj){
        if(!obj) {
            if(typeof(e.srcElement) == 'undefined') {
                obj = e.currentTarget;
            } else {
                obj = e.srcElement;
            }
        }
        strValue = obj.value;
        if( obj.className == "formButton" ){
            changeClass(obj, "formButtonOver");
        }
    }
    /* ------------------------------------------- */

function ChangeProcessImage(sIMG, sOBJ)
{
	sOBJ.src = sIMG.value
}

function AddEditorImage(sIMG)
{
	var editor = document.getElementById('CE_fldMailOut_ID');
	editor.FocusDocument();
	editor.PasteHTML("<img class='IS_IMAGE' align=left style='margin-right:0' src='"+sIMG.value+"' border='0'>")
	
}

function AddEditorDocument(sIMG,sTEXT)
{
	if (sIMG.value != "")
	{
		var editor = document.getElementById('CE_fldMailOut_ID');
		editor.FocusDocument();
		var siteURL = "http://www.inhalesuite.com/"
		if (sTEXT=="")
		{
			sTEXT = "view document"
		}
	editor.PasteHTML('<a target=_blank href="'+siteURL + sIMG.value+'">'+sTEXT+'</a> ');
	}
}
	

function NahNahNah() {
	if ((event.keyCode < 48 || event.keyCode> 57) && event.keyCode != 190  && event.keyCode != 8) { 
		event.returnValue = false
	}
}	

function NahNahNahAtAll() {
	event.returnValue = false
}	

function CheckPublish(sURL) {

	var ans = confirm("This will Publish/Unpublish this item your web site, do you want to continue?")
	if (ans == false) {
		return false
	}
	else
	{
		window.location = sURL
	}
	
}

function CheckDeleteAndMove(sURL) {
	var ans = confirm("Are you sure that you want to delete this?")
	if (ans == false) {
		return false
	}
	else
	{
		window.location = sURL
	}
	
}

function CheckDeleteProductAndMove(sURL) {
	var ans = confirm("Are you sure that you want to delete this?\r\rBy deleting this Category you will be deleting:\r\r - ALL Sub Categories\r\r - ALL Products under this Category and it's Sub Categories")
	if (ans == false) {
		return false
	}
	else
	{
		window.location = sURL
	}
	
}

function noGo()
{
	document.form1.txtSubject.focus();
	alert("You cannot directly change the 'To' field. Use the 'Select Groups To Send To' in the toolbox to choose your Group(s).")
}

function selectGroups()
{
	var sel = document.getElementById('MailOut1:lstGroups')
	i = sel.selectedIndex;
	
	if (!(i == -1))
	{
		var v = document.getElementById('MailOut1:lstGroups').options[i].text
		var inOf 
		inOf = v.indexOf(" (")
		v = v.substring(0,inOf)
		document.form1.txtTo.value = document.form1.txtTo.value + v + ";"
		//document.getElementById('txtToDIV').innerHTML = document.getElementById('txtToDIV').innerHTML + v + ";"
	}
	else
	{
		alert("Please select a GROUP to send to!")
	}
}
	
function ClearToBox()
{
	document.form1.txtTo.value =""
	//document.getElementById('txtToDIV').innerHTML = ""
}

function ImportForm()
{
	var s, n
	s = editor.getInnerHTML()
	n = s.indexOf("~~@")
	if (n == -1)
	{
		editor.focusEditor();
		editor.insertHTML("<img src='inhaleform.jpg' alt='~@" + document.getElementById('MailOut1_ddlForms').options.value + "~~@'>")	
	}
	else
	{
		alert("You can only import one INHALEFORM!")
	}
}

function initEditor()
{

}
	function PreviewTemplate(id,url)
		{
			var editor = document.getElementById('CE_fldMailOut_ID');
			document.form1.HTMLPreview.value = editor.getHTML();
			var sURL = url + "?id=" + id //+ "&html=" + editor.getHTML();
			window.open(sURL,'winPreview','width=800,height=600,scrollbars=1');
		}
	
		function prepareTestSend()
		{
			//document.getElementById('MailOut1_btnSend').value = 'Sending Please Wait...'
			//document.getElementById('MailOut1_btnTestSend').value = 'Sending Please Wait...'
			//document.getElementById('MailOut1_btnSend').disabled = true
			//document.getElementById('txtTo').value = document.getElementById('txtToDIV').innerHTML
			
		}
	
		function warningSave()
		{
			if (confirm("The InhaleMail system allows you to save only one version of the text for MailOuts.\nClicking OK will overwrite any previous saved MailOut text.\nClick Cancel to not save text."))
			{
				document.getElementById('txtTo').disabled = false
				return true;
			}
			else
			{
				return false;
			}
		}
		
		function checkImport()
		{
			if (document.Form1.csvList.value.length < 5)
			{
				alert("Please Select A CSV Database To Upload.")
				document.Form1.csvList.focus();
				return false;
			}
			else
			{
				if (confirm("You are about to Import a CSV Database. Additional Fields in your CSV File will be added as Custom Fields."))
				{
					//document.Form1.btnImport.disabled = true
					document.Form1.btnImport.value = "Uploading..."
					return true;
				}
				else
				{
					return false;
				}
			}
		}
		
		function warningRestore()
		{	
			if (confirm("This Will OVERWRITE Text In MailOut Editor?"))
			{
				return true;
			}
			else
			{
				return false;
			}	
		}
		
		function prepareScheSend()
		{
			var sString = ""
			sString = sString + "   .:: Please Confirm Your Scheduled Mailout Details ::.   "
			sString = sString + "\n   .:: NOTE: This will Schedule your MailOut ::."
			sString = sString + "\n\n        Scheduled Send Date/Time: " + document.form1.MailOut1_txtTime.value + " " + document.form1.MailOut1_ddlScheTime.value
			sString = sString + "\n        To: " + document.form1.txtTo.value
			sString = sString + "\n        Subject: " + document.form1.txtSubject.value
			sString = sString + "\n        MailOut Content: MailOut Editor"
			sString = sString + "\n        Template: " + document.getElementById('tmp' + get_radio_value()).innerText
			sString = sString + "\n        Salutation: " + document.form1.MailOut1_ddlSALUTATION.value + " " + document.form1.MailOut1_ddlSALUTATIONS_OPTIONS.value
			sString = sString + "\n\nClick 'OK' To Confirm And Send, 'Cancel' To Return To The MailOut Editor"
			
			if (document.form1.txtTo.value.length < 1)	
			{
				alert("To Groups Field Empty, Please Select Groups To Send To.")
				return false;
			}
			else if (document.form1.txtSubject.value.length < 1)
			{
				alert("Subject Field Empty, Please Enter MailOut Subject.")
				return false;
			}
			else if (document.form1.MailOut1_txtTime.value == '')
			{
				alert("Please select a Scheduled Date/Time to send your MailOut.")
				return false;
			}
			else
			{
				if (confirm(sString))
				{
					return true;
				}
				else
				{
					return false;
				}
			}
		}
		
		function sDeleteSend(s)
		{
			if (confirm("Are you sure?"))
			{
				location.href='Default.aspx?d=1&s=' + s
				return true;
			}
			else
			{
				return false;
			}
		}
		
		function ValidateQuickAdd()
		{
			if (document.form1.MailOut1_txtQAFirstName.value.length < 1)	
			{
				alert("First Name Field Empty, Please Enter Client First Name.")
				document.form1.MailOut1_txtQAFirstName.focus()
				return false;
			}
			else if (document.form1.MailOut1_txtQALastName.value.length < 1)
			{
				alert("Last Name Field Empty, Please Enter Client Last Name.")
				document.form1.MailOut1_txtQALastName.focus()
				return false;
			}
			var expr = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
			var email = document.form1.MailOut1_txtQAEmailAddress.value
			if(!(expr.test(email)))
			{
				alert("Email Address Invalid.")
				document.form1.MailOut1_txtQAEmailAddress.focus();
				return false	
			}
			else if (document.form1.MailOut1_ddlQAGroupName.value == "Select Group")
			{
				alert("Group Name Field Empty, Please Select A Group To Be Added To.")
				document.form1.MailOut1_ddlQAGroupName.focus()
				return false;
			}
		}
		
		function prepareSend()
		{
			var sString = ""
			sString = sString + "   .:: Please Confirm Your Scheduled Mailout Details ::.   "
			sString = sString + "\n\n        To: " + document.form1.txtTo.value
			sString = sString + "\n        Subject: " + document.form1.txtSubject.value
			sString = sString + "\n        MailOut Content: MailOut Editor"
			sString = sString + "\n        Template: " + document.getElementById('tmp' + get_radio_value()).innerText
			sString = sString + "\n        Salutation: " + document.form1.MailOut1_ddlSALUTATION.value + " " + document.form1.MailOut1_ddlSALUTATIONS_OPTIONS.value
			sString = sString + "\n\nClick 'OK' To Confirm And Send, 'Cancel' To Return To The MailOut Editor"
			
			if (document.form1.txtTo.value.length < 1)	
			{
				alert("To Groups Field Empty, Please Select Groups To Send To.")
				return false;
			}
			else if (document.form1.txtSubject.value.length < 1)
			{
				alert("Subject Field Empty, Please Enter MailOut Subject.")
				return false;
			}
			else
			{
				if (confirm(sString))
				{
				
				}
				else
				{
					return false;
				}
					//document.getElementById('MailOut1_btnSend').value = 'Sending Please Wait...'
					//document.getElementById('MailOut1_btnTestSend').value = 'Sending Please Wait...'
					//document.getElementById('MailOut1_btnTestSend').disabled = true
					//document.form1.txtTo.disabled = false
			}
		}
		//document.form1.rTemplates[0].value
		function get_radio_value()
		{
			if (document.form1.rTemplates.value == 1)
			{
				var rad_val = 1
				return rad_val	
			}
			else
			{
				for (var i=0; i < document.form1.rTemplates.length; i++)
				{
					if (document.form1.rTemplates[i].checked)
					{
						var rad_val = document.form1.rTemplates[i].value;
						return rad_val
					}
				}
			}
		}

		function CheckDelete() {
		var ans = confirm("Are you sure that you want to delete this?")
		if (ans == false) {
			return false
		}
		else
		{
			return true
		}
		
	}
	
	function DisplayTableAuto(sTYPE) {
		Credit.style.visibility = "hidden"
		Credit.style.display = "none"
		Direct.style.visibility = "hidden"
		Direct.style.display = "none"
		
		switch (sTYPE) {
			case "CREDIT" :
				Credit.style.visibility = "visible"
				Credit.style.display = ""
				break;
			case "DIRECT" :
				Direct.style.visibility = "visible"
				Direct.style.display = ""
				break;
			
		}
	}

	function DisplayTable(sTYPE) {
		Credit.style.visibility = "hidden"
		Credit.style.display = "none"
		Cheque.style.visibility = "hidden"
		Cheque.style.display = "none"
	
		switch (sTYPE) {
			case "CREDIT" :
				Credit.style.visibility = "visible"
				Credit.style.display = ""
				break;
			case "CHEQUE" :
				Cheque.style.visibility = "visible"
				Cheque.style.display = ""
				break;
		}
		
	}

	function ShadeOut(sObj) {
		sObj.disabled = true
		sObj.value = "Processing..."
		document.forms(0).submit()
	}
	
	function NumericOnly() {
		var x = event.keyCode
		
		if ((x >= 48 && x <= 57) || (x >= 96 && x <= 105) ||(x == 8) || (x == 9)) {
			event.returnValue = true
		}
		else {
			event.returnValue = false
		}
	}
	
	function OpenCalendar(ReturnTo) {
		oParentWindow = window.open("calendar/default.asp?ReturnTo=" + ReturnTo,"myCalendar","width=250,height=200,scrollbars=no",true)
		oParentWindow.focus
	}
	
	function OpenReceipt(ID) {
		oParentWindow = window.open("centre_page/reports/receipts.asp?ID=" + ID,"myReceipt","scrollbars=no",true)
		oParentWindow.focus
	}
	
	
	function MainNavigation(sIn) {
		switch (sIn){
			case "ENQUIRIES" : 
				window.location = "default.asp?page=enquiries"
				break;
			
			case "MEMBERS" : 
				window.location = "default.asp?page=members"
				break;
			case "PAYMENTS" : 
				window.location = "default.asp?page=payments"
				break;
			case "SEARCH" : 
				window.location = "default.asp?page=search"
				break;
			case "BANKING" : 
				window.location = "default.asp?page=banking"
				break;
			case "REPORTS" : 
				window.location = "default.asp?page=reports"
				break;
		    default : 
				window.location = "default.asp";
		}

	}
	
	function ResizeCenter(newWidth,newHeight) {
		if (document.layers)
		{
		  tmp1 = parent.outerWidth - parent.innerWidth;
		  tmp2 = parent.outerHeight - parent.innerHeight;
		  newWidth -= tmp1;
		  newHeight -= tmp2;
		 }
		 parent.window.resizeTo(newWidth,newHeight);
		 parent.window.moveTo((self.screen.width-newWidth)/2,(self.screen.height-newHeight)/2);
	}
	
	function ChangePassword() {
		window.open("centre_page/changepassword.asp","myPassword","scrollbars=no",true)
	}
	
	function SubNavigation(sPage,sSubpage) {
		window.location = "default.asp?page=" + sPage + "&subpage=" + sSubpage + "&New=Y"

	}
	
	
	
	function ValidateForm(sPage,sSubpage) {
		var sMissing = ""
		
		//---------------
		switch (sPage){
		//@@@@@@@@@@@@@@@
		//Enquiries pages
		case "LOGIN" : 
			if (Login.Username.value == "") {
				Login.Username.style.backgroundColor = "yellow"
				sMissing = sMissing + "\rA Username"
			}
			if (Login.Password.value == "") {
				Login.Password.style.backgroundColor = "yellow"
				sMissing = sMissing + "\rA Password"
			}
			break;
		
		//@@@@@@@@@@@@@@@
		//Enquiries pages
		case "PARTICIPANT" : 
			//if (processFORM.user_username.value == "") {
			//	processFORM.user_username.style.backgroundColor = "gainsboro"
			//	sMissing = sMissing + "\rUsername"
			//}
			//if (processFORM.user_username.value == "") {
			//	processFORM.user_username.style.backgroundColor = "gainsboro"
			//	sMissing = sMissing + "\rUsername"
			//}
			if (processFORM.user_company.value == "") {
				processFORM.user_company.style.backgroundColor = "gainsboro"
				sMissing = sMissing + "\rCompany Name"
			}
			if (processFORM.user_first_name.value == "") {
				processFORM.user_first_name.style.backgroundColor = "gainsboro"
				sMissing = sMissing + "\rFirst Name"
			}
			if (processFORM.user_last_name.value == "") {
				processFORM.user_last_name.style.backgroundColor = "gainsboro"
				sMissing = sMissing + "\rA Surname"
			}
			if (processFORM.user_email.value == "") {
				processFORM.user_email.style.backgroundColor = "gainsboro"
				sMissing = sMissing + "\rEmail Address"
			}
			if (processFORM.user_phone.value == "") {
				processFORM.user_phone.style.backgroundColor = "gainsboro"
				sMissing = sMissing + "\rPhone Number"
			}
			if (processFORM.user_address_line1.value == "") {
				processFORM.user_address_line1.style.backgroundColor = "gainsboro"
				sMissing = sMissing + "\rAddress"
			}
			if (processFORM.user_city.value == "") {
				processFORM.user_city.style.backgroundColor = "gainsboro"
				sMissing = sMissing + "\rCity/Suburb"
			}
			if (processFORM.user_state.value == "") {
				processFORM.user_state.style.backgroundColor = "gainsboro"
				sMissing = sMissing + "\rState"
			}
			if (processFORM.user_postcode.value == "") {
				processFORM.user_postcode.style.backgroundColor = "gainsboro"
				sMissing = sMissing + "\rPostcode"
			}
			if (processFORM.user_country.value == "") {
				processFORM.user_country.style.backgroundColor = "gainsboro"
				sMissing = sMissing + "\rCountry"
			}
			break;
				
		
		//@@@@@@@@@@@@@@@
		//Default pages
		default : 
				sMissing = ""
		}
			
		//--------------
		if (sMissing != "") {
			alert("Please supply the following\r" + sMissing)
			return false
		}
		else {
			return true
		}
	}