$(document).ready(function() {
slides = put_in_slides();
$('#mainimg ul').html(slides);
$('#mainimg ul').data('currLI','one');
setInterval('fader()',10000);
$('#container #inner #header li ul').css({
left: 'auto',
display: 'none'
});
$('#container #inner #header > ul li').hover(function() {
$(this)
.find('ul')
.stop(true,true)
.slideDown(500);
}, function() {
$(this)
.find('ul')
.stop(true,true)
.slideUp(500);
})
$("#files").hide();
$("p.fileslink").removeClass('invisible');
$(".images").click(function() {
$("#files").toggle(1250);
return false;
});
$("#first").focus;
setTimeout(function() {
$("#mainformcont").slideUp('slow');
},4000);
$(".moreinfo").click(function() {
$('body').css('overflow-y', 'hidden');
$('<div id="overlay"></div>').css('opacity', '0').appendTo('body').animate({'opacity': '0.5'}, 'slow');
$('<div id="message_container"></div>').appendTo('body');
$('<p id="first"></p>').appendTo('#message_container').hide().text('Step 1: Fill in the form and we will consider your wood floor. If it is suitable we will make you an offer by email.');
$('<p id="second"></p>').appendTo('#message_container').hide().text('Step 2: You email back if the offer is acceptable. If so, we will contact you to agree delivery and payment details by phone or email.');
var top = ($(window).height() - $('#message_container').height()) / 2;
var left = ($(window).width() - $('#message_container').width()) / 2;
$("#message_container").css({
'top': top + $(document).scrollTop(),
'left': left
}).show('slow',function() { 
$('#first').fadeIn('slow',function() {
setTimeout(function() {
$('#first').fadeOut('slow');
},5000);
});
});
setTimeout(function() {
$("#second").fadeIn('slow');
},7000);
setTimeout(function() {
$('#second').fadeOut('slow',function() {
$("#message_container").slideUp('slow',function() {
$(this).remove();
$('#overlay').remove();
$('body').css('overflow-y', 'auto');
});
});
},12000);

return false;
});
});

function fader() {
var currID = $('#mainimg ul').data('currLI');
var currLiStr = '#mainimg ul li#' + currID;
nextID = (currID == 'four') ? 'one' : $(currLiStr).next().attr('id');
nextLiStr = $('#mainimg ul li#' + nextID);
$(currLiStr).fadeOut(3000);
$(nextLiStr).fadeIn(2000);
$('#mainimg ul').data('currLI',nextID);
}

function put_in_slides() {
var slides = '<li id="one"><a href=""><img src="/files/images/mainimg.jpg" alt="slide1" /></a></li>';
slides += '<li id="two"><a href=""><img src="/files/images/image2.jpg" alt="slide2" /></a></li>';
slides += '<li id="three"><a href=""><img src="/files/images/image3.jpg" alt="slide3" /></a></li>';
slides += '<li id="four"><a href=""><img src="/files/images/image4.jpg" alt="slide4" /></a></li>';
return slides;
}

