{
	var pageURI = 
    $(document).ready(function() {    
    footer();
    thankYou();
    if(pageName().toLowerCase()=='gallery.html')
        loadThumbNails();
	mainNavMenu();
   contactFormValidate();
    });
}
function queryString() {
    return (window.location.search.substring(1));
}
function pageName() {
var sPath = window.location.pathname;
return (sPath.substring(sPath.lastIndexOf('/') + 1));
}
var thumbMaps = { 
    'bdqss': [
      {'thumb': 'images/thumb_ss_lg.png', 'large':'images/bdqss_lg.jpg'},
      {'thumb': 'images/thumb_ss_lg1.png', 'large':'images/bdqss_lg1.jpg'},
      {'thumb': 'images/thumb_ss_lg2.png', 'large':'images/bdqss_lg2.jpg'},
      {'thumb': 'images/thumb_ss_lg3.png', 'large':'images/bdqss_lg3.jpg'}
      ],
    'bdqstip': [      
      {'thumb': 'images/thumb_stip_lg.png', 'large':'images/bdqstip_lg.jpg'},
      {'thumb': 'images/thumb_stip_lg1.png', 'large':'images/bdqstip_lg1.jpg'},
      {'thumb': 'images/thumb_stip_lg2.png', 'large':'images/bdqstip_lg2.jpg'},
      {'thumb': 'images/thumb_stip_lg3.png', 'large':'images/bdqstip_lg3.jpg'}
      ]
};

function loadThumbNails() {
    var imageList = queryString();
    var thumbMap = thumbMaps[imageList];
    for(x=0;x<thumbMap.length;x++) {
        var func="selectThumbNail('" + imageList + "',"+x+")";
        var link=$('<a></a>').attr('href','#');
        link.attr('onClick',func);
        var element=$('<img />').attr('id','thumb' + x);
        element.attr('src',thumbMap[x].thumb);
        link.append(element);
        $('#thumbNails').append(link);
        
    }
    selectThumbNail(imageList,0);
}

function selectThumbNail(imageList, selectedImage) {
    var thumbMap = thumbMaps[imageList];
    var imageURL = 'url(' + thumbMap[selectedImage].large + ')';
    $('#largeImage').css('backgroundImage',imageURL);
    for(x=0;x<thumbMap.length;x++) {
        $('#thumb'+x).css('border-color','silver');
    }
    $('#thumb'+selectedImage).css('border-color','blue');
}
function thankYou() {
    if (pageName().toLowerCase()=='contact.html') {
        if (queryString().toLowerCase()=='thankyou') {
          var msg="<p>Your message was successfully sent to By Design Quilting, LLC. We will contact you soon.</p>";
            var element = $(msg).addClass('thankYou');
            
            element.innerHTML = msg;
            $('#content-intro').prepend(element);
        }
    }
}
function contactFormValidate() {
    if ($("#contactForm").length==0) {
        return;
    }
      $("#contactForm").validate({
          rules : {
              customerName: "required",
              email: {required: true,
                      email: true
                      },
              email2: {required: true,
                       equalTo: "#email"
                      },
              customerQuestion: "required"
              },
          messages : {
              customerName: "Please enter your name.",
              phone: "Please enter your phone number.",
              email: {required: "Please enter your email address.",
                      email: "Please enter your email address."
                      },
              email2: {required: "Please re-enter your email address.",
                       equalTo: "Please enter the same email address in both email boxes."
                       },
              customerQuestion: "Please answer the question."
              }
              }
              );
}
function popUp(location, width, height,scrollbars){
	width=width+20; //accounts for the scrollbar on the right side in IE
	height=height+20;
  if (typeof scrollbars === 'undefined') {
    scrollbars=0
  }
	window.open(location, "_blank", "height="+height+",width="+width+",scrollbars="+scrollbars);
	return false;
	}

function footer() {
  var tM = [];
  var i = 0;
    tM[i++] = "<p>&copy;2010 By Design Quilting. A website by Janzer Creative.<br />";
	tM[i++] = "Quilt images &copy;Pat Barry or used with permission from customers. Reproduction of any kind is strictly prohibited without express written permission.</p>";
$('#footer').append(tM.join(''));
}
function mainNavMenu() {
  var tM = [];
  var i = 0;
  tM[i++]='<ul id="mainNavList" class="lamp">';            
  tM[i++]='<li><a href="templates.html">Longarm Templates</a></li>';
  //tM[i++]='<li><a href="booklets.html">A Dozen Ideas About&#8230;</a></li>';
  tM[i++]='<li><a href="tip_sheets.html">PBQ Tip Sheets</a></li>';
  //tM[i++]='<li><a href="videos.html">Video How To&#39;s &#40;future&#41;</a></li>';
  tM[i++]='<li><a href="article_book.html">Articles &#38; Books</a></li>';
  tM[i++]='<li class="noLava"><hr /></li>';
  tM[i++]='<li><a href="quilting.html">Custom Quilting</a></li>';
  tM[i++]='<li><a href="classes.html">Classes</a></li>';
  tM[i++]='<li><a href="shows.html">Annual Show Schedule</a></li>';
  tM[i++]='<li><a href="sales.html">Gammill Sales</a></li>';
  tM[i++]='<li class="noLava"><hr /></li>';
  tM[i++]='<li><a href="about.html">Meet Pat</a></li>';
  tM[i++]='<li><a href="links.html">Links</a></li>';
  tM[i++]='<li><a href="contact.html">Contact Us</a></li>';
  if (pageName()=="index.html")
    tM[i++]='<li><a href="index.html">Home</a></li>';
  else
    tM[i++]='<li><a href="/">Home</a></li>';
  tM[i++]='</ul>';  
  $('#mainNav').append(tM.join(''));
	$('#mainNavList').lavaLamp({speed: 500});
}
