(function(b){b.fn.form_prompt=a;function a(g,c){var f="";c=c||{};if(b.isFunction(g)){f=g.call(this)}else{f=g}var d=c.className||"form-prompt-text";var e=c.wrapperClassName||"form-prompt-wrapper";return this.each(function(){var j=b(this);var l=b('<div style="position:relative;overflow:hidden;display:inline-block;" />');if(b.browser.webkit){j.attr("placeholder",f);return}var k=l.attr("class");j.wrap(l.addClass(e));l.attr("class",k);if(j.val()==""){j.after("<div class='"+d+"'>"+f+"</div>")}else{j.after("<div class='"+d+"'></div>")}var l=j.parent("."+e);var i=l.find("."+d);i.css("position","absolute");i.css("top","0");i.css("left","0");i.css("z-index","1000");var h=function(){j.focus();i.hide()};j.click(h);j.keyup(h);i.click(h);j.blur(function(){if(j.val()==""){i.show()}})})}})(jQuery);

(function(e){e.fn.fixPNG=function(){return this.each(function(){var l=e(this).css("backgroundImage");if(l.match(/^url\(["']?(.*\.png)["']?\)$/i)){l=RegExp.$1;e(this).css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod="+(e(this).css("backgroundRepeat")=="no-repeat"?"crop":"scale")+", src='"+l+"')"}).each(function(){var m=e(this).css("position");if(m!="absolute"&&m!="relative"){e(this).css("position","relative")}})}})};var c,a,h=false,b=new Image,j,k=1,d=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i;var i=null,g=e.browser.msie&&e.browser.version.substr(0,1)==6&&!window.XMLHttpRequest,f=g||(e.browser.msie&&e.browser.version.substr(0,1)==7);e.fn.fancybox=function(l){var p=e.extend({},e.fn.fancybox.defaults,l);var w=this;function r(){c=this;a=e.extend({},p);q();return false}function q(){if(h){return}if(e.isFunction(a.callbackOnStart)){a.callbackOnStart()}a.itemArray=[];a.itemCurrent=0;if(p.itemArray.length>0){a.itemArray=p.itemArray}else{var x={};if(!c.rel||c.rel==""){var x={href:c.href,title:c.title};if(e(c).children("img:first").length){x.orig=e(c).children("img:first")}else{x.orig=e(c)}if(x.title==""||typeof x.title=="undefined"){x.title=x.orig.attr("alt")}a.itemArray.push(x)}else{var y=e(w).filter("a[rel="+c.rel+"]");var x={};for(var o=0;o<y.length;o++){x={href:y[o].href,title:y[o].title};if(e(y[o]).children("img:first").length){x.orig=e(y[o]).children("img:first")}else{x.orig=e(y[o])}if(x.title==""||typeof x.title=="undefined"){x.title=x.orig.attr("alt")}a.itemArray.push(x)}}}while(a.itemArray[a.itemCurrent].href!=c.href){a.itemCurrent++}if(a.overlayShow){if(g){e("embed, object, select").css("visibility","hidden");e("#fancy_overlay").css("height",e(document).height())}e("#fancy_overlay").css({"background-color":a.overlayColor,opacity:a.overlayOpacity}).show()}e(window).bind("resize.fb scroll.fb",e.fn.fancybox.scrollBox);s()}function s(){e("#fancy_right, #fancy_left, #fancy_close, #fancy_title").hide();var o=a.itemArray[a.itemCurrent].href;if(o.match("iframe")||c.className.indexOf("iframe")>=0){e.fn.fancybox.showLoading();n('<iframe id="fancy_frame" onload="jQuery.fn.fancybox.showIframe()" name="fancy_iframe'+Math.round(Math.random()*1000)+'" frameborder="0" hspace="0" src="'+o+'"></iframe>',a.frameWidth,a.frameHeight)}else{if(o.match(/#/)){var x=window.location.href.split("#")[0];x=o.replace(x,"");x=x.substr(x.indexOf("#"));n('<div id="fancy_div">'+e(x).html()+"</div>",a.frameWidth,a.frameHeight)}else{if(o.match(d)){b=new Image;b.src=o;if(b.complete){v()}else{e.fn.fancybox.showLoading();e(b).unbind().bind("load",function(){e("#fancy_loading").hide();v()})}}else{e.fn.fancybox.showLoading();e.get(o,function(y){e("#fancy_loading").hide();n('<div id="fancy_ajax">'+y+"</div>",a.frameWidth,a.frameHeight)})}}}}function v(){var z=b.width;var o=b.height;var B=(a.padding*2)+40;var A=(a.padding*2)+60;var x=e.fn.fancybox.getViewport();if(a.imageScale&&(z>(x[0]-B)||o>(x[1]-A))){var y=Math.min(Math.min(x[0]-B,z)/z,Math.min(x[1]-A,o)/o);z=Math.round(y*z);o=Math.round(y*o)}n('<img alt="" id="fancy_img" src="'+b.src+'" />',z,o)}function t(){if((a.itemArray.length-1)>a.itemCurrent){var o=a.itemArray[a.itemCurrent+1].href||false;if(o&&o.match(d)){objNext=new Image();objNext.src=o}}if(a.itemCurrent>0){var o=a.itemArray[a.itemCurrent-1].href||false;if(o&&o.match(d)){objNext=new Image();objNext.src=o}}}function n(B,x,D){h=true;var z=a.padding;if(f||i){e("#fancy_content")[0].style.removeExpression("height");e("#fancy_content")[0].style.removeExpression("width")}if(z>0){x+=z*2;D+=z*2;e("#fancy_content").css({top:z+"px",right:z+"px",bottom:z+"px",left:z+"px",width:"auto",height:"auto"});if(f||i){e("#fancy_content")[0].style.setExpression("height","(this.parentNode.clientHeight - "+z*2+")");e("#fancy_content")[0].style.setExpression("width","(this.parentNode.clientWidth - "+z*2+")")}}else{e("#fancy_content").css({top:0,right:0,bottom:0,left:0,width:"100%",height:"100%"})}if(e("#fancy_outer").is(":visible")&&x==e("#fancy_outer").width()&&D==e("#fancy_outer").height()){e("#fancy_content").fadeOut("fast",function(){e("#fancy_content").empty().append(e(B)).fadeIn("normal",function(){m()})});return}var C=e.fn.fancybox.getViewport();var F=(D+60)>C[1]?C[3]:(C[3]+Math.round((C[1]-D-60)*0.5));var y=(x+40)>C[0]?C[2]:(C[2]+Math.round((C[0]-x-40)*0.5));var E={left:y,top:F,width:x+"px",height:D+"px"};if(e("#fancy_outer").is(":visible")){e("#fancy_content").fadeOut("normal",function(){e("#fancy_content").empty();e("#fancy_outer").animate(E,a.zoomSpeedChange,a.easingChange,function(){e("#fancy_content").append(e(B)).fadeIn("normal",function(){m()})})})}else{if(a.zoomSpeedIn>0&&a.itemArray[a.itemCurrent].orig!==undefined){e("#fancy_content").empty().append(e(B));var A=a.itemArray[a.itemCurrent].orig;var o=e.fn.fancybox.getPosition(A);e("#fancy_outer").css({left:(o.left-20-a.padding)+"px",top:(o.top-20-a.padding)+"px",width:e(A).width()+(a.padding*2),height:e(A).height()+(a.padding*2)});if(a.zoomOpacity){E.opacity="show"}e("#fancy_outer").animate(E,a.zoomSpeedIn,a.easingIn,function(){m()})}else{e("#fancy_content").hide().empty().append(e(B)).show();e("#fancy_outer").css(E).fadeIn("normal",function(){m()})}}}function u(){if(a.itemCurrent!==0){e("#fancy_left, #fancy_left_ico").unbind().bind("click",function(o){o.stopPropagation();a.itemCurrent--;s();return false});e("#fancy_left").show()}if(a.itemCurrent!=(a.itemArray.length-1)){e("#fancy_right, #fancy_right_ico").unbind().bind("click",function(o){o.stopPropagation();a.itemCurrent++;s();return false});e("#fancy_right").show()}}function m(){if(e.browser.msie){e("#fancy_content")[0].style.removeAttribute("filter");e("#fancy_outer")[0].style.removeAttribute("filter")}u();t();e(document).bind("keydown.fb",function(x){if(x.keyCode==27&&a.enableEscapeButton){e.fn.fancybox.close()}else{if(x.keyCode==37&&a.itemCurrent!==0){e(document).unbind("keydown.fb");a.itemCurrent--;s()}else{if(x.keyCode==39&&a.itemCurrent!=(a.itemArray.length-1)){e(document).unbind("keydown.fb");a.itemCurrent++;s()}}}});if(a.hideOnContentClick){e("#fancy_content").click(e.fn.fancybox.close)}if(a.overlayShow&&a.hideOnOverlayClick){e("#fancy_overlay").bind("click",e.fn.fancybox.close)}if(a.showCloseButton){e("#fancy_close").bind("click",e.fn.fancybox.close).show()}if(typeof a.itemArray[a.itemCurrent].title!=="undefined"&&a.itemArray[a.itemCurrent].title.length>0){var o=e("#fancy_outer").position();e("#fancy_title div").text(a.itemArray[a.itemCurrent].title).html();e("#fancy_title").css({top:o.top+e("#fancy_outer").outerHeight()-32,left:o.left+((e("#fancy_outer").outerWidth()*0.5)-(e("#fancy_title").width()*0.5))}).show()}if(a.overlayShow&&g){e("embed, object, select",e("#fancy_content")).css("visibility","visible")}if(e.isFunction(a.callbackOnShow)){a.callbackOnShow(a.itemArray[a.itemCurrent])}if(e.browser.msie){e("#fancy_outer")[0].style.removeAttribute("filter");e("#fancy_content")[0].style.removeAttribute("filter")}h=false}return this.unbind("click.fb").bind("click.fb",r)};e.fn.fancybox.scrollBox=function(){var l=e.fn.fancybox.getViewport();if(a.centerOnScroll&&e("#fancy_outer").is(":visible")){var m=e("#fancy_outer").outerWidth();var n=e("#fancy_outer").outerHeight();var o={top:(n>l[1]?l[3]:l[3]+Math.round((l[1]-n)*0.5)),left:(m>l[0]?l[2]:l[2]+Math.round((l[0]-m)*0.5))};e("#fancy_outer").css(o);e("#fancy_title").css({top:o.top+n-32,left:o.left+((m*0.5)-(e("#fancy_title").width()*0.5))})}if(g&&e("#fancy_overlay").is(":visible")){e("#fancy_overlay").css({height:e(document).height()})}if(e("#fancy_loading").is(":visible")){e("#fancy_loading").css({left:((l[0]-40)*0.5+l[2]),top:((l[1]-40)*0.5+l[3])})}};e.fn.fancybox.getNumeric=function(l,m){return parseInt(e.curCSS(l.jquery?l[0]:l,m,true))||0};e.fn.fancybox.getPosition=function(l){var m=l.offset();m.top+=e.fn.fancybox.getNumeric(l,"paddingTop");m.top+=e.fn.fancybox.getNumeric(l,"borderTopWidth");m.left+=e.fn.fancybox.getNumeric(l,"paddingLeft");m.left+=e.fn.fancybox.getNumeric(l,"borderLeftWidth");return m};e.fn.fancybox.showIframe=function(){e("#fancy_loading").hide();e("#fancy_frame").show()};e.fn.fancybox.getViewport=function(){return[e(window).width(),e(window).height(),e(document).scrollLeft(),e(document).scrollTop()]};e.fn.fancybox.animateLoading=function(){if(!e("#fancy_loading").is(":visible")){clearInterval(j);return}e("#fancy_loading > div").css("top",(k*-40)+"px");k=(k+1)%12};e.fn.fancybox.showLoading=function(){clearInterval(j);var l=e.fn.fancybox.getViewport();e("#fancy_loading").css({left:((l[0]-40)*0.5+l[2]),top:((l[1]-40)*0.5+l[3])}).show();e("#fancy_loading").bind("click",e.fn.fancybox.close);j=setInterval(e.fn.fancybox.animateLoading,66)};e.fn.fancybox.close=function(){h=true;e(b).unbind();e(document).unbind("keydown.fb");e(window).unbind("resize.fb scroll.fb");e("#fancy_overlay, #fancy_content, #fancy_close").unbind();e("#fancy_close, #fancy_loading, #fancy_left, #fancy_right, #fancy_title").hide();__cleanup=function(){if(e("#fancy_overlay").is(":visible")){e("#fancy_overlay").fadeOut("fast")}e("#fancy_content").empty();if(a.centerOnScroll){e(window).unbind("resize.fb scroll.fb")}if(g){e("embed, object, select").css("visibility","visible")}if(e.isFunction(a.callbackOnClose)){a.callbackOnClose()}h=false};if(e("#fancy_outer").is(":visible")!==false){if(a.zoomSpeedOut>0&&a.itemArray[a.itemCurrent].orig!==undefined){var m=a.itemArray[a.itemCurrent].orig;var l=e.fn.fancybox.getPosition(m);var n={left:(l.left-20-a.padding)+"px",top:(l.top-20-a.padding)+"px",width:e(m).width()+(a.padding*2),height:e(m).height()+(a.padding*2)};if(a.zoomOpacity){n.opacity="hide"}e("#fancy_outer").stop(false,true).animate(n,a.zoomSpeedOut,a.easingOut,__cleanup)}else{e("#fancy_outer").stop(false,true).fadeOut("fast",__cleanup)}}else{__cleanup()}return false};e.fn.fancybox.build=function(){var l="";l+='<div id="fancy_overlay"></div>';l+='<div id="fancy_loading"><div></div></div>';l+='<div id="fancy_outer">';l+='<div id="fancy_inner">';l+='<div id="fancy_close"></div>';l+='<div id="fancy_bg"><div class="fancy_bg" id="fancy_bg_n"></div><div class="fancy_bg" id="fancy_bg_ne"></div><div class="fancy_bg" id="fancy_bg_e"></div><div class="fancy_bg" id="fancy_bg_se"></div><div class="fancy_bg" id="fancy_bg_s"></div><div class="fancy_bg" id="fancy_bg_sw"></div><div class="fancy_bg" id="fancy_bg_w"></div><div class="fancy_bg" id="fancy_bg_nw"></div></div>';l+='<a href="javascript:;" id="fancy_left"><span class="fancy_ico" id="fancy_left_ico"></span></a><a href="javascript:;" id="fancy_right"><span class="fancy_ico" id="fancy_right_ico"></span></a>';l+='<div id="fancy_content"></div>';l+="</div>";l+="</div>";l+='<div id="fancy_title"></div>';e(l).appendTo("body");e('<table cellspacing="0" cellpadding="0" border="0"><tr><td class="fancy_title" id="fancy_title_left"></td><td class="fancy_title" id="fancy_title_main"><div></div></td><td class="fancy_title" id="fancy_title_right"></td></tr></table>').appendTo("#fancy_title");if(e.browser.msie){e(".fancy_bg").fixPNG()}if(g){e("div#fancy_overlay").css("position","absolute");e("#fancy_loading div, #fancy_close, .fancy_title, .fancy_ico").fixPNG();e("#fancy_inner").prepend('<iframe id="fancy_bigIframe" src="javascript:false;" scrolling="no" frameborder="0"></iframe>');var m=e("#fancy_bigIframe")[0].contentWindow.document;m.open();m.close()}};e.fn.fancybox.defaults={padding:10,imageScale:true,zoomOpacity:true,zoomSpeedIn:0,zoomSpeedOut:0,zoomSpeedChange:300,easingIn:"swing",easingOut:"swing",easingChange:"swing",frameWidth:560,frameHeight:340,overlayShow:true,overlayOpacity:0.3,overlayColor:"#666",enableEscapeButton:true,showCloseButton:true,hideOnOverlayClick:true,hideOnContentClick:true,centerOnScroll:true,itemArray:[],callbackOnStart:null,callbackOnShow:null,callbackOnClose:null};e(document).ready(function(){i=e.browser.msie&&!e.boxModel;if(e("#fancy_outer").length<1){e.fn.fancybox.build()}})})(jQuery);

(function(a){a.ajaxSettings.accepts._default="text/javascript, text/html, application/xml, text/xml, */*"})(jQuery);(function(a){a.fn.reset=function(){return this.each(function(){if(typeof this.reset=="function"||(typeof this.reset=="object"&&!this.reset.nodeType)){this.reset()}})};a.fn.enable=function(){return this.each(function(){this.disabled=false})};a.fn.disable=function(){return this.each(function(){this.disabled=true})}})(jQuery);(function(a){a.extend({fieldEvent:function(b,f){var d=b[0]||b,c="change";if(d.type=="radio"||d.type=="checkbox"){c="click"}else{if(f&&d.type=="text"||d.type=="textarea"){c="keyup"}}return c}});a.fn.extend({delayedObserver:function(b,f){var c=a(this);if(typeof window.delayedObserverStack=="undefined"){window.delayedObserverStack=[]}if(typeof window.delayedObserverCallback=="undefined"){window.delayedObserverCallback=function(h){var g=window.delayedObserverStack[h];if(g.timer){clearTimeout(g.timer)}g.timer=setTimeout(function(){g.timer=null;g.callback(g.obj,g.obj.formVal())},g.delay*1000);g.oldVal=g.obj.formVal()}}window.delayedObserverStack.push({obj:c,timer:null,delay:b,oldVal:c.formVal(),callback:f});var d=window.delayedObserverStack.length-1;if(c[0].tagName=="FORM"){a(":input",c).each(function(){var g=a(this);g.bind(a.fieldEvent(g,b),function(){var h=window.delayedObserverStack[d];if(h.obj.formVal()==h.oldVal){return}else{window.delayedObserverCallback(d)}})})}else{c.bind(a.fieldEvent(c,b),function(){var g=window.delayedObserverStack[d];if(g.obj.formVal()==g.oldVal){return}else{window.delayedObserverCallback(d)}})}},formVal:function(){var b=this[0];if(b.tagName=="FORM"){return this.serialize()}if(b.type=="checkbox"||b.type=="radio"){return this.filter("input:checked").val()||""}else{return this.val()}}})})(jQuery);(function($){$.fn.extend({visualEffect:function(o){e=o.replace(/\_(.)/g,function(m,l){return l.toUpperCase()});return eval("$(this)."+e+"()")},appear:function(speed,callback){return this.fadeIn(speed,callback)},blindDown:function(speed,callback){return this.show("blind",{direction:"vertical"},speed,callback)},blindUp:function(speed,callback){return this.hide("blind",{direction:"vertical"},speed,callback)},blindRight:function(speed,callback){return this.show("blind",{direction:"horizontal"},speed,callback)},blindLeft:function(speed,callback){this.hide("blind",{direction:"horizontal"},speed,callback);return this},dropOut:function(speed,callback){return this.hide("drop",{direction:"down"},speed,callback)},dropIn:function(speed,callback){return this.show("drop",{direction:"up"},speed,callback)},fade:function(speed,callback){return this.fadeOut(speed,callback)},fadeToggle:function(speed,callback){return this.animate({opacity:"toggle"},speed,callback)},fold:function(speed,callback){return this.hide("fold",{},speed,callback)},foldOut:function(speed,callback){return this.show("fold",{},speed,callback)},grow:function(speed,callback){return this.show("scale",{},speed,callback)},highlight:function(speed,callback){return this.show("highlight",{},speed,callback)},puff:function(speed,callback){return this.hide("puff",{},speed,callback)},pulsate:function(speed,callback){return this.show("pulsate",{},speed,callback)},shake:function(speed,callback){return this.show("shake",{},speed,callback)},shrink:function(speed,callback){return this.hide("scale",{},speed,callback)},squish:function(speed,callback){return this.hide("scale",{origin:["top","left"]},speed,callback)},slideUp:function(speed,callback){return this.hide("slide",{direction:"up"},speed,callback)},slideDown:function(speed,callback){return this.show("slide",{direction:"up"},speed,callback)},switchOff:function(speed,callback){return this.hide("clip",{},speed,callback)},switchOn:function(speed,callback){return this.show("clip",{},speed,callback)}})})(jQuery);

var DEBUG = false;

// tracks a pageview
function track_pageview(link) {
  link = link.replace(/^[a-z]+:\/\/[^\/]+/, '');
  if (DEBUG) console.log('Pageview: ' + link);
  if (typeof(_gaq) != 'undefined')
    _gaq.push(['_trackPageview', link]);
}

// handler to track clicks using event tracking
function track_event(category, action, label) {
  if (DEBUG) console.log('Event: ' + category + ' > ' + action + ' > ' + label);
  if (typeof(_gaq) != 'undefined')
    _gaq.push(['_trackEvent', category, action, label]);
}

// links 3rd-party page via Analytics
function track_link(link) {
  if (DEBUG) console.log('Link: ' + link);
  if (typeof(_gaq) != 'undefined') {
    _gaq.push(['_link', link]);
    return false;
  }
}

function is_external() {
  if (!this.hostname || !location.hostname) return false;
  var hostname1 = this.hostname.replace(/^.*?([^\.]+\.\w+)$/, '$1');
  var hostname2 = location.hostname.replace(/^.*?([^\.]+\.\w+)$/, '$1');
  return hostname1 != hostname2;
}

function is_local() {
  return !is_external();
}

function fix_height(selector) {
  var height = $(selector).height();
  $(selector + ' > *').css('min-height', height);
}

// fixes height of floating list items
function fix_list_height(selector, items_per_row) {
  var row;
  $(selector + ' > *').each(function(i) {
    if (i % items_per_row == 0) {
      row = $(this);
    } else {
      var prev_height = row.last().height();
      var height = $(this).height();
      row = row.add(this);
      if (height != prev_height)
        row.height(prev_height > height ? prev_height : height);
    }
  });
}

// override fancybox defaults
$.extend($.fn.fancybox.defaults, {
  zoomOpacity: true,
  zoomSpeedIn: 200,
  zoomSpeedOut: 200,
  zoomSpeedChange: 100,
  frameWidth: 640,
  frameHeight: 505,
  callbackOnShow: function() {
    // remove asset URL appendix added by Rails
    url = this.itemArray[this.itemCurrent].href.replace(/\?[0-9]+$/, '');
    // track inline content
    if (url.match(/\.(jpg|jpeg|gif|png)$/) || url.match(/#\w+$/))
      track_pageview(url);
  }
});

// called when the DOM is ready
$(function() {
  // setup Fancybox
  $('a.thickbox').fancybox();
  $('a.inline').fancybox({hideOnContentClick: false})
  $('a.inline-wide').fancybox({hideOnContentClick: false, frameHeight: 385})
  
  // track all external links
  $('a[href^=http]').filter(is_external).attr('target', '_blank').click(function() {
    track_event('Outgoing Links', 'Click', this.href);
  });
  
  // link all links to forum and store
  $('a[href^="http://forum.djay-software.com"]').click(function() {return track_link(this.href)});
  $('a[href*="/buy"]').filter(is_local).click(function() {return track_link(this.href)});
  
  // track all downloads
  $('a:not(.thickbox)')
    .filter(function() {return this.href.match(/\.(jpg|jpeg|gif|png|tif|tiff|eps|pdf|dmg|zip)$/i)})
    .filter(is_local).click(function() {
    track_event('Downloads', 'Click', this.href.replace(/^[a-z]+:\/\/[^\/]+/, ''));
  });
  
  // add title tag to all fixed-width tables
  $('table.fixed-width td').each(function() {
    if (!$(this).attr('title'))
      $(this).attr('title', $(this).text());
  });
  
  // add form prompt to email fields
  $('input[name=email]').form_prompt('Enter your email address');
  
  // Home: fix height of divs
  fix_height('#features.grid_full');
});

if (typeof(console) == 'undefined') {
  console = {};
  console.log = function(msg) {alert(msg)};
}
