/*$(document).ready(function() {
	jQuery("a[href^=http]:not(a[href^=http://"+document.location.host+"])").attr('target','_blank');
}
);
		$("div.scrollable").scrollable({
			size: 3
		});

*/

function thanksDisplay() {
	$('.email-popup-inner','#email-popup').html($('#thanks-content').html());
	$('#email-popup').show();
	$('#email-popup .close').click(function(){
		$('#email-popup').hide();
	})
}
var currentEvent = 0;
function rotateCities() {
	jQuery('div.cityevent').eq(currentEvent).hide();
	jQuery('img.home-city').eq(currentEvent).hide();
	jQuery('a.home-city-link').eq(currentEvent).hide();
	if (currentEvent<jQuery('img.home-city').length-1) {
		currentEvent++;
	} else {
		currentEvent = 0;
	}
	jQuery('div.cityevent').eq(currentEvent).show();
	jQuery('img.home-city').eq(currentEvent).show();
	jQuery('a.home-city-link').eq(currentEvent).show();
}

$(document).ready(function(){
	setInterval('rotateCities()',5000);
	
	/*$('#regForm').submit(function(){
		window.open('https://intelligentreg.net/ebay/OnLocation/chicago/');
		return false;
	});*/
	
	$('#menu>ul>li:not(.active)>span:not(.ds)').hover(
			function(){
				$(this).parent().addClass('hover');
				$(this).find('.menu-down').width($(this).find('.menu-down ul').width());
			},
			function(){
				$(this).parent().removeClass('hover');
				$(this).find('.menu-down').width('auto');
			}
	)
	$('#submenu>ul>li:not(.active)').hover(
		function(){
			if ( $(this).find('.menu-down').length ) {
				$(this).addClass('sub-hover');
				$(this).find('.menu-down').width($(this).find('.menu-down ul').width());
			}
		},
		function(){
			if ( $(this).find('.menu-down').length ) {
				$(this).removeClass('sub-hover');
				$(this).find('.menu-down').width('auto');
			}
		}
	)
	
	$('.search-menu>li:eq(2)>a','#header').click(function(){
		$('.email-popup-inner','#email-popup').html($('#email-content').html());
		$('.sign-up','#email-popup').attr('value','');
		$('#email-popup').show();
		$("#newsletter_signup_form input").eq(0).focus();
		$("#newsletter_signup_form").ajaxForm({
			dataType: "json",
			success: function(response) {
						if (response.error) {
							var errors = '';
							$.each(response.error, function(index, value) {
								errors += value + "<br />";
							});
							$("div.req","#email-popup").html(errors);
						} else if(response.success) {
							thanksDisplay();
						}
					}
		});
		$('.close','#email-popup').click(function(){
			$('#email-popup').hide();
		})
		return false;
	});
	$("a.share, div.news-share a").addClass("addthis_button").attr('href','http://addthis.com/bookmark.php?v=250&amp;username=xa-4b65a59f234de84b');
	$("a.bmark").click(function(){return addthis_sendto('favorites')});
	 addthis_options         = 'email, digg, delicious, facebook, linkedin, twitter';
	$("div.scrollable").scrollable({
		clickable: false,
		size: 3
	});
})