isIE = false;
if ( navigator.appName == "Microsoft Internet Explorer") {
	isIE = true;
}

g_opacity_level = 10;
g_current_image = "img0";
g_direction = null;
g_timeout = null;
g_current_time = 0;
g_current_time_switcher = null;


function change_opacity_level( direction) {
	result = (direction) ? (g_opacity_level += 2) : ( g_opacity_level -= 2 );
	if ( isIE) {
		$( "#img_holder").style.filter = "alpha(opacity="+ (g_opacity_level * 10) +")";
	} else {
		$( "#img_holder").style.opacity = (g_opacity_level * 0.1);
	}
	if ( g_opacity_level == 0) {
		change_image();
	} else if ( g_opacity_level == 10) {
		clearTimeout( g_timeout);
		return true;
	} else {
		g_timeout = setTimeout( function() { change_opacity_level.call( this, direction)}, 50);
	}
}

function change_image() {
	$( "#img_holder").style.background = "url("+image_array[g_current_image].image.src+") 50% 0 no-repeat";
	change_opacity_level( true);
}


function change_house() {
    currentImg = parseInt( g_current_image.match(/img(\d+)/)[1]);
    currentImg = ( image_array[("img" + ++currentImg)] ) ? "img" + currentImg : "img0";
	clearTimeout( house_change);
	g_current_image = currentImg;
    house_change = window.setTimeout(change_house, 10000);
	change_opacity_level( false);
}



image_array = {};
image_array["img0"] = {};
image_array["img0"].image = new Image();
image_array["img0"].image.src = "img/r14.jpg";
image_array["img1"] = {};
image_array["img1"].image = new Image();
image_array["img1"].image.src = "img/r15.jpg";
image_array["img2"] = {};
image_array["img2"].image = new Image();
image_array["img2"].image.src = "img/r16.jpg";
image_array["img3"] = {};
image_array["img3"].image = new Image();
image_array["img3"].image.src = "img/r17.jpg";
image_array["img4"] = {};
image_array["img4"].image = new Image();
image_array["img4"].image.src = "img/r18.jpg";
image_array["img5"] = {};
image_array["img5"].image = new Image();
image_array["img5"].image.src = "img/r19.jpg";
image_array["img5"] = {};
image_array["img5"].image = new Image();
image_array["img5"].image.src = "img/r20.jpg";


/*
function click_handler() {
    location.href = image_array[g_current_image].href;
}
*/

house_change = window.setTimeout(change_house, 8000);isIE = false;
if ( navigator.appName == "Microsoft Internet Explorer") {
	isIE = true;
}

g_opacity_level = 10;
g_current_image = "img0";
g_direction = null;
g_timeout = null;
g_current_time = 0;
g_current_time_switcher = null;


function change_opacity_level( direction) {
	result = (direction) ? (g_opacity_level += 2) : ( g_opacity_level -= 2 );
	if ( isIE) {
		$( "#img_holder").style.filter = "alpha(opacity="+ (g_opacity_level * 10) +")";
	} else {
		$( "#img_holder").style.opacity = (g_opacity_level * 0.1);
	}
	if ( g_opacity_level == 0) {
		change_image();
	} else if ( g_opacity_level == 10) {
		clearTimeout( g_timeout);
		return true;
	} else {
		g_timeout = setTimeout( function() { change_opacity_level.call( this, direction)}, 50);
	}
}

function change_image() {
	$( "#img_holder").style.background = "url("+image_array[g_current_image].image.src+") 50% 0 no-repeat";
	change_opacity_level( true);
}


function change_house() {
    currentImg = parseInt( g_current_image.match(/img(\d+)/)[1]);
    currentImg = ( image_array[("img" + ++currentImg)] ) ? "img" + currentImg : "img0";
	clearTimeout( house_change);
	g_current_image = currentImg;
    house_change = window.setTimeout(change_house, 10000);
	change_opacity_level( false);
}



image_array = {};
image_array["img0"] = {};
image_array["img0"].image = new Image();
image_array["img0"].image.src = "img/w2.jpg";
image_array["img1"] = {};
image_array["img1"].image = new Image();
image_array["img1"].image.src = "img/w3.jpg";
image_array["img2"] = {};
image_array["img2"].image = new Image();
image_array["img2"].image.src = "img/w4.jpg";
image_array["img3"] = {};
image_array["img3"].image = new Image();
image_array["img3"].image.src = "img/w5.jpg";
image_array["img4"] = {};
image_array["img4"].image = new Image();
image_array["img4"].image.src = "img/w6.jpg";
image_array["img5"] = {};
image_array["img5"].image = new Image();
image_array["img5"].image.src = "img/w7.jpg";
image_array["img6"] = {};
image_array["img6"].image = new Image();
image_array["img6"].image.src = "img/w8.jpg";


/*
function click_handler() {
    location.href = image_array[g_current_image].href;
}
*/

house_change = window.setTimeout(change_house, 8000);
