
	function buildLoanPurposesSelect(selectedOption)
	{

		window.selectedOption1 = selectedOption;
		//window.dropDownListID = 'loanpurpose';

		$.post('../loanform.process.php', { event: "getLoanPurposes" }, showLoanPurposes, 'json');
		//alert(dd);
	}
	
	function buildMaritalStatusesSelect(selectedOption)
	{
		window.selectedOption2 = selectedOption;
		//window.dropDownListID = 'maritalstatus';

		$.post('../loanform.process.php', { event: "getMaritalStatuses" }, showMaritalStatuses, 'json');
		//alert(dd);
	}
	
	function showLoanPurposes(data, textStatus)
	{
		showDropDownOptions(data, textStatus, 'loanpurpose');
		$("#loanpurpose option[value='"+selectedOption1+"']").attr('selected', 'selected');
	}
	
	function showMaritalStatuses(data, textStatus)
	{
		showDropDownOptions(data, textStatus, 'maritalstatus');
		$("#maritalstatus option[value='"+selectedOption2+"']").attr('selected', 'selected');
	}
	
	function showDropDownOptions(data, textStatus, dropDownListID) 
	{
		//alert(selectedOption);
		$.each(data,
            function() {

            	if ( typeof(selectedOption) != 'undefined' && this.id == selectedOption )
            	{
            		var option = new Option(this.name, this.id, true);
            	}
            	else
            	{
                	var option = new Option(this.name, this.id);
            	}
                // Use Jquery to get select list element
                var dropdownList = $("#"+dropDownListID)[0];

	                if ($.browser.msie) {
	                    dropdownList.add(option);
	                }
	
	                else {
	
	                    dropdownList.add(option, null);
	
	                }

            }
            );
            //dropdownList.val(selectedOption);
            //$("#"+dropDownListID+" option[value='"+selectedOption+"']").attr('selected', 'selected');


    }


	function findAddressByPostCode(containerID, postalCode) {
	 $('#'+containerID+' .foundAddressesRow').css('display', '');
	 $('#'+containerID+' .foundAddresses').html('please wait...');
     $.ajax({
		   type: "GET",
		   url: blogURL + "/address_finder.php",
		   data: "postcode=" + postalCode + "&containerID="+containerID,
		   success: function(msg){
		     $('#'+containerID+' .foundAddresses').html(msg);
			 
			 var addressID = $('#'+containerID+' .address').val();
			 if ( addressID )
			 {
				 getFieldsByAddressID(containerID, addressID);
			 }
		   }
		 });
	};
	
	var addressID = 0;
	function getFieldsByAddressID(containerID, addressID) {
		
		if ( !addressID ){
			addressID = $('#'+containerID+' .address').val();
		}
	
		 $.ajax({
			   type: "POST",
			   url: blogURL + "/address_finder.php",
			   data: "address=" + addressID,
			   dataType: "json",
			   success: function(msg){
				 //alert(msg);
				 $('#'+containerID+' .postalcode').val(msg.postcode);
				 //$('#addressText').html('line1: ' + msg.line1 + '<br/>line2: ' + msg.line2 + '<br/>line3: ' + msg.line3 + '<br/>line4: ' + msg.line4);
				 if ( msg.building_name_or_number )
					$('#'+containerID+' .address1').val(msg.building_name_or_number);
				 else
					$('#'+containerID+' .address1').val(msg.organisation_name);
				 $('#'+containerID+' .address2').val(msg.thoroughfare_name + ' ' + msg.thoroughfare_descriptor);
				 $('#'+containerID+' .town').val(msg.post_town);
				 $('#'+containerID+' .county').val(msg.county);
				 //$('#addressTextRow').css('display', '');
				 $('#'+containerID+' .address1Row').css('display', '');
				 $('#'+containerID+' .address2Row').css('display', '');
				 $('#'+containerID+' .townRow').css('display', '');
				 $('#'+containerID+' .countyRow').css('display', '');
			   }
			 });
	};

	
	function submitRequest() {
		$('#noteRow').html('form submitting, please wait...');
		var formData = $("#loan").serialize();
		$.ajax({
		   type: "POST",
		   url: blogURL + "/loanform.process.php",
		   data: "event=process&thankyouPageURL=" + thankyouPageURL + '&' + formData,
		   //dataType: "json",
		   success: function(msg){
		   	$('#submitButton').removeAttr("disabled");
		   	 
		   	/*if (msg == 'ok' && thankyouPageURL)
		   	 {
		   	 	//window.location = thankyouPageURL + '?' + formData;
		   	 	$('#noteRow').html('redirecting...');
		   	 }
		   	 else
		   	 {
		     	$('#noteRow').html(msg);
		   	 }*/
		   	$('#noteRow').html(msg);
		     
		   }
		 });
	}

/*Array
(
    [id] => 9249125.00
    [seq] => 0
    [organisation_name] => Texstyle World
    [line1] => 152 Gallowgate
    [post_town] => Glasgow
    [county] => Lanarkshire
    [postcode] => G1 5DR
    [mailsort] => 10619
    [barcode] => (G15DR1BK)
    [is_residential] => 0
    [is_small_organisation] => 1
    [is_large_organisation] => 0
    
    Array
(
    [id] => 26742626.00
    [seq] => 0
    [organisation_name] => Arthur Amos Associates
    [line1] => Pool House
    [line2] => Elgar Business Centre
    [line3] => Moseley Road
    [line4] => Hallow
    [post_town] => Worcester
    [county] => Worcestershire
    [postcode] => WR2 6NJ
    [mailsort] => 31441
    [barcode] => (WR26NJ3NG)
    [is_residential] => 0
    [is_small_organisation] => 1
    [is_large_organisation] => 0
)
Array
(
    [id] => 51501819.00
    [seq] => 0
    [organisation_name] => Indigo Pink Ltd
    [line1] => Unit 9
    [line2] => Elgar Business Centre
    [line3] => Moseley Road
    [line4] => Hallow
    [post_town] => Worcester
    [county] => Worcestershire
    [postcode] => WR2 6NJ
    [mailsort] => 31441
    [barcode] => (WR26NJ4B5)
    [is_residential] => 0
    [is_small_organisation] => 1
    [is_large_organisation] => 0
)
Array
(
    [id] => 26742666.00
    [seq] => 0
    [line1] => 2 The Cottages
    [line2] => Moseley Road
    [line3] => Hallow
    [post_town] => Worcester
    [county] => Worcestershire
    [postcode] => WR2 6NJ
    [mailsort] => 31441
    [barcode] => (WR26NJ3HA)
    [is_residential] => 1
    [is_small_organisation] => 0
    [is_large_organisation] => 0
)

)*/

  

function find_addresses() { //v2.0
//alert('address_finder.php?postcode=' + document.forms.loan.postalcode.value);
  window.open('address_finder.php?postcode=' + document.forms.loan.postalcode.value, '', 'width=400, height=150');
}



function change_fields()
{
	change_fields_employmentstatus();
	change_fields_loanpurpose();
	change_fields_dm();
	change_fields_liveAtThisAddressSince();
		
		switch ($('#homestatus').val())
		{
			case 'homeowner':
				$('#homeowner').css('display', '');
				
				$('#propertyvalueRow').fadeIn('slow');
				$('#mortgageremainingRow').fadeIn('slow');
				
				$('#propValueH4, #mortgageAmountH4').removeClass('disable');
				$('#propValueInput, #mortgageAmountInput').attr('disabled', false);
				$('#bankruptRow').fadeOut('slow');
				$('#BACsRow').fadeOut('slow');
				$('#dmRow').fadeOut('slow');
				//tenant.style.display = 'none';
				break;
				
			case 'tenant':
				$('#homeowner').css('display', 'none');
				
				$('#propertyvalueRow').fadeOut('slow');
				$('#mortgageremainingRow').fadeOut('slow');
				
				$('#propValueH4, #mortgageAmountH4').addClass('disable');
				$('#propValueInput, #mortgageAmountInput').attr('disabled', true);
				$('#propValueInput').val('');				
				$('#mortgageremaining').val('');
				$('#bankruptRow').fadeIn('slow');
				//$('#BACsRow').fadeIn('slow');
				$('#dmRow').fadeIn('slow');
				//tenant.style.display = '';
				break;
				
			default :
				$('#homeowner').css('display', 'none');
				$('#propValueH4, #mortgageAmountH4').addClass('disable');
				$('#propValueInput, #mortgageAmountInput').attr('disabled', true);
				//tenant.style.display = 'none';
		}
//alert(a.value);
}

function change_fields1()
{
		switch ($('#isjointapplication').val())
		{
			case '1':

				//$('#annualincome2_row').css('display', '');
				$('#annualincome2Row').fadeIn('slow');
				break;
				
			case '0':
			{
				//$('#annualincome2_row').css('display', 'none');
				$('#annualincome2').val('');
				$('#annualincome2Row').fadeOut('slow');
			}
				break;
				
			default :
				$('#annualincome2_row').css('display', 'none')
		}
//alert(a.value);
}

function change_fields1_a()
{
		switch ($("input[@name='isjointapplication']:checked").val())
		{
			case '1':
				$('#secondAppl').removeClass('disable');
				$('#annualincome2').attr('disabled', false);
				$('#annualincome2Row').fadeIn('slow');
				break;
				
			case '0':
			{
				$('#secondAppl').addClass('disable');
				$('#annualincome2').attr('disabled', true);
				$('#annualincome2').val('');
				$('#annualincome2Row').fadeOut('slow');
			}
				break;
				
			default :
				$('#secondAppl').removeClass('disable');
		}
//alert(a.value);
}

function change_fields_loanpurpose()
{
	if ( $('#homestatus').val() == 'tenant' )
	{
		if ( $('select#loanpurpose').val() == 1 )
		{
			$('#numcreditorsRow').fadeIn('slow');
		}
		
		if ( $('select#loanpurpose').val() != 1 && $("input:radio[name=dm]:checked").val() != 'Yes' )
		{
			$('#numcreditorsRow').fadeOut('slow');
		}
	}
	else
	{
		$('#numcreditorsRow').fadeOut('slow');
	}
	
//alert(a.value);
}

function change_fields_dm()
{
	if ( $('#homestatus').val() == 'tenant' )
	{
		if ( $("input:radio[name=dm]:checked").val() == 'Yes' )
		{
			$('#numcreditorsRow').fadeIn('slow');
		}
		
		if ( $("input:radio[name=dm]:checked").val() == 'No' && $('select#loanpurpose').val() != 1 )
		{
			$('#numcreditorsRow').fadeOut('slow');
		}
	}
	else
	{
		$('#numcreditorsRow').fadeOut('slow');
	}
	
//alert(a.value);
}

function change_fields_liveAtThisAddressSince()
{
	if ( $('#homestatus').val() == 'tenant' && $('#liveAtThisAddressSince').val() !== '' 
		&& daysElapsed($('#liveAtThisAddressSince').val()) < 1095 )
	{
		$('#Add2').slideDown(800);
	}
	else
	{
		$('#Add2').slideUp(800);
	}
	//return false;
	
//alert(a.value);
}

function change_fields_employmentstatus()
{
	if ( $('#homestatus').val() == 'tenant' && ($('#employmentstatus').val() == 1 || $('#employmentstatus').val() == 2) )
	{
		$('#occupationRow').fadeIn('slow');
		$('#employernameRow').fadeIn('slow');
		$('#paymenttypeRow').fadeIn('slow');
		$('#employedsinceRow').fadeIn('slow');
		$('#BACsRow').fadeIn('slow');
	}
	else
	{
		$('#occupationRow').fadeOut('slow');
		$('#employernameRow').fadeOut('slow');
		$('#paymenttypeRow').fadeOut('slow');
		$('#employedsinceRow').fadeOut('slow');
		$('#BACsRow').fadeOut('slow');
	}
	//return false;
	
//alert(a.value);
}

function check_length(string, from, to)
{
	if ( !to )
	{
		var to = 1000;
	}
	
	if ( string.length >= from && string.length <= to )
	{
		return true;
	}
	else
	{
		return false;
	}
}

function checkform()
{
	$('#noteRow').html('data checking, please wait...');
	$('#submitButton').attr('disabled', 'true');
	var f = document.forms.loan;
	var color = '#FFDFE6';
	var validated = true;
	var problemIn = '';
	
	var i;
	var k=0;
	for ( i=0; i < f.elements.length; i++)
	{
		f.elements[i].style.backgroundColor = '';
	}
	
	if ( f.title.value == 'nil' )
	{
		f.title.style.backgroundColor = color;
		validated = false;
		problemIn = '';
	}
	
	if ( !check_length(f.firstname.value, 1) ) //!f.firstname.value || f.firstname.value.length < 5
	{
		f.firstname.style.backgroundColor = color;
		validated = false;
		problemIn = '';
	}
	
	if ( !check_length(f.lastname.value, 1) )
	{
		f.lastname.style.backgroundColor = color;
		validated = false;
		problemIn = '';
	}
	
	/*if ( f.dob.value == 'nil' )
	{
		f.dob.style.backgroundColor = color;
		validated = false;
	}
	
	if ( f.mob.value == 'nil' )
	{
		f.mob.style.backgroundColor = color;
		validated = false;
	}
	
	if ( f.yob.value == 'nil' )
	{
		f.yob.style.backgroundColor = color;
		validated = false;
	}*/
	if ( f.birthdate.value == '' )
	{
		f.birthdate.style.backgroundColor = color;
		validated = false;
		problemIn = '';	
		
	}
	
	if ( f.creditstatus.value == 'nil' )
	{
		f.creditstatus.style.backgroundColor = color;
		validated = false;
		problemIn = '';
	}
	
	
	$('#BACsArea').css('background-color', '')
	
	
	
	
	/*if ( f.doe.value == 'nil' )
	{
		f.doe.style.backgroundColor = color;
		validated = false;
	}
	
	if ( f.moe.value == 'nil' )
	{
		f.moe.style.backgroundColor = color;
		validated = false;
	}
	
	if ( f.yoe.value == 'nil' )
	{
		f.yoe.style.backgroundColor = color;
		validated = false;
	}*/
	
	if ( f.maritalstatus.value == 'nil' )
	{
		f.maritalstatus.style.backgroundColor = color;
		validated = false;
		problemIn = '';
	}


	$('#bankruptArea').css('background-color', '');

	
	$('#dmArea').css('background-color', '');
	

	
	if ( f.timetocall.value == 'nil' )
	{
		f.timetocall.style.backgroundColor = color;
		validated = false;
		problemIn = '';
	}
	
	
	
	if ( f.repaymentperiod.value == 'nil' )
	{
		f.repaymentperiod.style.backgroundColor = color;
		validated = false;
		problemIn = '';
	}
	
	if ( !check_length(f.address1.value, 1) )
	{
		f.address1.style.backgroundColor = color;
		validated = false;
		problemIn = '';
	}
	
	if ( !check_length(f.address2.value, 1) )
	{
		f.address2.style.backgroundColor = color;
		validated = false;
		problemIn = '';
	}
	
	if ( !check_length(f.town.value, 1) )
	{
		f.town.style.backgroundColor = color;
		validated = false;
		problemIn = '';
	}
	
	if ( !check_length(f.county.value, 1) )
	{
		f.county.style.backgroundColor = color;
		validated = false;
		problemIn = '';
	}

	if ( !check_length(f.postalcode.value, 6, 8) )
	{
		f.postalcode.style.backgroundColor = color;
		validated = false;
		problemIn = '';
	}
	
	
	

	
	/*if ( f.doa.value == 'nil' )
	{
		f.doa.style.backgroundColor = color;
		validated = false;
	}
	
	if ( f.moa.value == 'nil' )
	{
		f.moa.style.backgroundColor = color;
		validated = false;
	}
	
	if ( f.yoa.value == 'nil' )
	{
		f.yoa.style.backgroundColor = color;
		validated = false;
	}*/
		
	if ( !(/^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$/i.test(f.email.value)) )
	{
		f.email.style.backgroundColor = color;
		validated = false;
		problemIn = '';
	}
	
	//var str="Visit- Mi-crosoft - !";
	//alert(str.replace(/-/g, ""));

	f.homePhone.value = f.homePhone.value.replace(/-/g, "");
	f.homePhone.value = f.homePhone.value.replace(/ /g, "");
	f.workPhone.value = f.workPhone.value.replace(/-/g, "");
	f.workPhone.value = f.workPhone.value.replace(/ /g, "");
	f.mobilePhone.value = f.mobilePhone.value.replace(/-/g, "");
	f.mobilePhone.value = f.mobilePhone.value.replace(/ /g, "");

	if ( !((/^\d{10,}$/.test(f.homePhone.value)) && f.homePhone.value.length < 12) )
	{
		f.homePhone.style.backgroundColor = color;
		validated = false;
		problemIn = '';
	}
	
	if ( !((/^\d{10,}$/.test(f.mobilePhone.value)) && f.mobilePhone.value.length < 12) )
	{
		f.mobilePhone.style.backgroundColor = color;
		validated = false;
		problemIn = '';
	}
	
	/*if ( !f.homePhone.value && !f.workPhone.value && !f.mobilePhone.value)
	{
		f.homePhone.style.backgroundColor = color;
		validated = false;
	}
	else
	{
		if ( f.homePhone.value && !((/^\d{10,}$/.test(f.homePhone.value)) && f.homePhone.value.length < 12) )
		{
			f.homePhone.style.backgroundColor = color;
			validated = false;
		}
		else if ( f.workPhone.value && !((/^\d{10,}$/.test(f.workPhone.value)) && f.workPhone.value.length < 12) )
		{
			f.workPhone.style.backgroundColor = color;
			validated = false;
		}
		else if ( f.mobilePhone.value && !((/^\d{10,}$/.test(f.mobilePhone.value)) && f.mobilePhone.value.length < 12) )
		{
			f.mobilePhone.style.backgroundColor = color;
			validated = false;
		}
	}*/
	
	if ( f.loanpurpose.value == 'nil' )
	{
		f.loanpurpose.style.backgroundColor = color;
		validated = false;
		problemIn = '';
	}
	
	if ( f.loanamount.value == 'nil' )
	{
		f.loanamount.style.backgroundColor = color;
		validated = false;
		problemIn = '';
	}
	
	if ( f.isjointapplication.value == 'nil' )
	{
		f.isjointapplication.style.backgroundColor = color;
		validated = false;
		problemIn = '';
	}

	if ( !((/^\d+$/.test(f.annualincome1.value))) )
	{
		f.annualincome1.style.backgroundColor = color;
		validated = false;
		problemIn = '';
	}
	
	var jappvalue = (f.isjointapplication.value ? f.isjointapplication.value : $("input[@name='isjointapplication']:checked").val());
	if ( jappvalue == '1' && !((/^\d+$/.test(f.annualincome2.value))) )
	{
		f.annualincome2.style.backgroundColor = color;
		validated = false;
		problemIn = '';
	}	
		
	switch ( f.homestatus.value )
	{
		case 'nil' : 
			{
				f.homestatus.style.backgroundColor = color;
				validated = false;
				problemIn = '';
			}
			break;
			
		case 'homeowner' : 
			{
				if ( !((/^\d+$/.test(f.propertyvalue.value)) && f.propertyvalue.value > 0) )
				{
					f.propertyvalue.style.backgroundColor = color;
					validated = false;
					problemIn = '';
				}
				
				if ( !((/^\d+$/.test(f.mortgageremaining.value))) )
				{
					f.mortgageremaining.style.backgroundColor = color;
					validated = false;
					problemIn = '';
				}									
			}
			break;
			
		case 'tenant' :
			{
				/*if ( f.dob.value == 'nil' )
				{
					f.dob.style.backgroundColor = color;
					validated = false;
				}
				
				if ( f.mob.value == 'nil' )
				{
					f.mob.style.backgroundColor = color;
					validated = false;
				}
				
				if ( f.yob.value == 'nil' )
				{
					f.yob.style.backgroundColor = color;
					validated = false;
				}
				
				if ( f.timetocall.value == 'nil' )
				{
					f.timetocall.style.backgroundColor = color;
					validated = false;
				}
				
				if ( f.occupation.value == 'nil' )
				{
					f.occupation.style.backgroundColor = color;
					validated = false;
				}*/
				
				
				
				if ( f.employmentstatus.value == '' )
				{
					f.employmentstatus.style.backgroundColor = color;
					validated = false;
					problemIn = 'employmentstatus';
				}
				else if ( f.employmentstatus.value == 1 || f.employmentstatus.value == 2 )
				{
					if ( f.occupation.value == '' )
					{
						f.occupation.style.backgroundColor = color;
						validated = false;
						problemIn = 'occupation';
					}
					
					if ( f.employername.value == '' )
					{
						f.employername.style.backgroundColor = color;
						validated = false;
						problemIn = 'employername';
					}
					
					if ( f.paymenttype.value == '' )
					{
						f.paymenttype.style.backgroundColor = color;
						validated = false;
						problemIn = 'paymenttype';
					}
				
					if ( f.employedsince.value == '' )
					{
						f.employedsince.style.backgroundColor = color;
						validated = false;
						problemIn = 'employedsince';
					}					
					
					if ( !$('input[name=BACs]:checked').val())
					{
						$('#BACsArea').css('background-color', color)
						validated = false;
						problemIn = 'BACs';
					}
				}
				
				
				if ( !$('input[name=bankrupt]:checked').val())
				{
					$('#bankruptArea').css('background-color', color)
					validated = false;
					problemIn = 'bankrupt';
				}
				
				if ( !$('input[name=dm]:checked').val())
				{
					$('#dmArea').css('background-color', color)
					validated = false;
					problemIn = 'dm';
				}
				
				// num creditors should be specified for Debt Consolidation loan purpose, or participation in debt management programe
				if ( (f.loanpurpose.value == 1 || $('input[name=dm]:checked').val() == 'Yes') && f.numcreditors.value == 'nil' )
				{
					f.numcreditors.style.backgroundColor = color;
					validated = false;
					problemIn = 'numcreditors';
				}
				
				if ( !check_length(f.liveAtThisAddressSince.value, 10) )
				{
					f.liveAtThisAddressSince.style.backgroundColor = color;
					validated = false;
					problemIn = 'liveAtThisAddressSince';
				}
				
				if ( $('#liveAtThisAddressSince').val() !== '' && daysElapsed($('#liveAtThisAddressSince').val()) < 1095 )
				{
					if ( !check_length(f.address2_1.value, 1) )
					{
						f.address2_1.style.backgroundColor = color;
						validated = false;
						problemIn = 'address2_1';
					}
					
					if ( !check_length(f.address2_2.value, 1) )
					{
						f.address2_2.style.backgroundColor = color;
						validated = false;
						problemIn = 'address2_2';
					}
					
					if ( !check_length(f.town2.value, 1) )
					{
						f.town2.style.backgroundColor = color;
						validated = false;
						problemIn = 'town2';
					}
					
					if ( !check_length(f.county2.value, 1) )
					{
						f.county2.style.backgroundColor = color;
						validated = false;
						problemIn = 'county2';
					}
				
					if ( !check_length(f.postalcode2.value, 6, 8) )
					{
						f.postalcode2.style.backgroundColor = color;
						validated = false;
						problemIn = 'postalcode2';
					}
					
					if ( !check_length(f.liveAtThisAddressSince2.value, 10) )
					{
						f.liveAtThisAddressSince2.style.backgroundColor = color;
						validated = false;
						problemIn = 'liveAtThisAddressSince2';
					}
				}
			}
			break;
	}
	
	if ( !validated )
	{
		alert('Please fill in requared fields with correct values!');
		$('#submitButton').removeAttr("disabled");
		$('#noteRow').html('');
	}
	else
	{
		if ( f.agreement.checked == false )
		{
			alert('Please agree with our terms & conditions!');
			$('#submitButton').removeAttr("disabled");
			$('#noteRow').html('');
		}
		else
		{
			//alert('THANK YOU!');
			submitRequest();			
		}
		
	}
	return false;
}

function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=600,height=400,scrollbars=yes');
return false;
}


function daysElapsed(sourceDate) {
var date1 = new Date()
var date2 = convertDbDate (sourceDate)

    // The number of milliseconds in one day
    var ONE_DAY = 1000 * 60 * 60 * 24

    // Convert both dates to milliseconds
    var date1_ms = date1.getTime()
    var date2_ms = date2.getTime()

    // Calculate the difference in milliseconds
    var difference_ms = Math.abs(date1_ms - date2_ms)
    
    // Convert back to days and return
    var retval = Math.round(difference_ms/ONE_DAY)
	return retval

}

function convertDbDate (DbDate) {
var day = DbDate.substring(0, 2);
var month = DbDate.substring(3, 5);
var year = DbDate.substring(6);

var return_date = new Date()
return_date.setYear(year)
return_date.setMonth(month -1)
return_date.setDate(day) 

return return_date;
}



function popitup(url) {
	newwindow=window.open(url,'name','height=700,width=820,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
	return false;
}


