/*

Underneath written and/ or included in pdfmyurl

*/

/*

http://www.strictly-software.com/scripts/downloads/encoder.js

*/



/* 

used to load user voice

*/

/*

pasted from script for http://widget.uservoice.com/otf2fHbU9gLxqxSEXLz3A.js

*/
//
// This is the new tab.js -- it can add a Feedback tab to the page, and it can pop up an iframe.  It's included on a 3rd party customer site.
//
//
// It has the following interface that can be manually called by a customer:
// UserVoice.showPopupWidget(options);    // Show the widget now with these options.
// UserVoice.showTab(options);            // Show the feedback tab with these options.  When clicked, it will show the popup widget.
// UserVoice.insertWidget(options);       // Insert the feedback tab into your site
//
// If uvOptions is defined, it can override any setting in the defaults.
//

if (!UserVoice) {
  var UserVoice = {};
}

if (!UserVoice || !UserVoice.showPopupWidget) {
(function() {

  // Micro libraries.  Extracted from other files.

  // base64 encode something
  var base64Encode = function(input) {
    function uTF8Encode(string) {
      string = string.replace(/\x0d\x0a/g, "\x0a");
      var output = "";
      for (var n = 0; n < string.length; n++) {
        var c = string.charCodeAt(n);
        if (c < 128) {
          output += String.fromCharCode(c);
        } else if ((c > 127) && (c < 2048)) {
          output += String.fromCharCode((c >> 6) | 192);
          output += String.fromCharCode((c & 63) | 128);
        } else {
          output += String.fromCharCode((c >> 12) | 224);
          output += String.fromCharCode(((c >> 6) & 63) | 128);
          output += String.fromCharCode((c & 63) | 128);
        }
      }
      return output;
    };

    var keyString = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
    var output = "";
    var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
    var i = 0;
    input = uTF8Encode(input);
    while (i < input.length) {
      chr1 = input.charCodeAt(i++);
      chr2 = input.charCodeAt(i++);
      chr3 = input.charCodeAt(i++);
      enc1 = chr1 >> 2;
      enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
      enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
      enc4 = chr3 & 63;
      if (isNaN(chr2)) {
        enc3 = enc4 = 64;
      } else if (isNaN(chr3)) {
        enc4 = 64;
      }
      output = output + keyString.charAt(enc1) + keyString.charAt(enc2) + keyString.charAt(enc3) + keyString.charAt(enc4);
    }
    return output;
  };

  // JSON stringifier.  Extracted from json2
  var jsonStringify = null;
  //////
  (function(){function f(n){return n<10?'0'+n:n;}
  if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+
  f(this.getUTCMonth()+1)+'-'+
  f(this.getUTCDate())+'T'+
  f(this.getUTCHours())+':'+
  f(this.getUTCMinutes())+':'+
  f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}
  var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
  function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
  if(typeof rep==='function'){value=rep.call(holder,key,value);}
  switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
  gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
  v=partial.length===0?'[]':gap?'[\n'+gap+
  partial.join(',\n'+gap)+'\n'+
  mind+']':'['+partial.join(',')+']';gap=mind;return v;}
  if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
  v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+
  mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
  jsonStringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
  rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
  return str('',{'':value});};
  }());
  //////

  //
  // Utility functions
  //
  // requestAnimationFrame
  // Credit: Paul Irish http://paulirish.com/2011/requestanimationframe-for-smart-animating/
  if (!window.requestAnimationFrame) {
    window.requestAnimationFrame = (function() {
      return  window.requestAnimationFrame       ||
              window.webkitRequestAnimationFrame ||
              window.mozRequestAnimationFrame    ||
              window.oRequestAnimationFrame      ||
              window.msRequestAnimationFrame     ||
              function(/* function */ callback, /* DOMElement */ element){
                window.setTimeout(callback, 1000 / 60);
              };
    })();
  }

  // Mark's lightweight animation function. I call it wiggly. You can give it multiple
  // properties, like { height: '300px', width: '300px' } can also pass in a duration.
  // Only works in pixels for now. Also, a callback.
  var Wiggly = function(el) {
    this.el      = el;
    this.cancel  = false;
    this.running = false;
  };

  Wiggly.prototype.animate = function(opts, callback) {
    this.stop();
    this.cancel  = false;
    this.running = true;

    var self = this;

    var duration = opts.duration || 1000;
    delete opts.duration;

    var start, now, elapsed = 0;
    var animations = [];

    for (var key in opts) {
      var animStart = self.el.style[key] ? parseInt(self.el.style[key]) : 0;
      var finish  = parseInt(opts[key]);
      var anim = {
        prop: key,
        start: animStart,
        current: animStart,
        finish: finish,
        distance: Math.abs(finish - animStart),
        reverse: animStart > finish
      };

      animations.push(anim);
    }

    function animate() {
      if (self.cancel) {
        return;
      }

      if (elapsed < duration) {

        requestAnimationFrame(animate);
        draw();
      } else {
        // we made it to the end. make sure we're set to the end spot.
        for (var i = 0, al = animations.length; i < al; i++) {
          self.el.style[anim.prop] = [anim.finish, 'px'].join('');
        }

        if (typeof callback === 'function') {
          // no need to apply this to a context yet
          callback();
        }
      }
    }

    function draw() {
      start    = start || +new Date();
      now      = +new Date();
      elapsed  = now - start;

      for (var i = 0, al = animations.length; i < al; i++) {
        var anim = animations[i];
        var current = Math.round(easeOut(elapsed, 0, anim.distance, duration));

        anim.current = (anim.reverse ? anim.start - current : anim.start + current);
        self.el.style[anim.prop] = [anim.current, 'px'].join('');

      }
    }

    function easeOut(t, b, c, d) {
      return -c *(t/=d)*(t-2) + b;
    }

    animate();
  };

  Wiggly.prototype.stop = function() {
    if (this.running) {
      this.cancel = true;
    }
  };

  // Simple browser detection for the bane of my existance; every other browser is sane enough to not need detection.
  var isIe = !!/msie (\d+\.\d+);/.test(navigator.userAgent.toLowerCase());
  var isIe6 = new Number(RegExp.$1) == 6;
  var isIeQuirks = isIe && document.compatMode && document.compatMode == "BackCompat";
  // for mobile safari
  var isTouch = "ontouchstart" in window;

  // Logs arguments to console
  var log = function() {
    if (typeof console !== "undefined" && typeof console.log !== "undefined" && typeof console.log.apply !== "undefined") {
      console.log.apply(console, arguments);
    }
  };

  var append = function(original) {
    var i, l, key;
    for (i = 1, l = arguments.length; i < l; i++) {
      var extended = arguments[i] || {};
      for (key in extended) original[key] = extended[key];
    }
    return original;
  };

  // Takes a template like "hi there, #{person}" and params {"person": "Dave"} and returns "hi there, Dave"
  var render = function(template, params) {
    return template.replace(/\#\{([^{}]*)\}/g,
      function(a, b) {
        var r = params[b];
        return typeof r === 'string' || typeof r === 'number' ? r : a;
      }
    );
  };

  var insertHtml = function(html) {
    var dummy = document.createElement('div');
    dummy.innerHTML = html;
    document.body.insertBefore(dummy.firstChild, document.body.firstChild);
    return document.body.firstChild;
  };
  
  var htmlentities = function(str) {
      return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  };

  // Converts object {sso: 'abcd', forum: 1} into "sso=abcd&forum=1"
  // NOTE: does not URI encode, that needs to be done beforehand.
  var toQueryString = function(params) {
    var pairs = [];
    for (key in params) {
      if (params[key] != null && params[key] != '' && typeof params[key] != 'function') {
        pairs.push([key, params[key]].join('='));
      }
    }
    return pairs.join('&');
  };

  // Adds the css string to the page
  var includeCss = function(cssString) {
    var styleElement = document.createElement('style');
    styleElement.type = 'text/css'; styleElement.media = 'screen';
    if (styleElement.styleSheet) {
      styleElement.styleSheet.cssText = cssString;
    } else {
      styleElement.appendChild(document.createTextNode(cssString));
    }
    document.getElementsByTagName('head')[0].appendChild(styleElement);
  };
  
  var includePrintCss = function() {
    // Don't show tab on printed pages
    var cssString = '#uvTab {display:none !important;}';
    var styleElement = document.createElement('style');
    styleElement.type = 'text/css'; styleElement.media = 'print';
    if (styleElement.styleSheet) {
      styleElement.styleSheet.cssText = cssString;
    } else {
      styleElement.appendChild(document.createTextNode(cssString));
    }
    document.getElementsByTagName('head')[0].appendChild(styleElement);
  };

  var htmlElement = function() {
    return document.getElementsByTagName('html')[0];
  };

  var addClassToElement = function(element, className) {
    element.className += (element.className ? ' ' : '') + className;
  };

  var removeClassFromElement = function(element, className) {
    element.className = element.className.replace(new RegExp("(^|\\s+)" + className + "(\\s+|$)", "g"), ' ');
  };

  var pageDimensions = function() {
    var de = document.documentElement;
    var width = window.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
    var height = window.innerHeight || (de && de.clientHeight) || document.body.clientHeight;
    return {width: width, height: height};
  };

  var elementDimensions = function(element) {
    var display = element.display;
    if (display != 'none' && display != null) { // Safari bug
      return {width: element.offsetWidth, height: element.offsetHeight};
    }

    // All *Width and *Height properties give 0 on elements with display none,
    // so enable the element temporarily
    var els = element.style;
    var originalVisibility = els.visibility;
    var originalPosition = els.position;
    var originalDisplay = els.display;
    els.visibility = 'hidden';
    els.position = 'absolute';
    els.display = 'block';
    var originalWidth = element.clientWidth;
    var originalHeight = element.clientHeight;
    els.display = originalDisplay;
    els.position = originalPosition;
    els.visibility = originalVisibility;
    return {width: originalWidth, height: originalHeight};
  };

	var getScrollTop = function() {
	  var scrollTop;
	  if( typeof( window.pageYOffset ) == 'number' ) {
	    scrollTop = window.pageYOffset;
	  } else if( document.body && ( document.body.scrollTop ) ) {
	    scrollTop = document.body.scrollTop;
	  } else if( document.documentElement && ( document.documentElement.scrollTop ) ) {
	    scrollTop = document.documentElement.scrollTop;
	  }
	  return scrollTop;
	};

	// http://james.padolsey.com/javascript/get-document-height-cross-browser/
	function getDocumentHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
	}

  var referrer = function() {
    var ref = window.location.href;
    if (ref.indexOf('?') != -1) {
      ref = ref.substring(0, ref.indexOf('?'));
    }
    return encodeURIComponent(ref);
  };

  // Takes in options (defaults to uservoiceOptions) and sanitizes them.  Raises errors if they are invalid.
  var prepareOptions = function(options) {
    var defaultOptions = {
      key: 'pdfmyurl',
      host: 'pdfmyurl.uservoice.com',
      widget_key: 'otf2fHbU9gLxqxSEXLz3A'
    };
    var clientOptions = {"tab":{"label":"feedback","inverted":false,"enabled":true,"color":"CC6D00"}};

    defaultOptions = append(defaultOptions, (typeof clientOptions === "object" ? clientOptions : {}));

    options = append(defaultOptions, (typeof(uvOptions) !== "undefined" ? uvOptions : {}), options || {});
    options.params = options.params || {};

    // Be explicit about the things we put into params:

    if (options.sso) {
      options.params.sso = options.sso;
    }
    if (options.sess) {
      options.params.sess = options.sess;
    }
    if (options.custom_fields) {
      options.params.custom_fields = options.custom_fields;
    }
    if (options.default_mode) {
      options.params.default_mode = options.default_mode;
    }

    // Add in the referrer
    options.params.referrer = referrer();

    // Add in custom fields
    if (options.params.custom_fields && (typeof options.params.custom_fields == "object")) {
      options.params.custom_fields = encodeURIComponent(base64Encode(jsonStringify(options.params.custom_fields)));
    }

    // The wiggly
    options.tab = options.tab || {};
    options.tab = append({
      enabled: true,
      position: 'bottom-right',
      color: 'CC6D00',
      label: 'feedback &amp; support',
      inverted: false
    }, options.tab);

    // TODO: add in language


    return options;
  };
  
  //
  // Modules
  //

  var Tab = {
    template: '<div id="uvTab" style="#{tabStyle}">' +
              '<a id="uvTabLabel" style="background-color: transparent; #{linkStyle}" href="javascript:return false;"><img src="#{imgSrc}" alt="#{label}" style="border:0; background-color: transparent;" /></a></div>',

    show: function(opts) {
      this.setOptions(opts);

      if (this.element) {
        this.element.parentNode.removeChild(this.element);
      }

      if (true && this.options.enabled) {
        var tab = this;
        var img   = new Image();

        // We're going to wait until the tab text is loaded
        img.onload = function() {
          tab.createElement();
        };
        
        img.src = tab.options.imgSrc;
        includePrintCss();
      }

    },

    createElement: function() {
      var tab  = this;
      var el   = tab.element = insertHtml(render(tab.template, tab.options));
      var a    = el.getElementsByTagName('a')[0];
      // var peeker;

      tab.animator = new Wiggly(el);
      tab.dimensions = elementDimensions(el);

      if (tab.rotation) {
        el.style["marginTop"] = ['-', Math.round(tab.dimensions.height / 2), "px"].join('');
      }

      el.style[tab.margin] = ["-", (tab.rotation ? tab.dimensions.width : tab.dimensions.height), "px"].join('');
      el.style["display"] = 'block';

      a.onmouseover = a.onfocus = function(e) {
        if (!this.widgetInited) {
          Widget.init();
          this.widgetInited = true;
        }
      };

      a.onclick = function(e) {
        e && e.preventDefault();

        Widget.show();

        return false;
      }
      
      if (isTouch) {
        tab.bindTouchEvents();
      }
      
      tab.animateOn(false);
    },

    animateOn: function(short, callback) {
      var tab = this;

      if (short) {
        tab.element.style[tab.margin] = "0px";
        // tab.minimize(callback);
      } else {
        tab.maximize();
      }
    },

    minimize: function(callback) {
      var anim = { "duration": 200 };

      anim[this.margin] = ["-", this.dimensions.width - 34, "px"].join('');
      this.animator.animate(anim, callback);
    },

    maximize: function(callback) {
      var anim = { "duration": 200 };

      anim[this.margin] = "0px";
      this.animator.animate(anim, callback);
    },

    setOptions: function(opts) {
      opts = prepareOptions(opts).tab;

      var posArray = /([^\-]+)-([^\-]+)/.exec(opts.position);
      var verticalPos = posArray[1];
      var horizontalPos = posArray[2];
      var rotation = posArray[1] === 'middle' ? 90 : 0;
      var tabStyle = ['tab-', opts.inverted ? 'light-' : 'dark-', opts.position].join('');
      var linkStyle = rotation ? 'link-vertical' : 'link-horizontal';
      var assetHost = [("https:" == document.location.protocol ? "https://" : "http://"), "widget.uservoice.com"].join('');
      var image = [assetHost, "/dcache/widget/feedback-tab.png?t=", encodeURIComponent(opts.label), "&c=", opts.inverted ? encodeURIComponent(opts.color) : 'ffffff', "&r=", encodeURIComponent(rotation), opts.inverted ? '&i=yes' : ''].join('');
      var bgImage = opts.position.replace(/middle-/, '').replace(/(bottom|top)-(right|left)/, 'horizontal');
      bgImage = [assetHost, "/images/clients/widget2/tab-", bgImage, opts.inverted ? '-light' : '-dark', '.png'].join('');

      opts.bgImage = bgImage;
      opts.imgSrc = image;
      opts.label = htmlentities(opts.label);

      tabStyle = tabCss[tabStyle];
      linkStyle = tabCss[linkStyle];
      
      // CSS expression to fix the lack of position:fixed support in ie6 & ie Quirks mode
      if (isIe6 || isIeQuirks) {
        tabStyle += "position:absolute !important;"
        
        if (verticalPos === 'top') {
          tabStyle += "top: expression(((document.documentElement.scrollTop || document.body.scrollTop) + (!this.offsetHeight && 0)) + 'px');"
        } else if (verticalPos === 'middle') {
          tabStyle += "top: expression(((document.documentElement.scrollTop || document.body.scrollTop) + ((((document.documentElement.clientHeight || document.body.clientHeight) + (!this.offsetHeight && 0)) / 2) >> 0)) + 'px');"
        } else if (verticalPos === 'bottom') {
          tabStyle += "top: expression(((document.documentElement.scrollTop || document.body.scrollTop) + (document.documentElement.clientHeight || document.body.clientHeight) - this.offsetHeight) + 'px');"
        }
      }

      opts.tabStyle  = render(tabStyle, opts);
      opts.linkStyle = render(linkStyle, opts);

      this.options = opts;
      this.rotation = rotation;

      if (verticalPos === 'bottom') {
        this.margin = 'marginBottom';
      } else if (verticalPos === 'top') {
        this.margin = 'marginTop';
      } else if (horizontalPos === 'right') {
        this.margin = 'marginRight';
      } else {
        this.margin = 'marginLeft';
      }
    },
    
    bindTouchEvents: function() {
      var top;
      var tab = this;
      var pos = /([^\-]+)-([^\-]+)/.exec(tab.options.position);
      var timer;
      var getTop;
      
      pos = (pos && pos[1]) || 'bottom';
      
      if (pos === 'top') {
        getTop = function() { return (window.pageYOffset + 'px') };
      } else if (pos === 'middle') {
        getTop = function() { return Math.round(window.pageYOffset + (window.innerHeight / 2) - (tab.dimensions.width / 2)) + 'px' };
      } else {
        getTop = function() { return (window.pageYOffset + window.innerHeight - tab.dimensions.height) + 'px' };
      }
      
      document.addEventListener('touchstart', onTouchStart, false);
      document.addEventListener('touchend', onTouchEnd, false);
      window.addEventListener('scroll', onScroll, false);

      function onTouchStart(event) {
        tab.element.style.display = 'none';
      }

      function onTouchEnd(event) {
        tab.element.style.display = 'block';
      }
      
      function onScroll(event) {
        clearTimeout(timer);
        
        timer = setTimeout(function() {
          tab.element.style.bottom = 'auto';
          tab.element.style.top = getTop();
        }, 100);
      }
      
      // fire this in case we're in the middle of a page
      onScroll();
    }
  };

  var assetHost = [("https:" == document.location.protocol ? "https://" : "http://"), "widget.uservoice.com"].join('');

  var Widget = {
    //iframeTemplate: '<iframe id="uservoice-dialog-iframe" src="#{url}?#{query}" frameborder="0" scrolling="no" allowtransparency="true" width="#{width}" height="#{height}" style="height: #{height}; width: #{width};"></iframe>',
    iframeTemplate: '<iframe id="uvw-dialog-iframe" src="#{url}?#{query}" frameBorder="0" name="uvw-iframe" style="display: block; background: #FAFBFC; border: none; -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; height: 100%; padding: none; position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%;"></iframe>',
    dialogTemplate: '<div class="uvOverlay1" id="#{overlay_id}" style="position: relative; visibility:hidden; z-index: 100003;"><div id="#{overlay_background_id}" style="background: #000; -ms-filter: alpha(opacity=75); filter: alpha(opacity=75); opacity: .75; position: fixed; top: 0; right: 0; bottom: 0; left: 0;"></div><div class="uvOverlay2" style="height: 100%; overflow: auto; position: fixed; top: 0; right: 0; bottom: 0; left: 0;"><div class="uvOverlay3" style="height: 100%; min-height: 550px; min-width: 900px; position: relative; width: 100%;"><div id="#{dialog_id}" style="-webkit-box-shadow: rgba(0,0,0,.5) 0 5px 5px; height: 500px; margin: -250px 0 0 -444px; position: absolute; top: 50%; left: 50%; width: 888px;">' +
                      '<div onclick="return UserVoice.hidePopupWidget();" id="#{dialog_close_id}" title="Close Dialog" style="z-index: 100004; background: transparent url('+assetHost+'/images/clients/widget2/close.png) 0 0 no-repeat; height: 48px; margin: 0; padding: 0; position: absolute; top: -22px; right: -24px; width: 48px;"><button style="background: none; border: none; -moz-box-shadow: none; -webkit-box-shadow: none; box-shadow: none; cursor: pointer; height: 30px; margin: 6px 0 0 9px; padding: 0; width: 30px; text-indent: -9000px;">Close Dialog</button></div>' +
                      '<div id="#{dialog_content_id}" style="position:static; width:100%; height:100%"></div>' +
                                                
                      '<a id="#{dialog_powered_by_id}" href="http://uservoice.com/?utm_campaign=Powered By&amp;utm_medium=widget2&amp;utm_source=pdfmyurl.uservoice.com" target="_blank" style="background: url('+assetHost+'/images/clients/widget2/powered_by.png) 0 0 no-repeat; font-size: 11px; height: 20px; position: absolute; bottom: -25px; right: 10px; text-indent: -9000px; width: 150px;">Powered by UserVoice</a>' +
                      
                    '</div></div></div></div>',

    dialog_id: 'uvw-dialog',
    dialog_close_id: 'uvw-dialog-close',
    dialog_powered_by_id: 'uvw-dialog-powered-by',
    dialog_content_id: 'uvw-dialog-content',
    overlay_id: 'uvw-overlay',
    overlay_background_id: 'uvw-overlay-background',
    
    show: function(opts) {
      
      // If IE6, touch device or IE in quirks mode, pop widget up in a new window
      if (isIe6 || isTouch || isIeQuirks) {
        this.options = prepareOptions(opts);
        popupUrl = this.url();
        newwindow=window.open(popupUrl,'uservoice_widget','height=500,width=888,resizable=yes,scrollbars=1');
      } else {
        
        // Build the dialog/iframe and shove it up in the dom (if it's not there already)
        this.init(opts);
        this.pokeWidgetLocationViaHash('opened');
      
        // Finally, show the dialog and focus it
        this.overlay.style.visibility = 'visible';
        this.overlay.style.display = 'block';
        this.dialog.focus();

        addClassToElement(htmlElement(), "uvw-dialog-open");
      }
    },
    
    hide: function() {
      this.pokeWidgetLocationViaHash();
      
      if (this.overlay) {
        this.overlay.style.display = 'none';
      }
      
      removeClassFromElement(htmlElement(), "uvw-dialog-open");
    },
    
    // Protected
    pokeWidgetLocationViaHash: function(kind) {
      kind = kind || 'reset';
      
      // if we sandbox jquery in the widget, this will have to be fixed.
      var widgetWindow = frames['uvw-iframe'];
      try {
        widgetWindow.location.href = [this.iframeSrc, (+ new Date()).toString() + kind].join('#');
      } catch (e) {
        // swallow. it's not that important
      }      
    },
    
    init: function(opts) {
      this.options = prepareOptions(opts);

      if (!this.overlay) {
        // Insert dialog CSS:
        includeCss(dialogCss);  // TODO: customize with options

        this.overlay = insertHtml(render(this.dialogTemplate, this));
      }
      
      // Render if the dialog hasn't been rendered before or if we want to render a different widget
      if (!this.dialog || this.dialog.getAttribute('data-widget-key') != this.options.widget_key) {
        // Construct iframe HTML:
        var iframeOptions = {
          url:  this.url(),
          query: toQueryString(this.options.params)
        };
        var iframeHtml = render(this.iframeTemplate, iframeOptions);
        this.iframeSrc = [iframeOptions.url, iframeOptions.query].join('?');
        this.dialogContent = document.getElementById(this.dialog_content_id);
        this.dialogContent.innerHTML = iframeHtml;
        this.dialog = document.getElementById(this.dialog_id);
        this.dialog.setAttribute('data-widget-key', this.options.widget_key);
      }
    },
    
    // REMOVE? This was used for IE6, but we now open that in a new window. ^JR
    positionDialog: function() {
      // NOTE: this won't work as it is.  It was designed with a different DOM
      var dialogDimensions = elementDimensions(this.overlay);
      var pageDims = pageDimensions();

      // log("Ok, dialogDimensions = ", dialogDimensions);
      // log("Ok, pageDims = ", pageDims);

      var elementStyle = this.overlay.style;
      elementStyle.width = 'auto';
      elementStyle.height = 'auto';
      elementStyle.left = ((pageDims.width - dialogDimensions.width) / 2) + "px";
      var computedHeight = ((pageDims.height - dialogDimensions.height) / 2);
      elementStyle.top = Math.max(computedHeight, 55) + "px";
    },

    url: function() {
      // NOTE: whether it's app.uv.com or key.uv.com or feeback.key.com really depends on if we want to do xhr or jsonp
      var url;
      if ("https:" == document.location.protocol && this.options.key != null) {
        url = 'https://' + this.options.key + '.uservoice.com/clients/widgets/' + this.options.widget_key + '.html';
      } else {
        url =  'http://' + this.options.host + '/clients/widgets/' + this.options.widget_key + '.html';
      }
      return url;
    }
  };

  //
  // CSS
  //
  var tabCss = {"link-vertical":"display: block;padding: 39px 5px 10px 5px;text-decoration: none;","tab-dark-middle-left":"background: red url(#{bgImage}) 50% 0 no-repeat;border: 1px solid #FFF;border-left: none;-moz-border-radius: 0 4px 4px 0;-webkit-border-radius: 0 4px 4px 0;border-radius: 0 4px 4px 0;-moz-box-shadow: inset rgba(255,255,255,.25) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;-webkit-box-shadow: inset rgba(255,255,255,.25) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;box-shadow: inset rgba(255,255,255,.25) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;font: normal normal bold 14px/1em Arial, sans-serif;position: fixed;left: 0;top: 50%;z-index: 9999;background-color: ##{color};","tab-dark-bottom-left":"background: red url(#{bgImage}) 0 50% no-repeat;border: 1px solid #FFF;border-bottom: none;-moz-border-radius: 4px 4px 0 0;-webkit-border-radius: 4px 4px 0 0;border-radius: 4px 4px 0 0;-moz-box-shadow: inset rgba(255,255,255,.25) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;-webkit-box-shadow: inset rgba(255,255,255,.25) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;box-shadow: inset rgba(255,255,255,.25) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;font: normal normal bold 14px/1em Arial, sans-serif;position: fixed;left: 10px;bottom: 0;z-index: 9999;background-color: ##{color};","tab-light-top-right":"background: red url(#{bgImage}) 0 50% no-repeat;border: 1px solid red;border-top: none;-moz-border-radius: 0 0 4px 4px;-webkit-border-radius: 0 0 4px 4px;border-radius: 0 0 4px 4px;-moz-box-shadow: inset rgba(255,255,255,.9) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;-webkit-box-shadow: inset rgba(255,255,255,.9) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;box-shadow: inset rgba(255,255,255,.9) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;font: normal normal bold 14px/1em Arial, sans-serif;position: fixed;right: 10px;top: 0;z-index: 9999;background-color: ##{color};border-color: ##{color};","link-horizontal":"display: block;padding: 6px 10px 2px 42px;text-decoration: none;","tab-dark-middle-right":"background: red url(#{bgImage}) 50% 0 no-repeat;border: 1px solid #FFF;border-right: none;-moz-border-radius: 4px 0 0 4px;-webkit-border-radius: 4px 0 0 4px;border-radius: 4px 0 0 4px;-moz-box-shadow: inset rgba(255,255,255,.25) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;-webkit-box-shadow: inset rgba(255,255,255,.25) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;box-shadow: inset rgba(255,255,255,.25) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;font: normal normal bold 14px/1em Arial, sans-serif;position: fixed;right: 0;top: 50%;z-index: 9999;background-color: ##{color};","tab-light-middle-left":"background: red url(#{bgImage}) 50% 0 no-repeat;border: 1px solid red;border-left: none;-moz-border-radius: 0 4px 4px 0;-webkit-border-radius: 0 4px 4px 0;border-radius: 0 4px 4px 0;-moz-box-shadow: inset rgba(255,255,255,.9) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;-webkit-box-shadow: inset rgba(255,255,255,.9) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;box-shadow: inset rgba(255,255,255,.9) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;font: normal normal bold 14px/1em Arial, sans-serif;position: fixed;left: 0;top: 50%;z-index: 9999;background-color: ##{color};border-color: ##{color};","tab-light-top-left":"background: red url(#{bgImage}) 0 50% no-repeat;border: 1px solid red;border-top: none;-moz-border-radius: 0 0 4px 4px;-webkit-border-radius: 0 0 4px 4px;border-radius: 0 0 4px 4px;-moz-box-shadow: inset rgba(255,255,255,.9) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;-webkit-box-shadow: inset rgba(255,255,255,.9) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;box-shadow: inset rgba(255,255,255,.9) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;font: normal normal bold 14px/1em Arial, sans-serif;position: fixed;left: 10px;top: 0;z-index: 9999;background-color: ##{color};border-color: ##{color};","tab-dark-top-right":"background: red url(#{bgImage}) 0 50% no-repeat;border: 1px solid #FFF;border-top: none;-moz-border-radius: 0 0 4px 4px;-webkit-border-radius: 0 0 4px 4px;border-radius: 0 0 4px 4px;-moz-box-shadow: inset rgba(255,255,255,.25) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;-webkit-box-shadow: inset rgba(255,255,255,.25) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;box-shadow: inset rgba(255,255,255,.25) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;font: normal normal bold 14px/1em Arial, sans-serif;position: fixed;right: 10px;top: 0;z-index: 9999;background-color: ##{color};","tab-dark-bottom-right":"background: red url(#{bgImage}) 0 50% no-repeat;border: 1px solid #FFF;border-bottom: none;-moz-border-radius: 4px 4px 0 0;-webkit-border-radius: 4px 4px 0 0;border-radius: 4px 4px 0 0;-moz-box-shadow: inset rgba(255,255,255,.25) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;-webkit-box-shadow: inset rgba(255,255,255,.25) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;box-shadow: inset rgba(255,255,255,.25) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;font: normal normal bold 14px/1em Arial, sans-serif;position: fixed;right: 10px;bottom: 0;z-index: 9999;background-color: ##{color};","tab-light-bottom-left":"background: red url(#{bgImage}) 0 50% no-repeat;border: 1px solid red;border-bottom: none;-moz-border-radius: 4px 4px 0 0;-webkit-border-radius: 4px 4px 0 0;border-radius: 4px 4px 0 0;-moz-box-shadow: inset rgba(255,255,255,.9) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;-webkit-box-shadow: inset rgba(255,255,255,.9) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;box-shadow: inset rgba(255,255,255,.9) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;font: normal normal bold 14px/1em Arial, sans-serif;position: fixed;left: 10px;bottom: 0;z-index: 9999;background-color: ##{color};border-color: ##{color};","tab-light-bottom-right":"background: red url(#{bgImage}) 0 50% no-repeat;border: 1px solid red;border-bottom: none;-moz-border-radius: 4px 4px 0 0;-webkit-border-radius: 4px 4px 0 0;border-radius: 4px 4px 0 0;-moz-box-shadow: inset rgba(255,255,255,.9) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;-webkit-box-shadow: inset rgba(255,255,255,.9) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;box-shadow: inset rgba(255,255,255,.9) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;font: normal normal bold 14px/1em Arial, sans-serif;position: fixed;right: 10px;bottom: 0;z-index: 9999;background-color: ##{color};border-color: ##{color};","tab-light-middle-right":"background: red url(#{bgImage}) 50% 0 no-repeat;border: 1px solid red;border-right: none;-moz-border-radius: 4px 0 0 4px;-webkit-border-radius: 4px 0 0 4px;border-radius: 4px 0 0 4px;-moz-box-shadow: inset rgba(255,255,255,.9) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;-webkit-box-shadow: inset rgba(255,255,255,.9) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;box-shadow: inset rgba(255,255,255,.9) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;font: normal normal bold 14px/1em Arial, sans-serif;position: fixed;right: 0;top: 50%;z-index: 9999;background-color: ##{color};border-color: ##{color};","tab-dark-top-left":"background: red url(#{bgImage}) 0 50% no-repeat;border: 1px solid #FFF;border-top: none;-moz-border-radius: 0 0 4px 4px;-webkit-border-radius: 0 0 4px 4px;border-radius: 0 0 4px 4px;-moz-box-shadow: inset rgba(255,255,255,.25) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;-webkit-box-shadow: inset rgba(255,255,255,.25) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;box-shadow: inset rgba(255,255,255,.25) 1px 1px 1px, rgba(0,0,0,.5) 0 1px 2px;font: normal normal bold 14px/1em Arial, sans-serif;position: fixed;left: 10px;top: 0;z-index: 9999;background-color: ##{color};"};

  var dialogCss = "\
    html.uvw-dialog-open object,\
    html.uvw-dialog-open iframe,\
    html.uvw-dialog-open embed {\
      visibility: hidden;\
    }\
    html.uvw-dialog-open iframe#uvw-dialog-iframe {\
      visibility: visible;\
    }\
    ";

  // if (isIe6) {
  //   tabCss += "";
  //   dialogCss += "";
  // }

  //
  // Public Functions
  //

  UserVoice.showPopupWidget = function(opts) {
    //log("UserVoice.showPopupWidget: enter");
    Widget.show(opts);
  };

  UserVoice.hidePopupWidget = function() {
    //log("UserVoice.hidePopupWidget: enter");
    Widget.hide();
    return false;
  };

  UserVoice.showTab = function(opts) {
    Tab.show(opts);
  };

  // Get the party started
  Tab.show();
})();

}

/* 

used to style login forms button 

*/
$(function() {
    //all hover and click logic for buttons
    $(".fg-button:not(.ui-state-disabled)").hover(

    function() {
        $(this).addClass("ui-state-hover");
    },

    function() {
        $(this).removeClass("ui-state-hover");
    }).mousedown(function() {
        $(this).parents('.fg-buttonset-single:first').find(".fg-button.ui-state-active").removeClass("ui-state-active");
        if ($(this).is('.ui-state-active.fg-button-toggleable, .fg-buttonset-multi .ui-state-active')) {
            $(this).removeClass("ui-state-active");
        } else {
            $(this).addClass("ui-state-active");
        }
    }).mouseup(function() {
        if (!$(this).is('.fg-button-toggleable, .fg-buttonset-single .fg-button,  .fg-buttonset-multi .fg-button')) {
            $(this).removeClass("ui-state-active");
        }
    });
});

$(document).ready(function() {

    // Toggle advanced options
    $("#loc-adv a").click(function() {
        $("#map").slideToggle("slow");
        return false;
    });
    
    // light(color)box used for login dialog
    // http://colorpowered.com/colorbox/
    $(".subscribe").colorbox({
        iframe: true,
        innerWidth: 800,
        innerHeight: 600,
        speed: 500
    });
    
    $(".textWindow").colorbox();
    $('.login').colorbox({
        href: "loginForm.jsp div#loginform",
        innerWidth: 450,
        innerHeight: 270,
        preloading: true,
        speed: 500
    });
    $('.logout').colorbox({
        href: "logoutForm.jsp div#logoutform",
        innerWidth: 275,
        innerHeight: 150,
        preloading: true,
        speed: 500
    });
    $('.history').colorbox({
        iframe: true,
        innerWidth: 800,
        innerHeight: 450,
        speed: 500
    });

    
    /*
    $(".login").colorbox({
        iframe: true,
        innerWidth: 425,
        innerHeight: 200,
        speed: 500
    });
    */

    // Add .last class to certain lists
    $("ul.lst li:last, ul.press li:last").addClass("last");

    if ($.getUrlVar("err") != null) {
        // message if errors happen
        $urlmessage = "The url entered does not load, confirm that the url is spelled correctly! (e.g. http://bbc.co.uk)";
        $("#url").val($urlmessage);
        $("#url").css({
            'color': 'red'
        });
    } else {
        // default message when no errors happen
        $urlmessage = 'Enter url location to pdf (e.g. http://bbc.co.uk)';
        $("#url").val($urlmessage);
        $("#url").css({
            'color': 'black'
        });
    }

    //animate the login link so that its 
    $("#loginLink").animate({ color: "yellow" }, 500);
    $("#loginLink").animate({ color: "brown" }, 500);
    $("#loginLink").animate({ color: "black" }, 500);
    //http://jqueryui.com/demos/effect/
    setTimeout(function(){
      $("#loginLink").effect("bounce", {}, "normal");
      $("#licenseLink").effect("transfer", { to: "#loginLink", className: 'ui-effects-transfer' }, 800);
      //$("#licenseLink").effect("bounce", {}, "normal");
      $("#loginLink").effect("transfer", { to: "#licenseLink", className: 'ui-effects-transfer' }, 800);
    }, 2000);

});

//http://jquery-howto.blogspot.com/2009/09/get-url-parameters-values-with-jquery.html
$.extend({
    getUrlVars: function() {
        var vars = [],
            hash;
        var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
        for (var i = 0; i < hashes.length; i++) {
            hash = hashes[i].split('=');
            vars.push(hash[0]);
            if (hash[1] == null) hash[1] = "";
            vars[hash[0]] = hash[1];
        }
        return vars;
    },
    getUrlVar: function(name) {
        return $.getUrlVars()[name];
    }
});


/*

used to handle login form

*/
function handleLoginForm(userName, password) {

    //alert("submitted form! " + userName + ", " + password);

    $.ajax({
        url: 'loginCheck.jsp?userName='+userName+'&password='+password ,
        type: 'POST',
        timeout: 1000,
        error: function() {
          $("#errorMessage").removeAttr("style");
          $("#errorMessage").effect("shake", {}, 20, function(){});
        },
        success: function(xml) {

            if (xml.indexOf("true") != -1) {

                //alert("we can redirect");
                var url = "/";
                $(parent.location).attr("href",url);

            } else if (xml.indexOf("sent") != -1) {

              $("#userName, #password").stop().animate({
                  borderTopColor: "#FF6633",
                  borderLeftColor: "#FF6633",
                  borderRightColor: "#FF6633",
                  borderBottomColor: "#FF6633",
                  backgroundColor: "#FBEFEF"
              },
              1250);

              $("#errorMessageUserPass").attr('style', 'display: none');
              $("#errorMessageEmail").removeAttr("style");
              $("#errorMessageEmail").effect("shake", {}, 20, function(){});

            } else {

              $("#userName, #password").stop().animate({
                  borderTopColor: "#FF6633",
                  borderLeftColor: "#FF6633",
                  borderRightColor: "#FF6633",
                  borderBottomColor: "#FF6633",
                  backgroundColor: "#FBEFEF"
              },
              1250);

              $("#errorMessageEmail").attr('style', 'display: none');
              $("#errorMessageUserPass").removeAttr("style");
              $("#errorMessageUserPass").effect("shake", {}, 20, function(){});
              
            }

        }
    });
}


/*

used to handle login form

*/
function handleLogoutForm() {

    //alert("submitted form! " + userName + ", " + password);

    $.ajax({
        url: 'logoutCheck.jsp',
        type: 'POST',
        timeout: 1000,
        error: function() {
          $("#errorMessage").removeAttr("style");
          $("#errorMessage").effect("shake", {}, 20, function(){});
        },
        success: function(xml) {

            if (xml.indexOf("true") != -1) {

                //alert("we can redirect");
                var url = "/";
                $(parent.location).attr("href",url);

            } else {
              $("#errorMessage").removeAttr("style");
              $("#errorMessage").effect("shake", {}, 20, function(){});
            }
        }
    });
}

$(document).ready(function() {

    // make a delete column of domains table
    // http://stackoverflow.com/questions/376081/how-to-get-a-table-cell-value-using-jquery
    // http://stackoverflow.com/questions/1075415/jquery-add-html-table-column
    var c = $("#domainTable tr:first td").length;
    $("#domainTable tr:first").append("<th>Delete</th>");
    $("#domainTable tr:gt(0)").each(function() {
        var domainId = $(this).find("td").html();
        $(this).append("<td><a title=\"Click to delete\" href=\"javascript:handleDelete('" + domainId + "')\">x</a></td>");
        //alert($(this).html()); 
    });
    
    // only show accordion after the page has loaded
    $("#accordion").removeAttr("style");
    // set up an accordion ui navigation: true
    // http://jqueryui.com/demos/accordion/#collapsible
    $("#accordion").accordion({
  			collapsible: true,
  			navigation: true, 
        active: false, 
        autoHeight: false,
        alwaysOpen: false 
		});
		// hack, http://jqueryui.com/demos/accordion/#methods
		var activate = false;
		if (window.location.href.indexOf("#domain") != -1)
  		activate = 2;
		$("#accordion").accordion("activate", activate);

    //-------------------- on submit
    
    $('#submitDomain').click(function() {
        //alert("submitDomain");
        $.ajax({
            url: 'domainCheck.jsp?action=add&domain=' + $('#domain').val(),
            type: 'POST',
            timeout: 1000,
            error: function() {
                //alert('error. No domain entered! Please re-enter');
                $("#errorMessage").removeAttr("style");
                $("#errorMessage").effect("shake", {}, 20, function(){});
            },
            success: function(xml) {
    
                if (xml.indexOf("true") != -1) {
    
                    //alert("Domains have been added");
                    var url = "createDeleteDomain.jsp?#domain";
                    if (window.location.href.indexOf("#domain") != -1) {
                      location.reload();
                    } else {
                      window.location.href=url;
                      //$(location).attr("href", url);
                    }
    
                } else if (xml.indexOf("false domain") != -1) {
    
                    //alert(xml);
    
                    $("#domain").stop().animate({
                        borderTopColor: "#FF6633",
                        borderLeftColor: "#FF6633",
                        borderRightColor: "#FF6633",
                        borderBottomColor: "#FF6633",
                        backgroundColor: "#FBEFEF"
                    },
                    1250);
    
    
                    $("#errorMessageDomain").removeAttr("style");
                    $("#errorMessageDomain").effect("shake", {}, 20, function(){});

    
                } else if (xml.indexOf("false too many domains") != -1) {
    
                    //alert(xml);
    
                    //$("#domain").stop().animate({
                    //    borderTopColor: "#FF6633",
                    //    borderLeftColor: "#FF6633",
                    //    borderRightColor: "#FF6633",
                    //    borderBottomColor: "#FF6633",
                    //    backgroundColor: "#FBEFEF"
                    //},
                    //1250);
    
                    $("#errorMessageTooManyDomains").removeAttr("style");
                    $("#errorMessageTooManyDomains").effect("shake", {}, 20, function(){});
    
                } else {
    
                    //alert(xml);
    
                    $("#domain").stop().animate({
                        borderTopColor: "#FF6633",
                        borderLeftColor: "#FF6633",
                        borderRightColor: "#FF6633",
                        borderBottomColor: "#FF6633",
                        backgroundColor: "#FBEFEF"
                    },
                    1250);
    
                    $("#errorMessage").removeAttr("style");
                    $("#errorMessage").effect("shake", {}, 20, function(){});
                }
            }
        });
    });
    
    
    $('#submitUrlForm, #submitTicketIdForm, #submitDomainForm').click(function(e) {
    
        //alert("#here: " + e);
        //alert($(this).attr("id"));
        
        var formId = $(this).parents("form").attr("id");
        //alert("formId" + formId); 
        e.preventDefault();
        
        // Get all the forms elements and their values in one step
        var values = $('#' + formId).serialize();

        //alert("#" + formId + ": " + values);
        $.ajax({
            url: 'processOptions.jsp?' + values,
            type: 'POST',
            timeout: 1000,
            error: function() {
                alert('error! Please try again.');
                return false;
            },
            success: function(xml) {
                //alert("success: " + xml);
                if (xml.indexOf("true") != -1) {

                    $("#successMessage").removeAttr("style");
                    $("#successMessage").effect("pulsate", { times:2 }, 1000);

                    return false;
    
                } else {
                    
                    //alert("got error: " + xml);
                    return false;

/* shouldn't really happen 
                    $("#errorMessage").stop().animate({
                        borderTopColor: "#FF6633",
                        borderLeftColor: "#FF6633",
                        borderRightColor: "#FF6633",
                        borderBottomColor: "#FF6633",
                        backgroundColor: "#FBEFEF"
                    },
                    1250);

                    $("#errorMessage").removeAttr("style");
                    $("#errorMessage").effect("shake", {}, 20, function(){});
*/

                }
            }// success
        });// ajax
    }); //click
});

function handleDelete(domain) {

    //alert("submitted form!" + username + passticket_id);
    $.ajax({
        url: 'domainCheck.jsp?action=delete&domain=' + domain,
        type: 'POST',
        timeout: 1000,
        error: function() {
            //alert('error');
            $("#errorMessage").removeAttr("style");
            $("#errorMessage").effect("shake", {}, 20, function(){});

        },
        success: function(xml) {
            //alert(xml);
            if (xml.indexOf("true") != -1) {

                //alert("we can redirect");
                var url = "createDeleteDomain.jsp?new#domain";
                if (window.location.href.indexOf("#domain") != -1) {
                  location.reload();
                } else {
                  window.location.href=url;
                  //$(location).attr("href", url);
                }

            } else {
                //alert(xml);
                $("#username, #pass").stop().animate({
                    borderTopColor: "#FF6633",
                    borderLeftColor: "#FF6633",
                    borderRightColor: "#FF6633",
                    borderBottomColor: "#FF6633",
                    backgroundColor: "#FBEFEF"
                },
                1250);

                $("#errorMessage").removeAttr("style");
                $("#errorMessage").effect("shake", {}, 20, function(){});

            }

        }
    });

}

// ColorBox v1.3.6 - a full featured, light-weight, customizable lightbox based on jQuery 1.3
// c) 2009 Jack Moore - www.colorpowered.com - jack@colorpowered.com
// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php

(function ($) {
	// Shortcuts (to increase compression)
	var colorbox = 'colorbox',
	hover = 'hover',
	TRUE = true,
	FALSE = false,
	cboxPublic,
	isIE = !$.support.opacity,
	isIE6 = isIE && !window.XMLHttpRequest,

	// Event Strings (to increase compression)
	cbox_open = 'cbox_open',
	cbox_load = 'cbox_load',
	cbox_complete = 'cbox_complete',
	cbox_cleanup = 'cbox_cleanup',
	cbox_closed = 'cbox_closed',
	cbox_resize = 'resize.cbox_resize',

	// Cached jQuery Object Variables
	$overlay,
	$cbox,
	$wrap,
	$content,
	$topBorder,
	$leftBorder,
	$rightBorder,
	$bottomBorder,
	$related,
	$window,
	$loaded,
	$loadingBay,
	$loadingOverlay,
	$loadingGraphic,
	$title,
	$current,
	$slideshow,
	$next,
	$prev,
	$close,

	// Variables for cached values or use across multiple functions
	interfaceHeight,
	interfaceWidth,
	loadedHeight,
	loadedWidth,
	element,
	bookmark,
	index,
	settings,
	open,
	active,
	
	// ColorBox Default Settings.	
	// See http://colorpowered.com/colorbox for details.
	defaults = {
		transition: "elastic",
		speed: 350,
		width: FALSE,
		height: FALSE,
		innerWidth: FALSE,
		innerHeight: FALSE,
		initialWidth: "400",
		initialHeight: "400",
		maxWidth: FALSE,
		maxHeight: FALSE,
		scalePhotos: TRUE,
		scrolling: TRUE,
		inline: FALSE,
		html: FALSE,
		iframe: FALSE,
		photo: FALSE,
		href: FALSE,
		title: FALSE,
		rel: FALSE,
		opacity: 0.9,
		preloading: TRUE,
		current: "image {current} of {total}",
		previous: "previous",
		next: "next",
		close: "close",
		open: FALSE,
		overlayClose: TRUE,
		
		slideshow: FALSE,
		slideshowAuto: TRUE,
		slideshowSpeed: 2500,
		slideshowStart: "start slideshow",
		slideshowStop: "stop slideshow",
		
		onOpen: FALSE,
		onLoad: FALSE,
		onComplete: FALSE,
		onCleanup: FALSE,
		onClosed: FALSE
	};
	
	// ****************
	// HELPER FUNCTIONS
	// ****************
		
	// Convert % values to pixels
	function setSize(size, dimension) {
		dimension = dimension === 'x' ? $window.width() : $window.height();//document.documentElement.clientWidth : document.documentElement.clientHeight;
		return (typeof size === 'string') ? Math.round((size.match(/%/) ? (dimension / 100) * parseInt(size, 10) : parseInt(size, 10))) : size;
	}

	// Checks an href to see if it is a photo.
	// There is a force photo option (photo: true) for hrefs that cannot be matched by this regex.
	function isImage(url) {
		url = $.isFunction(url) ? url.call(element) : url;
		return settings.photo || url.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i);
	}
	
	// Assigns functions results to their respective settings.  This allows functions to be used to set ColorBox options.
	function process() {
		for (var i in settings) {
			if ($.isFunction(settings[i]) && i.substring(0, 2) !== 'on') { // checks to make sure the function isn't one of the callbacks, they will be handled at the appropriate time.
			    settings[i] = settings[i].call(element);
			}
		}
		settings.rel = settings.rel || element.rel;
		settings.href = settings.href || element.href;
		settings.title = settings.title || element.title;
	}

	function launch(elem) {
		
		element = elem;
		
		settings = $(element).data(colorbox);
		
		process(); // Convert functions to their returned values.
		
		if (settings.rel && settings.rel !== 'nofollow') {
			$related = $('.cboxElement').filter(function () {
				var relRelated = $(this).data(colorbox).rel || this.rel;
				return (relRelated === settings.rel);
			});
			index = $related.index(element);
			
			// Check direct calls to ColorBox.
			if (index < 0) {
				$related = $related.add(element);
				index = $related.length - 1;
			}
		} else {
			$related = $(element);
			index = 0;
		}
		
		if (!open) {
			open = TRUE;
			
			active = TRUE; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys.
			
			bookmark = element;
			
			bookmark.blur(); // Remove the focus from the calling element.
			
			// Set Navigation Key Bindings
			$(document).bind("keydown.cbox_close", function (e) {
				if (e.keyCode === 27) {
					e.preventDefault();
					cboxPublic.close();
				}
			}).bind("keydown.cbox_arrows", function (e) {
				if ($related.length > 1) {
					if (e.keyCode === 37) {
						e.preventDefault();
						$prev.click();
					} else if (e.keyCode === 39) {
						e.preventDefault();
						$next.click();
					}
				}
			});
			
			if (settings.overlayClose) {
				$overlay.css({"cursor": "pointer"}).one('click', cboxPublic.close);
			}
			
			$.event.trigger(cbox_open);
			if (settings.onOpen) {
				settings.onOpen.call(element);
			}
			
			$overlay.css({"opacity": settings.opacity}).show();
			
			// Opens inital empty ColorBox prior to content being loaded.
			settings.w = setSize(settings.initialWidth, 'x');
			settings.h = setSize(settings.initialHeight, 'y');
			cboxPublic.position(0);
			
			if (isIE6) {
				$window.bind('resize.cboxie6 scroll.cboxie6', function () {
					$overlay.css({width: $window.width(), height: $window.height(), top: $window.scrollTop(), left: $window.scrollLeft()});
				}).trigger("scroll.cboxie6");
			}
		}
		
		$current.add($prev).add($next).add($slideshow).add($title).hide();
		
		$close.html(settings.close).show();
		
		cboxPublic.slideshow();
		
		cboxPublic.load();
	}

	// ****************
	// PUBLIC FUNCTIONS
	// Usage format: $.fn.colorbox.close();
	// Usage from within an iframe: parent.$.fn.colorbox.close();
	// ****************
	
	cboxPublic = $.fn.colorbox = function (options, callback) {
		var $this = this;
		
		if (!$this.length) {
			if ($this.selector === '') { // empty selector means a direct call, ie: $.fn.colorbox();
				$this = $('<a/>');
				options.open = TRUE;
			} else { // else the selector didn't match anything, and colorbox should go ahead and return.
				return this;
			}
		}
		
		$this.each(function () {
			var data = $.extend({}, $(this).data(colorbox) ? $(this).data(colorbox) : defaults, options);
			
			$(this).data(colorbox, data).addClass("cboxElement");
			
			if (callback) {
				$(this).data(colorbox).onComplete = callback;
			}
		});
		
		if (options && options.open) {
			launch($this);
		}
		
		return this;
	};

	// Initialize ColorBox: store common calculations, preload the interface graphics, append the html.
	// This preps colorbox for a speedy open when clicked, and lightens the burdon on the browser by only
	// having to run once, instead of each time colorbox is opened.
	cboxPublic.init = function () {
		
		// jQuery object generator to save a bit of space
		function $div(id) {
			return $('<div id="cbox' + id + '"/>');
		}
		
		// Create & Append jQuery Objects
		$window = $(window);
		$cbox = $('<div id="colorbox"/>');
		$overlay = $div("Overlay").hide();
		$wrap = $div("Wrapper");
		$content = $div("Content").append(
			$loaded = $div("LoadedContent").css({width: 0, height: 0}),
			$loadingOverlay = $div("LoadingOverlay"),
			$loadingGraphic = $div("LoadingGraphic"),
			$title = $div("Title"),
			$current = $div("Current"),
			$slideshow = $div("Slideshow"),
			$next = $div("Next"),
			$prev = $div("Previous"),
			$close = $div("Close")
		);
		$wrap.append( // The 3x3 Grid that makes up ColorBox
			$('<div/>').append(
				$div("TopLeft"),
				$topBorder = $div("TopCenter"),
				$div("TopRight")
			),
			$('<div/>').append(
				$leftBorder = $div("MiddleLeft"),
				$content,
				$rightBorder = $div("MiddleRight")
			),
			$('<div/>').append(
				$div("BottomLeft"),
				$bottomBorder = $div("BottomCenter"),
				$div("BottomRight")
			)
		).children().children().css({'float': 'left'});
		
		$loadingBay = $("<div style='position:absolute; top:0; left:0; width:9999px; height:0;'/>");
		
		$('body').prepend($overlay, $cbox.append($wrap, $loadingBay));
				
		if (isIE) {
			$cbox.addClass('cboxIE');
			if (isIE6) {
				$overlay.css('position', 'absolute');
			}
		}
		
		// Add rollover event to navigation elements
		$content.children()
		.bind('mouseover mouseout', function(){
			$(this).toggleClass(hover);
		}).addClass(hover);
		
		// Cache values needed for size calculations
		interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(TRUE) - $content.height();//Subtraction needed for IE6
		interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(TRUE) - $content.width();
		loadedHeight = $loaded.outerHeight(TRUE);
		loadedWidth = $loaded.outerWidth(TRUE);
		
		// Setting padding to remove the need to do size conversions during the animation step.
		$cbox.css({"padding-bottom": interfaceHeight, "padding-right": interfaceWidth}).hide();
		
		// Setup button & key events.
		$next.click(cboxPublic.next);
		$prev.click(cboxPublic.prev);
		$close.click(cboxPublic.close);
		
		// Adding the 'hover' class allowed the browser to load the hover-state
		// background graphics.  The class can now can be removed.
		$content.children().removeClass(hover);
		
		$('.cboxElement').live('click', function (e) {
			if (e.button !== 0 && typeof e.button !== 'undefined') {// checks to see if it was a non-left mouse-click.
				return TRUE;
			} else {
				launch(this);			
				return FALSE;
			}
		});
	};

	cboxPublic.position = function (speed, loadedCallback) {
		var
		animate_speed,
		winHeight = $window.height(),
		// keeps the top and left positions within the browser's viewport.
		posTop = Math.max(winHeight - settings.h - loadedHeight - interfaceHeight,0)/2 + $window.scrollTop(),
		posLeft = Math.max(document.documentElement.clientWidth - settings.w - loadedWidth - interfaceWidth,0)/2 + $window.scrollLeft();
		
		// setting the speed to 0 to reduce the delay between same-sized content.
		animate_speed = ($cbox.width() === settings.w+loadedWidth && $cbox.height() === settings.h+loadedHeight) ? 0 : speed;
		
		// this gives the wrapper plenty of breathing room so it's floated contents can move around smoothly,
		// but it has to be shrank down around the size of div#colorbox when it's done.  If not,
		// it can invoke an obscure IE bug when using iframes.
		$wrap[0].style.width = $wrap[0].style.height = "9999px";
		
		function modalDimensions (that) {
			// loading overlay size has to be sure that IE6 uses the correct height.
			$topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = that.style.width;
			$loadingGraphic[0].style.height = $loadingOverlay[0].style.height = $content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = that.style.height;
		}
		
		$cbox.dequeue().animate({width:settings.w+loadedWidth, height:settings.h+loadedHeight, top:posTop, left:posLeft}, {duration: animate_speed,
			complete: function(){
				modalDimensions(this);
				
				active = FALSE;
				
				// shrink the wrapper down to exactly the size of colorbox to avoid a bug in IE's iframe implementation.
				$wrap[0].style.width = (settings.w+loadedWidth+interfaceWidth) + "px";
				$wrap[0].style.height = (settings.h+loadedHeight+interfaceHeight) + "px";
				
				if (loadedCallback) {loadedCallback();}
			},
			step: function(){
				modalDimensions(this);
			}
		});
	};

	cboxPublic.resize = function (object) {
		if(!open){ return; }
		
		var topMargin,
		prev,
		prevSrc,
		next,
		nextSrc,
		photo,
		timeout,
		speed = settings.transition==="none" ? 0 : settings.speed;
		
		$window.unbind(cbox_resize);
		
		if(!object){
			timeout = setTimeout(function(){ // timer allows IE to render the dimensions before attempting to calculate the height
				var $child = $loaded.wrapInner("<div style='overflow:auto'></div>").children(); // temporary wrapper to get an accurate estimate of just how high the total content should be.
				settings.h = $child.height();
				$loaded.css({height:settings.h});
				$child.replaceWith($child.children()); // ditch the temporary wrapper div used in height calculation
				cboxPublic.position(speed);
			}, 1);
			return;
		}
		
		$loaded.remove();
		$loaded = $('<div id="cboxLoadedContent"/>').html(object);
		
		function getWidth(){
			settings.w = settings.w || $loaded.width();
			settings.w = settings.mw && settings.mw < settings.w ? settings.mw : settings.w;
			return settings.w;
		}
		function getHeight(){
			settings.h = settings.h || $loaded.height();
			settings.h = settings.mh && settings.mh < settings.h ? settings.mh : settings.h;
			return settings.h;
		}
		
		$loaded.hide()
		.appendTo($loadingBay)// content has to be appended to the DOM for accurate size calculations.  Appended to an absolutely positioned element, rather than BODY, which avoids an extremely brief display of the vertical scrollbar in Firefox that can occur for a small minority of websites.
		.css({width:getWidth(), overflow:settings.scrolling ? 'auto' : 'hidden'})
		.css({height:getHeight()})// sets the height independently from the width in case the new width influences the value of height.
		.prependTo($content);
		
		$('#cboxPhoto').css({cssFloat:'none'});// floating the IMG removes the bottom line-height and fixed a problem where IE miscalculates the width of the parent element as 100% of the document width.
		
		// Hides SELECT elements in IE6 because they would otherwise sit on top of the overlay.
		if (isIE6) {
			$('select:not(#colorbox select)').filter(function(){
				return this.style.visibility !== 'hidden';
			}).css({'visibility':'hidden'}).one(cbox_cleanup, function(){
				this.style.visibility = 'inherit';
			});
		}
				
		function setPosition (s) {
			cboxPublic.position(s, function(){
				if (!open) { return; }
				
				if (isIE) {
					//This fadeIn helps the bicubic resampling to kick-in.
					if( photo ){$loaded.fadeIn(100);}
					//IE adds a filter when ColorBox fades in and out that can cause problems if the loaded content contains transparent pngs.
					$cbox[0].style.removeAttribute("filter");
				}
				
				//Waited until the iframe is added to the DOM & it is visible before setting the src.
				//This increases compatability with pages using DOM dependent JavaScript.
				if(settings.iframe){
					$loaded.append("<iframe id='cboxIframe'" + (settings.scrolling ? " " : "scrolling='no'") + " name='iframe_"+new Date().getTime()+"' frameborder=0 src='"+settings.href+"' " + (isIE ? "allowtransparency='true'" : '') + " />");
				}
				
				$loaded.show();
				
				$title.show().html(settings.title);
				
				if ($related.length>1) {
					$current.html(settings.current.replace(/\{current\}/, index+1).replace(/\{total\}/, $related.length)).show();
					$next.html(settings.next).show();
					$prev.html(settings.previous).show();
					
					if(settings.slideshow){
						$slideshow.show();
					}
				}
				
				$loadingOverlay.hide();
				$loadingGraphic.hide();
				
				$.event.trigger(cbox_complete);
				if (settings.onComplete) {
					settings.onComplete.call(element);
				}
				
				if (settings.transition === 'fade'){
					$cbox.fadeTo(speed, 1, function(){
						if(isIE){$cbox[0].style.removeAttribute("filter");}
					});
				}
				
				$window.bind(cbox_resize, function(){
					cboxPublic.position(0);
				});
			});
		}
		
		if((settings.transition === 'fade' && $cbox.fadeTo(speed, 0, function(){setPosition(0);})) || setPosition(speed)){}
		
		// Preloads images within a rel group
		if (settings.preloading && $related.length>1) {
			prev = index > 0 ? $related[index-1] : $related[$related.length-1];
			next = index < $related.length-1 ? $related[index+1] : $related[0];
			nextSrc = $(next).data(colorbox).href || next.href;
			prevSrc = $(prev).data(colorbox).href || prev.href;
			
			if(isImage(nextSrc)){
				$('<img />').attr('src', nextSrc);
			}
			
			if(isImage(prevSrc)){
				$('<img />').attr('src', prevSrc);
			}
		}
	};

	cboxPublic.load = function () {
		var href, img, setResize, resize = cboxPublic.resize;
		
		active = TRUE;
		
		/*
		 
		// I decided to comment this out because I can see it causing problems as users
		// really should just set the dimensions on their IMG elements instead,
		// but I'm leaving the code in as it may be useful to someone.
		// To use, uncomment the function and change 'if(textStatus === "success"){ resize(this); }'
		// to 'if(textStatus === "success"){ preload(this); }'
		
		// Preload loops through the HTML to find IMG elements and loads their sources.
		// This allows the resize method to accurately estimate the dimensions of the new content.
		function preload(html){
			var
			$ajax = $(html),
			$imgs = $ajax.find('img'),
			x = $imgs.length;
			
			function loadloop(){
				var img = new Image();
				x = x-1;
				if(x >= 0){
					img.onload = loadloop;
					img.src = $imgs[x].src;
				} else {
					resize($ajax);
				}
			}
			
			loadloop();
		}
		*/
		
		element = $related[index];
		
		settings = $(element).data(colorbox);
		
		//convert functions to static values
		process();
		
		$.event.trigger(cbox_load);
		if (settings.onLoad) {
			settings.onLoad.call(element);
		}
		
		// Evaluate the height based on the optional height and width settings.
		settings.h = settings.height ?
				setSize(settings.height, 'y') - loadedHeight - interfaceHeight :
				settings.innerHeight ?
					setSize(settings.innerHeight, 'y') :
					FALSE;
		settings.w = settings.width ?
				setSize(settings.width, 'x') - loadedWidth - interfaceWidth :
				settings.innerWidth ?
					setSize(settings.innerWidth, 'x') :
					FALSE;
		
		// Sets the minimum dimensions for use in image scaling
		settings.mw = settings.w;
		settings.mh = settings.h;
		
		// Re-evaluate the minimum width and height based on maxWidth and maxHeight values.
		// If the width or height exceed the maxWidth or maxHeight, use the maximum values instead.
		if(settings.maxWidth){
			settings.mw = setSize(settings.maxWidth, 'x') - loadedWidth - interfaceWidth;
			settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw;
		}
		if(settings.maxHeight){
			settings.mh = setSize(settings.maxHeight, 'y') - loadedHeight - interfaceHeight;
			settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh;
		}
		
		href = settings.href;
		
		$loadingOverlay.show();
		$loadingGraphic.show();
		
		if (settings.inline) {
			// Inserts an empty placeholder where inline content is being pulled from.
			// An event is bound to put inline content back when ColorBox closes or loads new content.
			$('<div id="cboxInlineTemp" />').hide().insertBefore($(href)[0]).bind(cbox_load+' '+cbox_cleanup, function(){
				$(this).replaceWith($loaded.children());
			});
			resize($(href));
		} else if (settings.iframe) {
			// IFrame element won't be added to the DOM until it is ready to be displayed,
			// to avoid problems with DOM-ready JS that might be trying to run in that iframe.
			resize(" ");
		} else if (settings.html) {
			resize(settings.html);
		} else if (isImage(href)){
			img = new Image();
			img.onload = function(){
				var percent;
				
				img.onload = null;
				
				img.id = 'cboxPhoto';
				
				$(img).css({margin:'auto', border:'none', display:'block', cssFloat:'left'});
				
				if(settings.scalePhotos){
					setResize = function(){
						img.height -= img.height * percent;
						img.width -= img.width * percent;	
					};
					if(settings.mw && img.width > settings.mw){
						percent = (img.width - settings.mw) / img.width;
						setResize();
					}
					if(settings.mh && img.height > settings.mh){
						percent = (img.height - settings.mh) / img.height;
						setResize();
					}
				}
				
				if (settings.h) {
					img.style.marginTop = Math.max(settings.h - img.height,0)/2 + 'px';
				}
				
				resize(img);
				
				if($related.length > 1){
					$(img).css({cursor:'pointer'}).click(cboxPublic.next);
				}
				
				if(isIE){
					img.style.msInterpolationMode='bicubic';
				}
			};
			img.src = href;
		} else {
			$('<div />').appendTo($loadingBay).load(href, function(data, textStatus){
				if(textStatus === "success"){
					resize(this);
				} else {
					resize($("<p>Request unsuccessful.</p>"));
				}
			});
		}
	};

	// Navigates to the next page/image in a set.
	cboxPublic.next = function () {
		if(!active){
			index = index < $related.length-1 ? index+1 : 0;
			cboxPublic.load();
		}
	};
	
	cboxPublic.prev = function () {
		if(!active){
			index = index > 0 ? index-1 : $related.length-1;
			cboxPublic.load();
		}
	};

	cboxPublic.slideshow = function () {
		var stop, timeOut, className = 'cboxSlideshow_';
		
		$slideshow.bind(cbox_closed, function(){
			$slideshow.unbind();
			clearTimeout(timeOut);
			$cbox.removeClass(className+"off"+" "+className+"on");
		});
		
		function start(){
			$slideshow
			.text(settings.slideshowStop)
			.bind(cbox_complete, function(){
				timeOut = setTimeout(cboxPublic.next, settings.slideshowSpeed);
			})
			.bind(cbox_load, function(){
				clearTimeout(timeOut);	
			}).one("click", function(){
				stop();
				$(this).removeClass(hover);
			});
			$cbox.removeClass(className+"off").addClass(className+"on");
		}
		
		stop = function(){
			clearTimeout(timeOut);
			$slideshow
			.text(settings.slideshowStart)
			.unbind(cbox_complete+' '+cbox_load)
			.one("click", function(){
				start();
				timeOut = setTimeout(cboxPublic.next, settings.slideshowSpeed);
				$(this).removeClass(hover);
			});
			$cbox.removeClass(className+"on").addClass(className+"off");
		};
		
		if(settings.slideshow && $related.length>1){
			if(settings.slideshowAuto){
				start();
			} else {
				stop();
			}
		}
	};

	// Note: to use this within an iframe use the following format: parent.$.fn.colorbox.close();
	cboxPublic.close = function () {
		
		$.event.trigger(cbox_cleanup);
		if (settings.onCleanup) {
			settings.onCleanup.call(element);
		}
		
		open = FALSE;
		$(document).unbind("keydown.cbox_close keydown.cbox_arrows");
		$window.unbind(cbox_resize+' resize.cboxie6 scroll.cboxie6');
		$overlay.css({cursor: 'auto'}).fadeOut('fast');
		
		$cbox
		.stop(TRUE, FALSE)
		.fadeOut('fast', function () {
			$('#colorbox iframe').attr('src', 'about:blank');
			$loaded.remove();
			$cbox.css({'opacity': 1});
			
			try{
				bookmark.focus();
			} catch (er){
				// do nothing
			}
			
			$.event.trigger(cbox_closed);
			if (settings.onClosed) {
				settings.onClosed.call(element);
			}
		});
	};

	// A method for fetching the current element ColorBox is referencing.
	// returns a jQuery object.
	cboxPublic.element = function(){ return $(element); };

	cboxPublic.settings = defaults;

	// Initializes ColorBox when the DOM has loaded
	$(cboxPublic.init);

}(jQuery));

