$(document).ready(function () {
	$('#house_images').cycle({ 
    	fx:    'fade', 
    	speed:  1500,
		pause: 1
 	});

	$('#start_images').cycle({ 
    	fx:    'fade', 
    	speed:  1500
 	});

	$('#history_images').cycle({
		fx:    'fade',
		speed:  1500,
		pause: 1,
		after: setYear
   });
});

function setYear () {
	if (this.alt.length > 0) {
		$('div#history .show_year').html(this.alt);
		$('div#history .show_year').show();
	} else {
		$('div#history .show_year').hide();
	}
}

function changePic(img){
	$('#house_images').html('<img src="'+img+'">');
}

function getElement (id) {
	if (document.getElementById && document.getElementById(id)) {
		return document.getElementById(id);
	}

	if (document.all && document.all[id]) {
		return document.all[id];
	}

	if (document.layers) {
		for (var i = 1; i < document.layers.length; i++) {
			if (document.layers[i].id == id) {
				return document.layers[i].id;
			}
		}
	}
	return null;
}

function divSwap (id, hidden) {
	var obj = getElement(id);

	if (! obj) return;

	if (obj.className) {
		obj.className = hidden ? 'hide' : 'show';
		return;
	}

	if (obj.style.display) {
		obj.style.display = hidden ? 'none' : 'block';
	} else if (obj.style.visibility) {
		obj.style.visibility = hidden ? 'hidden' : 'visible';
	}

	if (obj.style.height) {
		obj.style.height = hidden ? '0px' : 'auto';
	}
	if (obj.style.overflow) {
		obj.style.overflow = hidden ? 'hidden' : 'auto';
	}
}

function divShow (id) {
	divSwap(id);
}

function divHide (id) {
	divSwap(id, true);
}

/* Show/hide div */
function divToggle (id) {
	var obj = getElement(id);

	if (! obj) return;

	if (obj.className) {
		obj.className = obj.className == 'show' ? 'hide' : 'show';
		return;
	}

	if (obj.style.display) {
		obj.style.display = obj.style.display == 'none' ? 'block' : 'none';
	} else if (obj.style.visibility) {
		obj.style.visibility = obj.style.visibility == 'hidden' ? 'visible' : 'hidden';
	}

	if (obj.style.height) {
		obj.style.height = obj.style.height == '0px' ? 'auto' : '0px';
	}

	if (obj.style.overflow) {
		obj.style.overflow = obj.style.overflow == 'hidden' ? 'visible' : 'hidden';
	}
}

function trToggle (id) {
	var obj = getElement(id);

	if (! obj) return;

	if (obj.style.display) {
		if (obj.style.display != 'none') {
			obj.style.display = 'none';
		} else {
			if (navigator.appName == 'Microsoft Internet Explorer') {
				obj.style.display = 'block';
			} else {
				obj.style.display = 'table-row';
			}
		}
	}
}

function custompop(win, width, height, status, menu, scrollbars) {
	bakom=window.open(win, 'bakom', 'toolbar=no,location=no,directories=no,status=' + status +  ',menubar=' + menu + ',scrollbars=' + scrollbars + ',resizable=yes,copyhistory=no,width=' + width + ',height=' + height);
	bakom.focus();
}

function divShowActivity (id) {
	if (! id) return;

	for (i = 1 ; i <= 7 ; i++) {
		var obj = getElement(i);

		if (obj.style.display && id == i) {
			obj.style.display = obj.style.display == 'none' ? 'block' : 'none';
		} else {
			obj.style.display = 'none';
		}
	}
}
