//copyright Brisbane Website Design 30.com.au
$(document).ready(function() {
  //Box hover effects ---------------------------------------------------------
  $(".box .content").hover(function () {
      $(this).prev("div").animate({opacity: 0}, {queue:false,duration:200});			
    }, function () {
      $(this).prev("div").animate({opacity: 1}, {queue:false,duration:400});			
    }
  );	
  $('.box').click(function() {
    window.location.href = $(this).find('a').attr('href');
    return(false);
  });
  
  
  //Automatic Google Translation via API --------------------------------------
  $.translate(function(){ 
      function translateTo( destLang ){ 
          
                           
          originalColor = '#262c33';
          var tlc = $.translate().toLanguageCode 
          if( tlc( destLang ) == "en" && tlc($.cookie("destLang")) == "en") {
            $('#flags ul').find('a').removeClass('load');
            return;
          }
            $('.sf-menu, #contact-ad, #custom-area-1, #welcome-teaser, #main, #right').translate( 'en', destLang, {   //translate from english to the selected language 
              not: '#jq-translate-ui, .syntaxhighlighter',  //by default the generated element has this id  
              fromOriginal:true,   //always translate from english (even after the page has been translated) 
              start: function(){ 
                  $('#container').css('color', '#a0a8b2');
                  $('#ozwebsites').removeClass('robot');
                  $('#ozwebsites').html($('#ozwebsites-translate').html()) 
                  $('#ozwebsites').show() 
              },   
              complete: function(){ 
                  $('#container').css('color', originalColor);
                  //$('#ozwebsites').hide();
                  $('#ozwebsites').addClass('robot');
                  $('#flags').find('a.load').removeClass('load').addClass('finish');
                  if (destLang == 'en') {
                    $('#ozwebsites').hide() 
                  } else {
                    $('#ozwebsites').html($('#ozwebsites-hint').html()); 
                  }

              },  
              error: function(){ 
                  $('#container').css('color', originalColor);
                  $('#ozwebsites').hide() 
              } 
          }); 
      } 
      $("#ozwebsites a").live("click", function(){
        translateTo('en');
        $('#flags ul').find('a').removeClass('finish');
        $('#flags ul').find('a').removeClass('load');
        return(false);
      });
      $('#flags').find('a').click(function(){
        $('#flags').find('a').removeClass('finish');
        $(this).addClass('load');
        var lang = $(this).attr('id');
        translateTo( lang );
        $.cookie('destLang', lang );
        return false;
      }); 
      //if dont exist an cookie set browserlang to cookielang
      if( $.cookie("destLang") == null) $.cookie('destLang', browserlang);
      var destLang = $.cookie('destLang'); //get previously translated language 
      if( destLang ) translateTo( destLang ); 
  }); 

  
    
  //Forms ---------------------------------------------------------------------
  $("input[type=text], textarea").bind("focus",function(){
    $(this).addClass("formactive");
  });
  $("input[type=text], textarea").bind("blur",function(){
    $(this).removeClass("formactive");
  });


  //Navigation ----------------------------------------------------------------
  $("a.button").hover(function () {
      if (!$(this).hasClass('active')) $(this).animate({opacity: 1}, {queue:true, duration:200});			
    }, function () {
      if (!$(this).hasClass('active')) $(this).animate({opacity: 0.6}, {queue:true, duration:400});			
    }
  );	
  $("a.button").css('opacity', 0.6);	
  $("a.button.active").css('opacity', 1);	  
  $(".level_1 .trail a:first").css('opacity', 1).addClass('active');	  
  $("a.submenu.button").click(function() {
    return(false);
  });
  $('.sf-menu').superfish({ 
    hoverClass:    'sfHover',          // the class applied to hovered list items 
    pathClass:     'overideThisToUse', // the class you have applied to list items that lead to the current page 
    pathLevels:    2,                  // the number of levels of submenus that remain open or are restored using pathClass 
    delay:         800,                // the delay in milliseconds that the mouse can remain outside a submenu without it closing 
    animation:     {opacity: 'show'},  // an object equivalent to first parameter of jQuery’s .animate() method 
    speed:         300,                // speed of the animation. Equivalent to second parameter of jQuery’s .animate() method 
    autoArrows:    true,               // if true, arrow mark-up generated automatically = cleaner source code at expense of initialisation performance 
    dropShadows:   false,              // completely disable drop shadows by setting this to false 
    disableHI:     false,              // set to true to disable hoverIntent detection 
    onInit:        function(){},       // callback function fires once Superfish is initialised – 'this' is the containing ul 
    onBeforeShow:  function(){},       // callback function fires just before reveal animation begins – 'this' is the ul about to open 
    onShow:        function(){},       // callback function fires once reveal animation completed – 'this' is the opened ul 
    onHide:        function(){}        // callback function fires after a sub-menu has closed – 'this' is the ul that just closed 
  });   
});

            
