jQuery(document).ready(function() {
	$('.contact').click(openContact);
	$('.agent').click(openAgent);
	$('.video').click(resetMenu);
	$('.gallery').click(resetMenu);
	$('#slideshow IMG:first').addClass('active');
	$('#slideshow IMG:first').css({
		opacity: 1.0
	});
	$('#slideshow_port .img_portfolio:first').addClass('active');
	$('#slideshow_port .img_portfolio:first').css({
		opacity: 1.0
	});

});

function initBtnGallery() {
	if (imgGallTot <= 1) {
		$('.next').hide();
		$('.previous').hide();
	} else if (step == 1) {
		$('.next').show();
		$('.previous').hide();
	}
	$('.next').click(slideSwitchNext);
	$('.previous').click(slideSwitchPrev);
}
function openContact() {
	$('#contact').show();
	$('.contact').addClass('selected');
	$('#agent').hide();
	$('.agent').removeClass('selected');
	return false;
}
function openAgent() {
	$('#contact').hide();
	$('.contact').removeClass('selected');
	$('#agent').show();
	$('.agent').addClass('selected');
	return false;
}
function resetMenu() {
	$('#contact').hide();
	$('.contact').removeClass('selected');
	$('#agent').hide();
	$('.agent').removeClass('selected');
}
function slideSwitchNext() {
	step++;
	if (step == 1) {
		$('.next').show();
		$('.previous').hide();
	} else if (step >= 1) {
		$('.next').show();
		$('.previous').show();
	}
	if (step == imgGallTot) {
		$('.next').hide();
		$('.previous').show();
	}
	$('#slideshow IMG').css({
		opacity: 0.0
	});
	var $active = $('#slideshow IMG.active');
	if ($active.length == 0) $active = $('#slideshow IMG:last');
	var $next = $active.next().length ? $active.next() : $('#slideshow IMG:first');
	$active.addClass('last-active');
	$next.css({
		opacity: 0.0
	}).addClass('active').animate({
		opacity: 1.0
	}, 1000, function() {
		$active.removeClass('active last-active');
	});
	return false;
}
function slideSwitchPrev() {
	step--;
	if (step == 1) {
		$('.next').show();
		$('.previous').hide();
	} else if (step >= 1) {
		$('.next').show();
		$('.previous').show();
	}
	if (step == imgGallTot) {
		$('.next').hide();
		$('.previous').show();
	}
	$('#slideshow IMG').css({
		opacity: 0.0
	});
	var $active = $('#slideshow IMG.active');
	if ($active.length == 0) $active = $('#slideshow IMG:last');
	var $next = $active.prev().length ? $active.prev() : $('#slideshow IMG:first');
	$active.addClass('last-active');
	$next.css({
		opacity: 0.0
	}).addClass('active').animate({
		opacity: 1.0
	}, 1000, function() {
		$active.removeClass('active last-active');
	});
	return false;
}
function initBtnGalleryPortfolio() {
	if (imgGallTot <= 1) {
		$('.next').hide();
		$('.previous').hide();
	} else if (step == 1) {
		$('.next').show();
		$('.previous').hide();
	}
	$('.next').click(slideSwitchNextPort);
	$('.previous').click(slideSwitchPrevPort);

}

function slideSwitchNextPort() {
	step++;

	if (step == 1) {
		$('.next').show();
		$('.previous').hide();
	} else if (step >= 1) {
		$('.next').show();
		$('.previous').show();
	}
	if (step == imgGallTot) {
		$('.next').hide();
		$('.previous').show();
	}
	$('#slideshow_port .img_portfolio').css({
		opacity: 0.0
	});
	var $active = $('#slideshow_port .img_portfolio.active');
	if ($active.length == 0) $active = $('#slideshow_port .img_portfolio:last');
	var $next = $active.next().length ? $active.next() : $('#slideshow_port .img_portfolio:first');
	$active.addClass('last-active');
	$next.css({
		opacity: 0.0
	}).addClass('active').animate({
		opacity: 1.0
	}, 1000, function() {
		$active.removeClass('active last-active');
	});
	return false;
}
function slideSwitchPrevPort() {
	step--;

	if (step == 1) {
		$('.next').show();
		$('.previous').hide();
	} else if (step >= 1) {
		$('.next').show();
		$('.previous').show();
	}
	if (step == imgGallTot) {
		$('.next').hide();
		$('.previous').show();
	}
	$('#slideshow_port .img_portfolio').css({
		opacity: 0.0
	});
	var $active = $('#slideshow_port .img_portfolio.active');
	if ($active.length == 0) $active = $('#slideshow_port .img_portfolio:last');
	var $next = $active.prev().length ? $active.prev() : $('#slideshow_port .img_portfolio:first');
	$active.addClass('last-active');
	$next.css({
		opacity: 0.0
	}).addClass('active').animate({
		opacity: 1.0
	}, 1000, function() {
		$active.removeClass('active last-active');
	});
	return false;
}

