function doDelete(categoryId,fullName) {
	frm = document.doMainForm
	
	//handle the deleting of the categoryid from the othercategories value
	strItem = frm.othercategories.value
	strReplace = String(" "+categoryId+",")
	intPosx = strItem.indexOf(strReplace)
	if (intPosx > -1) {
		intReplaceLength = strReplace.length
		strValue = strItem.substring(0,intPosx) + strItem.substring(intPosx+intReplaceLength,strItem.length)
		frm.othercategories.value = strValue	
	
		//handle the deleting of the fullname from the othercategorynames value
		strItem = frm.othercategorynames.value
		strReplace = String(fullName)
		intPosx = strItem.indexOf(strReplace)
		intReplaceLength = strReplace.length
		strValue = strItem.substring(0,intPosx) + strItem.substring(intPosx+intReplaceLength,strItem.length)
		frm.othercategorynames.value = strValue	
	}
	//Handle removing url from box
	strItem = String(frm.othercategoryurl.value)
	intStartPosx = strItem.indexOf(categoryId)
	intEndPosx = strItem.indexOf(":",intStartPosx)
	var strNewValue = ""
	strNewValue = strItem.substr(1,intStartPosx-1)
	strTempNewValue = strNewValue
	strNewValue += strItem.substr(intEndPosx+1,strItem.length)
	frm.othercategoryurl.value = strNewValue

	//Handle removing description from box
	strItem = String(frm.othercategorydescription.value)
	intStartPosx = strItem.indexOf(categoryId)
	intEndPosx = strItem.indexOf(":",intStartPosx)
	var strNewValue = ""
	strNewValue = strItem.substr(1,intStartPosx-1)
	strNewValue += strItem.substr(intEndPosx+1,strItem.length)
	frm.othercategorydescription.value = strNewValue

}

function doDeleteCurrent(categoryId,fullName) {
	frm = document.doMainForm
	
	strItem = frm.currentcategories.value
	strFind = String(" "+categoryId+",")
	intPosx = String(strItem).indexOf(strFind)	
	if (intPosx == -1) {
		frm.currentcategories.value = frm.currentcategories.value + " " + categoryId + ", " 
		//handle the deleting of the fullname from the othercategorynames value
		strItem = frm.currentcategorynames.value
		strReplace = String(fullName)
		intPosx = strItem.indexOf(strReplace)
		intReplaceLength = strReplace.length
		strValue = strItem.substring(0,intPosx) + strItem.substring(intPosx+intReplaceLength,strItem.length)
		frm.currentcategorynames.value = strValue	
	}
}


function doPopulateSubscription() {
	frm = document.doMainForm
	if (frm.populate.checked) {
		frm.subscriptionemail.value = frm.username.value
		frm.subscriptioncontactname.value = frm.usercontactname.value	
		frm.subscriptionaddress.value = frm.useraddress.value	
		frm.subscriptioncity.value = frm.usercity.value	
		frm.subscriptionstate.value = frm.userstate.value	
		frm.subscriptionzipcode.value = frm.userzipcode.value	
		frm.subscriptioncountry.value = frm.usercountry.value	
		frm.subscriptionphone.value = frm.userphone.value	
		frm.subscriptionfax.value = frm.userfax.value	
	}
}

function doPopulateBilling(whichone) {
	frm = document.doMainForm
	if (frm.populateBilling[0].checked) {
	} else if (frm.populateBilling[1].checked) {
		
		frm.billingemail.value = frm.subscriptionemail.value
		frm.billingname.value = frm.subscriptioncontactname.value	
		frm.billingaddress.value = frm.subscriptionaddress.value	
		frm.billingcity.value = frm.subscriptioncity.value	
		frm.billingstate.value = frm.subscriptionstate.value	
		frm.billingzipcode.value = frm.subscriptionzipcode.value	
		frm.billingcountry.value = frm.subscriptioncountry.value	
		frm.billingphone.value = frm.subscriptionphone.value	
		frm.billingfax.value = frm.subscriptionfax.value	
	} else if (frm.populateBilling[2].checked) {
		frm.billingemail.value = frm.username.value
		frm.billingname.value = frm.usercontactname.value	
		frm.billingaddress.value = frm.useraddress.value	
		frm.billingcity.value = frm.usercity.value	
		frm.billingstate.value = frm.userstate.value	
		frm.billingzipcode.value = frm.userzipcode.value	
		frm.billingcountry.value = frm.usercountry.value	
		frm.billingphone.value = frm.userphone.value	
		frm.billingfax.value = frm.userfax.value	
	}
}

function submitForm(pageType) {
	frm = document.doMainForm
	strMsg = ""

	switch(pageType) {
		case 1:
			strMsg = checkSubscriptionInformation(strMsg,pageType)
			strMsg = checkUserInformation(strMsg)
		break;
		case 2:
			strMsg = checkBillingInformation(strMsg)
			strMsg = checkSubscriptionInformation(strMsg,pageType)
			strMsg = checkUserInformation(strMsg)
		break;
		case 3:
			strMsg = checkSubscriptionInformation(strMsg,pageType)
		break;
		case 5:
			strMsg = checkUserInformation(strMsg)
		break;

	}
	if (strMsg == "") {
		frm.submit()
	} else {
		alert(strMsg)
	}
}

function submitInvitationForm()
{	frm = document.doMainForm
	strMsg = ""
	strMsg = checkInvitationInformation(strMsg)
	if (strMsg == "") {
		//frm.submit()
		return true
	} else {
		alert(strMsg)
		return false
	}
}

function checkInvitationInformation(strCurrentMsg) {
	frm = document.doProcessInvitation
	strMsg = strCurrentMsg
	
	if (frm.invitationcode.value == "") {
		strMsg = "Please enter Invitation Code"
		frm.invitationcode.focus()
	}
	return strMsg
}

function checkUserInformation(strCurrentMsg) {
	frm = document.doMainForm
	strMsg = strCurrentMsg
	if (frm.userphone.value == "") {
		strMsg = "Please enter a User Phone number"
		frm.userphone.focus()
	}
		
	if (frm.usercountry.value == "") {
		strMsg = "Please enter a User Country"
		frm.usercountry.focus()
	}
	if (frm.userzipcode.value == "") {
		strMsg = "Please enter a User Zipcode"
		frm.userzipcode.focus()
	}
	if (frm.userstate.value == "") {
		strMsg = "Please enter a User State"
		frm.userstate.focus()
	}
	if (frm.usercity.value == "") {
		strMsg = "Please enter a User City"
		frm.usercity.focus()
	}
	if (frm.useraddress.value == "") {
		strMsg = "Please enter a User Address"
		frm.useraddress.focus()
	}
	if (frm.usercontactname.value == "") {
		strMsg = "Please enter a User Contact Name"
		frm.usercontactname.focus()
	}
	if (frm.passwordhint.value == "") {
		strMsg = "Please enter a Password Hint"
		frm.passwordhint.focus()
	}
	if (frm.password.value == "") {
		strMsg = "Please enter a User Password"
		frm.password.focus()
	}
	if (frm.password.value != frm.confirmpassword.value) {
		strMsg = "Please enter a Matching Password and Confirmation Password."
		frm.password.value = ""
		frm.confirmpassword.value = ""
		frm.password.focus()
	}
	if (frm.username.value == "") {
		strMsg = "Please enter a UserName"
		frm.username.focus()
	}
	return strMsg
}

function checkSubscriptionInformation(strCurrentMsg,pageType) {
	frm = document.doMainForm
	strMsg = strCurrentMsg
	if (frm.subscriptionemail.value == "") {
		strMsg = "Please enter a Subscription Email"
		frm.subscriptionemail.focus()
	}
	if (frm.subscriptionphone.value == "") {
		strMsg = "Please enter a Subscription Phone Number"
		frm.subscriptionphone.focus()
	}
	if (frm.subscriptioncountry.value == "") {
		strMsg = "Please enter a Subscription Country"
		frm.subscriptioncountry.focus()
	}
	if (frm.subscriptionzipcode.value == "") {
		strMsg = "Please enter a Subscription Zipcode"
		frm.subscriptionzipcode.focus()
	}
	if (frm.subscriptionstate.value == "") {
		strMsg = "Please enter a Subscription State"
		frm.subscriptionstate.focus()
	}
	if (frm.subscriptioncity.value == "") {
		strMsg = "Please enter a Subscription City"
		frm.subscriptioncity.focus()
	}
	if (frm.subscriptionaddress.value == "") {
		strMsg = "Please enter a Subscription Address"
		frm.subscriptionaddress.focus()
	}
	if (frm.subscriptionname.value == "") {
		strMsg = "Please enter a Company Name"
		frm.subscriptionname.focus()
	}
	if (frm.subscriptioncontactname.value == "") {
		strMsg = "Please enter a Subscription Contact Name"
		frm.subscriptioncontactname.focus()
	}
	if (pageType!=3) {
		if (frm.othercategories.value.indexOf(",") == -1) {
			strMsg = "You need to select a category."
		}
	}
	return strMsg
}


function checkBillingInformation(strCurrentMsg) {
	frm = document.doMainForm
	strMsg = strCurrentMsg
	if (frm.billingemail.value == "") {
		strMsg = "Please enter a Billing Email"
		frm.billingemail.focus()
	}
	if (frm.billingphone.value == "") {
		strMsg = "Please enter a Billing Phone Number"
		frm.billingphone.focus()
	}
	if (frm.billingcountry.value == "") {
		strMsg = "Please enter a Billing Country"
		frm.billingcountry.focus()
	}
	if (frm.billingzipcode.value == "") {
		strMsg = "Please enter a Billing Zipcode"
		frm.billingzipcode.focus()
	}
	if (frm.billingstate.value == "") {
		strMsg = "Please enter a Billing State"
		frm.billingstate.focus()
	}
	if (frm.billingcity.value == "") {
		strMsg = "Please enter a Billing City"
		frm.billingcity.focus()
	}
	if (frm.billingaddress.value == "") {
		strMsg = "Please enter a Billing Address"
		frm.billingaddress.focus()
	}
	if (frm.billingname.value == "") {
		strMsg = "Please enter a Billing Credit Holder Name"
		frm.billingname.focus()
	}
/*	if (frm.creditcardexpirationdate.value == "") {
		strMsg = "Please enter a Billing Credit Card Expiration Date"
		frm.creditcardexpirationdate.focus()
	}
	if (frm.creditcardnumber.value == "") {
		var strMsg = "Please enter a Billing Credit Card Number"
		frm.creditcardnumber.focus()
	}
*/	
	return strMsg
}

