/* Author: 

*/

$('#container header .right > nav.bottom > div').hover(function(){
  $(this).addClass('dropdown');
},function(){
  $(this).removeClass('dropdown');
});

/* A HREF FUNCTIONS */
  // make external links open in a new window.. //
  
  $('a').each(function() {
    
  var thisUrl = $(this).attr('href');
  
  if(thisUrl!=undefined){
  var thisRel = $(this).attr('rel');
  if(thisUrl.indexOf('www') >= 0 && thisUrl.indexOf('http://') < 0){
  
  $(this).attr('href', 'http://'+thisUrl);
  if(thisRel==''){
  
  $(this).attr('rel', 'external');
  }
  
  };
  
  
  if(thisUrl.indexOf('http://') >= 0){
  if(thisRel==''){
  $(this).attr('rel', 'external');
  }
  };
  }
  });
  // other functions
  $('a[href=#]').click(function(){
    return false;
  });
  
  $('a[rel=external]').click(function(){
    window.open(this.href);
    return false;
  });

  $('a[href=#top]').click(function(){
    $('html').animate({scrollTop:0}, 'slow');
    return false;
  });
  $('a[rel=slide]').click(function(){
    
  var id = $(this).attr('title');
   $('html').animate({scrollTop: $("a[name="+id+"]").offset().top},'slow');
   return false;
});

  $('form a.submit').click(function(){
    $(this).parents('form:first').submit();
  });
  
  
  $('.ajax a.submit, .ajax input[type=submit], .ajax input[type=image]').click(function(e){
      e.preventDefault();
      var x;
      var namearray=[];
      var valuearray=[];
      var theAction = $(this).parents('form:first').attr('action');
      var theName = $(this).parents('form:first').attr('name');
           
      
    
   
        $.ajax( {
          type : "GET",
          url : theAction,
         
          dataType : 'html',
          data : ($("form[name="+theName+"]").serialize()),
          success : function(msg) {
           
              
            if(msg==0){
              $("form[name="+theName+"]").children(".error").fadeIn();
              $("form[name="+theName+"]").children(".description_text").fadeOut();
            }else{
             
              $("form[name="+theName+"]").css("display","none");
              $("form[name="+theName+"]").siblings(".success").html(msg);
              
              $("form[name="+theName+"]").siblings(".success").fadeIn();
            }
           }
        });
        
        
        
      });





$('#slider').nivoSlider({directionNav:false});


$(' .tabs .tabs_holder a').click(function(){
  $(this).siblings('.selected').removeClass("selected");
  $(this).addClass('selected');
  var theShow =$(this).attr('rel');
  $('.tabs .content_holder article:not(#'+theShow+'):visible').hide();
  $('.tabs .content_holder article#'+theShow+':hidden').show();
});

$(document).ready(function(){
	$("form").validationEngine();	
});
