


var twofold = {
  
  init : function() {
    twofold.prepNavigation();
    twofold.prepSliders();
   // twofold.prepTooltips();
   // twofold.prepScrollers();
    //twofold.prepHand();
   // twofold.prepWork();
    twofold.prepRounded();
//    initializegmaps();
  }
  
  ,prepNavigation : function() {
    $('#nav_611603 li').each(function() {
      if (!$(this).hasClass('selected'))
        $(this).find('a').prepend('<span class="base"></span>');
    });
    
  	//Hide (Collapse) the toggle containers on load
  	$(".toggle_container").hide(); 
  	//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
  	$("span.trigger").click(function(){
  		$(this).toggleClass("active").next().slideToggle("slow");
  		return false; //Prevent the browser jump to the link anchor
  	});
  }

  ,prepSliders : function() {
    //$('#slider1 li:first .slider-text').css({ marginLeft: '480px' });
    $('#slider1').anythingSlider({
   		    startStopped    : false, // If autoPlay is on, this can force it to start stopped
			width           : 2000,   // Override the default CSS width
			height          : 550,   // Override the default CSS width
			theme           : 'minimalist-round',
			buildArrows     : true,
			autoPlayLocked  : true,  // If true, user changing slides will not stop the slideshow
			resumeDelay     : 10000, // Resume slideshow after user interaction, only if autoplayLocked is true (in milliseconds).
			onSlideComplete : function(slider){
				// alert('Welcome to Slide #' + slider.currentPage);
			}
			,onSlideBegin : function(slider) {
			  var target_slide = $('li.activePage').next();
			  if ($('li.activePage').length == 0 || target_slide.length == 0) target_slide = $('#slider1 li:first').next().next();
			  var target_text = target_slide.find('.slider-text');
			  target_text.animate({
			    marginLeft: '480px'
			  }, 1000, 'easeInOutExpo');
			}
			,onSlideComplete : function(slider) {
			  var target_slide = $('li.activePage').next();
			  target_slide.find('.slider-text').css({ marginLeft: '1280px' });
			}
		});
//		$('#slider2').anythingSlider({
//			width               : 546,   // if resizeContent is false, this is the default width if panel size is not defined
//			height              : 512,   // if resizeContent is false, this is the default height if panel size is not defined
//			resizeContents      : false,
//			theme           : 'minimalist-round',
//			buildArrows     : false,
//			pauseOnHover    : true,      //
//			autoPlayLocked  : true,  // If true, user changing slides will not stop the slideshow
//			resumeDelay     : 17000, // Resume slideshow after user interaction, only if autoplayLocked is true (in milliseconds).
//			onSlideComplete : function(slider){
//				// alert('Welcome to Slide #' + slider.currentPage);
//			}
//		});
		
		// External Link
//		$("a.muppet").click(function(){
//			$('#slider1').anythingSlider(5);
//			$(document).scrollTop(0);
//			return false;
//		});
		// Report Events to console & features list
//		$('#slider1').bind('before_initialize initialized swf_completed slideshow_start slideshow_stop slideshow_paused slideshow_unpaused slide_init slide_begin slide_complete', function(e, slider){
//			// show object ID + event (e.g. "slider1: slide_begin")
//			var txt = slider.$el[0].id + ': ' + e.type + ', now on panel #' + slider.currentPage;
//			$('#status').text(txt);
//			if (window.console && window.console.firebug){ console.debug(txt); } // added window.console.firebug to make this work in Opera
//		});
		// Add a slide
//		var imageNumber = 1;
//		$('button.add').click(function(){
//			$('#slider1')
//				.append('<li><img src="images/slide-tele-' + (++imageNumber%2 + 1)  + '.jpg" alt="" /></li>')
//				.anythingSlider(); // update the slider
//		});
//		$('button.remove').click(function(){
//			if ($('#slider1').data('AnythingSlider').pages > 1) {
//				$('#slider1 > li:not(.cloned):last').remove();
//				$('#slider1').anythingSlider(); // update the slider
//			}
//		});
  }
  
  ,prepTooltips : function() {
//    $('a.tipsy-trigger').tipsy({
//      gravity: 's', 
//      offset: -48, 
//      fade: true
//    });
  }
  
  ,prepScrollers : function() {
//    $("#toTop").scrollToTop({speed:1000,ease:"easeInOutExpo",start:0});
//    $('.work-splitter-top li:last a').click(function() {
//      $('html,body').animate({ scrollTop: '670' }, 500, 'easeInOutExpo');
//      return false;
//    });
  }
  
  ,prepHand : function() {
//    $('#iphone').hover(function() {
//      $(this).stop().animate({ width: "255px" }, 500, 'easeInOutExpo');
//    }, function() {
//      $(this).stop().animate({ width: '54px' }, 800, 'easeInOutExpo');
//    });
  }
  
  ,prepWork : function() {
    /*$(".image-grid li").live("mouseover mouseout", function(event) {
      if ( event.type == "mouseover" ) {
        event.stopPropagation();
        $(this).find('strong').animate({ top: '0px' });
        $(this).find('span').animate({ top: '34px' });
      } else {
        $(this).find('strong').animate({ top: '-60px' });
        $(this).find('span').animate({ top: '-34px' });
      }
    });*/
    
//    $('.image-grid li').hover(function() {
//      $(this).find('strong').animate({ top: '0px' });
//      $(this).find('span').animate({ top: '34px' });
//    }, function() {
//      $(this).find('strong').animate({ top: '-60px' });
//      $(this).find('span').animate({ top: '-34px' });
//    });
  }
  
  ,prepRounded : function() {
    
    var myBorder = RUZEE.ShadedBorder.create({ corner:25, shadow:0 });
    $(".rounded-splitter").each(function() {
      myBorder.render($(this));
    })
    
    var myBorder1 = RUZEE.ShadedBorder.create({ corner:20, shadow:0 });
    $(".rounded-20, .rounded-comments").each(function() {
      myBorder1.render($(this));
    })
    
    var myBorder2 = RUZEE.ShadedBorder.create({ corner:8, shadow:0 });
    $(".rounded-8, .pagination").each(function() {
      myBorder2.render($(this));
    })

  }

}

$(document).ready(twofold.init);

// On window load. This waits until images have loaded which is essential

