
jQuery(window).ready(function($){
							  
	//png fix
	jQuery(document).pngFix();
	
	//brick style layout
	jQuery('#loop-container').masonry({ columnWidth: 240, itemSelector: '.hentry', resizeable: false });	
 
	
	//who page
	jQuery('.bio-wrapper').hide();
	
	jQuery('.person-wrapper').live('mouseenter',function(event){
		event.stopPropagation();
		jQuery('.bio-wrapper').stop(true , true);
		jQuery(this).children('.bio-wrapper').fadeIn(400);
		
		return false;
	});
	jQuery('.person-wrapper').live('mouseleave',function(event){
		event.stopPropagation();
		jQuery(this).children('.bio-wrapper').hide();
		return false;
	});
	
	//ipad support:
	jQuery('.person-wrapper').live('touchstart',function(event){
		if(jQuery(this).children('.bio-wrapper').first().css("display") == 'none'){
			event.stopPropagation();
			jQuery('.bio-wrapper').stop(true , true);
			jQuery('.bio-wrapper').hide();
			jQuery(this).children('.bio-wrapper').fadeIn(400);
			return false;
		}
	});
	
	jQuery('#people-slider-wrapper .scrollingHotSpotLeft').live("mouseenter",function(){ jQuery('#slider-prev').css('backgroundPosition','bottom'); });
	jQuery('#people-slider-wrapper .scrollingHotSpotLeft').live("mouseleave",function(){ jQuery('#slider-prev').css('backgroundPosition','top'); });
	jQuery('#people-slider-wrapper .scrollingHotSpotRight').live("mouseenter",function(){ jQuery('#slider-next').css('backgroundPosition','bottom'); });
	jQuery('#people-slider-wrapper .scrollingHotSpotRight').live("mouseleave",function(){ jQuery('#slider-next').css('backgroundPosition','top'); });
	
	jQuery("#people-slider-wrapper").smoothDivScroll({startAtElementId:"person-19"});
	
	
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
		/*$("#people-slider-wrapper .scrollingHotSpotRight").bind('touchstart', function(){
	        
	    });
	    $("#people-slider-wrapper .scrollingHotSpotLeft").bind('touchstart', function(){
	        
	    });*/
	    
	    $("#people-slider-wrapper .scrollingHotSpotLeft").bind('touchend', function(){
	    	$("#people-slider-wrapper").smoothDivScroll("stopAutoScroll");
	    });   
	    $("#people-slider-wrapper .scrollingHotSpotLeft").bind('touchend', function(){
	    	$("#people-slider-wrapper").smoothDivScroll("stopAutoScroll");
	    });   
	    
	}
	
	/*jQuery('#people-slider-wrapper .scrollingHotSpotRight').live("click",function(){
	
	});
	jQuery('#people-slider-wrapper .scrollingHotSpotLeft').live("click",function(){
	
	});*/
	
	jQuery('.hoverable').hover(function(){
		jQuery(this).css('backgroundPosition','bottom');
	},
	function(){
		jQuery(this).css('backgroundPosition','top');
	});
	
	
	//small - box sliders
	jQuery('.type-post').each(function(index) {
		var fulllink = jQuery(this).find(".fulllink");
		var img = jQuery(this).find("img");
		var slidedown = jQuery(this).find(".slide-down")
		var slideup = jQuery(this).find(".slide-up")
		$(fulllink).hover(function(event){
			event.stopPropagation();
			jQuery('.slide-down').stop(true , true);
			jQuery('.slide-up').stop(true , true);
			
			$(slidedown).slideToggle(600, function(){return false;});
			$(slideup).slideToggle(600, function(){return false;});
			
			return false;
		});
		
		$(img).hover(function(event){
			event.stopPropagation();
			$(slidedown).slideToggle(600);
			$(slideup).slideToggle(600);
			return false;
		});
	});

							
	if ($.browser.webkit) {
		$('input').attr('autocomplete', 'off');
	}
					
	$('#s').attr("tabindex", "10");
	$('#searchsubmit').attr("tabindex", "11");
	
	//add needed class to checkbox for styling
	$('#choice_6_1').addClass('styled');
	
	//login form, change action based on selected value							
	jQuery("#select-list").change(function(){
		var selectedValue = jQuery(this).find(":selected").val();		
		if (selectedValue=="emailROI") {
			jQuery('#login-form').attr({ action: 'http://emailer.emailroi.com/dbadmin/login.pl' });
		} else if (selectedValue=="ecomROI") {
			jQuery('#login-form').attr({ action: 'https://secure.eroi.com/servlet/com.gcm.servlet.security.SecureLogin' });
		} else if (selectedValue=="eventROI") {
			jQuery('#login-form').attr({ action: 'https://secure.eroi.com/servlet/com.gcm.servlet.security.SecureLogin' });
		} else if (selectedValue=="blogROI") {
			jQuery('#login-form').attr({ action: 'http://blog.eroidelivers.com/bins/mt/mt.cgi' });
		} else {
			jQuery('#login-form').attr({ action: 'http://emailer.emailroi.com/dbadmin/login.pl' });
		}
	});
	
	//custom dropdown menu styling						
	$('#select-list').selectmenu({style:'dropdown'});
	
	//homepage cycle
	$('.slideup').cycle({
		fx:      'custom',
		cssBefore: {
			top:  17,
			opacity: 0,
			zIndex: 1
		},
		animOut: {
			opacity: 0,
			top:  -17
		},
		animIn: {
			top: 0,
			opacity: 1
		},
		cssAfter: {
			zIndex: 0
		},
		delay: -1000
	});
	
	
	//search slide
	$('.scroll').slideto({
		target : '#search',
		speed  : 'slow'
	});

	//form validation
	var initialVal = $('input[type="text"]').val();
	$('input[type="text"]').focus(function() {
		$(this).val("");
	});						   
	$("#newsletterForm").validate({
		rules: {
			Email: {
				required: true,
				email: true
			}
		}

	});
	$("#newsletterForm").submit(function() {
		if ($("#newsletterForm #email").hasClass("error")) {
			$("#newsletterForm #label-email").html("* Email address");
			$("#newsletterForm #label-email").addClass("custom-error");
			return false;
		} else {
			$(this).ajaxSubmit(); 
			$("#newsletterForm #label-email").hide();
			$("#newsletterForm #email").hide();
			$("#newsletterForm h2").hide();
			$("#newsletterForm .submit").hide();
			$("#thanks").fadeIn();
			$("p.signup-intro").html("<h3 id='thanks'>Thank You!</h3><em class='gray'>You are now on our list. We look forward to giving you great content straight to your inbox.</em>");
			$("p.signup-intro-lightbox").html("<em class='gray'>You are now on our list. We look forward to giving you great content straight to your inbox.</em>");
			return false; 
		}
	});	
});
	
	
							   

