function getGreeting(){
	var curDateTime = new Date();
	var curHour = curDateTime.getHours();
	var greeting = "Good Evening";
	if (curHour < 12  && curHour >= 0) {
		greeting = "Good Morning";
	}
	if (curHour >=12 && curHour < 18) {
		greeting = "Good Afternoon";
	}
	return greeting;
}
function updateCountryRegions2() {
	if(typeof(document.formQuickSearch)!='undefined') {
		if(this.value=='') { 
			document.formQuickSearch.regionID.length=0; document.formQuickSearch.regionID.options[0] = new Option('LOCATION', ''); 
		} else { 
			document.formQuickSearch.regionID.length=0; document.formQuickSearch.regionID.options[0] = new Option('All Locations', ''); 
		}
	}
}
function updateCountryRegions(setAddressValue) {
	if(typeof(document.formQuickSearch)!='undefined') {
		var A = document.formQuickSearch;
		A.propertyAddress.options.length=0;
		switch(A.country.value) {
			case "France" : 
				A.propertyAddress.options[0] = new Option('All Regions', '');
				A.propertyAddress.options[1] = new Option('French Riviera', 'French Riviera');
				A.propertyAddress.options[2] = new Option('French Alps', 'French Alps');
				A.propertyAddress.options[3] = new Option('Provence', 'Provence');
				break;
			case "Italy" : 
				A.propertyAddress.options[0] = new Option('All Regions', '');
				A.propertyAddress.options[1] = new Option('Tuscany', 'Tuscany');
				A.propertyAddress.options[2] = new Option('Umbria', 'Umbria');
				break;
			case "Portugal" : 
				A.propertyAddress.options[0] = new Option('All Regions', '');
				A.propertyAddress.options[1] = new Option('Algarve', 'Algarve');
				break;
			case "Spain" : 
				A.propertyAddress.options[0] = new Option('Costa del Sol', 'Costa del Sol');
				break;
			case "Cyprus" : 
				A.propertyAddress.options[0] = new Option('All Regions', '');
				A.propertyAddress.options[1] = new Option('Aphrodite Hills', 'Aphrodite Hills');
				A.propertyAddress.options[2] = new Option('Limassol', 'Limassol');
				A.propertyAddress.options[3] = new Option('Paphos', 'Paphos');
				break;
			case "The Balearics" : 
				A.propertyAddress.options[0] = new Option('All Regions', '');
				A.propertyAddress.options[1] = new Option('Ibiza', 'Ibiza');
				A.propertyAddress.options[2] = new Option('Mallorca', 'Mallorca');
				break;
			case "Barbados" : 
				A.propertyAddress.options[0] = new Option('All Locations', '');
				A.propertyAddress.options[1] = new Option('Christchurch', 'Christchurch');
				A.propertyAddress.options[2] = new Option('St Peter', 'St Peter');
				A.propertyAddress.options[3] = new Option('St James', 'St James');
				break;
			default : 
				A.propertyAddress.options[0] = new Option('REGION', '');
				break;
		}
		if (setAddressValue && ($("#selectedRegion").html()!="")) {
			A.propertyAddress.value=$("#selectedRegion").html() 
		}
	}
}

function updateCountryLocations(setRegionValue) {
	if(typeof(document.formQuickSearch)!='undefined') {
		var A = document.formQuickSearch;
		A.regionID.options.length=0;
		A.propertyTypeStyle.options.length=0;
		/*hide villa for french alps*/
		if(A.propertyAddress.value == "French Alps"){			
			A.propertyTypeStyle[0] = new Option('Type','');			
			A.propertyTypeStyle[1] = new Option('Apartment','13');
			A.propertyTypeStyle[2] = new Option('Hotel','36');
			A.propertyTypeStyle[3] = new Option('Chalet','3');
		}else{			
			A.propertyTypeStyle[0] = new Option('Type','');
			A.propertyTypeStyle[1] = new Option('Villa','12');
			A.propertyTypeStyle[2] = new Option('Apartment','13');
			A.propertyTypeStyle[3] = new Option('Hotel','36');
			A.propertyTypeStyle[4] = new Option('Chalet','3');
		}
		/*-----------------------------------------*/
		switch(A.propertyAddress.value) {
			case "Algarve" : 
			A.regionID.options[0] = new Option('All Locations', '');
			A.regionID.options[1] = new Option('Almancil', '106');
			A.regionID.options[2] = new Option('Quinta do Lago', '8');
			A.regionID.options[3] = new Option('Vale do Lobo', '9');
			A.regionID.options[4] = new Option('Vilamoura', '130');
			
			break;
			case "Ibiza" : 
			A.regionID.options[0] = new Option('All Locations', '');
			break;
			case "Mallorca" : 
			A.regionID.options[0] = new Option('All Locations', '');
			A.regionID.options[1] = new Option('Andratx ', '142');
			//A.regionID.options[2] = new Option('Bendinat ', '140');
			//A.regionID.options[3] = new Option('Palma', '136');
			A.regionID.options[2] = new Option('Santa Ponca', '134');
			A.regionID.options[3] = new Option('Son Vida ', '138');
			break;
			case "Provence" : 
			A.regionID.options[0] = new Option('All Locations', '');
			break;
			case "Tuscany" : 
			A.regionID.options[0] = new Option('All Locations', '');
			break;
			case "Costa del Sol" : 
			A.regionID.options[0] = new Option('All Locations', '');
			A.regionID.options[1] = new Option('Benahavis', '126');
			A.regionID.options[2] = new Option('Estepona', '15');
			A.regionID.options[3] = new Option('Marbella', '18');
			A.regionID.options[4] = new Option('Nueva Andalucia', '128');
			//A.regionID.options[5] = new Option('Puerto Banus', '144');
			A.regionID.options[5] = new Option('Sotogrande', '22');
			break;
			case "Umbria" : 
			A.regionID.options[0] = new Option('All Locations', '');
			break;
			case "French Alps" : 
			A.regionID.options[0] = new Option('All Locations', '');
			A.regionID.options[1] = new Option('Annecy','164');						
			A.regionID.options[2] = new Option('Chamonix','215');
			A.regionID.options[3] = new Option('Chatel','162');
			A.regionID.options[4] = new Option('Flaine and Les Carroz','169');												
			A.regionID.options[5] = new Option('Les Contamines','157');
			A.regionID.options[6] = new Option('Les Gets','160');						
			A.regionID.options[7] = new Option('Megeve','158');			
			A.regionID.options[8] = new Option('Meribel','171');			
			A.regionID.options[9] = new Option('Morzine','159');						
			A.regionID.options[10] = new Option('Samoens','168');
			A.regionID.options[11] = new Option('Sixt Fer A Cheval','170');
			A.regionID.options[12] = new Option('St Gervais','156');
			break;
			case "French Riviera" : 
			A.regionID.options[0] = new Option('All Locations', '');
			A.regionID.options[1] = new Option('Antibes', '27');
			A.regionID.options[2] = new Option('Cannes', '29');
			A.regionID.options[3] = new Option('Cap Ferrat', '31');
			A.regionID.options[4] = new Option('Cap Martin', '32');
			A.regionID.options[5] = new Option('Grasse', '34');
			A.regionID.options[6] = new Option('Mougins', '36');
			A.regionID.options[7] = new Option('Nice', '102');
			A.regionID.options[8] = new Option('St Paul de Vence', '120');
			A.regionID.options[9] = new Option('St Tropez', '33');
			A.regionID.options[10] = new Option('Valbonne', '39');
			A.regionID.options[11] = new Option('Vence', '38');
			A.regionID.options[12] = new Option('Villefranche', '122');
			break;
			case "Aphrodite Hills" : 
			A.regionID.options[0] = new Option('All Locations', '');
			break;
			case "Paphos" : 
			A.regionID.options[0] = new Option('All Locations', '');
			//A.regionID.options[1] = new Option('CORAL BAY', '60');
			//A.regionID.options[2] = new Option('LATCHI', '63');
			//A.regionID.options[3] = new Option('MINTHIS HILLS', '65');
			//A.regionID.options[4] = new Option('SEA CAVES', '61');
			//A.regionID.options[5] = new Option('ST GEORGES', '64');
			//A.regionID.options[6] = new Option('TALA', '62');
			break;
			case "Limassol" : 
			A.regionID.options[0] = new Option('All Locations', '');
			A.regionID.options[1] = new Option('Limassol Marina', '40');
			A.regionID.options[2] = new Option('Souni', '132');
			break;
			
			default : 
			A.regionID.options[0] = new Option('LOCATION', '');						
			break;
		}
		if (setRegionValue && ($("#selectedLocation").html()!="")) {
			A.regionID.value=$("#selectedLocation").html() 
		}
	}
}

function addToBasket(profileID,department)
{
	
	self.frames['addToBasketFrame'].location.href='add_to_basket.php?profileID='+profileID+'&p_department='+department;

}

function updateBasketCount(basketCount)
{
	document.getElementById('basketCountSpan').innerHTML=basketCount;
}

function initializeGoogleMap() {
	var latlng = new google.maps.LatLng(document.getElementById('latitude').innerHTML,document.getElementById('longitude').innerHTML);
	var myOptions = {
		zoom: 12,
		center: latlng,
		mapTypeControl:false,
		navigationControl:false,
		scrollwheel:false,
		/*zoomControl: true,
		zoomControlOptions: {
			style: google.maps.ZoomControlStyle.SMALL
    	},*/
		draggable:false,
		mapTypeId: google.maps.MapTypeId.HYBRID,
		//mapTypeId: google.maps.MapTypeId.ROADMAP,
		streetViewControl:false
		/*mapTypeControl: true,
        mapTypeControlOptions: {
        	style: google.maps.MapTypeControlStyle.DROPDOWN_MENU,
			position: google.maps.ControlPosition.TOP_RIGHT
        }*/
	};
	var map = new google.maps.Map(document.getElementById("mapCanvas"),myOptions);
	var image = 'images/map-marker.png';
    var customMarker = new google.maps.Marker({
        position: latlng,
        map: map,
        icon: image,
		title: document.getElementById('address').innerHTML
    });
}

function initializeGoogleMapLarge() {
	var latlng = new google.maps.LatLng(document.getElementById('latitude').innerHTML,document.getElementById('longitude').innerHTML);
	var myOptions = {
		zoom: 12,
		center: latlng,
		mapTypeControl:false,
		navigationControl:false,
		scrollwheel:false,
		zoomControl: true,
		zoomControlOptions: {
			style: google.maps.ZoomControlStyle.SMALL
    	},
		//draggable:false,
		mapTypeId: google.maps.MapTypeId.HYBRID,
		streetViewControl:false,
		mapTypeControl: true,
        mapTypeControlOptions: {
        	style: google.maps.MapTypeControlStyle.DROPDOWN_MENU,
			position: google.maps.ControlPosition.TOP_RIGHT
        }
	};
	var map = new google.maps.Map(document.getElementById("mapCanvasLarge"),myOptions);
	var image = 'images/map-marker.png';
    var customMarker = new google.maps.Marker({
        position: latlng,
        map: map,
        icon: image,
		title: document.getElementById('address').innerHTML
    });
	/*google.maps.event.addListener(map, 'click', function() {
		toggleMapOff()
	});*/
}

	  
function selectAll(element) {
	var T = document.form1.elements[element];   
	for (var i=0;i<T.length;i++) {
 		T[i].checked = true;
	}
}

function switchVendorLoginDiv(divID) {
	
	if (document.getElementById('div_'+divID)) { document.getElementById('div_vendor_summary').style.display = 'none'; document.getElementById('span_vendor_summary').style.fontWeight = 'normal'; }
	if (document.getElementById('div_'+divID)) { document.getElementById('div_vendor_marketing').style.display = 'none'; document.getElementById('span_vendor_marketing').style.fontWeight = 'normal'; }
	if (document.getElementById('div_'+divID)) { document.getElementById('div_vendor_viewings').style.display = 'none'; document.getElementById('span_vendor_viewings').style.fontWeight = 'normal'; }
	if (document.getElementById('div_'+divID)) { document.getElementById('div_vendor_offers').style.display = 'none'; document.getElementById('span_vendor_offers').style.fontWeight = 'normal'; }
	
	document.getElementById('div_'+divID).style.display = 'block';
	document.getElementById('span_'+divID).style.fontWeight = 'bold';
	
}

function selectAllAdvanced(element) {
	var A=element;
	if (A) {
		if (A.length!=undefined) {
			for(var i=0; i<A.length;i++) {
				if (!A[i].disabled) {
					A[i].checked=true;	
				}else{
					A[i].checked=false;
				}			
			}			
		}else{ 
			if (!A.disabled) {
				A.checked=true;
			}else{
				A.checked=false;
			}
		}
	}
}

function deSelectAll(element) {
	var T = document.form1.elements[element];   
	for (var i=0;i<T.length;i++) {
 		T[i].checked = false;
	}
}

function deSelectAllAdvanced(element) {
	var A=element;
	if (A) {
		if (A.length!=undefined) {
			for(var i=0; i<A.length;i++) {
				A[i].checked=false;				
			}			
		}else{ 
			A.checked=false;
		}
	}	
}

function toggleShowObject(value,display) {
	if (document.getElementById(value)) {
		if (display) { 
			document.getElementById(value).style.display='block';
		}else{
			document.getElementById(value).style.display='none';
		}
	}
}

function toggleShowTableRow(elementName) {
	
	if (document.getElementById(elementName)) {
	
		var row = document.getElementById(elementName);
	
		if(navigator.appName.indexOf("Microsoft")>-1) {
			row.style.display = (row.style.display == 'block')? 'none' : 'block';
		}else{
			row.style.display = (row.style.display == 'table-row')? 'none' : 'table-row';
		}
	
	}
	
}

function getSelectedRadioValue(elementName) {
	// returns the value of the selected radio button or "" if no button is selected
	var A=document.form1.elements[elementName];
	if (A) {
   		var i = getSelectedRadio(A);
   		if (i == -1) {
			return "";
		}else{
			if (A[i]) { // Make sure the button group is an array (not just one button)
				return A[i].value;
			}else{ // The button group is just the one button, and it is checked
				return A.value;
			}
		}
	}else{
		return '';
	}
}

function validateCheckboxesTicked(elementName) {
	
	var A = document.form1.elements[elementName+'[]'];
	
	var numTicked = 0;
	
	if (A.length!=undefined) {
		
		for (var i=0; i<A.length; i++) {
			if (A[i].checked==true) {
				numTicked++;	
			}
		}
		
	}else{
		if (A.checked==true) {
			numTicked++;	
		}
	}
	
	if (numTicked>0) {
		return true;
	}else{
		return false;
	}
	
}

function validateEmail(emailStr) {
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
		
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
		//alert("Email address seems incorrect (check @ and .'s)")
		return false;
	}
	var user=matchArray[1]
	var domain=matchArray[2]
		
	if (user.match(userPat)==null) {
		//alert("The username doesn't seem to be valid.")
		return false;
	}
		
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		// this is an IP address
		for (var i=1;i<=4;i++) {
		if (IPArray[i]>255) {
			//alert("Destination IP address is invalid!")
			return false;
		}
		}
		return true;
	}
		
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		//alert("The domain name doesn't seem to be valid.")
		return false;
	}
		
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || 
		domArr[domArr.length-1].length>4) {
	  // alert("The address must end in a three-letter domain, or two letter country.")
	   return false;
	}
		
	if (len<2) {
	   var errStr="This address is missing a hostname!"
	   //alert(errStr)
	   return false;
	}
		
	return true;
}

function validatePostcode(postcode){ //check postcode format is valid
	test = postcode;
	size = test.length
	while (test.slice(0,1) == " ") {
		test = test.substr(1,size-1);size = test.length
	}
	while(test.slice(size-1,size)== " ") {
		test = test.substr(0,size-1);size = test.length
	}
	if (size < 6 || size > 8) { return false; }
	if (!(isNaN(test.charAt(0)))) { return false; }
	if (isNaN(test.charAt(size-3))) { return false; }
	if (!(isNaN(test.charAt(size-2)))) { return false; }
	if (!(isNaN(test.charAt(size-1)))) { return false; }
	if (!(test.charAt(size-4) == " ")) { return false;  }
	count1 = test.indexOf(" ");count2 = test.lastIndexOf(" ");
	if (count1 != count2){ return false; }
	return true;
}

function formatNumber(nStr) {
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

/*jquery multiple select*/
function jqueryRegionSelect() {
	$(document).ready( function() {
		multiselect = $("#regionID").multiSelect({ 
			selectAllText: 'Select All', 
			noneSelected: 'Any Location' 
		});
	});
}
/*end*/

function updatePrices(department) {
	
	var A = document.formQuickSearch;
	var B = 0;
	
	var selectedIndexNumber = 0
	
	if (department=="RS") {
		
		B = 0;
		selectedIndexNumber = 0;
		
		A.minimumPrice.length=0;
		
		if (minBlankOption!="") { A.minimumPrice.options[0] = new Option(minBlankOption, ''); B++; }
		
		for (var i=B; i<minPriceArray.length; i++) {
			A.minimumPrice.options[i] = new Option('£'+formatNumber(minPriceArray[i]),minPriceArray[i]);
			if (minPriceArray[i]==minDefault) { selectedIndexNumber = i; }
		}
		A.minimumPrice.selectedIndex=selectedIndexNumber;
		
		B = 0;
		selectedIndexNumber = 0;
		
		A.maximumPrice.length=0;
		
		if (maxBlankOption!="") { A.maximumPrice.options[0] = new Option(maxBlankOption, ''); B++; }
		
		for (var i=B; i<maxPriceArray.length; i++) {
			A.maximumPrice.options[i] = new Option('£'+formatNumber(maxPriceArray[i]),maxPriceArray[i]);
			if (maxPriceArray[i]==maxDefault) { selectedIndexNumber = i; }
		}
			
		A.maximumPrice.selectedIndex=selectedIndexNumber;

		B = 0;
		selectedIndexNumber = 0;
		if (document.getElementById('regionIDDiv')) {
			document.getElementById('regionIDDiv').innerHTML='<select name="regionID" id="regionID"></select>';
		}
		A.regionID.length=0;
		
		if (regionBlankOption!="") { A.regionID.options[0] = new Option(regionBlankOption, ''); B++; }
		
		for (var i=0; i<RSRegionArray.length; i++) {
			regionSplit=RSRegionArray[i].split("|"); 
			A.regionID.options[B] = new Option(regionSplit[1],regionSplit[0]);
			if (regionSplit[0]==regionDefault) { selectedIndexNumber = B; }
			B++;
		}
			
		A.regionID.selectedIndex=selectedIndexNumber;
		if (document.getElementById('regionIDDiv')) {
			jqueryRegionSelect();
		} 
	}
	
	if (department=="RL") {
		
		B = 0;
		selectedIndexNumber = 0;
		
		A.minimumPrice.length=0;
		
		if (minBlankOption!="") { A.minimumPrice.options[0] = new Option(minBlankOption, ''); B++; }
		
		rentFrequency = A.minimumRentFrequency.value;
		
		if (rentFrequency=="") { // if no frequency set yet
			rentFrequency = minRentArray.pop();
			A.minimumRentFrequency.value = rentFrequency;
		}
		
		for (var i=B; i<minRentArray.length; i++) {
			A.minimumPrice.options[i] = new Option('£'+formatNumber(minRentArray[i])+' '+rentFrequency,minRentArray[i]);
			if (minPriceArray[i]==minDefault) { selectedIndexNumber = i; }
		}
			
		A.minimumPrice.selectedIndex=selectedIndexNumber;
		
		B = 0;
		selectedIndexNumber = 0;
		
		A.maximumPrice.length=0;
		
		if (maxBlankOption!="") { A.maximumPrice.options[0] = new Option(maxBlankOption, ''); B++; }
		
		rentFrequency = A.maximumRentFrequency.value;
		
		if (rentFrequency=="") { // if no frequency set yet
			rentFrequency = maxRentArray.pop();
			A.maximumRentFrequency.value = rentFrequency;
		}
		
		for (var i=B; i<maxRentArray.length; i++) {
			A.maximumPrice.options[i] = new Option('£'+formatNumber(maxRentArray[i])+' '+rentFrequency,maxRentArray[i]);
			if (maxPriceArray[i]==maxDefault) { selectedIndexNumber = i; }
		}
			
		A.maximumPrice.selectedIndex=selectedIndexNumber;

		B = 0;
		selectedIndexNumber = 0;
		if (document.getElementById('regionIDDiv')) {
			document.getElementById('regionIDDiv').innerHTML='<select name="regionID" id="regionID"></select>';
		}
		A.regionID.length=0;
		
		if (regionBlankOption!="") { A.regionID.options[0] = new Option(regionBlankOption, ''); B++; }
		
		for (var i=0; i<RLRegionArray.length; i++) {
			regionSplit=RLRegionArray[i].split("|"); 
			A.regionID.options[B] = new Option(regionSplit[1],regionSplit[0]);
			if (regionSplit[0]==regionDefault) { selectedIndexNumber = B; }
			B++;
		}
			
		A.regionID.selectedIndex=selectedIndexNumber;
		if (document.getElementById('regionIDDiv')) {
			jqueryRegionSelect();
		} 
	} 
	
	if (department=="C") {
		
		B = 0;
		selectedIndexNumber = 0;
		if (document.getElementById('regionIDDiv')) {
			document.getElementById('regionIDDiv').innerHTML='<select name="regionID" id="regionID"></select>';
		}
		A.regionID.length=0;
		
		if (regionBlankOption!="") { A.regionID.options[0] = new Option(regionBlankOption, ''); B++; }
		
		for (var i=0; i<CRegionArray.length; i++) {
			regionSplit=CRegionArray[i].split("|"); 
			A.regionID.options[B] = new Option(regionSplit[1],regionSplit[0]);
			if (regionSplit[0]==regionDefault) { selectedIndexNumber = B; }
			B++;
		}
			
		A.regionID.selectedIndex=selectedIndexNumber;
		if (document.getElementById('regionIDDiv')) {
			jqueryRegionSelect();
		} 
	}
	
	if (department=="LA") {
		
		B = 0;
		selectedIndexNumber = 0;
		if (document.getElementById('regionIDDiv')) {
			document.getElementById('regionIDDiv').innerHTML='<select name="regionID" id="regionID"></select>';
		}
		A.regionID.length=0;
		
		if (regionBlankOption!="") { A.regionID.options[0] = new Option(regionBlankOption, ''); B++; }
		
		for (var i=0; i<LARegionArray.length; i++) {
			regionSplit=LARegionArray[i].split("|"); 
			A.regionID.options[B] = new Option(regionSplit[1],regionSplit[0]);
			if (regionSplit[0]==regionDefault) { selectedIndexNumber = B; }
			B++;
		}
			
		A.regionID.selectedIndex=selectedIndexNumber;
		if (document.getElementById('regionIDDiv')) {
			jqueryRegionSelect();
		} 
	}
	
}

function in_array(checkField, checkArray) {
	var inArray = false;
	for (var i=0; i<checkArray.length; i++) {
		if (checkArray[i]==checkField) { inArray=true; }
	}
	return inArray;
}

function updateRegistrationRows(department) {
	
	toggleRegistrationFields(department);
	
}

// turn off fields that aren't used by the passed department and turn on the ones that are
function toggleRegistrationFields(department) {	
	
	var arrayNumber = 0;
	var numbersToCheck = new Array();
	switch (department) {
		case "RS": { arrayNumber = 0; break; }
		case "RL": { arrayNumber = 1; break; }
		case "C": { arrayNumber = 2; break; }
		case "LA": { arrayNumber = 3; break; }
		default: { alert("Invalid department"); }
	}
	
	for (var a=0; a<4; a++) {
		for (var i=0; i<fieldsArray[a].length; i++) {
			toggleShowObject('row_registration_'+fieldsArray[a][i],false);
			toggleShowObject('row_registration_'+fieldsArray[a][i]+'a',false);
			toggleShowObject('row_registration_'+fieldsArray[a][i]+'b',false);
		}
	}
	
	// turn on fields for passed department
	for (var i=0; i<fieldsArray[arrayNumber].length; i++) {
		toggleShowTableRow('row_registration_'+fieldsArray[arrayNumber][i]);
		toggleShowTableRow('row_registration_'+fieldsArray[arrayNumber][i]+'a');
		toggleShowTableRow('row_registration_'+fieldsArray[arrayNumber][i]+'b');
	}
	
}

//parse a form and return a querystring
function parseForm(formname) { 
var theform = document.forms[formname]; 
var PostText = ""; 
var amp = ""; 
for(i=0; i<theform.elements.length; i++){ 
if(theform.elements[i].type == "text" || theform.elements[i].type == "textarea" || theform.elements[i].type == "hidden"){ 
PostText += amp+theform.elements[i].name+"="+encodeURIComponent(theform.elements[i].value); 
} else if (theform.elements[i].type == "checkbox") { 
if (theform.elements[i].checked)
PostText += amp+theform.elements[i].name+"="+encodeURIComponent(theform.elements[i].value); 
} else if (theform.elements[i].type == "select-one") { 
PostText += amp+theform.elements[i].name+"="+theform.elements[i].options[theform.elements[i].selectedIndex].value; 
} 
amp = "&"; 
} 

return PostText;

}

function removeMyAccountFunction() {
	document.form1.removeMyAccount.value=1;
	document.form1.submit();
}

