$(function() { 
	//EQUAL HEIGHT CODE
	var homeLeft = $('#home-left');
	var sidebar = $('#sidebar');
	var calendar = $('#calendar-content');
	var initiatives = $('#initiatives-content');
	var authors = $('#authors');
	var homeContent = $('#home-content');
	
	//home-content / authors equal height
	(authors.height() < homeContent.height()) 
		? authors.height(homeContent.height())
		: homeContent.height(authors.height());
	
	//sidebar and homeleft equal height
	(sidebar.height() < homeLeft.height()) 
		? sidebar.height(homeLeft.height()+10)
		: homeLeft.height(sidebar.height()-10);
			
	//calendar and initiatives equal height
	var calPadding = ($.browser.safari) ? 24 : 24;
	var initPadding = ($.browser.safari) ? 0 : 24;
	(calendar.height() < initiatives.height()) 
		? calendar.height(initiatives.height()-initPadding)
		: initiatives.height(calendar.height()+calPadding);	
		

		
	//BROWSER CHECK
	if(!$.browser.safari) {
		$('#social input[type=text], #social input[type=text]').each(function() {
			var placeholder = $(this).attr('placeholder');
			var value = $(this).attr('value');
			
			if(value == '') $(this).attr('value',placeholder)
		});
		
		$('#social input[type=text], #social input[type=text]').live('focus', function() {
			var placeholder = $(this).attr('placeholder');
			var value = $(this).attr('value');
			
			if(value == placeholder) $(this).attr('value','');
		});
		
		$('#social input[type=text], #social input[type=text]').live('blur', function() {
			var placeholder = $(this).attr('placeholder');
			var value = $(this).attr('value');
			
			if(value == '') $(this).attr('value',placeholder);
		});
	}
	
	if($.browser.msie && $.browser.version <= '8.0') {
		$('#navigation li:last-child a').css({ 'backgroundImage': 'none', 'background':'#f5dc10','color':'#000' });
		$('#navigation li:last-child[class=active] a').css({ 'background':'url(images/bg_slideshow-learn-about.png) center right no-repeat', 'color':'#fff' });
		$('#navigation li:last-child a').hover(function(){ 
			$(this).css({ 'background':'url(/wp-content/themes/chalkboard/images/bg_slideshow-learn-about.png) center right no-repeat', 'color':'#fff' });
		},function(){ 
			$(this).css({ 'backgroundImage': 'none', 'background':'#f5dc10','color':'#000' });
		});
	}
	
	// SPONSORS / INITIATIVES DEMO
	var sponsorsLink = $('#initiatives .tabs a');
	var sponsorsContent = $('#initiatives #initiatives-content');
	
	sponsorsLink.click(function(){
		var sponsorsHTML = '';
		var height = initiatives.height();
		
		if($(this).attr('class') != 'active' && $(this).text() != 'Sponsors')
		{
			sponsorsHTML += '<div class="row">\n';
			sponsorsHTML += '  <a href="http://www.openbooksproject.org/" target="_blank" title=""><img src="/wp-content/themes/chalkboard/images/fpo_open-book.jpg" alt="" /></a>\n';
			//sponsorsHTML += '  <a href="http://chalkboardproject.org/what-we-do/oregon-mentoring-program/" target="_blank" title=""><img src="/wp-content/themes/chalkboard/images/fpo_mentoring-educators.jpg" alt="" /> </a>\n';
			sponsorsHTML += '  <a href="http://educators4reform.org/" target="_blank" title=""><img src="/wp-content/themes/chalkboard/images/fpo_educators-4-reform.jpg" alt="" /> </a>\n';
			sponsorsHTML += '</div>\n';
			sponsorsHTML += '<div class="row">\n';
			sponsorsHTML += '  <a href="http://blog.chalkboardproject.org/" target="_blank" title=""><img src="/wp-content/themes/chalkboard/images/fpo_chalkbloggers.jpg" alt="" /></a>\n';
			sponsorsHTML += '  <a href="http://educators4reform.org/" target="_blank" title=""><img src="/wp-content/themes/chalkboard/images/fpo_class.jpg" alt="" /> </a>\n';
			sponsorsHTML += '</div>';
		}
		else
		{
			sponsorsHTML += '<div class="row">\n';
			sponsorsHTML += '  <a href="http://www.ocf1.org/" target="_blank" title="" style="margin:0 7px"><img src="/wp-content/themes/chalkboard/images/fpo_sponsors-ocf.jpg" alt="" /></a>\n';
			sponsorsHTML += '  <a href="http://www.tfff.org/" target="_blank" title="" style="margin:0 7px"><img src="/wp-content/themes/chalkboard/images/fpo_sponsors-ford.jpg" alt="" /> </a>\n';
			sponsorsHTML += '  <a href="http://www.millerfnd.org/" target="_blank" title="" style="margin:0 7px"><img src="/wp-content/themes/chalkboard/images/fpo_sponsors-miller.jpg" alt="" /> </a>\n';
			sponsorsHTML += '</div>\n';
			sponsorsHTML += '<div class="row" style="text-align:left;">\n';
			sponsorsHTML += '  <div class="right" style="width:278px; margin-right:50px; margin-top:-20px"><a href="http://www.mmt.org/" target="_blank" title=""><img src="/wp-content/themes/chalkboard/images/fpo_sponsors-meyer.jpg" alt="" /></a> <a href="http://www.jeld-wenfoundation.org/" target="_blank" title=""><img src="/wp-content/themes/chalkboard/images/fpo_sponsors-jeldwen.jpg" alt="" /></a></div>\n';
			sponsorsHTML += '  <a href="http://www.collinsfoundation.org/" target="_blank" title="" style="position:absolute; margin-left:40px;"><img src="/wp-content/themes/chalkboard/images/fpo_sponsors-collins.jpg" alt="" /></a>\n';
			sponsorsHTML += '</div>';
		}
		
		sponsorsContent.html(sponsorsHTML);
		initiatives.height(height)
		
		$('#initiatives .tabs li').removeClass();
		$(this).parent('li').addClass('active');
		
		return false;
	});
	
});
