
/*!
 * Genentech Pipeline JS
 * Ericm@zaaz.com
 * Date: Sat Feb 13 22:33:48 2010 -0500
 */

    var moleculeGrid = "";
    var moleculePhase = "";
    var moleculeName = "";
    var moleculeType = "";
    var moleculeDesc = "";
	var firstClick = false;
	var view ="list";
	
	var prevClipA = null;
	var prevClipB = null;
	var prevIDa = "";
	var prevIDb = "";
	var curPhaseA = null;
	var curPhaseB = null;
	var curDisciplineA = null;
	var curDisciplineB = null;
	
	
	
	
$(document).ready(function () {

    $.ajax({
        type: "GET",
        url: "pipes.xml",
        dataType: "xml",
        success: parseXml
    });

});

function parseXml(xml) {
	
	// Gather all elements and assign based on grid or list,
	var countBG = 0;
     $(xml).find("molecule").each(function (i) {
        var moleculeListItems = "";
        var moleculeListGridItems1 = "";
        var moleculeListGridItems2 = "";
        
        
		$(".headerBox h3").text("Browse Molecules ("+(i+1)+")" );
        moleculeName = $(this).find("name").text();
        moleculePhase = $(this).find("phase").text();
        moleculeTitle = $(this).find("phaseTitle").text();
        moleculeType = $(this).find("type").text();
        moleculeDesc = $(this).find("description").text();
		moleculeId = $(this).find("overlayId").text();
		moleculeTrial = $(this).find("trialLink").text();


		var lengthA =   $(this).find("list").children().length;

        $(this).find("list item ").each(function (i) {
        	
        	if(i == (lengthA-1)){
        		 moleculeListItems += '<li class="last"><div class="itemText">' 
        		 + $(this).find("text").text()+'</div><span class="phase'+$(this).find("itemphase").text()+'">'+$(this).find("itemphase").text()+'</span><br style="clear:both"/></li>';
        		
        	}else{
                 moleculeListItems += '<li><div class="itemText">' + $(this).find("text").text()+'</div><span class="phase'+$(this).find("itemphase").text()+'">'+$(this).find("itemphase").text()+'</span><span style="clear:both; display:block;"></span></li>';
           }
           
           
        });
        
       
        $(this).find("list item").each(function (i) {
        	
        	
        	var itemPhaseID = $(this).find("itemphase").text()
        	
        	if(itemPhaseID == 1){
        		 moleculeListGridItems1 += '<li class="last"><div class="itemText">' 
        		 + $(this).find("text").text()+'</div><span class="phase'+$(this).find("itemphase").text()+'"></span><span style="clear:both"></span></li>';
        		
        	}else if(itemPhaseID == 2){
        		
        		
                 moleculeListGridItems2 += '<li><div class="itemText">' + $(this).find("text").text()+'</div><span class="phase'+$(this).find("itemphase").text()+'"></span><span style="clear:both; "></span></li>';
            }
           
           
        });
        
         if(moleculeListGridItems1 != ""){
         	
        	var mList1 = '<h3 style="color:#B8CE01;">Phase 1</h3><ul>' + moleculeListGridItems1 + '</ul>';
        }else{ 
        	var mList1 =""
        }
        	
        if(moleculeListGridItems2 != ""){
        	
        	var mList2 = '<h3 style="color:#B8CE01;">Phase 2</h3><ul>' + moleculeListGridItems2 + '</ul>';
        }else{ 
        	var mList2 =""
        }
       
		
		countBG++;
		//Configure the grid view
        moleculeGrid = '<a href="#" class="mLink moleculeBox ' + moleculeType + ' ' + moleculePhase + ' '+'bg'+countBG +'" rel="#'+moleculeId+'" onclick="displayOverlay(this, true);return false;">'
	        +'<div class="innerBox">' 
	        //+'<a href="#'+moleculeId+'" class="mLink" ></a> '
	        + '<h3>Phase ' + moleculeTitle + '</h3>' 
	        + '<h2>' + moleculeName + '</h2>' 
	        + '<h4>' + moleculeDesc + '</h4>' 
	        + '<ul>' + moleculeListItems + '</ul>' + '</div>'
	        +'<div class="innerBoxHover" style="display:none;">' 
	        + '<h2 style="color:#666;">' + moleculeName + '</h2>' 
	        + '<h4  style="color:#666;">' + moleculeDesc + '</h4>' 
	        + mList1
	        + mList2
	        + '</div>'
	        +'</a>';

        if(countBG == 3){countBG = 0;}
        
        
        if(moleculeType == "oncology"){
	        var moleculeListOn =  '<tr class="'+moleculeType+ ' ' + moleculePhase + '">'
	        +'<td class="moleculeName"><a href="#" rel="#'+moleculeId+'" class="mLink" onclick="return false;">'+moleculeName+'</a></td>'
	        //+'<td class="trial"><a href="'+moleculeTrial+'" rel="#" target="_blank"><img alt="Clinical Trials" title="Clinical Trials" src="images/clinicalTArrow.png" style="margin:0 0 0 15px;"/></a></td>'
	        +'<td class="moleculeDesc">'+moleculeDesc+'</td>'
	        +'<td class="moleculeListItems"><ul>' +moleculeListItems+'</ul></td>'
	        //+'<td class="moleculePhase"><span class="phase'+moleculePhase+'"></span></td>'
	        +'</tr>';
        }else if(moleculeType == "immunology"){
        	var moleculeListIm =  '<tr class="'+moleculeType+ ' ' + moleculePhase + '">'
	        +'<td class="moleculeName"><a href="#" rel="#'+moleculeId+'" class="mLink" onclick="return false;">'+moleculeName+'</a></td>'
	        //+'<td class="trial"><a href="'+moleculeTrial+'" rel="#" target="_blank"><img alt="Clinical Trials" title="Clinical Trials" src="images/clinicalTArrow.png" style="margin:0 0 0 15px;"/></a></td>'
	        +'<td class="moleculeDesc">'+moleculeDesc+'</td>'
	        +'<td class="moleculeListItems"><ul>' +moleculeListItems+'</ul></td>'
	       // +'<td class="moleculePhase"><span class="phase'+moleculePhase+'"></span></td>'
	        +'</tr>';
        }else if(moleculeType == "metabolism"){
        	var moleculeListMe =  '<tr class="'+moleculeType+ ' ' + moleculePhase + '">'
	        +'<td class="moleculeName"><a href="#" rel="#'+moleculeId+'" class="mLink" onclick="return false;">'+moleculeName+'</a></td>'
	        //+'<td class="trial"><a href="'+moleculeTrial+'" rel="#" target="_blank"><img alt="Clinical Trials" title="Clinical Trials" src="images/clinicalTArrow.png" style="margin:0 0 0 15px;"/></a></td>'
	        +'<td class="moleculeDesc">'+moleculeDesc+'</td>'
	        +'<td class="moleculeListItems"><ul>' +moleculeListItems+'</ul></td>'
	       // +'<td class="moleculePhase"><span class="phase'+moleculePhase+'"></span></td>'
	        +'</tr>';
        }else if(moleculeType == "neuroscience"){
        	var moleculeListNe =  '<tr class="'+moleculeType+ ' ' + moleculePhase + '">'
	        +'<td class="moleculeName"><a href="#" rel="#'+moleculeId+'" class="mLink" onclick="return false;">'+moleculeName+'</a></td>'
	        //+'<td class="trial"><a href="'+moleculeTrial+'" rel="#" target="_blank"><img alt="Clinical Trials" title="Clinical Trials" src="images/clinicalTArrow.png" style="margin:0 0 0 15px;"/></a></td>'
	        +'<td class="moleculeDesc">'+moleculeDesc+'</td>'
	        +'<td class="moleculeListItems"><ul>' +moleculeListItems+'</ul></td>'
	       // +'<td class="moleculePhase"><span class="phase'+moleculePhase+'"></span></td>'
	        +'</tr>';
        }
        
        
        $("#moleculeListHolder table.oncology").append(moleculeListOn).fadeIn(500);
        $("#moleculeListHolder table.immunology").append(moleculeListIm);
        $("#moleculeListHolder table.metabolism").append(moleculeListMe);
        $("#moleculeListHolder table.neuroscience").append(moleculeListNe);


        $("#output").append($(this).find("name").text());

        $("#moleculeHolder").append(moleculeGrid);
        
        mList1 =""
        mList2 =""
        
    });

	enableHandlers();

	    //Sets table row to be clickable.
		$("table tr td").click(function(){
			
			var tdOn = $(this).attr('class')
			
			if(tdOn == "trial"){
				
			}else{
				
				var pass = $(this).parent().children(".moleculeName").children("a").attr("rel");
				displayOverlay(pass,false)
			}
			
			//
			//$('a',this).click();
		});	    
	    
	    
	    // Reset all filters.
	    $('#clearFilters').click(function(){
	    	
	    	killAllFilters();
	    	return false;
	    });

	    
	    // Overlay click functions for grid and List
	    
	    
	    
	    

}


function enableHandlers() {
    //find every Tutorial and print the author
   var numberOfListMolecules;
   var numberOfMolecules;
    $('a.listViewBtn').click(function () {
    	//Hide and Show function
        $('#moleculeHolder').hide();
        $('#moleculeListHolder').show();
        $('#filterBox').hide();
        $('#filterBoxList').show();
        $(this).addClass('active');
        $('a.gridViewBtn').removeClass('active');
        $('#listPrint').show();
        updateMoleculeCount("list");
		
		view = "list";		
    });

    $('a.gridViewBtn').click(function () {
    	//Hide and Show function
        $('#moleculeHolder').show();
        $('#moleculeListHolder').hide();
        $('#filterBoxList').hide();
        $('#listPrint').hide();
        
        $('#filterBox').show();
        $(this).addClass('active');
        $('a.listViewBtn').removeClass('active');
        
        
        if (!firstClick){ 
	        $('#moleculeHolder').masonry({
		        columnWidth: 1,
		        itemSelector: ".moleculeBox",
		        saveOptions: true,
		        animate:true
		    });
	    firstClick = true;
	    }
	    
	   updateMoleculeCount("no");
	    
	    view = "grid";
    });
		listEnabled();
        gridEnabled();
	
	$('a.listViewBtn').click();
$('#loadingImg').hide();
    ////CODE FOR MOVING GREEN little green BOX
    var oHeight = $(".pipeline-content").height();
    $("#leftNav").height(oHeight - 20);
    //left nav-icon position
    var w = $("#leftNav").width();
    w = (w - 30);
    var y = oHeight - 42;
    $("#nav-icon").css({ 'position': 'absolute', 'top': y, 'left': w , "z-index" : 0 });
    
    $('#cb1').attr('checked', false);
    $('#cb2').attr('checked', false);
    $('#cb1l').attr('checked', false);
    $('#cb2l').attr('checked', false);
    
    
	$("#phase1Cb").hover(function(){
   	 	$("#bPhase1").toggle();
    	
    	
    });

    
    $("#phase2Cb").hover(function(){
    	$("#bPhase2").toggle();
    	
    });
    
    $("#phase1CbGrid").hover(function(){
   	 	$("#bPhase1Grid").toggle();
    	
    	
    });

    
    $("#phase2CbGrid").hover(function(){
    	$("#bPhase2Grid").toggle();
    	
    });


}


function gridEnabled(){

    var checkBoolean1 = false;
    var checkBoolean2 = false;
    

    

    var speed = 100; // animation speed
    $('#cb1').click(function(){
    	checkBoolean1 = $(this).is(':checked');
		checkBoolean2 = $("#cb2").is(':checked');
		
		var curChildren = (curDisciplineA != null ?  curChildren = $('#moleculeHolder').children("."+curDisciplineA) : curChildren = $('#moleculeHolder').children() );
		//console.log($('#moleculeHolder').children("."+curDiscipline))

		if(checkBoolean1 && checkBoolean2){
			curPhaseA = null;
		    curChildren.filter('.invis').removeClass('invis').fadeIn(speed);
		}else if(checkBoolean1 && !checkBoolean2){
		 	curPhaseA = ".1";
		    curChildren.not('.1').toggleClass('invis').fadeOut(speed);
		
		}else if(checkBoolean2 && !checkBoolean1){
		 	curPhaseA = ".2";
		    curChildren.not('.2').toggleClass('invis').fadeOut(speed);
		}else{
		 	curPhaseA = null;
		 	curChildren.filter('.invis').removeClass('invis').fadeIn(speed);
		}
		 
		setTimeout(function(){ updateMoleculeCount()}, 400);
 		//console.log(curChildren)
		//console.log("curDiscipline:",curDiscipline," | ", "curPhase:",curPhase, "checkBoolean1:", checkBoolean1 , "checkBoolean2:", checkBoolean2)
	});
	
	$('#cb2').click(function(){
		checkBoolean1 = $("#cb1").is(':checked');
		checkBoolean2 = $(this).is(':checked');
		var curChildren = (curDisciplineA != null ?   curChildren = $('#moleculeHolder').children("."+curDisciplineA) :  curChildren = $('#moleculeHolder').children() );

		if(checkBoolean1 && checkBoolean2){
			curPhaseA = null;
		    curChildren.filter('.invis').removeClass('invis').fadeIn(speed);
		 }else if(checkBoolean2 && !checkBoolean1){
		 	curPhaseA = ".2";
		    curChildren.not('.2').toggleClass('invis').fadeOut(speed);
		 }else if(checkBoolean1 && !checkBoolean2){
		 	curPhaseA = ".1";
		    curChildren.not('.1').toggleClass('invis').fadeOut(speed);
		 
		 }else{
		 	curPhaseA = null;
		 	curChildren.filter('.invis').removeClass('invis').fadeIn(speed);
		 }
		 
		setTimeout(function(){ updateMoleculeCount()}, 400);

	});
    
    
    $('.moleculeBox').mouseover(function(){
    	$('.innerBox',this).hide();
    	$('.innerBoxHover',this).show();
    	
    	//$(this).removeClass("oncology")
    	$(this).css( {
    		backgroundPosition: "-300px 0",
    		backgroundColor : "#fff",
    		border : "1px solid #666"
    	});
		$('li',this).css({
			 color : '#666'
		});
    });
    
     $('.moleculeBox').mouseout(function(){
    	$('.innerBoxHover',this).hide();
    	$('.innerBox',this).show();
    	
    	//$(this).addClass("oncology")
    	$(this).css( {
    		backgroundPosition: "0 0",
    		backgroundColor : "",
    		border : ""
    	});
		  $('li',this).css({
			 color : ""
		  });
    });

    
    
    $('#filtering-nav a').click(function () {

        var colorClass = '.' + $(this).attr('id');
			
		
        if (prevClipA != null) {
            $(prevClipA).removeClass('active');

        }

        //PREV ID is EQUAL to this id REMOVE FILTER OF Discipline 
        
        if (prevIDa== $(this).attr("id")) {
			curDisciplineA = null;
			var curChildren = (curPhaseA != null ?  curChildren = $('#moleculeHolder').children(curPhaseA) : curChildren = $('#moleculeHolder').children() );

            $(prevClipA).removeClass('active');
            curChildren.filter('.invis').removeClass('invis').fadeIn(speed);

            
            
            prevIDa= "";
            
        } else {
            $(this).addClass('active');

            curDisciplineA = $(this).attr('id');
            
            var curChildren = (curPhaseA != null ?  curChildren = $('#moleculeHolder').children(curPhaseA) : curChildren = $('#moleculeHolder').children() );
            
            
            // hide visible boxes 
            curChildren.not(colorClass+", .invis").toggleClass('invis').fadeOut(speed);

            // show hidden boxes
            curChildren.filter(colorClass + '.invis').toggleClass('invis').fadeIn(speed);


            prevIDa= $(this).attr("id");

        }
       // console.log("curDiscipline:",curDiscipline," | ", "curPhase:",curPhaseA," | ", "curChildren:",curChildren )
        updateMoleculeCount();
        
        prevClipA = this;
        
        return false;
	});
	
}


function listEnabled(){

	var speed = 300; // animation speed
	var checkBoolean1 = false;
    var checkBoolean2 = false;
    
	
	$('#cb1l').click(function(){
		
		checkBoolean1 = $(this).is(':checked');
		checkBoolean2 = $("#cb2l").is(':checked');

		var curChildren = (curDisciplineB != null ?  curChildren = $('#moleculeListHolder table tbody').children("."+curDisciplineB) : curChildren = $('#moleculeListHolder table tbody').children() );

		 if(checkBoolean1 && checkBoolean2){
			 curPhaseB = null;
		     curChildren.filter('.invis').removeClass('invis').fadeIn(speed);
		 }else if(checkBoolean1 && !checkBoolean2){
		 	 curPhaseB = ".1";
		     curChildren.not('.1').toggleClass('invis').fadeOut(speed);	
		 }else if(checkBoolean2 && !checkBoolean1){
		 	 curPhaseB = ".2";
		     curChildren.not('.2').toggleClass('invis').fadeOut(speed);
		 }else{
		 	 curPhaseB = null;
		 	 curChildren.filter('.invis').removeClass('invis').fadeIn(speed);
		 }
		 
		setTimeout(function(){ updateMoleculeCount("list")}, 400);


	});
	
	$('#cb2l').click(function(){
		checkBoolean1 = $("#cb1l").is(':checked');
		checkBoolean2 = $(this).is(':checked');
		
		var curChildren = (curDisciplineB != null ?  curChildren = $('#moleculeListHolder table tbody').children("."+curDisciplineB) : curChildren = $('#moleculeListHolder table tbody').children() );

		 if(checkBoolean1 && checkBoolean2){
			 curPhaseB = null;
		     curChildren.filter('.invis').removeClass('invis').fadeIn(speed);
		 }else if(checkBoolean2 && !checkBoolean1){
		 	 curPhaseB = ".2";
		     curChildren.not('.2').toggleClass('invis').fadeOut(speed);	
		 }else if(checkBoolean1 && !checkBoolean2){
		 	 curPhaseB = ".1";
		     curChildren.not('.1').toggleClass('invis').fadeOut(speed);
		 }else{
		 	 curPhaseB = null;
		 	 curChildren.filter('.invis').removeClass('invis').fadeIn(speed);
		 }
		 
		//console.log("curDiscipline:",curDisciplineB," | ", "curPhase:",curPhaseB, "checkBoolean1:", checkBoolean1 , "checkBoolean2:", checkBoolean2)
		setTimeout(function(){ updateMoleculeCount("list")}, 400);

		
		
	});
	
	
	
	
	$('#filtering-navList a').click(function () {

        var colorClass = '.' + $(this).attr('id');
		 var colorId = '#' +$(this).attr('id')
		if (prevClipB != null) {
            $(prevClipB).removeClass('active');
			
        }
		
		if (prevIDb == $(this).attr("id")) {
			
			curDisciplineB = null;
			var curChildren = (curPhaseB != null ?  curChildren = $('#moleculeListHolder table tbody').children(curPhaseB) : curChildren = $('#moleculeListHolder table tbody').children());

            $(prevClipB).removeClass('active');
            
            
            $("#moleculeListHolder table .header").fadeIn(speed);
            
            curChildren.filter('.invis').removeClass('invis').fadeIn(speed);
            
            
            prevIDb = "";
        
        } else {
			
            $(this).addClass('active');

            curDisciplineB = $(this).attr('id');
            
            var curChildren = (curPhaseB != null ?  curChildren = $('#moleculeListHolder table tbody').children(curPhaseB) : curChildren = $('#moleculeListHolder table tbody').children() );

            curChildren.not(colorClass+", .invis").toggleClass('invis').fadeOut(speed,function(){
            	 
            	 curChildren.filter(colorClass + ' .invis').toggleClass('invis').fadeIn(speed);
            	 
            });
           
            

            buttonHolder = this;
            
			prevIDb = $(this).attr("id");
		}
		prevClipB = this;
		
		
		
		
		setTimeout(function(){ updateMoleculeCount("list")}, 400);
	
		return false;
		
	});
}


function updateMoleculeCount(type){
	var numberOfMolecules = "";
	
	  if(type == "list"){
		 numberOfMolecules = $('#moleculeListHolder table tbody').children().not('.header,:hidden').length;
		 //checkList();
	  }else{
		  numberOfMolecules = $('#moleculeHolder').children().not(".invis").length;
		  
		  masonryThis();
		   
         ////console.log("GRID",numberOfMolecules,$('#moleculeHolder').children().not(".invis"))
	  }
	
	if(numberOfMolecules != 30){
		clearFilterShow(this )
		
	}else{
		clearFilterShow(null )
		
	}
	
	
	////console.log($('#moleculeListHolder table tbody').children().not('.header,:hidden')  )
	
	$(".headerBox h3").text("Browse Molecules ("+numberOfMolecules+")" );
}

function masonryThis(){
	
	$('#moleculeHolder').masonry({
                columnWidth: 1,
                itemSelector: '.moleculeBox:not(.invis)',
                animate: true

            });
	
}



function checkList(){
	
	var oCount = $('#moleculeListHolder table.oncology tbody').children('.invis').length;
	var iCount = $('#moleculeListHolder table.immunology tbody').children('.invis').length;
	var mCount = $('#moleculeListHolder table.metabolism tbody').children('.invis').length;
	var nCount = $('#moleculeListHolder table.neuroscience tbody').children('.invis').length;
	
	
	
	var oDisplay = (oCount != 0 ?   true:false  );
	var iDisplay = (iCount != 0 ?   true:false  );
	var mDisplay = (mCount != 0 ?   true:false  );
	var nDisplay = (nCount != 0 ?   true:false  );
	
	
	
	if(!oDisplay){
		$('#moleculeListHolder table.oncology').fadeIn();
	}else{
		
		$('#moleculeListHolder table.oncology').fadeOut();
	}

	
	
	
	
}

function overlayPop(mthis){
	
	$(mthis).overlay({
			onBeforeLoad: function(){
			this.getOverlay().appendTo("body");
			},
				fixed: false,
				
				left: 'center',
				closeOnClick: true,
				mask: {
				color: '#000',
				loadSpeed: 0,
				opacity: 0.6,
				closeSpeed: 100
			    },
			speed: 0
		}); 
	
}


function clearFilterShow(cur){
	

	if(cur != null){
		$('#clearFilters').fadeIn('fast');
		
		
	}else{
		$('#clearFilters').fadeOut('fast');
		
	}

}


function killAllFilters(){
	
	
	if(view == "list"){
		var checkBool1 = $('#cb1l').is(':checked');
		var checkBool2 = $('#cb2l').is(':checked');
		var oncologyNavBool =  $('#filtering-navList a.oncology').hasClass('active');
		var immunologyNavBool =  $('#filtering-navList a.immunology').hasClass('active');
		var metabolismNavBool =  $('#filtering-navList a.metabolism').hasClass('active');
		var neuroscienceNavBool =  $('#filtering-navList a.neuroscience').hasClass('active');
		
		//console.log(checkBool1,checkBool2,oncologyNavBool,immunologyNavBool,metabolismNavBool,neuroscienceNavBool)
		
		if(checkBool1){
			$('#cb1l').removeAttr("checked");
			checkBool1 = $('#cb1l').is(':checked')
			
		}
		if(checkBool2){
			$('#cb2l').removeAttr("checked");
			checkBool2 = $('#cb2l').is(':checked')
			
		}
		
		
		if(oncologyNavBool){
			$('#filtering-navList a.oncology').removeClass('active');
		}
		if(immunologyNavBool){
			$('#filtering-navList a.immunology').removeClass('active');
		}
		if(metabolismNavBool){
			$('#filtering-navList a.metabolism').removeClass('active');
		}
		if(neuroscienceNavBool){
			$('#filtering-navList a.neuroscience').removeClass('active');
		}
		
		
		prevIDb = '';
		prevClipB = null;
		curPhaseB = null;
		curDisciplineB = null;
		
		
		var curChildren = $('#moleculeListHolder table tbody').children()
		
		
		curChildren.removeClass('invis').fadeIn(200);
		
		updateMoleculeCount();
		
		
		
	}
	
	if(view == "grid"){
		var checkBool1 = $('#cb1').is(':checked');
		var checkBool2 = $('#cb2').is(':checked');
		var oncologyNavBool =  $('#filtering-nav a.oncology').hasClass('active');
		var immunologyNavBool =  $('#filtering-nav a.immunology').hasClass('active');
		var metabolismNavBool =  $('#filtering-nav a.metabolism').hasClass('active');
		var neuroscienceNavBool =  $('#filtering-nav a.neuroscience').hasClass('active');
		
		
		if(checkBool1){
			$('#cb1').removeAttr("checked");
			checkBool1 = $('#cb1l').is(':checked')
		}
		if(checkBool2){
			$('#cb2').removeAttr("checked");
			checkBool2 = $('#cb2l').is(':checked')
		}
		
		if(oncologyNavBool){
			$('#filtering-nav a.oncology').removeClass('active');
		}
		if(immunologyNavBool){
			$('#filtering-nav a.immunology').removeClass('active')
		}
		if(metabolismNavBool){
			$('#filtering-nav a.metabolism').removeClass('active')
		}
		if(neuroscienceNavBool){
			$('#filtering-nav a.neuroscience').removeClass('active')
		}
		
		
		curPhaseA = null;
		prevIDa = '';
		prevClipA = null;
		curDisciplineA = null;
		
		
		var curChildren  = $('#moleculeHolder').children()
		
		
		curChildren.removeClass('invis').fadeIn(200);
		
		updateMoleculeCount();
		
	}
	
	
	
}


function displayOverlay(div,grid){

	if(grid){
		div = $(div).attr('rel');
	}

	$(div).addClass('active');
	$('#moleculeListHolder').removeClass('active');
	
	if ($(div).hasClass("init")) {
   	    $(div).overlay().load();
	}
	else {
		//console.log("go")
	    $(div).addClass("init");
	    $(div).overlay({ 
	    
			onClose: function(){
				$(div).removeClass('active');
				$('#moleculeListHolder').addClass('active')
			},
			
	     	onBeforeLoad: function(){
			},
				left: 'center',
				fixed: false,
				closeOnClick: true,
				mask: {
					color: '#000',
					loadSpeed: 0,
					opacity: 0.6,
					closeSpeed: 100
			    },
		 		speed: 0,
	     		load: true
	    });
	}
	
	 
	
	
	
}






