jQuery.noConflict();
jQuery(document).ready(function($){

  $('#distributors a').fadeTo('fast', 0.7);

// 
  if($('#distributors').length) {
    $('#distributors a').hover( function() {
      $(this).fadeTo(70, 1);
    }, function() {
      $(this).fadeTo(10, 0.7);
    });
  }

// E-mail defuscator

  $('a[href^="mailto:"]').addClass('email');
  if ($('a.email').length > 0) { $('a.email').defuscate(); }

// External links auto-styler

  $('p a').filter(function() {
    return this.hostname && this.hostname !== location.hostname;
  }).addClass('external');

  $('a.external').click(function(){
    window.open(this.href);
    return false;
  });

// Button styling

  $('button').hover( function() { $(this).css ('cursor', 'pointer') })

// Swap value text form

    swapValues = [];
    $(".swap-value").each(function(i){
        swapValues[i] = $(this).val();
        $(this).focus(function(){
            if ($(this).val() == swapValues[i]) {
                $(this).val("");
            }
        }).blur(function(){
            if ($.trim($(this).val()) == "") {
                $(this).val(swapValues[i]);
            }
        });
    });  
  
  $('#menu ul').addClass('spritesnav');
  $('.spritesnav').sprites();
  
  $('#bottom-menu li:first').css('padding-left', '0').css('margin-left', '0').css('background-image','none');
  $('#distributors li:first').css('padding-left', '0').css('margin-left', '0').css('background-image','none');
  
  $("#accordion").accordion();
  $("#tabs").tabs();
  
  $('#apps') 
  .before("<div id='carousel'><ul id='nav'><li id='prev'> &lsaquo; </li><li id='next'> &rsaquo; </li>") 
  .after("<div class='clearfix'></div>") 
  .cycle({ 
      next:   '#next', 
      prev:   '#prev',
      fx:     'fade', 
      speed:  'fast', 
      timeout: 0, 
      pager:  '#nav', 
      pagerAnchorBuilder: function(idx, slide) { 
        /*$("#" + slide.id).find("img").addClass('reflected');*/
        caption = $("#" + slide.id).find("h2").text();
        splited = $("#" + slide.id).find("img").attr("src").split("/");
        path = '/img/' + splited[splited.length - 2] + '/thumbs/' + splited[splited.length - 1];
        $("#carousel").addClass(splited[splited.length - 2] + '-c');
        return '<li><a href="#"><img src="' + path + '" width="110" height="56" alt="' + caption + '" title="' + caption + '"/></a><div>' + caption + '</div></li>'; 
    } 
  });
  
  $('li#next').appendTo("ul#nav");
  $('ul#nav').after('</div>');
  
  $('li#prev, li#next').hover(
    function() { $(this).addClass('ui-state-hover'); },
    function() { $(this).removeClass('ui-state-hover'); }
  );   
  
  /*$('.reflected').reflect( {height: 0.3, opacity: 0.25} );*/
  /*$('div.reflected').css({'float' : 'left', 'margin' : '0 3em 23em 0'});*/

    $('#homepage #promo').flash ({
      swf: 'swf/promo.swf', 
      width: 960,
      height: 370,
      params: { play: 'true', loop: 'true', autoplay: '1', wmode: 'transparent' }  
    });


// Addthis button

  $('#addthis').mouseover( function(){
    return addthis_open(this, '', '[URL]', '[TITLE]')
  });
  $('#addthis').mouseout(function(){ addthis_close(); });
  $('#addthis').click(function(){ return addthis_sendto(); });		
		
	if($('.fancyzoom').length > 0) {
    $('.fancyzoom').fancyZoom( {width:950, height:600 } ); 
    $('.fancyzoom').click ( function () {
      $('#roi-calculator-button iframe').attr('src','/roi-calculator.html');
    });
	}

  if( $('.the-solution-c').length > 0 ) {
    $('#apps').css('height','350px');
  };

		
});

window.onload = function(){ 
  if( document.getElementById('atff') != null ) {
    var flash_cookie = document.getElementById('atff');
    flash_cookie.parentNode.style.display = 'none';
  }
} 