function gallery() {

timeOut = 10;
obj= document.getElementById("scroller");

picTime = 5000;
minPic = 0;
maxPic = $("#slides img").length;
img = $("#slides img");
img.eq(minPic).fadeIn(500);

x=setTimeout("picCount()",picTime);


$("#menuBack").css("opacity","0.5");
$("#menu").animate({"top": "250px"}, 1000, "swing");
$("#menu ul").slideDown(2000);

$("#contentBack").css("opacity","0.5");
$("#content").slideDown(1000);

$("#contentBack2").css("opacity","0.5");
$("#content2").slideDown(1000);

$("#contentBack3").css("opacity","0.5");
$("#content3").slideDown(1000);

$("#designBack").css("opacity","0.5");
$("#design").slideDown(1000);

var thumbs = $("#thumbs ul li");
var full = $("#full img");
pic = 0;
$("#thumbs ul li b").css("opacity","0.5");

thumbs.eq(pic).children("b").slideDown(500);

thumbs.click(function() {
current = ($(this).index());

if (current != pic) {

thumbs.eq(pic).children("b").slideUp(500);
full.eq(pic).fadeOut(600);
pic=current;
thumbs.eq(pic).children("b").slideDown(500);
full.eq(pic).fadeIn(2000);
}

});

$("#menu ul li a").mouseover(function() {
$(this).animate({"backgroundPosition": "(0px 0px)"}, 700, "swing");
});
$("#menu ul li a").mouseout(function() {
$(this).animate({"backgroundPosition": "(-250px 0px)"}, 700, "swing");
});
$("#menu ul li a").click(function() {
$(this).css("outline","0");
$(this).animate({"backgroundPosition": "(-250px 0px)"}, 700, "swing");
});


/* scroller */
var htmlStr = $("#scroller").html();
$('#scroller').append(htmlStr);

/* stop/startt timer */
$("#scroller").mouseout(function() {
clearTimeout(t);
x=setTimeout("picCount()",picTime);
});
$("#scroller").mouseover(function() {
clearTimeout(x);
t=setTimeout("timedCount()",timeOut);
});

$("#slides").mouseout(function() {
x=setTimeout("picCount()",picTime);
});
$("#slides").mouseover(function() {
clearTimeout(x);
});


$(".question").click(function() {
	if (this.className.indexOf("clicked") == -1) {
		$(".question").children("div").slideUp(250);
		$(".question").removeClass("clicked");
		$(this).addClass("clicked");
		$(this).children("div").slideDown(250);
	}
	else {
		$(this).removeClass("clicked");
		$(this).children("div").slideUp(250);
	}
});

/* construction */

$(".constructImages li").hide();
var constructPos = $("#construct li");
var constructImgPos = $(".constructImages li");

constructImgPos.eq(0).show();

$("#construct li").click (function(){
if (this.className.indexOf('clicked') == -1) {
$("#construct li").removeClass('clicked');
$(this).addClass('clicked');
constr = ($(this).index())
constructImgPos.slideUp(500);
constructImgPos.eq(constr).children("div").hide();
constructImgPos.eq(constr).show();
constructImgPos.eq(constr).children(":first").slideDown(500);
}
});


/* customer designs */

$(".constructImages2 li").hide();
var constructPos2 = $("#construct2 li");
var constructImgPos2 = $(".constructImages2 li");

constructImgPos2.children("div").hide();
constructImgPos2.eq(0).show();
constructImgPos2.eq(0).children(":first").slideDown(500);

$("#construct2 li").click (function(){
if (this.className.indexOf('clicked') == -1) {
$("#construct2 li").removeClass('clicked');
$(this).addClass('clicked');
constr2 = ($(this).index())
constructImgPos2.slideUp(500);
constructImgPos2.eq(constr2).children("div").hide();
constructImgPos2.eq(constr2).show();
constructImgPos2.eq(constr2).children(":first").slideDown(500);
}
});

/* design */

$(".designsImages li").hide();
var designPos = $("#designs li");
var designImgPos = $(".designsImages li");

designImgPos.eq(0).show();

$("#designs li").click (function(){
if (this.className.indexOf('clicked') == -1) {
$("#designs li").removeClass('clicked');
$(this).addClass('clicked');
des = ($(this).index())
designImgPos.slideUp(500);
designImgPos.eq(des).children("div").hide();
designImgPos.eq(des).show();
designImgPos.eq(des).children(":first").slideDown(500);
}
});


$(".next").click (function(){
$(this).parent().hide();
$(this).parent().next().fadeIn(500);

});
$(".previous").click (function(){
$(this).parent().hide();
$(this).parent().prev().fadeIn(500);

});

$(".nextd").click (function(){
$(this).parent().hide();
$(this).parent().next('div').fadeIn(500);

});
$(".previousd").click (function(){
$(this).parent().hide();
$(this).parent().prev('div').fadeIn(500);

});

/* ads opacity */
$("#ads img").fadeTo(100,0.4);

$("#ads img").mouseover (function(){
$(this).fadeTo(500,1.0);
});

$("#ads img").mouseout (function(){
$(this).fadeTo(500,0.4);
});

}
/* auto run image control */ 
function timedCount() {
	pos = 1;
	scrollHeight = $(".testimonials").height();
	scrollPos = $("#scroller").position().top;
	scrollPos--;
	if ((scrollPos + scrollHeight) < 0) {scrollPos = 15; $("#scroller").css("top","0px"); pos = 2;}
	if (pos == 1) {
	obj.style.top = scrollPos+"px";
	}
	t=setTimeout("timedCount()",timeOut);
}

function picCount() {
	img.eq(minPic).fadeOut(1000);
	minPic++;
	if (minPic == maxPic) {minPic=0;}
	img.eq(minPic).fadeIn(1000);
	x=setTimeout("picCount()",picTime);
}

window.onload=gallery; 

