$(document).ready(function() {
	
    $('.menulink').bind('click',function(){
    	title = $(this).parent().attr('id');
    	close('home');
    	topflop(title);
    });
    
    $('#portfolio_link').bind('click',function(){$('#portfolio_menu').click();});
    $('#contact_link').bind('click',function(){$('#contact_menu').click();});
        
    $('.intlink').bind('mouseenter',function(){$(this).addClass('grey');});
    $('.intlink').bind('mouseleave',function(){$(this).removeClass('grey');});
    
	// MOUSE ENTER
    $('.menulink').bind('mouseenter',function(){
    	imsrc = $(this).find('img').attr('src');
    	
    	// replace .jpg with _g.png
    	if(imsrc.search('_g.png')>0){
    		// its grey already
    	} else {
    		// replace .jpg with _g.png
    		newsrc = imsrc.replace('.png','_g.png');
    		imsrc = $(this).find('img').attr('src',newsrc);	
    	}
    });
    

	// MOUSE LEAVE
    $('.menulink').bind('mouseleave',function(){
    	imsrc = $(this).find('img').attr('src');
    	
    	// replace .jpg with _g.png
    	if(imsrc.search('_g.png')>0){
    		newsrc = imsrc.replace('_g.png','.png');
    		imsrc = $(this).find('img').attr('src',newsrc);
    	} else {
    		// its blue already
    	}
    });
    
    $('.worktitle').bind('click',function(){
    	id = $(this).attr('id');
    	flop(id);
    });
    
    $('.bvb_link').bind('mouseenter',function(){$(this).addClass('bvb_hover');});
    $('.bvb_link').bind('mouseleave',function(){$(this).removeClass('bvb_hover');}); 
    
  

    $('.portfolioimthumbspan').bind('click',function(){
    	id = $(this).attr('id').replace('image','');
    	id = id.replace('thumb','');
    	seriesid = $(this).parent().parent().attr('id').replace('works','').replace('_content','');
  	    boxshow($(this).children().attr('src'),id,seriesid);
    }); 
 
    $('.newstitle').bind('click',function(){
    	id = $(this).attr('id');
		flop(id);
    });
    
    $('#overlay').bind('click',function(){$('#overlay').hide();$('body').removeClass('noscroll');});
    	

	
	 $('#bigim').click(function(event){
	     event.stopPropagation();
	 });

	 $('#bigimcaption').click(function(event){
	     event.stopPropagation();
	 });

	 $('#overlaynav').click(function(event){
	     event.stopPropagation();
	 });       

	 $('#closeoverlay').click(function(){
	    $('#overlay').click();
	 }); 

	 $('.nextim').click(function(){
	    getNext();
	 }); 

	 $('.previm').click(function(){
	    getPrevious();
	 }); 
	      
    
});





function close(itemid){
	$('#'+itemid+'_content').css("display","none");
}

