if (document.documentMode==8) {
	Cufon.replace('#mnav a:not(li li a), .second #leftCol h2:not(.content h2), .links h2 a, .links h3 a, #pnav .donate, #pnav .contact, .home #body .hometext p, .second #snav a', {
		hover: true,
		fontFamily: 'Interstate'
	});
} else {
	Cufon.replace('#mnav a, .second #leftCol h2:not(.content h2), .links h2 a, .links h3 a, #pnav .donate, #pnav .contact, .home #body .hometext p, .second #snav a', {
		hover: true,
		fontFamily: 'Interstate'
	});
}


Cufon.replace('.second #leftCol h1:not(.content h1), .prev, .next, .buttonLink', {
	hover: true,
	fontFamily: 'Interstate-Reg'
});

//var $ = jQuery.noConflict();
$(document).ready(function() {
	
	//Submenu
	
	$(" #mnav ul ul ").css({display: "none"}); // Opera Fix
	$(" #mnav ul li").hover(function(){
			$('#body').css('zIndex', 1);
			$('#header').css('zIndex', 15);
			$('#mnav').css('zIndex', 20);
			$('#pnav').css('zIndex', 16);
			$("#mnav ul").css('zIndex', 1000);
			$(this).find('ul:first').css({visibility: "visible",display: "none"}).show();
			$(this).find('ul:first').css('zIndex', 1500);
			},function(){
			$(this).find('ul:first').css({visibility: "hidden"});
			});
	
	
	//Animate home page boxes
	$('#home_watchvideo').fadeIn('slow', function() {
		$('#home_give').fadeIn('slow', function() {
			$('#home_share').fadeIn('slow', function() {
				$('#home_apply').fadeIn('slow', function() {
   			});	
			});
		});
	});



	if(!window.XMLHttpRequest) {
		$('body').pngFix();
		
		//HOVERS for IE6
		$('#mnav a').hover(
		function(){
			var c = $(this).parent('li').attr('class').replace(' selected', '')
			var c = c + '-hover';
			//console.log(c + '-hover');
			$(this).parent('li').addClass(c);
		}, function(){
			$(this).parent('li').removeClass('student-info-hover programs-hover volunteer-hover about-hover partners-hover news-events-hover')
		});
		
		//SELECTED -- to overcome poor multi-classing in IE
		$('#mnav li').each(function(){
			if ($(this).hasClass('selected')) {
				var c = $(this).attr('class').replace(' selected', '')
				var c = c + '-selected';
				$(this).removeClass('selected').addClass(c);
			}
		});
		
	};
	
	
	//CYCLE sponsors
	//$('#sponsorlist').cycle('fade');
	
	//SEARCHBOX swap text
	$('input.searchbox').focus(function(){
		if ($(this).attr('value') == 'Search'){
			$(this).attr('value', '');
		};
	});
	
	$('input.searchbox').blur(function(){
		if ($(this).attr('value') == ''){
			$(this).attr('value', 'Search');
		};
	});
	
		
	//ACCORDIONS
	//set up
	$('.content .col1 h3 + div').css('position', 'relative').slideUp(0);
	$('.content .col1 h3').wrapInner('<a href="#"></a>').append('<img class="acrdn-btn" src="/wp-content/themes/coachart/img/basic/arrow-right.gif" alt="" />');
	$('.content .col1 h3:first').find('.acrdn-btn').attr('src', '/wp-content/themes/coachart/img/basic/arrow-down.gif');
	$('.content .col1 h3 + div:first').show();
	
	//accordion function
	$('.content .col1 h3').live('click', function(){
		if($(this).next('div').is(':visible')) {
			$(this).find('.acrdn-btn').attr('src', '/wp-content/themes/coachart/img/basic/arrow-right.gif');
		} else {
			$(this).find('.acrdn-btn').attr('src', '/wp-content/themes/coachart/img/basic/arrow-down.gif');
		}
		$(this).next('div').width(380).slideToggle(500);
		return false;
	})
	
	//SUCCESS STORIES
	if ($('#success-stories').length > 0) {
		$('#success-stories').cycle({ 
		    fx:     'fade', 
		    speed:  'fast', 
		    timeout: 0, 
		    next:   '.next', 
		    prev:   '.prev' 
		});
	}

	
	if((window.XMLHttpRequest && document.all) || !window.XMLHttpRequest){
		//sets the body height correctly in ie6 and ie7
		
		var bodyh = $('.second #body #leftCol').height();
		//alert(bodyh);
		//$('.second #body .content .wrap').css('height', (bodyh - 40) + 'px');
		
		if (bodyh < 960){
			bodyh = 960;
		} else {
			$('.second #rap').css('height', (bodyh + 195) + 'px');
			//$('.second #body').css('height', (bodyh + 35) + 'px');
		}
		//alert(bodyh);
	
		//fix bottom padding issue
		$('.content p').each(function(){
			if( $(this).next().length <= 0 ){
				$(this).addClass('last-p');
			}
		});	
	}
	
	
	
	
	
	/*PARTNERS*/
	
/*
	$('#slideshow').before('<ul id="nav">').cycle({ 
	    fx:     'fade', 
	    speed:  'fast', 
	    timeout: 0, 
	    pager:  '#nav', 

	    // callback fn that creates a thumbnail to use as pager anchor 
	    pagerAnchorBuilder: function(idx, slide) { 
	        return '<li><a href="#"><img src="' + slide.src + '" width="50" height="50" /></a></li>'; 
	    } 
	});*/

	/*CALL TO ACTION*/
/*
	$('.links h3 a').hover(function() {
		console.log($(this).parent().parent().find('h2 a').css('background-image',''));
	});*/
	
	
	var swap_text_boxes = [];

  function init_swap_text_boxes(){
    //Store the default value for each box
    var target = $('input[type=text][value].swaptextbox,textarea.swaptextbox');
    target.each(function() {
      swap_text_boxes[$(this).attr('id')] = $(this).attr('value');
    });
    //Add focus and blur events to set or clear the value
    target.bind('focus', function() {
      if($(this).val() == swap_text_boxes[$(this).attr('id')]) {
        $(this).val('');
      }
    });
    target.bind('blur', function() {
      if($(this).val() == '') {
        $(this).val(swap_text_boxes[$(this).attr('id')]);
      }
    });
  }

  init_swap_text_boxes();

});