// User Defined Function
$(document).ready(function() {
	/*
	 * Light Box
	 */
	try {
	$('.lightbox a').lightBox();
	} catch(err) { }

	// Used for switching between login and forget box
	$('.show_leftbox').click(function(){
		if($(this).attr('name')=='login') {
			$('#login_area').css('display','none');
			$('#forgot_area').css('display','block');
		}else if($(this).attr('name')=='forgot') {
			$('#login_area').css('display','block');
			$('#forgot_area').css('display','none');
		}
	});

	// For validation on forgot password
	$("#forgot_pass").validate();
	$("#contact_realtor_form").validate();
	$("#request_moreinfo_form").validate();
	$("#send_to_friend_form").validate();
	$("#contact_office_form").validate();
	$("#send_testimonials_form").validate();
	$("#form_save_searches").validate();

	// for User name choice in buyer registration and seller registration
	$('.username_choice').click(function(){

		if($(this).attr("checked")){
			$('.user_name').css('display', 'none');
			$('.usernam_error').css('display', 'block');
		} else{
			$('.user_name').css('display', 'block');
			$('.usernam_error').css('display', 'none');
		}
	});
	if($('.username_choice').attr("checked")){
		$('.user_name').css('display', 'none');
		$('.usernam_error').css('display', 'block');
	} else{
		$('.user_name').css('display', 'block');
		$('.usernam_error').css('display', 'none');
	}


	//scroll the message box to the top offset of browser's scrool bar
	$(window).scroll(function()
	{
  		$('.popupBox').animate({top:$(window).scrollTop()+"px" },{queue: false, duration: 350});
	});
    //when the close button at right corner of the message box is clicked
	$('.close_msg').click(function()
	{
  		//the messagebox gets scrool down with top property and gets hidden with zero opacity
		$('.popupBox').animate({ top:"+=50px",opacity:0 }, "slow");
	});


	// Save Property in Remeberlist
	$('.RememberListSaveProperty').click(function(){
		location.href = siteUrl+'listings/save_property/'+$(this).attr('name')+'/property';
	});

	//Save realtor in RememberList
	$('.RememberListSaveRealtor').click(function() {
		location.href = siteUrl+'realtors/save_realtor/'+$(this).attr('name')+'/realtor';
	});

	// Image Gallery For Property View
	$('#photos').galleryView({
		panel_width: 380,
		panel_height: 227,
		frame_width: 50,
		frame_height: 50
	});

	// innerfade on banners
	$('#banners').innerfade({
			animationtype: 'fade',
			speed: 4000,
			timeout: 6000,
			type: 'sequence',
			containerheight: '120px'
		});

	$('#select_realtor').bind('change',function(){
			location.href = siteUrl+'realtors/view/'+$(this).val();
	});


	$('.remember_list').bind('click',function(){

		if($(this).attr("name") == 'realtor'){
			$('#property_remember_list').css('display', 'none');
			$('#realtor_remember_list').css('display', 'block');
			$('.realtor_list').addClass('currentmy');
			$('.property_list').removeClass('currentmy');

		}
		else{
			$('#realtor_remember_list').css('display', 'none');
			$('#property_remember_list').css('display', 'block');
			$('.realtor_list').removeClass('currentmy');
			$('.property_list').addClass('currentmy');
		}
	});

	$('.button_rememberlist').click(function() {
		document.getElementById('mystatus').value = $(this).attr('alt');
		if($(this).attr('alt')=='remove'){
			jConfirm('Are you sure you want to remove this from the remembered list?', 'Remax Confirm', function(result){
				if (result) {
					document.mychangestatus.submit();
				} else {
				  	return false;
				}
			});
		} else{
			document.mychangestatus.submit();
		}
	});

	try {
    jQuery($('ShowRealtorsBox')).fancybox({
	'titleShow'       : false,
	  'transitionIn'  : 'none',
	  'transitionOut' : 'none'
	  });
	} catch(err) { }
});