//	Start New Window Script
//	Used on all pages
	function openWindow(url, w, h, s) 
	{
		if (document.all || document.layers) 
		{
			pagew = screen.availWidth;
			pageh = screen.availHeight;
		}
		var leftPos = (pagew-w)/2, topPos = (pageh-h)/2;
		var windowprops = "width=" + w + ",height=" + h + ",scrollbars=" + s + ",Top=" + topPos + ",Left=" + leftPos ;
		popup = window.open(url,'remote',windowprops);
	}
//	End New Window Script

//	Start Form Validation Script
//	Used by form validation functions
	function isEmailAddr(email)
	{
		var result = false;
		var theStr = new String(email);
		var index = theStr.indexOf("@");
		if (index > 0)
		{
			var pindex = theStr.indexOf(".",index);
			if ((pindex > index+1) && (theStr.length > pindex+1))
				result = true;
		}
		return result;
	}	

	function validRequired(formField,fieldLabel,Message)
	{
		var result = true;
		if (formField.value == "")
		{
			alert(Message);
			formField.focus();
			result = false;
		}
	return result;
	}

	function validEmail(formField,fieldLabel,required)
	{
		var result = true;
		if (required && !validRequired(formField,fieldLabel))
			result = false;
		if (result && ((formField.value.length < 3) || !isEmailAddr(formField.value)) )
		{
			alert("Please enter a complete email address in the form: yourname@yourdomain.com");
			formField.focus();
			result = false;
		}
		return result;
	}

	function validNum(formField,fieldLabel,required)
	{
		var result = true;
		if (required && !validRequired(formField,fieldLabel,"Error in Birthday Field"))
			result = false;
	 	if (result)
 		{
 			var num = parseInt(formField.value);
 			if (isNaN(num))
 			{
 				alert('Please enter a number for the "' + fieldLabel +'" field.');
				formField.focus();		
				result = false;
			}
		} 
		return result;
	}

	function validDate(formField,fieldLabel,required)
	{
		var result = true;
		//if (!validRequired(formField,fieldLabel))
		//	alert('Please enter a date in the format MM/DD/YYYY for the "' + fieldLabel +'" field.');
		//	result = false;
	 	if (result)
 		{
 			var elems = formField.value.split("/");
	 		result = (elems.length == 3); // should be three components
 			if (result)
 			{
 				var month = parseInt(elems[0]);
  				var day = parseInt(elems[1]);
 				var year = parseInt(elems[2]);
				result =	!isNaN(month) && (month > 0) && (month < 13) &&
							!isNaN(day) && (day > 0) && (day < 32) &&
							!isNaN(year) && (elems[2].length == 4);
 			}
 			if (!result)
 			{
 				alert('Please enter a date in the format M/D/YYYY for the "' + fieldLabel +'" field.');
				formField.focus();		
			}
		} 
		return result;
	}
//	End Form Validation Script

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//	Start Affiliate Contact Us Validation
//	Used on /affiliates/contact-us.asp
	function validateAffiliateContact(theForm)
	{
		if (!validRequired(theForm.name,"name", "You need to enter your name!"))
		return false;		
		if (!validEmail(theForm.email,"email"))
		return false;	
		if (!validRequired(theForm.query,"query", "You need to enter your query!"))
		return false;		
		return true;
	}
//	End Affiliate Contact Us Validation
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//	Start Affiliate Login Validation
//	Used on /affiliates/login.asp  /affiliates/default.asp
	function validateAffiliateLogin(theForm)
	{
		if (!validRequired(theForm.userid,"userid", "You need to enter your strUsername!"))
		return false;		
		if (!validRequired(theForm.strPassword,"strPassword", "You need to enter your strPassword!"))
		return false;			
		return true;
	}
//	End Affiliate Login Validation
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//	Start Affiliate Section Payment Option
	function copyData(from,to) 
	{ 
		if (document.Form1.mycheckbox.checked)
		{
			to.value = from.value; 
		}
		else
		{
			to.value='';
		}
	}
	// This is an old function and was replaced by the NetellerChangeOver function below
	function MakeVisible()
	{
		if (document.Form1.strPaymentMethod.selectedIndex == 1)
		{
			document.getElementById("myhiddenlayer").style.visibility="visible";
		}
		else
		{
			document.getElementById("myhiddenlayer").style.visibility="hidden";
		}
	}
	function NetellerChangeOver(page)
	{
		if (document.Form1.strPaymentMethod.selectedIndex == 1 )
		{
			document.getElementById('accountnumber').innerHTML='NETeller Email Address*';
		}
		else
		{
			if (document.Form1.strPaymentMethod.selectedIndex == 2)
			{
				if (page == "profile")
				{
					openWindow('/affiliates/bank_wire_info.asp','600','400','yes');
				}
				else
				{
					openWindow('/affiliates/bank_wire_info2.asp','600','400','yes');
				}
			}
			document.getElementById('accountnumber').innerHTML='<a href="#" title="Your Neteller email address, Casino Playing account No. , Infinia Card No. or your Bank Account No. should be entered here as appropriate.">Account Number</a> *';
		}
	}
//	End Affiliate Section Payment Option
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//	Start Validate Webmaster Application
	function validateForm(theForm, method)
	{
		// Start ------->
		if (!validRequired(theForm.strUsername,"strUsername", "You need to enter your Username"))
			return false;
		if (method == "apply")
		{
			
			if (!validRequired(theForm.strPassword,"", "You must insert your Password!"))
				return false;
		}
		
		if (!validRequired(theForm.strFullName,"strFullName", "You need to enter your Fullname!"))
			return false;

		if (!validEmail(theForm.strEmailAddress,"strEmailAddress"))
			return false;

		if (!validRequired(theForm.strAddress1,"strAddress1", "You need to enter your address"))
			return false;

		if (!validRequired(theForm.strCity,"strCity", "You need to enter your city"))
			return false;
			
		if (!validRequired(theForm.strBankName,"strBankName", "You need to enter your Account Holders Name"))
			return false;
		
		var mycheckpay;
		mycheckpay = '';
		mycheckpay = document.Form1.strPaymentMethod.options[document.Form1.strPaymentMethod.selectedIndex].value;
		if ((mycheckpay == 'Bank Wire') || (mycheckpay == 'ACH'))
		{
			var mycheckacc;
			mycheckacc = '';
			mycheckacc = document.Form1.strAccountType.options[document.Form1.strAccountType.selectedIndex].value;
			//if ((document.Form1.strAccountType.options[document.Form1.strAccountType.selectedIndex].value != 'Savings') || (document.Form1.strAccountType.options[document.Form1.accounttype.selectedIndex].value != 'Check'))
			if (mycheckacc == '') 
			{
				alert('You must enter your Bank Account Type');
				theForm.strAccountType.focus();
				return false;
			}
			
			//This is no longer required as Accounts have requested all the banking address and details to be removed
			//from both the affiliate registration page and the affiliate profile update page. They are
			//affiliates/registration.asp and affiliates/affiliatearea/profile.asp respectively
			//if (!validRequired(theForm.strBankAddress1,"strBankAddress1", "You must enter your Bank Name"))
				//return false;
			
			if (!validRequired(theForm.strbankrouting,"strbankrouting", "You need to enter your Bank Routing/Swift Code"))
				return false;	
		}
		return true;
	}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//	Start Date DDL
//
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Created by: Lee Hinder, lee.hinder@ntlworld.com -->

<!-- Begin
//function for returning how many days there are in a month including leap years
function DaysInMonth(WhichMonth, WhichYear)
{
  var DaysInMonth = 31;
  if (WhichMonth == "Apr" || WhichMonth == "Jun" || WhichMonth == "Sep" || WhichMonth == "Nov") DaysInMonth = 30;
  if (WhichMonth == "Feb" && (WhichYear/4) != Math.floor(WhichYear/4))	DaysInMonth = 28;
  if (WhichMonth == "Feb" && (WhichYear/4) == Math.floor(WhichYear/4))	DaysInMonth = 29;
  return DaysInMonth;
}

//function to change the available days in a months
function ChangeOptionDays(Which)
{
  DaysObject = eval("document.Form1." + Which + "Day");
  MonthObject = eval("document.Form1." + Which + "Month");
  YearObject = eval("document.Form1." + Which + "Year");

  Month = MonthObject[MonthObject.selectedIndex].text;
  Year = YearObject[YearObject.selectedIndex].text;

  DaysForThisSelection = DaysInMonth(Month, Year);
  CurrentDaysInSelection = DaysObject.length;
  if (CurrentDaysInSelection > DaysForThisSelection)
  {
    for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
    {
      DaysObject.options[DaysObject.options.length - 1] = null
    }
  }
  if (DaysForThisSelection > CurrentDaysInSelection)
  {
    for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
    {
      NewOption = new Option(DaysObject.options.length + 1);
      DaysObject.add(NewOption);
    }
  }
    if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
}
//	End Date DDL
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//	Start Back
function back() 
{
    history.go(-1);
}
//	End Back
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//	Start Toggle
function ToggleCampaign(item) 
{
	obj=document.getElementById(item);
	visible=(obj.style.display!="none")
	key=document.getElementById("campaign" + item);
	if (visible) 
	{
		obj.style.display="none";
		key.innerHTML="<img src='images/plus.gif' hspace='0' vspace='0' border='0'>";
		
	} 
	else 
	{
		obj.style.display="block";
		key.innerHTML="<img src='images/minus.gif' hspace='0' vspace='0' border='0'>";
	}
}
//	End Toggle
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//	Start Validate Contact Us 
	function validateContact(theForm, method)
	{
		if (!validRequired(theForm.name,"name", "You need to enter your Username"))
			return false;
		if (!validEmail(theForm.email,"email"))
			return false;			
		if (!validRequired(theForm.comments,"comments", "You need to enter a comment"))
			return false;
		return true;
	}			
//	End Contact

