$(document).ready(function(){
	/*Marketing large graphic*/
	$('.markettext').animate({bottom:"0"}, 1000).slideDown().animate({opacity:".9"}, 7000);
	
	$('#marketing ul a').click(function(){		
			var matchreg = /\d+\b/;		
			var location = $(this).attr("href");
			var imgnum = location.match(matchreg);
			if ($(this).parent("li").attr("class") == "next") {
				if (startslide == lastslide) {
					imgnum = 1;
				} else {
					imgnum = startslide + 1;
				}
			}
			if ($(this).parent("li").attr("class") == "prev") {
				if (startslide == 1) {
					imgnum = lastslide;
				} else {
					imgnum = startslide - 1;
				}
			}
			location = "/?ad=" + imgnum;
			startslide = imgnum;
			
			$('#marketimage').load("/images/home-marketing/" + imgnum +".html").ajaxComplete(function(request, settings){
				$('.markettext').hide();
				$('.markettext').animate({bottom:"0"}, 200).slideDown();
			 });
			return false;
	});
	
	/*small ads */
	$('#ads img').animate({opacity:".9"}, 0)
	$('#ads img').hover(
      function () {
        $(this).animate({opacity:"1"}, 100)
      },
	  function () {
        $(this).animate({opacity:".9"}, 200)
      }
	);
	
	
	
	$('#flexible-options').hover(function () {
        $(this).addClass("hover");
      },
	  function () {
        $(this).removeClass("hover");
      }
	);
	$('#flexible-options').click(function() {
		location.href = $(this).children('a').attr("href");
	});
	
	/*apply button*/ 
		/*note filter is to remove effect from IE */
	$('#apply img').animate({opacity:".9", filter:""}, 0)
	$('#apply img').hover(
      function () {
        $(this).animate({opacity:"1", filter:""}, 0)
      },
	  function () {
        $(this).animate({opacity:".9", filter:""}, 0)
      }
	);
	
});

var i;

