function nextPage()
{
	jQuery.newpage = jQuery.vcCarousel.currPage +1;
	if( jQuery.newpage == jQuery.vcCarousel.totalPages  )
		{
		jQuery.newpage=0;
		}
	changePage(null, jQuery.newpage);
	setTimeout("nextPage();",6000);
}


function changePage(ev, page) {
	if (!jQuery.vcCarousel.animated) {
		jQuery.vcCarousel.animated = true;
		if (page == null) {
			page = (parseInt(jQuery(this).attr('href').replace("#vc-carousel-",
					"")));
		}
		jQuery.vcCarousel.currPage = page;
		jQuery("div.carousel-navigation").find('a').each(function() {
			jQuery(this).removeClass('on');
			jQuery(this).addClass('off');
		});
		jQuery("#vc-carousel-" + page).removeClass('off');
		jQuery("#vc-carousel-" + page).addClass('on');
		jQuery('#homepage_brand').animate( {
			scrollLeft : page * (jQuery.vcCarousel.pageWidth * 1.05)
		}, 450, function callback() {
			jQuery.vcCarousel.animated = false;
		});
		return false;
	}
	return false;
}

jQuery(document)
		.ready(
				function() {
					setTimeout("nextPage();",6000);
					vcCarousel = {
						length : parseInt(jQuery('#homepage_brand ul > li > a').length)/2,
						pageWidth : 515
					};

					vcCarousel.totalPages = Math.round(vcCarousel.length / 4);
					if (vcCarousel.totalPages < (vcCarousel.length / 4)) {
						vcCarousel.totalPages++;
					}
					vcCarousel.totalWidth = ((Math.round(vcCarousel.length / 4) + 1) * vcCarousel.pageWidth);
					vcCarousel.currPage = 0;
					vcCarousel.animated = false;
					jQuery.vcCarousel = vcCarousel;
					jQuery('#homepage_brand ul').width(vcCarousel.totalWidth);
					jQuery('div.carousel-navigation').empty();
					if (vcCarousel.totalPages > 1) {
						var a = document.createElement('a');
						jQuery(a).attr('id', 'vc-carousel-0');
						jQuery(a).attr('href', '#vc-carousel-0');
						jQuery(a).addClass('on');
						jQuery(a).text('1');
						jQuery('div.carousel-navigation').append(a);
						jQuery('#vc-carousel-0').click(changePage);
						for (i = 1; i < Math.round(vcCarousel.totalPages); i++) {
							var a = document.createElement('a');
							jQuery(a).attr('id', 'vc-carousel-' + i);
							jQuery(a).attr('href', '#vc-carousel-' + i);
							jQuery(a).addClass('off');
							jQuery(a).text((i + 1));
							jQuery('div.carousel-navigation').append(a);
							jQuery('#vc-carousel-' + i).click(changePage);
						}
					}

				});



//This is email submiting stub 

jQuery(document).ready(
		function() {
			jQuery('#get_most_popular > form > input').focus(function(){
				jQuery(this).val('');
				jQuery(this).css("color","#000");
			});
			
			jQuery("a.submit_newsletter").click(function(){
				jQuery('#get_most_popular > form').submit()
					
				return false;
			});
		});