
$(document).ready(function(){

var pageClass = $('body').attr('class');

$('a').click(function() {
	$(this).blur();	
})

//WHERE ARE YOU?
$('.' + pageClass).addClass('active');

//SIDEBAR
$('ul.sidenav li:not(.active) ul').hide();

//DL TOGGLES
$('dd').hide();
$('dt a').click(function() {
	$('dl dd:visible').hide();
	$(this).parent().next().fadeIn();
	return false;	
})

//HOMEPAGE FLASH
$('body.home div.flash-area').flash({
    src: 'media/home_holder.swf',
    width: 960,
    height: 315
});


//NEWS PAGES
$('body.news div#content .cont-row img').each(function() {
	var theSRC = $(this).attr("src");
	theSRC = theSRC.replace("../","http://www.enviromedia.com/");
	$(this).attr("src",theSRC);	
})

//BLOG MODIFICATIONS TO FIX LINKS ON ENVIROMEDIA SERVER
$('body.blog #content a').each(function() {
	var theHREF = $(this).attr('href');
	theHREF = theHREF.replace("green_canary_blog/","");	
	theHREF = theHREF.replace("enviroblog","green_canary_blog");	
	$(this).attr("href",theHREF);	
});

$('body.blog form#commentform').each(function() {
	var theACTION = $(this).attr('action');
	theACTION = theACTION.replace("enviroblog","green_canary_blog");	
	$(this).attr("action",theACTION);	
});

//PROCESS FLASH
$('#process_flash_holder').flash({
    src: 'media/process_1.swf',
    width: 688,
    height: 505
});

$('#process_flash_holder embed').attr("name","processFlash");

$('li.assessment_call a').click(function() {
	getFlashMovie("processFlash").rotateWheelAssessment2();
	return false;
});

$('li.integration_call a').click(function() {
	getFlashMovie("processFlash").rotateWheelIntegration2();
	return false;
});

$('li.immersion_call a').click(function() {
	getFlashMovie("processFlash").rotateWheelImmersion2();
	return false;
});


//HOMEPAGE NEWS
$('body.home ul.news-list li').each(function() {
	var theIndex = $("ul.news-list li").index(this);
	if (theIndex > 2) {
		$(this).remove();
	}
});

//NEWS PAGE
$('body.news ul.news-list li').each(function() {
	var theIndex = $("ul.news-list li").index(this);
	if (theIndex > 10) {
		$(this).remove();
	}
});

//SAFARI HACK
jQuery.each(jQuery.browser, function(i) {
  if($.browser.safari){
     $('ul.sidenav li a').css("padding-bottom","2px");
  }
});




 });//close on ready
 
function getFlashMovie(movieName) {
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  return (isIE) ? window[movieName] : document[movieName];
}
