<!--
form_submitted=false
function ValidateEmail(theinput)
{
	s=theinput.value
	if(s.search)
	{
		return (s.search(new RegExp('^([-!#$%&\'*+./0-9=?A-Z^_`a-z{|}~'+unescape('%7F')+'])+@([-!#$%&\'*+/0-9=?A-Z^_`a-z{|}~'+unescape('%7F')+']+\\.)+[a-zA-Z]{2,6}$','gi'))>=0)
	}
	if(s.indexOf)
	{
		at_character=s.indexOf('@')
		if(at_character<=0 || at_character+4>s.length)
			return false
	}
	if(s.length<6)
		return false
	else
		return true
}
function isNotValidURL(url)
{
    var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
    if(RegExp.test(url)){
        return false;
    }else{
        return true;
    }
} 
counter = 0;

function ValidateForm(theform)
{

	if(((theform['tax_class'].value!='Individual') && (theform['tax_class'].value!='Sole Proprietorship'))
		&& (theform['business_name'].value==''))
	{
		if(theform['business_name'].focus)
			theform['business_name'].focus()
		alert(theform['IDS_AFFIL_EDIT_VALID_COMPANY'].value)
		form_submitted=false
		return false
	}
	if((theform['create'].value == '1') && (theform['website_url'].value !=''))
	{
		var value=theform['website_url'].value;
		if(theform['website_url'].value.search("http") != 0)
			value='http://' + theform['website_url'].value;
		theform['website_url'].value = value;

		if(isNotValidURL(theform['website_url'].value))
		{
			if(theform['website_url'].focus)
				theform['website_url'].focus()
			alert(theform['IDS_AFFIL_EDIT_VALID_WEB_URL'].value)
			form_submitted=false
			return false
		}
		if(theform['website_name'].value=='')
		{
			if(theform['website_name'].focus)
				theform['website_name'].focus()
			alert(theform['IDS_AFFIL_EDIT_VALID_WEB_NAME'].value)
			form_submitted=false
			return false
		}
	}
	if((theform['create'].value == '1') && (theform['login'].value==''))
	{
		if(theform['login'].focus)
			theform['login'].focus()
		alert(theform['IDS_AFFIL_EDIT_VALID_LOGIN'].value)
		form_submitted=false
		return false
	}
	if((theform['create'].value == '1') && (theform['login'].value.indexOf(':') != -1))
	{
		if(theform['login'].focus)
			theform['login'].focus()
		alert(theform['IDS_AFFIL_EDIT_VALID_LOGIN_COLON'].value)
		form_submitted=false
		return false
	}
	if(theform['fname'].value=='')
	{
		if(theform['fname'].focus)
			theform['fname'].focus()
		alert(theform['IDS_AFFIL_EDIT_VALID_FIRST_NAME'].value)
		form_submitted=false
		return false
	}
	if(theform['lname'].value=='')
	{
		if(theform['lname'].focus)
			theform['lname'].focus()
		alert(theform['IDS_AFFIL_EDIT_VALID_LAST_NAME'].value)
		form_submitted=false
		return false
	}
	
	if(theform['birthMonth'].value=='')
	{
		if(theform['birthMonth'].focus)
			theform['birthMonth'].focus()
		alert(theform['IDS_AFFIL_EDIT_VALID_BIRTH_MONTH'].value)
		form_submitted=false
		return false
	}
	if(theform['birthDay'].value=='')
	{
		if(theform['birthDay'].focus)
			theform['birthDay'].focus()
		alert(theform['IDS_AFFIL_EDIT_VALID_BIRTH_DAY'].value)
		form_submitted=false
		return false
	}
	if(theform['birthYear'].value=='')
	{
		if(theform['birthYear'].focus)
			theform['birthYear'].focus()
		alert(theform['IDS_AFFIL_EDIT_VALID_BIRTH_YEAR'].value)
		form_submitted=false
		return false
	}
	if(ValidateEmail(theform['e_mail'])==false)
	{
		if(theform['e_mail'].focus)
			theform['e_mail'].focus()
		alert(theform['IDS_AFFIL_EDIT_VALID_EMAIL'].value)
		form_submitted=false
		return false
	}
	if((theform['password1'].value=='') && (theform['create'].value == '1'))
	{
		if(theform['password1'].focus)
			theform['password1'].focus()
		alert(theform['IDS_AFFIL_EDIT_VALID_PASSWORD'].value)
		form_submitted=false
		return false
	}
	if((theform['confirm_password'].value!=theform['password1'].value))
	{
		if(theform['confirm_password'].focus)
			theform['confirm_password'].focus()
		alert(theform['IDS_AFFIL_EDIT_VALID_PASSWORD_TYPO'].value)
		form_submitted=false
		return false
	}
	if(theform['question'].value=='')
	{
		if(theform['question'].focus)
			theform['question'].focus()
		alert(theform['IDS_AFFIL_EDIT_VALID_REMINDER'].value)
		form_submitted=false
		return false
	}
	if(theform['question'].value==theform['password1'].value)
	{
		if(theform['question'].focus)
			theform['question'].focus()
		alert(theform['IDS_AFFIL_EDIT_VALID_REMINDER_PASSWORD'].value)
		form_submitted=false
		return false
	}
	if(theform['answer'].value=='' && (theform['create'].value == '1'))
	{
		if(theform['answer'].focus)
			theform['answer'].focus()
		alert(theform['IDS_AFFIL_EDIT_VALID_QUESTION'].value)
		form_submitted=false
		return false
	}
	if(theform['answer'].value==theform['password1'].value && (theform['create'].value == '1'))
	{
		if(theform['answer'].focus)
			theform['answer'].focus()
		alert(theform['IDS_AFFIL_EDIT_VALID_QUESTION_PASSWORD'].value)
		form_submitted=false
		return false
	}
	if(theform['address'].value=='')
	{
		if(theform['address'].focus)
			theform['address'].focus()
		alert(theform['IDS_AFFIL_EDIT_VALID_ADDRESS'].value)
		form_submitted=false
		return false
	}
	if(theform['city'].value=='')
	{
		if(theform['city'].focus)
			theform['city'].focus()
		alert(theform['IDS_AFFIL_EDIT_VALID_CITY'].value)
		form_submitted=false
		return false
	}
	
	if(theform['country_id'].selectedIndex==0)
	{
		if(theform['country_id'].focus)
			theform['country_id'].focus()
		alert(theform['IDS_AFFIL_EDIT_VALID_COUNTRY'].value)
		form_submitted=false
		return false
	}
	if(theform['post_code'].value=='')
	{
		if(theform['post_code'].focus)
			theform['post_code'].focus()
		alert(theform['IDS_AFFIL_EDIT_VALID_ZIP'].value)
		form_submitted=false
		return false
	}
	if(theform['work_phone'].value=='')
	{
		if(theform['work_phone'].focus)
			theform['work_phone'].focus()
		alert(theform['IDS_AFFIL_EDIT_VALID_WORK_PHONE'].value)
		form_submitted=false
		return false
	}
	if(theform['processor_id'].value==0)
	{
		if(theform['processor_id'].focus)
			theform['processor_id'].focus()
		alert(theform['IDS_AFFIL_EDIT_VALID_PAYMENT_METHOD'].value)
		form_submitted=false
		return false
	}
	switch(theform['processor_id'].value)
	{
		case '14':
			if(theform['payee_name'].value=='')
			{
				if(theform['payee_name'].focus)
					theform['payee_name'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_PAYEE_NAME'].value)
				form_submitted=false
				return false
			}
			break;
		case '36':
			if(theform['payee_name'].value=='')
			{
				if(theform['payee_name'].focus)
					theform['payee_name'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_PAYEE_NAME'].value)
				form_submitted=false
				return false
			}
			if(document.user_form.country_id.value != document.user_form.US_id.value)
			{
				if(theform['processor_id'].focus)
					theform['processor_id'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_ECHECKUS_NON_US'].value)
				form_submitted=false
				return false
			}
			break;
		case '20':
			if(theform['dd_login'].value=='')
			{
				if(theform['dd_login'].focus)
					theform['dd_login'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_LOGIN_DD'].value)
				form_submitted=false
				return false
			}
			break;
		case '63':
			if(document.user_form.country_id.value != document.user_form.US_id.value)
			{
				if(theform['processor_id'].focus)
					theform['processor_id'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_ECHECKUS_NON_US'].value)
				form_submitted=false
				return false
			}
			if(theform['account_number'].value =='')
			{
				if(theform['account_number'].focus)
					theform['account_number'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_BANK_NUMBER'].value)
				form_submitted=false
				return false
			}
			if(theform['bank_name'].value =='')
			{
				if(theform['bank_name'].focus)
					theform['bank_name'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_BANK_NAME'].value)
				form_submitted=false
				return false
			}
			if(theform['account_routing'].value =='')
			{
				if(theform['account_routing'].focus)
					theform['account_routing'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_BANK_ROUTING'].value)
				form_submitted=false
				return false
			}
			if(theform['ssn'].value =='')
			{
				if(theform['ssn'].focus)
					theform['ssn'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_SSN'].value)
				form_submitted=false
				return false
			}
			break;
		case '12':
			if(theform['account_number'].value =='')
			{
				if(theform['account_number'].focus)
					theform['account_number'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_BANK_NUMBER'].value)
				form_submitted=false
				return false
			}
			if(theform['payee_name'].value=='')
			{
				if(theform['payee_name'].focus)
					theform['payee_name'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_PAYEE_NAME'].value)
				form_submitted=false
				return false
			}
			if(theform['wire_address'].value=='')
			{
				if(theform['wire_address'].focus)
					theform['wire_address'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_WIRE_ADDRESS'].value)
				form_submitted=false
				return false
			}
			if(theform['bank_name'].value =='')
			{
				if(theform['bank_name'].focus)
					theform['bank_name'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_BANK_NAME'].value)
				form_submitted=false
				return false
			}
			if(theform['bank_address'].value =='')
			{
				if(theform['bank_address'].focus)
					theform['bank_address'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_BANK_ADDRESS'].value)
				form_submitted=false
				return false
			}
			break;
		case '19':
			if(theform['account_number'].value =='')
			{
				if(theform['account_number'].focus)
					theform['account_number'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_BANK_NUMBER'].value)
				form_submitted=false
				return false
			}
			if(theform['payee_name'].value=='')
			{
				if(theform['payee_name'].focus)
					theform['payee_name'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_PAYEE_NAME'].value)
				form_submitted=false
				return false
			}
			if(theform['account_routing'].value =='')
			{
				if(theform['account_routing'].focus)
					theform['account_routing'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_BANK_ROUTING'].value)
				form_submitted=false
				return false
			}
			break;
		case '21':
			if(theform['account_number'].value =='')
			{
				if(theform['account_number'].focus)
					theform['account_number'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_NAVAHO_NUMBER'].value)
				form_submitted=false
				return false
			}
			if(theform['payee_name'].value=='')
			{
				if(theform['payee_name'].focus)
					theform['payee_name'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_ACCOUNT_NAME'].value)
				form_submitted=false
				return false
			}
			break;
		case '9':
			if(theform['account_number'].value =='')
			{
				if(theform['account_number'].focus)
					theform['account_number'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_ACCOUNT_NUMBER'].value)
				form_submitted=false
				return false
			}
			if(ValidateEmail(theform['nt_email'])==false)
			{
				if(theform['nt_email'].focus)
					theform['nt_email'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_NETELLER_EMAIL'].value)
				form_submitted=false
				return false
			}
			break;
		case '3':
			if(ValidateEmail(theform['nt_email'])==false)
			{
				if(theform['nt_email'].focus)
					theform['nt_email'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_NETELLER_EMAIL'].value)
				form_submitted=false
				return false
			}
			break;
		case '28':
			if(theform['account_number'].value =='')
			{
				if(theform['account_number'].focus)
					theform['account_number'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_ACCOUNT_NUMBER'].value)
				form_submitted=false
				return false
			}
			break;
		case '10':
		case '24':
			if(theform['account_number'].value =='')
			{
				if(theform['account_number'].focus)
					theform['account_number'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_ACCOUNT_NUMBER'].value)
				form_submitted=false
				return false
			}
			break;
		case '4':
			if(theform['account_number'].value =='')
			{
				if(theform['account_number'].focus)
					theform['account_number'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_ACCOUNT_NUMBER'].value)
				form_submitted=false
				return false
			}
			if(theform['expiry'].value =='')
			{
				if(theform['expiry'].focus)
					theform['expiry'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_EXPIRY_DATE'].value)
				form_submitted=false
				return false
			}
			break;
		case '13':
			if(theform['account_number'].value =='')
			{
				if(theform['account_number'].focus)
					theform['account_number'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_ACCOUNT_NUMBER'].value)
				form_submitted=false
				return false
			}
			if(theform['pan'].value =='')
			{
				if(theform['pan'].focus)
					theform['pan'].focus()
				alert(theform['IDS_AFFIL_EDIT_VALID_PAN'].value)
				form_submitted=false
				return false
			}
			break;
	}
	
	if(theform['create'].value == '1')
	{
		if(theform['hear_about_us'].value == "None")
		{
			if(theform['hear_about_us'].focus)
				theform['hear_about_us'].focus()
			alert(theform['IDS_AFFIL_EDIT_VALID_HEARD_ABOUT'].value)
			form_submitted=false
			return false
		}
		if(theform['accept'].checked == false)
		{
			if(theform['accept'].focus)
				theform['accept'].focus()
			alert(theform['IDS_AFFIL_EDIT_VALID_T_AND_C'].value)
			form_submitted=false
			return false
		}
	}
	if((theform['create'].value != '1') && (theform['security_check'].value =='1') && (theform['answer'].value==''))
	{
		if(theform['answer'].focus)
			theform['answer'].focus()
		alert(theform['IDS_AFFIL_EDIT_VALID_EXTRA_SECURITY_CHECK'].value)
		form_submitted=false
		return false
	}
	if(form_submitted) 
	{ 
		alert(theform['IDS_AFFIL_EDIT_VALID_SUBMITTED_WAIT'].value)
		return false 
	}
	form_submitted=true;
	return true
}

function selectCountry(theform) {
	var province = document.getElementById('province');
	var state    = document.getElementById('state');
	var label    = document.getElementById('prov_label');

	if (document.user_form.country_id.value == document.user_form.Canada_id.value) {
		label.style.display = 'block';
		province.style.display = 'block';
		state.style.display = 'none';
	} else if(document.user_form.country_id.value == document.user_form.US_id.value) {
		label.style.display = 'block';
		state.style.display = 'block';
		province.style.display = 'none';
	} else {
		label.style.display = 'none';
		province.style.display = 'none';
		state.style.display    = 'none';
	}
}

function selectPaymentType() {
	
	var processor_id = document.getElementById('processor_id');
	var nt_email = document.getElementById('nt_email');
	nt_email.style.display = 'none';
	var account_number = document.getElementById('account_number');
	account_number.style.display = 'none';
	var payee_name = document.getElementById('payee_name');
	payee_name.style.display = 'none';
	var bank_name = document.getElementById('bank_name');
	bank_name.style.display = 'none';
	var account_type = document.getElementById('account_type');
	account_type.style.display = 'none';
	var account_routing = document.getElementById('account_routing');
	account_routing.style.display = 'none';
	var account_routing_required = document.getElementById('account_routing_required');
	if(account_routing_required != null)
	{
		account_routing_required.style.display = 'none';
	}
	var bank_extra = document.getElementById('bank_extra');
	bank_extra.style.display = 'none';
	var swift = document.getElementById('swift');
	swift.style.display = 'none';
	var iban = document.getElementById('iban');
	iban.style.display = 'none';
	var wire_address = document.getElementById('wire_address');
	wire_address.style.display = 'none';
	var bank_address = document.getElementById('bank_address');
	bank_address.style.display = 'none';
	var ssn = document.getElementById('ssn');
	ssn.style.display = 'none';
	var expiry = document.getElementById('expiry');
	expiry.style.display = 'none';
	var pan = document.getElementById('pan');
	pan.style.display = 'none';
	var dd_casino_id = document.getElementById('dd_casino_id');
	dd_casino_id.style.display = 'none';
	var dd_login = document.getElementById('dd_login');
	dd_login.style.display = 'none';

	switch(processor_id.value)
	{
		case '14':
			payee_name.style.display = '';
			break;
		case '36':
			payee_name.style.display = '';
			break;
		case '20':
			dd_login.style.display = '';
			dd_casino_id.style.display = '';
			break;
		case '12':
			bank_name.style.display = '';
			account_number.style.display = '';
			account_routing.style.display = '';
			bank_extra.style.display = '';
			iban.style.display = '';
			swift.style.display = '';
			bank_address.style.display = '';
			payee_name.style.display = '';
			wire_address.style.display = '';
			break;
		case '19':
			account_number.style.display = '';
			account_routing.style.display = '';
			if(account_routing_required != null)
			{
				account_routing_required.style.display = '';
			}
			payee_name.style.display = '';
			break;
		case '21':
			account_number.style.display = '';
			payee_name.style.display = '';
			break;
		case '9':
			nt_email.style.display = '';
			account_number.style.display = '';
			break;
		case '3':
			nt_email.style.display = '';
			break;
		case '28':
			account_number.style.display = '';
			break;
		case '10':
		case '24':
			account_number.style.display = '';
			break;
		case '4':
			account_number.style.display = '';
			expiry.style.display = '';
			break;
		case '13':
			account_number.style.display = '';
			pan.style.display = '';
			break;
		case '63':
			bank_name.style.display = '';
			account_number.style.display = '';
			account_routing.style.display = '';
			account_type.style.display = '';
			ssn.style.display = '';
			break;
		default:
			break;
	}
	
}


function autoFillAddress(theform) {
	if(document.user_form.wire_address.value ==null || document.user_form.wire_address.value =='')
	{
		if(document.user_form.address.value !=null && document.user_form.address.value !='')
		{
			document.user_form.wire_address.value += document.user_form.address.value + '\n';
		}
		if(document.user_form.address2.value !=null && document.user_form.address2.value !='')
		{
			document.user_form.wire_address.value += document.user_form.address2.value + '\n';
		}
		if(document.user_form.city.value !=null && document.user_form.city.value !='')
		{
			document.user_form.wire_address.value += document.user_form.city.value;
		}
		if (document.user_form.country_id.value == document.user_form.Canada_id.value)
		{
			document.user_form.wire_address.value += ', ' + document.user_form.province_id.options[document.user_form.province_id.selectedIndex].text;
		}
		else if(document.user_form.country_id.value == document.user_form.US_id.value)
		{
			document.user_form.wire_address.value += ', ' + document.user_form.state_id.options[document.user_form.state_id.selectedIndex].text;
		}
		if(document.user_form.country_id.options[document.user_form.country_id.selectedIndex].value != 0)
		{
			document.user_form.wire_address.value += '\n' + document.user_form.country_id.options[document.user_form.country_id.selectedIndex].text;
		}
		if(document.user_form.post_code.value !=null && document.user_form.post_code.value !='')
		{
			document.user_form.wire_address.value += '  ' + document.user_form.post_code.value;
		}
	}
}

function autoFillPayee(theform) {
	if(document.user_form.payee_name.value ==null || document.user_form.payee_name.value =='')
	{
		if(document.user_form.fname.value !=null && document.user_form.fname.value !='')
		{
			document.user_form.payee_name.value += document.user_form.fname.value;
		}
		if(document.user_form.lname.value !=null && document.user_form.lname.value !='')
		{
			document.user_form.payee_name.value += ' ' + document.user_form.lname.value;
		}
	}
}

function initEdit() {
	selectCountry();
	selectPaymentType();
}
// --
 

