jQuery(document).ready(function($){
  
  // PORTFOLIO IMAGE HOVER:
	$('.menu-main-menu-container a').click(function(){		
		if(!$(this).attr('href')) return false;
	});
  
  	$('.menu-item').click(function() {
		href = $(this).find('a:first').attr('href');
		if(!href) return false;
		window.location = href;
	});
	
  var speed = 300;
  var portfolio_link_opacity = 1;
  var icon_link_opacity = 1;

  if($.browser.msie)
  { portfolio_link_opacity = 0.2;
    icon_link_opacity = 0.65;
  }
  
   $('.gallery-icon').find('a').click(function(){
    $.prettyPhoto.open($(this).attr('href'),'','');
    
   return false;
   });
  $('#fc_submit').click(function(){
     var send_email = true;
    var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
        

    if (!filter.test($('#fc_email').attr('value')) || $('#fc_email').attr('value') == '') {
        $('#fc_email').animate({left:-10},100).animate({left:10},100).animate({left:-10},100).animate({left:10},100).animate({left:0},100);
       
    /*    $('#cf_mail').animate({borderTop: '1px solid #ff0000'},{duration:5000, queue:false}); 
        $('#cf_mail').animate({borderLeft: '1px solid #ff0000'},{duration:5000, queue:false});  
        $('#cf_mail').animate({borderRight: '1px solid #ff0000'},{duration:5000, queue:false});
        $('#cf_mail').animate({borderBottom: '1px solid #ff0000'},{duration:5000, queue:false});    */
       send_email = false;  
    }
 
    if( $('#fc_name').attr('value') == '' ) { 
      $('#fc_name').animate({left:-10},100).animate({left:10},100).animate({left:-10},100).animate({left:10},100).animate({left:0},100);
     
      send_email = false;  
    }
   
    if( $('#fc_text').attr('value') == '' ) {
      $('#fc_text').animate({left:-10},100).animate({left:10},100).animate({left:-10},100).animate({left:10},100).animate({left:0},100);
     
      send_email = false;
    }
 
    if(send_email == false){ return false;}    
  } );
  
  
  $('.portfolio_link, .pretty').hover(function(){
  
    $(this).find('.portfolio_hover').css('opacity', '0');
    $(this).find('.portfolio_hover').css('display', 'block');
    $(this).find('.portfolio_hover').stop().animate({opacity:portfolio_link_opacity},speed);
    
    //$(this).find('.icon_zoom').css('opacity', '0');
    //$(this).find('.icon_zoom').css('display', 'block');
    //$(this).find('.icon_zoom').stop().animate({opacity:icon_link_opacity},speed);
    
    //$(this).find('.icon_play').css('opacity', '0');
    //$(this).find('.icon_play').css('display', 'block');
    //$(this).find('.icon_play').stop().animate({opacity:icon_link_opacity},speed);
    
  },function(){
    var div_holder = $(this).find('div');
    $(this).find('.portfolio_hover').stop().animate({opacity:0},speed, function(){ div_holder.css('display','none'); });
    //$(this).find('.icon_zoom').stop().animate({opacity:0},speed, function(){ div_holder.css('display','none'); });
    //$(this).find('.icon_play').stop().animate({opacity:0},speed, function(){ div_holder.css('display','none'); });
  });
  
    $('.gallery_link').hover(function(){
    $(this).find('.gallery_hover').css('opacity', '0');
    $(this).find('.gallery_hover').css('display', 'block');
    $(this).find('.gallery_hover').stop().animate({opacity:portfolio_link_opacity},speed);
    
    //$(this).find('.icon_zoom').css('opacity', '0');
    //$(this).find('.icon_zoom').css('display', 'block');
    //%this).find('.icon_zoom').stop().animate({opacity:icon_link_opacity},speed);
    
    //$(this).find('.icon_play').css('opacity', '0');
    //$(this).find('.icon_play').css('display', 'block');
    //$(this).find('.icon_play').stop().animate({opacity:icon_link_opacity},speed);
    
  },function(){
    var div_holder = $(this).find('div');
    $(this).find('.gallery_hover').stop().animate({opacity:0},speed, function(){ div_holder.css('display','none'); });
    //$(this).find('.icon_zoom').stop().animate({opacity:0},speed, function(){ div_holder.css('display','none'); });
    //$(this).find('.icon_play').stop().animate({opacity:0},speed, function(){ div_holder.css('display','none'); });
  });
	jQuery(".toggle_body").hide(); 

	jQuery("h4.toggle").toggle(function(){
		jQuery(this).addClass("toggle_active");
		}, function () {
		jQuery(this).removeClass("toggle_active");
	});
	
	jQuery("h4.toggle").click(function(){
		jQuery(this).next(".toggle_body").slideToggle();

	});
 
// NAVIGATION HOVER!

  $('.sc_tab').click(function() {
  var which = $(this).attr('title');
  $(this).parent().parent().find('.sc_tab_single_box').css('display','none'); 
  $(this).parent().parent().find('.sc_tab_single_box').eq(which).css('display','block');
  });

    var dropdown_level = 0;
    
    $('.sub-menu').parent().find('a:first').addClass('nav_sub_arrow');
    $('#nav_wrapper .menu').children('li').children('a').addClass('top_level');
    $('#nav_wrapper .menu').children('li').children('a').removeClass('nav_sub_arrow');
    
    $('#nav_wrapper .menu-item').hover(function(){
      if(dropdown_level == 0){
            $('#nav_wrapper .menu').find('a').removeClass('nav_sub_arrow_active');  
            //$('#nav_wrapper .menu').find('a').addClass('nav_sub_arrow_passive');  
          $(this).addClass('main_hover_left');
          $(this).children('a').addClass('main_hover_right');
            $('.sub-menu').parent().find('a:first').addClass('nav_sub_arrow');
        $('#nav_wrapper .menu').children('li').children('a').addClass('top_level');
        $('#nav_wrapper .menu').children('li').children('a').removeClass('nav_sub_arrow');
      //alert('sasa');
      }                                                                                             
       
      $(this).find('.sub-menu:first').stop(true,true).slideDown(200).show();        
      $(this).find('a:first').addClass('nav_sub_arrow_active');
      $('#nav_wrapper .menu').children('li').children('a').removeClass('nav_sub_arrow_active');       
      dropdown_level++;
    },function(){            
      $(this).find('.sub-menu:first').stop(true,true).slideUp(0);
      $(this).find('a:first').removeClass('nav_sub_arrow_active');
      dropdown_level--;
       if(dropdown_level == 0){
        $(this).removeClass('main_hover_left');
          $(this).children('a').removeClass('main_hover_right');
       }
    } );
 
  
});
