// JavaScript for an Individual Registering a Business Name
//Dave Fitz 30/06/07

function checkdate()
{
 var tday = document.registerind.DOADay[document.registerind.DOADay.selectedIndex].text;
   var tmonth = document.registerind.DOAMonth[document.registerind.DOAMonth.selectedIndex].text;
	 var tyear = document.registerind.DOAYear[document.registerind.DOAYear.selectedIndex].text;

var y=new Date();
	var u = y.getFullYear();
		var r = y.getMonth() + 1;
			var x = y.getDate();


        var expire=new Date(tyear,tmonth,tday)  ; 
		  var expire2=new Date(u,r,x);
	//alert(expire2);
	 if (expire > expire2)
	{
		alert("You have entered the Date of Adoption of your Business Name to be a date in the future.\nApplications cannot be processed with an effective future date.");
		document.registerind.DOADay.focus();
			return false;
    }
	 	 
}
  
  
//trim function 
function trimAll(sString) 
{
	
while (sString.substring(0,1) == ' ')
{
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
//alert(sString.length);

return sString;

}  

function validate_form()
{

window.sel = document.registerind.istatus;
window.sel2 = document.registerind.paymentmethod;

window.sel3 = document.registerind.DOADay;
window.sel4 = document.registerind.DOAMonth;
window.sel5 = document.registerind.DOAYear;

window.sel9 = document.registerind.howfound;


//window.sel9 = document.registerind.istatus;

  if(sel3.options[sel3.selectedIndex].text == '--' )
   {
   alert("Please enter the Day of Adoption for your business name");
   document.registerind.DOADay.focus();
   return false;
   } 
   else if(sel4.options[sel4.selectedIndex].text == '--' )
   {
   alert("Please enter the Month of Adoption for your business name");
   document.registerind.DOAMonth.focus();
   return false;
   } 
   else if(sel5.options[sel5.selectedIndex].text == '-- --' )
   {
   alert("Please enter the Year of Adoption for your business name");
   document.registerind.DOAYear.focus();
   return false;
   } 
   else if (trimAll(document.registerind.iname.value).length == 0)
   {
   alert("Please enter the Business Name to be registered");
   document.registerind.iname.focus();
   return false;
   }
   else if (trimAll(document.registerind.inature.value).length == 0)
   {
   alert("Please enter the 'Nature' of the Business");
   document.registerind.inature.focus();
   return false;
   }
   else if (trimAll(document.registerind.iaddress.value).length == 0)
   {
   alert("Please enter the Business Address");
   document.registerind.iaddress.focus();
   return false;
   }
   else if (trimAll(document.registerind.compname.value).length == 0)
   {
   alert("Please enter the Company Name");
   document.registerind.compname.focus();
   return false;
   }
   else if (trimAll(document.registerind.compnum.value).length == 0)
   {
   alert("Please enter the Company Number");
   document.registerind.compnum.focus();
   return false;
   }
   else if (trimAll(document.registerind.compaddress.value).length == 0)
   {
   alert("Please enter the Company Address");
   document.registerind.compaddress.focus();
   return false;
   }
   else if (trimAll(document.registerind.compdirector.value).length == 0)
   {
   alert("Please enter the Representing Directors Name");
   document.registerind.compdirector.focus();
   return false;
   }
   else if(sel.options[sel.selectedIndex].text == 'Select ANSWER from drop-down list.' )
   {
       alert("Please select a value from the 'Status' dropdown");
		  document.registerind.istatus.focus();
		         return false;
   }
   else if (trimAll(document.registerind.cname.value).length == 0)
   {
   alert("Please enter your Name");
   document.registerind.cname.focus();
   return false;
   }
   else if (trimAll(document.registerind.cphone.value).length == 0)
   {
   alert("Please enter your Phone Number");
   document.registerind.cphone.focus();
   return false;
   }
  else if (trimAll(document.registerind.cemail.value).length == 0)
   {
   alert("Please enter your Email Address");
   document.registerind.cemail.focus();
   return false;
   }
   else if(document.registerind.cemail.value != document.registerind.cemail2.value)
   {
   alert('The two email addresses do not match...please verify');
		   document.registerind.cemail.focus();
		        return false;
   }
   else if (trimAll(document.registerind.caddress.value).length == 0)
   {
   alert("Please enter your Postal Address.\n All documentation will be sent to this address.");
   document.registerind.caddress.focus();
   return false;
   }
   else if(sel9.options[sel9.selectedIndex].text == '********Please Indicate how you heard about FORMit.ie ********')
   {
       alert("Please indicate how you found FORMit.ie");
		  document.registerind.howfound.focus();
		         return false;
   }
 //  else if(sel2.options[sel2.selectedIndex].text == '********Please Select Payment Method ********' )
//   {
//       alert("Please select an option from the 'Payment' dropdown");
//		  document.registerind.paymentmethod.focus();
//		         return false;
//   }
   else if(document.registerind.terms.checked == false)
	{
 alert('You must agree to our Terms and Conditions. \n Please tick the Terms and Conditions checkbox at the end of the page.');
		           return false;
	} 

return checkdate();
//end validate form function bracket
}
 

function eunational()
{
	
     if(document.registerind.istatus.options[document.registerind.istatus.selectedIndex].text == 'Non EU National' )
      {
       alert("Are you a Non EU National? \n \nIf so, Business Permission must be sought from Department of Justice, Equality and Law Reform before you can begin to trade in this country. You will need to post a photocopy of your permission documentation (Green book / I.D. CARD) with stamp 4 together with the Business Name you are Registering to: FORMit.ie, Unit 9, Willow Business Park, Dublin 12. (FORMit.ie will indicate when to post this) \n \n A reminder of this message will be included in our confimation email to you when you complete this form.");
		  //document.registerind.istatus.focus();
		         return false;
      }
	
}


function SubmitLabel()
{
	//window.payment = document.registerind.paymentmethod;
//	
//    if(payment.options[payment.selectedIndex].text == 'Payment will be made by cheque') 
//	{	
//		document.registerind.submit2.value = "Pay By Cheque";
//	}
//	else
//	{
		document.registerind.submit2.value = "Proceed to Secure Server";
//	}
	
}



function setPrice()
{

	// user is registering a domain name

	 	if (document.registerind.domain.value != '')
		{
		document.registerind.total1.value = 84.56;
		document.registerind.vat.value = 19.44;
		document.registerind.outlay.value = 20.00;
		document.registerind.amount.value = 124.00;
		document.registerind.amountincents.value = 12400;
		}
	   else
	   {
	   document.registerind.total1.value = 36.59;
	   document.registerind.vat.value = 8.41;
	   document.registerind.outlay.value = 20.00;
	   document.registerind.amount.value = 65.00;
	   document.registerind.amountincents.value = 6500;
	   
	   document.registerind.domain.value = '';
	   }


}


function doBoth()
{
SubmitLabel();
setPrice();
}
   


function SubmitFormPayment()
{

//	window.payment = document.registerind.paymentmethod;
//	
//    if(payment.options[payment.selectedIndex].text == 'Payment will be made by cheque') 
//	{
//		//document.registerind.action = "redirect_cheques.asp";
//		document.registerind.action = "redirectcor.asp";
//		document.registerind.submit2.value = "Pay By Cheque";
//	}
//	else
//	{
		document.registerind.action="redirectcor.asp";	
//	}

  
}


function insert_domain_name()
{
 document.registerind.domain.value = document.registerind.iname.value + '.ie'
}	function rform()
{

	var Go_Submit = confirm("You are about to delete the data you entered in the form. \n Are you sure you want to do this?")

	if (Go_Submit)
	{
	window.location.href = "register_corporate.asp?delete=1";
		//return true;
	}
	else
	{
		return false;
	}

}
  
  

