history.navigationMode = 'compatible';

// CWT jquery Script
$(document).ready(function(){
// jquery include script
   $(".js-include").each(function(){
       var inc=$(this);
       $.get(inc.attr("title"), function(data){
           inc.replaceWith(data);
       });
   });

   // if the sidebar contains no content then hide it and expand the main div
   if($('#sidenav').length == 0) {
     $('#sidebar').remove();
     $("#main").width("97%");
   }

   // fade in for the main content div
   $('#main').hide().css({visibility: "visible"}).delay(100).fadeIn(1200);
   
   // code for callasping side menu
   // Grow/Shrink
   $(".expanded + ul").show("normal");
   $(".expanded").click(function() {
    $(this).toggleClass("expanded").toggleClass("collapsed").parent().find('> ul').stop(true,true).toggle(700);
    });
   $(".collapsed").click(function() {
    $(this).toggleClass("expanded").toggleClass("collapsed").parent().find('> ul').stop(true,true).toggle(700);
    });

   // code for zooming images
   $('img.zoomImage').attr('title','Click to see larger image.');
   // if window is resized then reposition the overlay box
   $(window).bind('resize',showOverlayBox);
   $(window).scroll(showOverlayBox);
   // activate when the link with class launchLink is clicked
   $('img.zoomImage').click( doOverlayOpen );         
   // close it when closeLink is clicked
   $('img.closeLink').click( doOverlayClose );

   // code for fading main menu dropdown
   // ul#topnav li:hover span
   $("#topnav > li").hover(function(){
       $(this).children("span").stop(true,true).fadeIn(500);
   },
   function(){
       $(this).children("span").stop(true,true).fadeOut(300);
   });
   
   var linkLocation='';
   $("a.transition").click(function(event){
     event.preventDefault();
     linkLocation = this.href;
     $("#topnav > li").children("span").stop(true,true).fadeOut(300);
     $("#main").fadeTo(500,0, function(){
         if (linkLocation != 'http://done/') window.location = linkLocation;
       });
   });
   
   $('#slideseco').jqFancyTransitions({ 
      effect: 'wave',
      width: 285, 
      height: 392,
      delay: 3000,
      titleSpeed: 1000,
      strips: 40,
      stripDelay: 40 });

   // setup service wizard
   wizloadnext("ggdsfger","step1","dsfdfgfd"); 
});

// service wizard
function wizloadnext(divout,divin,divcontent){

  $("." + divout).hide();
  $("." + divin).fadeIn("fast");
  $("." + divcontent).fadeIn("fast");
}

// slide show script
function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.fadeTo(0,0)
        .addClass('active')
        .fadeTo(2000,1.0, function() {
            $active.removeClass('active last-active');
        });
}
function slideSwitchsm() {
    var $active = $('#slideshowsm IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshowsm IMG:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshowsm IMG:first');

    $active.addClass('last-active');

    $next.fadeTo(0,0)
        .addClass('active')
        .fadeTo(2000,1.0, function() {
            $active.removeClass('active last-active');
        });
}


$(function() {
   $('#slideshow').jqFancyTransitions({ 
      effect: 'wave',
      width: 1024, 
      height: 450,
//      strips: 20,
      titleSpeed: 1000,
      stripDelay: 40 });
   $('#slideshowsm').jqFancyTransitions({
      effect: 'wave',
      width: 640, 
      height: 281,
//      strips: 20,
      titleSpeed: 1000,
      stripDelay: 40 });
});
// end slide show



