function init(){
	$('.mainNav ul li:first-child').addClass('first_li');
	$('.breadNav ul > li > a').not('.breadNav ul li:last-child a').append('<span class="pipe">></span>'); //	
	$('.breadNav ul li:first-child').addClass('first_li');	
	$('.footerNav ul > li > a').not('.footerNav ul li:last-child a').append('<span class="pipe">|</span>'); //	
	$('.footerNav ul li:first-child').addClass('first_li');
	if($('a.fbox').length>0){
		$('a.fbox').fancybox({
			'width'				: 900,
			'height'			: 450,
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe',
			'hideOnContentClick': false,
			'overlayShow'		: true,
			'overlayColor'		: '#000000'
		});
		
		$('a.fbox_rates').fancybox({
			'width'				: 325,
			'height'			: 200,
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe',
			'hideOnContentClick': false,
			'overlayShow'		: true,
			'overlayColor'		: '#000000'
		});
	}
	if($('a.fbox-sched').length>0){
		$('a.fbox-sched').fancybox({
			'width'				: 630,
			'height'			: 600,
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe',
			'hideOnContentClick': false,
			'overlayShow'		: true,
			'overlayColor'		: '#000000'
		});
	}
	if($('a.fbox-refer').length>0){
		$('a.fbox-refer').fancybox({
			'width'				: 450,
			'height'			: 500,
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe',
			'hideOnContentClick': false,
			'overlayShow'		: true,
			'overlayColor'		: '#000000'
		});
	}	
	if($('.form-home-go').length>0){	
		$('.form-home-go').click(function() {
			var var1 = $('input.var1').val();
			var var2 = $('input.var2').val();
			$.fancybox({
				'width'				: 430,
				'height'			: 500,
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe',
				'hideOnContentClick': false,
				'overlayShow'		: true,
				'overlayColor'		: '#000000',
				'href'              : 'home-value.php?address='+escape(var1)+'&city='+escape(var2)
			});
			return false;
		});
	}
	
};

/*dom ready*/
jQuery(document).ready(function($) {
	init();
	
	$(".add-favorite").live("click", function() {
		var id = $(this).attr('id').split('_')[1];
		var that = $(this);
		$.ajax({
			cache: false,
			type : 'POST',
			url  : 'favorites.php',
			data : 'type=add&mls='+id,
			success: function(rt, xhr) {
				if (rt == '1') {
					$(that).removeClass('add-favorite');
					$(that).addClass('rem-favorite');
					$(that).text('Remove from favorites'); 
				}
				else {
					$("a#register_link").click();
				}
			},
			error: function(rt, st) {
				alert('ERRORS: \nrt='+rt+' \nst='+st);
			}
		});
		return false;
	});

	$(".rem-favorite").live("click", function() {
		var id = $(this).attr('id').split('_')[1];
		var that = $(this);
		$.ajax({
			cache: false,
			type : 'POST',
			url  : 'favorites.php',
			data : 'type=remove&mls='+id,
			success: function(rt, xhr) {
				if (rt == '1') {
					$(that).removeClass('rem-favorite');
					$(that).addClass('add-favorite');
					$(that).text('Save to Favorites'); 
				}
				else {
					alert(rt);
				}
			},
			error: function(rt, st) {
				alert('ERRORS: \nrt='+rt+' \nst='+st);
			}
		});
		return false;
	});
	
});
