// JavaScript Document

$(document).ready(function () {

	$("a[rel=external]").click(function() {
          window.open(this.href);  
          return false;
     });
	
	if($("#slider")){
		
		$("#slider").scrollable({
			size: 3,
			clickable: false
		});
	}
	
	if($("#slider1")){
		
		$("#slider1").scrollable({
			size: 3,
			clickable: false
		});
	}
	
	if($("#slider2")){
	
		$("#slider2").scrollable({
			size: 3,
			clickable: false
		});
	}
	
	if($("#featured")){
		$("#featured").easySlider({
			auto: true,
			continuous: true,
			speed: 1000,
			pause: 5000,
			controlsShow: false
		});
	}
	
	$(".lightbox").lightbox();
		
	if($("#form")){
		$("#form").validate();
	}
	if($("#form1")){
		$("#form1").validate();
	}
	
});

function max_weight(check){
	if($(check).attr('checked') == true){
		$("#PropertySmallDogWeightMaximum").removeAttr("disabled").focus();
	}
	else {
		document.getElementById('PropertySmallDogWeightMaximum').disabled = 'disabled';
	}
}

function no_pets(no_pet){
	if($(no_pet).attr('checked') == true){
		$("form :checkbox").attr('disabled', 'disabled');
		$("form :text").attr('disabled', 'disabled');
		$(no_pet).removeAttr("disabled");
	}
	else {
		$("form :checkbox").removeAttr("disabled");
		$("form :text").removeAttr("disabled");
		if($("form :checkbox:first").attr('checked') == false){
			document.getElementById('PropertySmallDogWeightMaximum').disabled = 'disabled';
		}
	}
}

function no_pets_check(){
	if($("form :checkbox:last").attr('checked') == true){
		$("form :checkbox").attr('disabled', 'disabled');
		$("form :text").attr('disabled', 'disabled');
		$("form :checkbox:last").removeAttr("disabled");
	}
}


function showForm(param){
	alert('1');
	
	document.getElementById('omaha').style.display = 'none';
	document.getElementById('lincoln').style.display = 'none';
	
//	document.getElementById(param).style.display = 'block';
}




function photo_category(id, id1, id2){
	
	document.getElementById(id).style.display = 'block';
	document.getElementById(id1).style.display = 'none';
	document.getElementById(id2).style.display = 'none';
	
	big_pic_id = 'big_pic_' + id;
	big_pic_id1 = 'big_pic' + id1;
	big_pic_id2 = 'big_pic' + id2;
	
	big_pic_link_id = 'big_pic_link_' + id;
	big_pic_link_id1 = 'big_pic_link_' + id1;
	big_pic_link_id2 = 'big_pic_link_' + id2;
	
	document.getElementById(big_pic_link_id).style.display = 'block';
	document.getElementById(big_pic_link_id).href = document.getElementById(big_pic_id).src.replace("m_", "");
	
	document.getElementById('big_pic_link').href = document.getElementById(big_pic_id).src.replace("m_", "");
	$('#big_pic_link').attr('rel', id);
	
	document.getElementById(big_pic_link_id1).style.display = 'none';
	document.getElementById(big_pic_link_id2).style.display = 'none';
	
}

function photo_big(category, id){
	
	big_pic = 'big_pic_' + category;
	big_pic_link = 'big_pic_link_' + category;
	
	document.getElementById(big_pic).src = document.getElementById(id).src.replace("mm_", "m_");
	document.getElementById('big_pic_link').href = document.getElementById(id).src.replace("mm_", "");
	document.getElementById('big_pic_link').title = document.getElementById(id).alt;
	document.getElementById(big_pic_link).href = document.getElementById(id).src.replace("mm_", "");
	document.getElementById(big_pic_link).title = document.getElementById(id).alt;
	
}


function details_nav(id1, id2, id3, id4){
	
	document.getElementById(id1).style.display = 'block';
	document.getElementById(id2).style.display = 'none';
	document.getElementById(id3).style.display = 'none';
	document.getElementById(id4).style.display = 'none';
	
	link_id1 = id1 + '_link';
	link_id2 = id2 + '_link';
	link_id3 = id3 + '_link';
	link_id4 = id4 + '_link';
	
	document.getElementById(link_id1).className += ' act';
	document.getElementById(link_id2).className = document.getElementById(link_id2).className.replace(" act", "");
	document.getElementById(link_id3).className = document.getElementById(link_id3).className.replace(" act", "");
	document.getElementById(link_id4).className = document.getElementById(link_id4).className.replace(" act", "");
}

function addFormField() {
	var id = document.getElementById("id").value;
	image = (id - 1) + 2;
	$("#divTxt").append("<fieldset id='row" + id + "'><a href='#' onClick='removeFormField(\"#row" + id + "\"); return false;' class='delete_link'><img src='/img/admin/ico_delete.png' alt='Delete' /></a> <div class='input file'> <label for='Photo" + id + "Img'>Image " + image + "</label> <input name='data[Photo][" + id + "][img]' value='' id='Photo" + id + "Img' type='file' class='required' /> </div> <div> <label>Photo Category:</label> <select name='data[Photo][" + id + "][photo_category_id]' class='required' id='Photo" + id + "PhotoCategoryId'> <option value=''>Select Category</option> <option value='1'>Interior Apartment</option> <option value='2'>Exterior Apartment</option> <option value='3'>Community</option> </select> </div> <div class='input text'> <label for='Photo" + id + "Caption'>Caption</label> <input name='data[Photo][" + id + "][caption]' maxlength='255' value='' id='Photo" + id + "Caption' type='text'> </div> </fieldset>");
	
	id = (id - 1) + 2;
	document.getElementById("id").value = id;
}

function removeFormField(id) {
	$(id).remove();
}