var step1 = true;
var step2 = false;
var step3 = false;

var currStep = 1;

var furnishings = 1;

var currClient = 1;


function init() {
	var images = new Array("1.jpg", "1_on.jpg", "2.jpg", "2_on.jpg", "3.jpg", "3_on.jpg");
	
	imageObj = new Image();
	
	for(var i = 0; i<=5; i++) {
		imageObj.src=images[i];	
	}
}

function init_furnishings() {
	var images = new Array("btn_guest_rooms.jpg", "btn_guest_rooms_on.jpg", "btn_seating.jpg", "btn_seating_on.jpg", "btn_common_areas.jpg", "btn_common_areas_on.jpg");
	
	imgObj = new Image();
	
	for(var i = 0; i < images.length; i++) {
		imgObj.src=images[i];	
	}
}


function init_clients() {
	var images = new Array("client1.png", "client2.png", "client3.png", "client4.png", "client6.png", "client7.png", "client8.png", "client9.png"); //, "client4.png");
	
	imgObj = new Image();
	
	for(var i = 0; i < images.length; i++) {
		imgObj.src=images[i];	
	}
}


function change_step(step) {
	var img1 = $('#step1_image').attr("src");
	var img2 = $('#step2_image').attr("src");
	var img3 = $('#step3_image').attr("src");
	
	switch(step) {
		case 1: 
			if(currStep != 1) { 
				$('#process_text'+currStep).fadeOut("fast", function() { $('#process_text1').fadeIn("fast"); } );
				currStep = 1;
		
				$('#step1_image').attr("src", img1.replace(".jpg", "_on.jpg"));
				$('#step2_image').attr("src", img2.replace("_on", ""));
				$('#step3_image').attr("src", img3.replace("_on", ""));
			}
		
			if(step3 == true) {
				$('#image3').animate({height : '0px', top : '303px'}); //.fadeOut("slow");
				step3 = false;
			}
			
			if(step2 == true) {
				$('#image2').animate({height : '0px', top : '303px'}); //.fadeOut("slow");	
				step2 = false;
			}
			
			
			
		break;
		
		case 2:
			if(currStep != 2) { 
				$('#process_text'+ currStep).fadeOut("fast", function() { $('#process_text2').fadeIn("fast"); }); 
				currStep = 2; 
			
				$('#step1_image').attr("src", img1.replace("_on", ""));
				$('#step2_image').attr("src", img2.replace(".jpg", "_on.jpg"));
				$('#step3_image').attr("src", img3.replace("_on", ""));		
			}
			
			if(step3 == true) {
				$('#image3').animate({height : '0px', top : '303px'}); //.fadeOut("slow");
				step3 = false;
			}
			
			if(step2 == false) {
				$('#image2').animate({height : '303px', top : '0px'}); //, //{ duration : "fast", easing : 'linear'}); //.fadeIn("slow");	
				step2 = true;
			}
			
		break;
		
		case 3:
			if(currStep != 3) { 
				$('#process_text'+ currStep).fadeOut("fast", function() { $('#process_text3').fadeIn('fast'); } ); 
				currStep = 3; 
						
				$('#step1_image').attr("src", img1.replace("_on", ""));
				$('#step2_image').attr("src", img2.replace("_on", ""));
				$('#step3_image').attr("src", img3.replace(".jpg", "_on.jpg"));		
			}
			
			if(step2 == false) {
				$('#image2').animate({height : '303px', top : '0px'}); //.fadeIn("slow");
				step2 = true;
			}
			
			if(step3 == false) {
				$('#image3').animate({height : '303px', top : '0px'}); //.fadeIn("slow");
				step3 = true;
			}
			
			break;
		
		default: alert("error");
	}
}

function change_furnishings(what) {
	var arr =  new Array("", "guest_room", "seating", "common_area");
	
	if(what != furnishings) {
		var img1 = $('#'+arr[furnishings]).attr("src");
		$('#'+arr[furnishings]).attr("src", img1.replace("_on", ""));
		
		var img1 = $('#'+arr[what]).attr("src");
		$('#'+arr[what]).attr("src", img1.replace(".jpg", "_on.jpg"));
		
		
		$('#'+arr[furnishings]+'_text').fadeOut("fast", function() { $('#'+arr[what]+'_text').fadeIn("fast"); });
		$('#furn_photo'+furnishings).fadeOut("fast", function() { $('#furn_photo'+what).fadeIn("fast"); });
		
		furnishings = what;
	}
	
}


function client_right() {
	/* move current left and new left at same time. */
	var nextClient = currClient + 1;
	if(nextClient > 9) nextClient = 1;
	if(nextClient == 5) nextClient = 6;
	
	
	
	$('#client'+nextClient).css({left: '343px'});
	$('#client'+currClient).animate({ left: '-=343px' });
	$('#client'+nextClient).animate( { left: '-=343px'});
	
	currClient = nextClient;
}

function client_left() {
	var nextClient = currClient - 1;
	if(nextClient == 0) nextClient = 9;	
	if(nextClient == 5) nextClient = 4;
	
	
	$('#client'+nextClient).css({left: '-343px'});
	$('#client'+currClient).animate({ left: '+=343px' });
	$('#client'+nextClient).animate( { left: '+=343px'});
	
	currClient = nextClient;
}

/* menu Functions */

var MenuActive = 0;
var timer = null;

function moveMenu(where) {	
	var Obj = new Object();
	Obj = { home: '-324px', 
			company: '-270px', 
			furnishings: '-204px',
			process: '-130px',
			contact: '-68px',
			clients: '-3px' };
	
	MenuActive = 1;
	
	$('#menubarhr').stop().animate( {backgroundPosition : Obj[where]+' -1px'});
	
	if(!timer) timer = setInterval("checkMenu()", 1000);
}

function resetMenu() {
	if(timer) { clearInterval(timer); timer = null; }
	
	var Obj = new Object();
	Obj = { home: '-324px', 
			company: '-270px', 
			furnishings: '-204px',
			process: '-130px',
			contact: '-68px',
			clients: '-3px' };
	
	$('#menubarhr').stop().animate( { backgroundPosition : Obj[currMenu] + ' -1px' });
	MenuActive = 0;
}

function returnMenu() {
		MenuActive = 2;
}

function checkMenu() {	
	if(MenuActive == 2) resetMenu();
}
