function switchImages(indicator, new_image) {
	var div = document.getElementById("show-image");	
	div.removeChild(indicator);
	div.appendChild(new_image);
}

var myrules = {
	'tr.tablerow' : function(el) {
		el.onmouseover = function() {
		    el.className = 'text row-hover';
		}
		el.onmouseout = function() {
			el.className = 'text row0';
		}
	},
	
	'#search_submit_button' : function(el) {
		el.onmouseover = function() {
			el.style.cursor = 'hand';
		}
	    el.onclick = function() {
	        document.getElementById('_searchsection_form').submit();
	    }
	},
	
	'#holiday-lets' : function(el) {
		el.onmouseover = function() {
			var image = document.getElementById('holiday-lets-arrow');
			image.src = "img/arrow-a.gif";
		},
		el.onmouseout = function() {
			var image = document.getElementById('holiday-lets-arrow');
			image.src = "img/arrow.gif";
		}
	},
	
	'#long-term-rentals' : function(el) {
		el.onmouseover = function() {
			var image = document.getElementById('long-term-rentals-arrow');
			image.src = "img/arrow-a.gif";
		},
		el.onmouseout = function() {
			var image = document.getElementById('long-term-rentals-arrow');
			image.src = "img/arrow.gif";
		}
	},
	
	'#property-sales' : function(el) {
		el.onmouseover = function() {
			var image = document.getElementById('property-sales-arrow');
			image.src = "img/arrow-a.gif";
		},
		el.onmouseout = function() {
			var image = document.getElementById('property-sales-arrow');
			image.src = "img/arrow.gif";
		}
	},
	
	'#cleaning' : function(el) {
		el.onmouseover = function() {
			var image = document.getElementById('cleaning-arrow');
			image.src = "img/arrow-a.gif";
		},
		el.onmouseout = function() {
			var image = document.getElementById('cleaning-arrow');
			image.src = "img/arrow.gif";
		}
	},
	
	'#building-maintenance' : function(el) {
		el.onmouseover = function() {
			var image = document.getElementById('building-maintenance-arrow');
			image.src = "img/arrow-a.gif";
		},
		el.onmouseout = function() {
			var image = document.getElementById('building-maintenance-arrow');
			image.src = "img/arrow.gif";
		}
	},
	
	'#satellite-services' : function(el) {
		el.onmouseover = function() {
			var image = document.getElementById('satellite-services-arrow');
			image.src = "img/arrow-a.gif";
		},
		el.onmouseout = function() {
			var image = document.getElementById('satellite-services-arrow');
			image.src = "img/arrow.gif";
		}
	},
	
	'#out-about' : function(el) {
		el.onmouseover = function() {
			var image = document.getElementById('out-about-arrow');
			image.src = "img/arrow-a.gif";
		},
		el.onmouseout = function() {
			var image = document.getElementById('out-about-arrow');
			image.src = "img/arrow.gif";
		}
	},
	
	'#restaurant-guide' : function(el) {
		el.onmouseover = function() {
			var image = document.getElementById('restaurant-guide-arrow');
			image.src = "img/arrow-a.gif";
		},
		el.onmouseout = function() {
			var image = document.getElementById('restaurant-guide-arrow');
			image.src = "img/arrow.gif";
		}
	},
	
	'#about-cyprus' : function(el) {
		el.onmouseover = function() {
			var image = document.getElementById('about-cyprus-arrow');
			image.src = "img/arrow-a.gif";
		},
		el.onmouseout = function() {
			var image = document.getElementById('about-cyprus-arrow');
			image.src = "img/arrow.gif";
		}
	},
	
	'#booking-info' : function(el) {
		el.onmouseover = function() {
			var image = document.getElementById('booking-info-arrow');
			image.src = "img/arrow-a.gif";
		},
		el.onmouseout = function() {
			var image = document.getElementById('booking-info-arrow');
			image.src = "img/arrow.gif";
		}
	},
	
	'#paphos-area' : function(el) {
		el.onmouseover = function() {
			var image = document.getElementById('paphos-area-arrow');
			image.src = "img/arrow-a.gif";
		},
		el.onmouseout = function() {
			var image = document.getElementById('paphos-area-arrow');
			image.src = "img/arrow.gif";
		}
	},
	
	'#local_search_submit_button' : function(el) {
	    el.onclick = function() {
	        document.getElementById('_local_searchsection_form').submit();
	    }
	},
	
	'#local_search_text_field' : function(el) {
		el.onclick = function() {
			el.value = '';
		}
	},
	
	'#calendar' : function(el) {
		el.onclick = function() {
		    calendar.select(document.forms[0].datevalue, 'anchor', 'dd.MM.yyyy'); 
		    return false;
		}
	},
	
	'#calendar_start' : function(el) {
		el.onclick = function() {
		    calendar.select(document.forms[0].start_datevalue, 'anchor', 'dd.MM.yyyy'); 
		    return false;
		}
	},
	
	'#calendar_end' : function(el) {
		el.onclick = function() {
		    more_calendar.select(document.forms[0].end_datevalue, 'anchor', 'dd.MM.yyyy'); 
		    return false;
		}
	},
	
	'#pricetype-link' : function(el) {
		el.onclick = function() {
			var val = el.value;
			if (val == "1") {
				el.innerHTML = 'Switch to fixed price';
				el.value = "2";
				document.getElementById('fixed-td').style.display = 'none';
				document.getElementById('range-td').style.display = 'block';
				document.getElementById('range-td').className = 'common-text text';
			}
			else if (val == "2") {
				el.innerHTML = 'Switch to price range';
				el.value = "1";
				document.getElementById('fixed-td').style.display = 'block';
				document.getElementById('range-td').style.display = 'none';
				document.getElementById('range-td').className = 'hidden';
			}
			document.getElementById('pricetype').value = el.value;
		}
	},
	
	'#propertyfor' : function(el) {
		el.onchange = function() {
			if (el.value != '-1' && el.value != '1') {
				document.getElementById('rental_period_row').style.display = 'block';
				document.getElementById('rental_period_row').className = '';
			}
			else {
				document.getElementById('rental_period_row').style.display = 'none';
				document.getElementById('rental_period_row').className = 'hidden-row';
			}
		}
	},
	
	'#currency-usd' : function(el) {
		el.onmouseover = function() {
			var status = document.getElementById('currencystatus').value;
			if (status != 'usd') {
		    	MM_swapImage('currency-usd','','img/currency-icons/usd-a.gif', 1);
			}
		    el.style.cursor = 'hand';
		}
		
		el.onmouseout = function() {
			var status = document.getElementById('currencystatus').value;
			if (status != 'usd') {
		    	MM_swapImgRestore();
			}
		    window.status=''; 
		}
		
		el.onclick = function() {
			var status = document.getElementById('currencystatus').value;
			var id = el.id;
			if (status == 'usd') {
				id = 'cyp';
			}
			var price, priceFrom, priceTo;
			
			if (document.getElementById('priceFrom') && document.getElementById('priceTo')) {
				cyp_priceFrom = document.getElementById('_priceFrom').value;
				cyp_priceFrom = cyp_priceFrom.replace(',', '');
				document.getElementById('priceFrom').innerHTML = oneCalcAmount(cyp_priceFrom, id);
				
				cyp_priceTo   = document.getElementById('_priceTo').value;
				cyp_priceTo   = cyp_priceTo.replace(',', '');
				document.getElementById('priceTo').innerHTML = oneCalcAmount(cyp_priceTo, id);
			}
			else if (document.getElementById('price')) {
				cyp_price = document.getElementById('_price').value;
				cyp_price = cyp_price.replace(',','');
				document.getElementById('price').innerHTML = oneCalcAmount(cyp_price, id);
			}
			
			if (document.getElementById('currencyID')) {
				if (status != 'usd') {
					document.getElementById('currencystatus').value = 'usd';
					document.getElementById('currencyID').innerHTML = 'USD';
					if (document.getElementById('currencyID2')) {
						document.getElementById('currencyID2').innerHTML = 'USD';
					}
					el.src = 'img/currency-icons/usd-a.gif';
				}
				else {
					document.getElementById('currencystatus').value = 'cyp';
					document.getElementById('currencyID').innerHTML = 'CYP';
					if (document.getElementById('currencyID2')) {
						document.getElementById('currencyID2').innerHTML = 'CYP';
					}
					el.src = 'img/currency-icons/usd.gif';
				}
				restoreImages(el.id);
			}
		}
	},

	'#currency-gbp' : function(el) {
		el.onmouseover = function() {
			var status = document.getElementById('currencystatus').value;
			if (status != 'gbp') {
		    	MM_swapImage('currency-gbp','','img/currency-icons/gbp-a.gif', 1);
			}
		    el.style.cursor = 'hand';
		}
		
		el.onmouseout = function() {
			var status = document.getElementById('currencystatus').value;
			if (status != 'gbp') {
		    	MM_swapImgRestore();
			}
		    window.status=''; 
		}
		
		el.onclick = function() {
			var status = document.getElementById('currencystatus').value;
			var id = el.id;
			if (status == 'gbp') {
				id = 'cyp';
			}
			var price, priceFrom, priceTo;
			
			if (document.getElementById('priceFrom') && document.getElementById('priceTo')) {
				cyp_priceFrom = document.getElementById('_priceFrom').value;
				cyp_priceFrom = cyp_priceFrom.replace(',', '');
				document.getElementById('priceFrom').innerHTML = oneCalcAmount(cyp_priceFrom, id);
				
				cyp_priceTo   = document.getElementById('_priceTo').value;
				cyp_priceTo   = cyp_priceTo.replace(',', '');
				document.getElementById('priceTo').innerHTML = oneCalcAmount(cyp_priceTo, id);
			}
			else if (document.getElementById('price')) {
				cyp_price = document.getElementById('_price').value;
				cyp_price = cyp_price.replace(',','');
				document.getElementById('price').innerHTML = oneCalcAmount(cyp_price, id);
			}
			
			if (document.getElementById('currencyID')) {
				if (status != 'gbp') {
					document.getElementById('currencystatus').value = 'gbp';
					document.getElementById('currencyID').innerHTML = 'GBP';
					if (document.getElementById('currencyID2')) {
						document.getElementById('currencyID2').innerHTML = 'GBP';
					}
					el.src = 'img/currency-icons/gbp-a.gif';
				}
				else {
					document.getElementById('currencystatus').value = 'cyp';
					document.getElementById('currencyID').innerHTML = 'CYP';
					if (document.getElementById('currencyID2')) {
						document.getElementById('currencyID2').innerHTML = 'CYP';
					}
					el.src = 'img/currency-icons/gbp.gif';
				}
				restoreImages(el.id);
			}
		}
	},
	
	'#currency-eur' : function(el) {
		el.onmouseover = function() {
			var status = document.getElementById('currencystatus').value;
			if (status != 'eur') {
		    	MM_swapImage('currency-eur','','img/currency-icons/euro-a.gif', 1);
			}
		    el.style.cursor = 'hand';
		}
		
		el.onmouseout = function() {
			var status = document.getElementById('currencystatus').value;
			if (status != 'eur') {
		    	MM_swapImgRestore();
			}
		    window.status=''; 
		}
		
		el.onclick = function() {
			var status = document.getElementById('currencystatus').value;
			var id = el.id;
			if (status == 'eur') {
				id = 'cyp';
			}
			var price, priceFrom, priceTo;
			
			if (document.getElementById('priceFrom') && document.getElementById('priceTo')) {
				cyp_priceFrom = document.getElementById('_priceFrom').value;
				cyp_priceFrom = cyp_priceFrom.replace(',', '');
				document.getElementById('priceFrom').innerHTML = oneCalcAmount(cyp_priceFrom, id);
				
				cyp_priceTo   = document.getElementById('_priceTo').value;
				cyp_priceTo   = cyp_priceTo.replace(',', '');
				document.getElementById('priceTo').innerHTML = oneCalcAmount(cyp_priceTo, id);
			}
			else if (document.getElementById('price')) {
				cyp_price = document.getElementById('_price').value;
				cyp_price = cyp_price.replace(',','');
				document.getElementById('price').innerHTML = oneCalcAmount(cyp_price, id);
			}
			
			if (document.getElementById('currencyID')) {
				if (status != 'eur') {
					document.getElementById('currencystatus').value = 'eur';
					document.getElementById('currencyID').innerHTML = 'EURO';
					if (document.getElementById('currencyID2')) {
						document.getElementById('currencyID2').innerHTML = 'EURO';
					}
					el.src = 'img/currency-icons/euro-a.gif';
				}
				else {
					document.getElementById('currencystatus').value = 'cyp';
					document.getElementById('currencyID').innerHTML = 'CYP';
					if (document.getElementById('currencyID2')) {
						document.getElementById('currencyID2').innerHTML = 'CYP';
					}
					el.src = 'img/currency-icons/euro.gif';
				}
				restoreImages(el.id);
			}
		}
	},

	'img.calc' : function(el) {
		el.onmouseover = function() {
			var status = document.getElementById('calcstatus_' + el.id).value;
			if (status != 'true') {
	        	MM_swapImage('calc_' + el.id,'','img/calc-a.gif', 1);
			}
		    el.style.cursor = 'hand';
		}
		
		el.onmouseout = function() {
			var status = document.getElementById('calcstatus_' + el.id).value;
			if (status != 'true') {
		    	// MM_swapImgRestore();
		    	MM_swapImage('calc_' + el.id,'','img/calc.gif', 1);
			}
		    window.status=''; 
		}
		
		el.onclick = function() {
			var status = document.getElementById('calcstatus_' + el.id).value;
			if (status != 'true') {
				document.getElementById('calcstatus_' + el.id).value = 'true';
				el.src = 'img/calc-a.gif';
				document.getElementById('row-' + el.id).className = 'visible';
				var price = 0;
				if (document.getElementById('priceFrom_' + el.id)) {
					price = document.getElementById('priceFrom_' + el.id).innerHTML;
				}
				else if (document.getElementById('price_' + el.id)) {
					price = document.getElementById('price_' + el.id).innerHTML;
				}
				price = price.replace(',', '');
				document.getElementById('sum_' + el.id).value = price;
				calcPropertyAmount(price, el.id);
			}
			else {
				document.getElementById('calcstatus_' + el.id).value = 'false';
				el.src = 'img/calc.gif';
				document.getElementById('row-' + el.id).className = 'hidden';				
			}
		}
	},

	'img.book' : function(el) {
		el.onmouseover = function() {
			var id = el.id.replace('book_', '');
        	MM_swapImage('book_' + id,'','img/book-a.gif', 1);
		    el.style.cursor = 'hand';
		}
		
		el.onmouseout = function() {
		    MM_swapImgRestore();
		    window.status=''; 
		}
	},
	
	'img.details' : function(el) {
		el.onmouseover = function() {
			var id = el.id.replace('details_', '');
        	MM_swapImage('details_' + id,'','img/details-a.gif', 1);
		    el.style.cursor = 'hand';
		}
		
		el.onmouseout = function() {
		    MM_swapImgRestore();
		    window.status=''; 
		}
	},

	'img.zoom' : function(el) {
		el.onmouseover = function() {
			var id = el.id.replace('zoom_', '');
        	MM_swapImage('zoom_' + id,'','img/zoom-a.gif', 1);
		    el.style.cursor = 'hand';
		}
		
		el.onmouseout = function() {
		    MM_swapImgRestore();
		    window.status=''; 
		}
	},
	
	'img.property-gallery' : function(el) {
		el.onmouseover = function() {
			var id = el.id.replace('gallery_', '');
        	MM_swapImage('gallery_' + id,'','img/propgallery-a.gif', 1);
		    el.style.cursor = 'hand';
		}
		
		el.onmouseout = function() {
		    MM_swapImgRestore();
		    window.status=''; 
		}
	},
	
	'img.property_gallery' : function(el) {
		el.onmouseover = function() {
			el.style.border = '2px solid #F19B13';
			el.style.cursor = 'hand';
		}
		
		el.onmouseout = function() {
			el.style.border = '2px solid #F5F5F5';
		}
		
		el.onclick = function() {
			var div = document.getElementById("show-image");
			
			var image = document.getElementById(el.name);
			div.removeChild(image);
			
			indicator = document.createElement("img");
			indicator.src = "img/indicator.gif";
			indicator.setAttribute("vspace", 40)
			indicator.setAttribute("border", 0)
			indicator.setAttribute("alt", "uploading...");
			div.appendChild(indicator);
			
			var path = el.src;
			path = path.replace("preview", "medium");
			
			new_image = document.createElement("img");
			new_image.src = path;
			new_image.setAttribute("id", el.name);
			new_image.setAttribute("vspace", 10);
			new_image.setAttribute("hspace", 0);
			new_image.setAttribute("border", 0);
			new_image.setAttribute("alt", image.alt);
			
			new_image.onLoad = interval = setInterval("switchImages(indicator, new_image); clearInterval(interval); ", 3000);
		}
	},
	
	'img.rollover' : function(el) {
		el.onmouseover = function() {
			el.style.border = '2px solid #F19B13';
			el.style.cursor = 'hand';
		}
		
		el.onmouseout = function() {
			el.style.border = '2px solid #F5F5F5';
		}
	}
};

Behaviour.register(myrules);