function slideShowNews() {
    $('#box-news div').css({ opacity: 0.0 });
    $('#box-news div:first').css({ opacity: 1.0 });
    setInterval('flashNews()', 6000);
}


function flashNews() {
    
    var current = ($('#box-news div.show') ? $('#box-news div.show') : $('#box-news div:first'));
    var next = ((current.next().length) ? ((current.next().hasClass('caption')) ? $('#box-news div:first') : current.next()) : $('#box-news div:first'));
    next.css({ opacity: 0.0 }).addClass('show').css('z-index', 500).animate({ opacity: 1.0 }, 1000);
    current.animate({ opacity: 0.0 }, 1000).removeClass('show').css('z-index', -500);
    
}
function slideShow() {
    $('#flash img').css({ opacity: 0.0 });
    $('#flash img:first').css({ opacity: 1.0 });
    setInterval('flash()', 6000);
}


function flash() {
    var current = ($('#flash img.show') ? $('#flash img.show') : $('#flash img:first'));
    var next = ((current.next().length) ? ((current.next().hasClass('caption')) ? $('#flash img:first') : current.next()) : $('#flash img:first'));
    next.css({ opacity: 0.0 }).addClass('show').animate({ opacity: 1.0 }, 1000);
    current.animate({ opacity: 0.0 }, 1000).removeClass('show');
}

$(document).ready(function () {
    Cufon.replace('.cufon-normal', { fontFamily: 'HelveticaNeue', hover: true });
    Cufon.replace('.project-files a.download', { fontFamily: 'HelveticaNeue', hover: true });
    Cufon.replace('.forspnsor', { fontFamily: 'HelveticaNeue', hover: true });
    Cufon.replace('.cufon-bold', { fontFamily: 'HelveticaNeueCond', hover: true });
    Cufon.replace('.slider h3', { fontFamily: 'HelveticaNeueCond', hover: true });
    Cufon.replace('#menu li a', { fontFamily: 'HelveticaNeueCond', hover: true });
    Cufon.replace('.sub-menu h2', { fontFamily: 'HelveticaNeue', hover: true });
    Cufon.replace('.sponsor-deck span.title', { fontFamily: 'HelveticaNeue', hover: true });
    Cufon.replace('.text h3', { fontFamily: 'HelveticaNeue', hover: true });
    Cufon.replace('.single h3', { fontFamily: 'HelveticaNeue', hover: true });
    Cufon.replace('#middle-bar', { fontFamily: 'HelveticaNeue', hover: true });

    Cufon.replace('.content h2', { fontFamily: 'HelveticaNeueLT Com 35 Th', hover: false });

    Cufon.replace('.highlight-top h3', { fontFamily: 'HelveticaNeueCond', hover: true });
    // Cufon.replace('ul.newsletters li a', { fontFamily: 'HelveticaNeueCond', hover: false });
    Cufon.replace('.ui-state-default a', { fontFamily: 'HelveticaNeueCond', hover: true });


    $('#menu').show();
    $('#langselect').show();
    $('.content h2').show();
    $('#middle-bar').show();

    slideShow();
    slideShowNews();
   

    $(".top-menu").hover(
      function () {
          $(".top-menu ul").hide();
          $(this).children('ul').css('display', 'block');
          $(".top-menu").children('a').children('h2').css('border-bottom', '0 solid #2e2c73');

          if ($(this).attr('id') == 'register' || $(this).attr('id') == 'contactus' || $(this).attr('id') == 'career') { }
          else {
              $(this).children('a').children('h2').css('border-bottom', '1px solid #2e2c73');
          }
      },
      function () {
          $(".top-menu ul").hide();
          $(".top-menu").children('a').children('h2').css('border-bottom', '0 solid #2e2c73');

          if (selectedMenuName == 'register' || selectedMenuName == 'contactus' || selectedMenuName == 'career') {

              $('#sub-' + selectedMenuName).css('display', 'block');
              $('#sub-' + selectedMenuName).parent().children('a').children('h2').css('border-bottom', '1px solid #2e2c73');
          }
          else {
              $('#sub-' + selectedMenuName + '-tr').css('display', 'block');
              $('#sub-' + selectedMenuName + '-tr').parent().children('a').children('h2').css('border-bottom', '1px solid #2e2c73');
              if (lang == 'en') {
                  $('#sub-' + selectedMenuName).css('display', 'block');
                  $('#sub-' + selectedMenuName).parent().children('a').children('h2').css('border-bottom', '1px solid #2e2c73');
              }
          }
      }
    );


    $(".hover1").hover(
      function () {
          $('#thumb1').css('display', 'block');
      },
      function () {
          $('#thumb1').hide();
      }
    );

    $(".hover2").hover(
      function () {
          $('#thumb2').css('display', 'block');
      },
      function () {
          $('#thumb2').hide();
      }
    );


    var status = false;
    $(".projects").mouseover(function () {
        status = true;
        $('#box-projects').fadeIn(300);
        $('#box-news').hide();
    });

    $("#box-projects").mouseover(function () {
        status = true;
        $('#box-projects').fadeIn(300);
    });

    $("#box-projects").mouseout(function () {
        setTimeout(function () {
            if (!status) {
                $('#box-projects').fadeOut(300);
                status = false;
            }
        }, 5000);

    });

    $(".projects").mouseout(function () {
        setTimeout(function () {
            if (!status) {
                $('#box-projects').fadeOut(300);
                status = false;
            }
        }, 5000);
    });

    $("#flash img").mouseover(function () {
        $('#box-projects').fadeOut(300);
        $('#box-news').fadeOut(300);
        status = false;
    });

    $(".content").mouseover(function () {
        $('#box-projects').fadeOut(300);
        $('#box-news').fadeOut(300);
        status = false;
    });




    var status2 = false;
    $(".news").mouseover(function () {
        status2 = true;
        $('#box-news').fadeIn(300);
        $('#box-projects').hide();
    });

    $("#box-news").mouseover(function () {
        status2 = true;
        $('#box-news').fadeIn(300);
    });

    $("#box-news").mouseout(function () {
        setTimeout(function () {
            if (!status2) {
                $('#box-news').fadeOut(300);
                status2 = false;
            }
        }, 5000);

    });

    $(".news").mouseout(function () {
        setTimeout(function () {
            if (!status2) {
                $('#box-news').fadeOut(300);
                status2 = false;
            }
        }, 5000);
    });


    $('#htmlslider').anythingSlider({
        easing: "easeInOutExpo",
        autoPlay: true,
        startStopped: false,
        delay: 6000,
        animationTime: 800,
        hashTags: false,
        pauseOnHover: true,
        navigationFormatter: null
    });
    $('#detay-slider').anythingSlider({
        easing: "easeInOutExpo",
        autoPlay: true,
        startStopped: false,
        delay: 6000,
        animationTime: 800,
        hashTags: false,
        pauseOnHover: true,
        navigationFormatter: null
    });
});

