ion0 = function() {

  var testimonial_wait = 15000;
  var clientbox_wait = 5000;

  // To add additional clients (aka larger image)
  // add additional offsets here for non-transition browsers
  var client_list_top = ['0', '-380px', '-740px'];

  // To add additional clients for transition capable browsers
  // add a frameN to the css and add it here 
  var client_list_transition = ['frame2', 'frame3', ''];

  var scroll_pos_idx = 1;

  function init() {
    $("#technologiesbox").accordion();

    var cssTransitionsSupported = checkCssTransitionsSupported();
    if (cssTransitionsSupported) {
      setTimeout(clientTransition, clientbox_wait);
      setTimeout(testimonialTransition, testimonial_wait);
    } 
    else {
      setTimeout(clientScroll, clientbox_wait);
      setTimeout(testimonialSwap, testimonial_wait);
    }

    $("#contact_name").bind("focus", function() { clearDefaultandCSS(this); })
      .bind("blur", function() { refillEmptyField(this, 'Your Name'); });
    $("#contact_company").bind("focus", function() { clearDefaultandCSS(this); })
      .bind("blur", function() { refillEmptyField(this, 'Your Company Name'); });
    $("#contact_email").bind("focus", function() { clearDefaultandCSS(this); })
      .bind("blur", function() { refillEmptyField(this, 'Your Email Address'); });
    $("#contact_phone").bind("focus", function() { clearDefaultandCSS(this); })
      .bind("blur", function() { refillEmptyField(this, 'Your Phone Number'); });
    $("#contact_message").bind("focus", function() { clearDefaultandCSS(this); })
      .bind("blur", function() { refillEmptyField(this, 'Your Message'); });
    $("#contact_form").bind("submit", function() { return validate(this); });
  }

  function checkCssTransitionsSupported() {
    var cssTransitionsSupported = false;
    (function() {
      var div = document.createElement('div');
      div.setAttribute('style', 'transition:top 1s ease;-webkit-transition:top 1s ease;-moz-transition:top 1s ease;');
      //cssTransitionsSupported = !!(div.style.transition || div.style.webkitTransition || div.style.MozTransition);
      // IE8 confused by thinking it supports transitions...
      cssTransitionsSupported = !!(div.style.webkitTransition || div.style.MozTransition);
      delete div;
    })();
    return cssTransitionsSupported;
  }

  function clearDefault(el) {
    if (el.defaultValueb == el.value) el.value = "" 
  }

  function clearDefaultandCSS(el) {
	  if (el.defaultValue == el.value) el.value = ""
	  // If Dynamic Style is supported, clear the style
	  if (el.style) el.style.cssText = ""
  }

  function refillEmptyField(field, text) {
    if (field.value == "") {
      field.value = text;
      field.style.color = "#CCC";
    }
  }
    
	function validate(form) { 
	  if (document.contact.name.value == "" || document.contact.name.value == "Your Name") { 
		  alert("Please enter your name"); 
		  return false;
		}
	
	  if (document.contact.email.value == "" || document.contact.email.value == "Your Email Address") { 
		  alert("Please enter your email address"); 
		  return false;
		}

	  if (document.contact.message.value == "" || document.contact.message.value == "Your Message") { 
		  alert("Please enter a message!"); 
		  return false;
		}

	  return true;
	}
	
  function clientTransition() {
    var el = $("#clientbox");

    el.removeClass(client_list_transition[scroll_pos_idx]);

    scroll_pos_idx += 1;
    if (scroll_pos_idx >= client_list_transition.length)
      scroll_pos_idx = 0;

    el.addClass(client_list_transition[scroll_pos_idx]);

    setTimeout(clientTransition, clientbox_wait);            
    return 0;
  }
    

  function clientScroll() {
    $("#clientbox").stop().animate(
      {'top' : client_list_top[scroll_pos_idx]}, 
      {duration : 500}
    );

    scroll_pos_idx += 1;
    if (scroll_pos_idx >= client_list_top.length)
      scroll_pos_idx = 0;

    setTimeout(clientScroll, clientbox_wait);            
  }


  function testimonialTransition(){
    var current = $("div.testimonial:not('.hidden')").addClass('hidden');
    next = current.nextAll(":first");
    if (!next.length) {
      next = $("div.testimonial:first");
    }
    next.removeClass('hidden');
    setTimeout(testimonialTransition, testimonial_wait);            
    return 0;
  }
    
  function testimonialSwap() {
    $("div.testimonial:not('.hidden')").fadeOut('fast', function() {
      $(this).addClass("hidden");
      next = $(this).nextAll(":first");

      if (!next.length) {
        next = $("div.testimonial:first");
      }

      next.removeClass('hidden');
      next.fadeIn('fast');

    });

    setTimeout(testimonialSwap, testimonial_wait);            
    return 0;
  }

  return {
    init: init
  }
}();

