﻿/// <reference path="json2.js" />
/// <reference path="messages.js" />
/// <reference path="~/Scripts/jquery-1.6.1-vsdoc.js" />

jQuery.fn.extend({
  everyTime: function (interval, label, fn, times, belay) {
    return this.each(function () {
      jQuery.timer.add(this, interval, label, fn, times, belay);
    });
  },
  oneTime: function (interval, label, fn) {
    return this.each(function () {
      jQuery.timer.add(this, interval, label, fn, 1);
    });
  },
  stopTime: function (label, fn) {
    return this.each(function () {
      jQuery.timer.remove(this, label, fn);
    });
  }
});

jQuery.extend({
  timer: {
    guid: 1,
    global: {},
    regex: /^([0-9]+)\s*(.*s)?$/,
    powers: {
      // Yeah this is major overkill...
      'ms': 1,
      'cs': 10,
      'ds': 100,
      's': 1000,
      'das': 10000,
      'hs': 100000,
      'ks': 1000000
    },
    timeParse: function (value) {
      if (value == undefined || value == null)
        return null;
      var result = this.regex.exec(jQuery.trim(value.toString()));
      if (result[2]) {
        var num = parseInt(result[1], 10);
        var mult = this.powers[result[2]] || 1;
        return num * mult;
      } else {
        return value;
      }
    },
    add: function (element, interval, label, fn, times, belay) {
      var counter = 0;

      if (jQuery.isFunction(label)) {
        if (!times)
          times = fn;
        fn = label;
        label = interval;
      }

      interval = jQuery.timer.timeParse(interval);

      if (typeof interval != 'number' || isNaN(interval) || interval <= 0)
        return;

      if (times && times.constructor != Number) {
        belay = !!times;
        times = 0;
      }

      times = times || 0;
      belay = belay || false;

      if (!element.$timers)
        element.$timers = {};

      if (!element.$timers[label])
        element.$timers[label] = {};

      fn.$timerID = fn.$timerID || this.guid++;

      var handler = function () {
        if (belay && this.inProgress)
          return;
        this.inProgress = true;
        if ((++counter > times && times !== 0) || fn.call(element, counter) === false)
          jQuery.timer.remove(element, label, fn);
        this.inProgress = false;
      };

      handler.$timerID = fn.$timerID;

      if (!element.$timers[label][fn.$timerID])
        element.$timers[label][fn.$timerID] = window.setInterval(handler, interval);

      if (!this.global[label])
        this.global[label] = [];
      this.global[label].push(element);

    },
    remove: function (element, label, fn) {
      var timers = element.$timers, ret;

      if (timers) {

        if (!label) {
          for (label in timers)
            this.remove(element, label, fn);
        } else if (timers[label]) {
          if (fn) {
            if (fn.$timerID) {
              window.clearInterval(timers[label][fn.$timerID]);
              delete timers[label][fn.$timerID];
            }
          } else {
            for (var fn in timers[label]) {
              window.clearInterval(timers[label][fn]);
              delete timers[label][fn];
            }
          }

          for (ret in timers[label]) break;
          if (!ret) { ret = null; delete timers[label]; }
        }

        for (ret in timers) break;
        if (!ret) element.$timers = null;
      }
    }
  }
});

if (jQuery.browser.msie)
  jQuery(window).one("unload", function () {
    var global = jQuery.timer.global;
    for (var label in global) {
      var els = global[label], i = els.length;
      while (--i) jQuery.timer.remove(els[i], label);
    }
  });


  // ajax wrapper
  (function ($) {
    $.AjaxJq = function (options) {

      // Load Defaults and make them public
      this.defaults = {
        TimeoutRequest: 30000,
        ShowLoading: true,
        LoaderContainerId: "#divLoader",
        LoaderText: "Пожалуйста подождите...",
        TimeoutLoader: 10000,
        ErrorCallBack: function (xmlHttpRequest, textStatus) {
          $(dialog).dialog('close');
          $(o).stopTime('timerAjaxLoader');
          if (xmlHttpRequest.status == 401) location.reload();
          if (typeof (xmlHttpRequest.responseText) === 'string' && xmlHttpRequest.responseText[0] != "<") {
            var response = eval("(" + xmlHttpRequest.responseText + ")");
            var output = "<p><b>Сообщение:</b> " + response.Message + "<br /><br />";
            if (response.StackTrace != null) output += "<b>Стек</b>: " + response.StackTrace.replace(/\n/g, '<br />');
            output += "</p>";
            alert(output, { title: "Ошибка " + xmlHttpRequest.status, width: 600 });
          }
          if (textStatus == 'timeout') alert("<p>Превышен интервал ожидания запроса.</p>", { title: "Ошибка " + xmlHttpRequest.status });
          if (textStatus == 'abort') alert("<p>Запрос прерван пользователем.</p>", { title: "Ошибка " + xmlHttpRequest.status });
        },
        Abort: function() { if (xhr && xhr.readystate != 4) xhr.abort(); }
      };
      
      var dialog = $.getOrCreateDialog('divLoader')
                    .dialog({
                      modal: true,
                      autoOpen: false,
                      title: "Обрабатывается запрос",
                      minHeight: 100,
                      resizable: false,
                      buttons: { 'Отмена': function () { o.Abort(); $(this).dialog("close"); } }
                    })
                    .parent().find(".ui-dialog-titlebar-close").hide().end().end();

      // Extend defaults into options
      var o = $.extend({}, this.defaults, options);

      var xhr = null;

      this.Post = function (webService, jsonData, successCallBack, errorCallback, showLoading, loaderText) {
        if (webService == "") return 1; // Incorrect Parameters
        if (errorCallback == null) errorCallback = o.ErrorCallBack;
        if (typeof (jsonData) === "object") jsonData = JSON.stringify(jsonData);
        if (showLoading != null ? showLoading : o.ShowLoading) showLoader(loaderText != null ? loaderText : o.LoaderText);

        xhr = $.ajax({
          type: "POST",
          url: webService,
          data: jsonData,
          timeout: o.TimeoutRequest,
          converters: { "json jsond": function (msg) { return msg.hasOwnProperty('d') ? msg.d : msg; } },
          contentType: "application/json; charset=utf-8"
        })
          .success(function () {
            $(o).stopTime('timerAjaxLoader');
            $(o.LoaderContainerId).stop(true, true).fadeOut("fast");
            $(dialog).dialog('close');
          })
          .success(successCallBack)
          .error(errorCallback) ;
        return 0; // Successful
      };

      function showLoader(loaderText) {
        $(o).oneTime(o.TimeoutLoader, 'timerAjaxLoader', function () {
          $(dialog).html("<p><img src='../images/async.gif'> " + loaderText + "</p>");
          $(dialog).dialog('open');
        });
      };

//      $(document).ready(function () {
//        $(o.LoaderContainerId).ajaxStop(function () {
//          $(this).stop(true, true).fadeOut("fast");
//          $(dialog).dialog('close');
//          $(o).stopTime('timerAjaxLoader');
//        });
//      });

      return this;
    };
  })(jQuery);
  
  var ajaxQuery = new $.AjaxJq();

/*
* Superfish v1.4.8 - jQuery menu widget
* Copyright (c) 2008 Joel Birch
*
* Dual licensed under the MIT and GPL licenses:
* 	http://www.opensource.org/licenses/mit-license.php
* 	http://www.gnu.org/licenses/gpl.html
*
* CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
*/

; (function ($) {
  $.fn.superfish = function (op) {

    var sf = $.fn.superfish,
      c = sf.c,
      $arrow = $(['<span class="', c.arrowClass, '"> &#187;</span>'].join('')),
      over = function () {
        var $$ = $(this), menu = getMenu($$);
        clearTimeout(menu.sfTimer);
        $$.showSuperfishUl().siblings().hideSuperfishUl();
      },
      out = function () {
        var $$ = $(this), menu = getMenu($$), o = sf.op;
        clearTimeout(menu.sfTimer);
        menu.sfTimer = setTimeout(function () {
          o.retainPath = ($.inArray($$[0], o.$path) > -1);
          $$.hideSuperfishUl();
          if (o.$path.length && $$.parents(['li.', o.hoverClass].join('')).length < 1) { over.call(o.$path); }
        }, o.delay);
      },
      getMenu = function ($menu) {
        var menu = $menu.parents(['ul.', c.menuClass, ':first'].join(''))[0];
        sf.op = sf.o[menu.serial];
        return menu;
      },
      addArrow = function ($a) { $a.addClass(c.anchorClass).append($arrow.clone()); };

    return this.each(function () {
      var s = this.serial = sf.o.length;
      var o = $.extend({}, sf.defaults, op);
      o.$path = $('li.' + o.pathClass, this).slice(0, o.pathLevels).each(function () {
        $(this).addClass([o.hoverClass, c.bcClass].join(' '))
          .filter('li:has(ul)').removeClass(o.pathClass);
      });
      sf.o[s] = sf.op = o;

      $('li:has(ul)', this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over, out).each(function () {
        if (o.autoArrows) addArrow($('>a:first-child', this));
      })
      .not('.' + c.bcClass)
        .hideSuperfishUl();

      var $a = $('a', this);
      $a.each(function (i) {
        var $li = $a.eq(i).parents('li');
        $a.eq(i).focus(function () { over.call($li); }).blur(function () { out.call($li); });
      });
      o.onInit.call(this);

    }).each(function () {
      var menuClasses = [c.menuClass];
      if (sf.op.dropShadows && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
      $(this).addClass(menuClasses.join(' '));
    });
  };

  var sf = $.fn.superfish;
  sf.o = [];
  sf.op = {};
  sf.IE7fix = function () {
    var o = sf.op;
    if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity != undefined)
      this.toggleClass(sf.c.shadowClass + '-off');
  };
  sf.c = {
    bcClass: 'sf-breadcrumb',
    menuClass: 'sf-js-enabled',
    anchorClass: 'sf-with-ul',
    arrowClass: 'sf-sub-indicator',
    shadowClass: 'sf-shadow'
  };
  sf.defaults = {
    hoverClass: 'sfHover',
    pathClass: 'overideThisToUse',
    pathLevels: 1,
    delay: 800,
    animation: { opacity: 'show' },
    speed: 'normal',
    autoArrows: true,
    dropShadows: true,
    disableHI: false, 	// true disables hoverIntent detection
    onInit: function () { }, // callback functions
    onBeforeShow: function () { },
    onShow: function () { },
    onHide: function () { }
  };
  $.fn.extend({
    hideSuperfishUl: function () {
      var o = sf.op,
        not = (o.retainPath === true) ? o.$path : '';
      o.retainPath = false;
      var $ul = $(['li.', o.hoverClass].join(''), this).add(this).not(not).removeClass(o.hoverClass)
          .find('>ul').hide().css('visibility', 'hidden');
      o.onHide.call($ul);
      return this;
    },
    showSuperfishUl: function () {
      var o = sf.op,
        sh = sf.c.shadowClass + '-off',
        $ul = this.addClass(o.hoverClass)
          .find('>ul:hidden').css('visibility', 'visible');
      sf.IE7fix.call($ul);
      o.onBeforeShow.call($ul);
      $ul.animate(o.animation, o.speed, function () { sf.IE7fix.call($ul); o.onShow.call($ul); });
      return this;
    }
  });

})(jQuery);

/*
 * Supersubs v0.2b - jQuery plugin
 * Copyright (c) 2008 Joel Birch
 *
 * Dual licensed under the MIT and GPL licenses:
 * 	http://www.opensource.org/licenses/mit-license.php
 * 	http://www.gnu.org/licenses/gpl.html
 *
 *
 * This plugin automatically adjusts submenu widths of suckerfish-style menus to that of
 * their longest list item children. If you use this, please expect bugs and report them
 * to the jQuery Google Group with the word 'Superfish' in the subject line.
 *
 */

;(function($){ // $ will refer to jQuery within this closure

  $.fn.supersubs = function(options){
    var opts = $.extend({}, $.fn.supersubs.defaults, options);
    // return original object to support chaining
    return this.each(function() {
      // cache selections
      var $$ = $(this);
      // support metadata
      var o = $.meta ? $.extend({}, opts, $$.data()) : opts;
      // get the font size of menu.
      // .css('fontSize') returns various results cross-browser, so measure an em dash instead
      var fontsize = $('<li id="menu-fontsize">&#8212;</li>').css({
        'padding' : 0,
        'position' : 'absolute',
        'top' : '-999em',
        'width' : 'auto'
      }).appendTo($$).width(); //clientWidth is faster, but was incorrect here
      // remove em dash
      $('#menu-fontsize').remove();
      // cache all ul elements
      $ULs = $$.find('ul');
      // loop through each ul in menu
      $ULs.each(function(i) {	
        // cache this ul
        var $ul = $ULs.eq(i);
        // get all (li) children of this ul
        var $LIs = $ul.children();
        // get all anchor grand-children
        var $As = $LIs.children('a');
        // force content to one line and save current float property
        var liFloat = $LIs.css('white-space','nowrap').css('float');
        // remove width restrictions and floats so elements remain vertically stacked
        var emWidth = $ul.add($LIs).add($As).css({
          'float' : 'none',
          'width'	: 'auto'
        })
        // this ul will now be shrink-wrapped to longest li due to position:absolute
        // so save its width as ems. Clientwidth is 2 times faster than .width() - thanks Dan Switzer
        .end().end()[0].clientWidth / fontsize;
        // add more width to ensure lines don't turn over at certain sizes in various browsers
        emWidth += o.extraWidth;
        // restrict to at least minWidth and at most maxWidth
        if (emWidth > o.maxWidth)		{ emWidth = o.maxWidth; }
        else if (emWidth < o.minWidth)	{ emWidth = o.minWidth; }
        emWidth += 'em';
        // set ul to width in ems
        $ul.css('width',emWidth);
        // restore li floats to avoid IE bugs
        // set li width to full width of this ul
        // revert white-space to normal
        $LIs.css({
          'float' : liFloat,
          'width' : '100%',
          'white-space' : 'normal'
        })
        // update offset position of descendant ul to reflect new width of parent
        .each(function(){
          var $childUl = $('>ul',this);
          var offsetDirection = $childUl.css('left')!==undefined ? 'left' : 'right';
          $childUl.css(offsetDirection,emWidth);
        });
      });
      
    });
  };
  // expose defaults
  $.fn.supersubs.defaults = {
    minWidth		: 9,		// requires em unit.
    maxWidth		: 25,		// requires em unit.
    extraWidth		: 0			// extra width can ensure lines don't sometimes turn over due to slight browser differences in how they round-off values
  };
  
})(jQuery); // plugin code ends


jQuery.fn.center = function (absolute) { return this.each(function () { var t = jQuery(this); t.css({ position: absolute ? 'absolute' : 'fixed', left: '50%', top: '50%', zIndex: '99' }).css({ marginLeft: '-' + (t.outerWidth() / 2) + 'px', marginTop: '-' + (t.outerHeight() / 2) + 'px' }); if (absolute) { t.css({ marginTop: parseInt(t.css('marginTop'), 10) + jQuery(window).scrollTop(), marginLeft: parseInt(t.css('marginLeft'), 10) + jQuery(window).scrollLeft() });
                                                                                                                                                                                                                                                                                                 } }); };


(function ($) {
  $.fn.hAlign = function () {
    return this.each(function (i) {
      var w = $(this).width();
      var ow = $(this).outerWidth();
      var ml = (w + (ow - w)) / 2;
      $(this).css("margin-left", "-" + ml + "px");
      $(this).css("left", "50%");
      $(this).css("position", "absolute");
    });
  };
})(jQuery);

/*!
 * jQuery corner plugin: simple corner rounding
 * Examples and documentation at: http://jquery.malsup.com/corner/
 * version 2.11 (15-JUN-2010)
 * Requires jQuery v1.3.2 or later
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Authors: Dave Methvin and Mike Alsup
 */

/**
 *  corner() takes a single string argument:  $('#myDiv').corner("effect corners width")
 *
 *  effect:  name of the effect to apply, such as round, bevel, notch, bite, etc (default is round). 
 *  corners: one or more of: top, bottom, tr, tl, br, or bl.  (default is all corners)
 *  width:   width of the effect; in the case of rounded corners this is the radius. 
 *           specify this value using the px suffix such as 10px (yes, it must be pixels).
 */
;(function($) { 

var style = document.createElement('div').style,
    moz = style['MozBorderRadius'] !== undefined,
    webkit = style['WebkitBorderRadius'] !== undefined,
    radius = style['borderRadius'] !== undefined || style['BorderRadius'] !== undefined,
    mode = document.documentMode || 0,
    noBottomFold = $.browser.msie && (($.browser.version < 8 && !mode) || mode < 8),

    expr = $.browser.msie && (function() {
        var div = document.createElement('div');
        try { div.style.setExpression('width','0+0'); div.style.removeExpression('width'); }
        catch(e) { return false; }
        return true;
    })();

$.support = $.support || {};
$.support.borderRadius = moz || webkit || radius; // so you can do:  if (!$.support.borderRadius) $('#myDiv').corner();

function sz(el, p) { 
    return parseInt($.css(el,p))||0; 
};
function hex2(s) {
    var s = parseInt(s).toString(16);
    return ( s.length < 2 ) ? '0'+s : s;
};
function gpc(node) {
    while(node) {
        var v = $.css(node,'backgroundColor'), rgb;
        if (v && v != 'transparent' && v != 'rgba(0, 0, 0, 0)') {
            if (v.indexOf('rgb') >= 0) { 
                rgb = v.match(/\d+/g); 
                return '#'+ hex2(rgb[0]) + hex2(rgb[1]) + hex2(rgb[2]);
            }
            return v;
        }
        if (node.nodeName.toLowerCase() == 'html')
            break;
        node = node.parentNode; // keep walking if transparent
    }
    return '#ffffff';
};

function getWidth(fx, i, width) {
    switch(fx) {
    case 'round':  return Math.round(width*(1-Math.cos(Math.asin(i/width))));
    case 'cool':   return Math.round(width*(1+Math.cos(Math.asin(i/width))));
    case 'sharp':  return Math.round(width*(1-Math.cos(Math.acos(i/width))));
    case 'bite':   return Math.round(width*(Math.cos(Math.asin((width-i-1)/width))));
    case 'slide':  return Math.round(width*(Math.atan2(i,width/i)));
    case 'jut':    return Math.round(width*(Math.atan2(width,(width-i-1))));
    case 'curl':   return Math.round(width*(Math.atan(i)));
    case 'tear':   return Math.round(width*(Math.cos(i)));
    case 'wicked': return Math.round(width*(Math.tan(i)));
    case 'long':   return Math.round(width*(Math.sqrt(i)));
    case 'sculpt': return Math.round(width*(Math.log((width-i-1),width)));
    case 'dogfold':
    case 'dog':    return (i&1) ? (i+1) : width;
    case 'dog2':   return (i&2) ? (i+1) : width;
    case 'dog3':   return (i&3) ? (i+1) : width;
    case 'fray':   return (i%2)*width;
    case 'notch':  return width; 
    case 'bevelfold':
    case 'bevel':  return i+1;
    }
};

$.fn.corner = function(options) {
    // in 1.3+ we can fix mistakes with the ready state
    if (this.length == 0) {
        if (!$.isReady && this.selector) {
            var s = this.selector, c = this.context;
            $(function() {
                $(s,c).corner(options);
            });
        }
        return this;
    }

    return this.each(function(index){
        var $this = $(this),
            // meta values override options
            o = [$this.attr($.fn.corner.defaults.metaAttr) || '', options || ''].join(' ').toLowerCase(),
            keep = /keep/.test(o),                       // keep borders?
            cc = ((o.match(/cc:(#[0-9a-f]+)/)||[])[1]),  // corner color
            sc = ((o.match(/sc:(#[0-9a-f]+)/)||[])[1]),  // strip color
            width = parseInt((o.match(/(\d+)px/)||[])[1]) || 10, // corner width
            re = /round|bevelfold|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dogfold|dog/,
            fx = ((o.match(re)||['round'])[0]),
            fold = /dogfold|bevelfold/.test(o),
            edges = { T:0, B:1 },
            opts = {
                TL:  /top|tl|left/.test(o),       TR:  /top|tr|right/.test(o),
                BL:  /bottom|bl|left/.test(o),    BR:  /bottom|br|right/.test(o)
            },
            // vars used in func later
            strip, pad, cssHeight, j, bot, d, ds, bw, i, w, e, c, common, $horz;
        
        if ( !opts.TL && !opts.TR && !opts.BL && !opts.BR )
            opts = { TL:1, TR:1, BL:1, BR:1 };
            
        // support native rounding
        if ($.fn.corner.defaults.useNative && fx == 'round' && (radius || moz || webkit) && !cc && !sc) {
            if (opts.TL)
                $this.css(radius ? 'border-top-left-radius' : moz ? '-moz-border-radius-topleft' : '-webkit-border-top-left-radius', width + 'px');
            if (opts.TR)
                $this.css(radius ? 'border-top-right-radius' : moz ? '-moz-border-radius-topright' : '-webkit-border-top-right-radius', width + 'px');
            if (opts.BL)
                $this.css(radius ? 'border-bottom-left-radius' : moz ? '-moz-border-radius-bottomleft' : '-webkit-border-bottom-left-radius', width + 'px');
            if (opts.BR)
                $this.css(radius ? 'border-bottom-right-radius' : moz ? '-moz-border-radius-bottomright' : '-webkit-border-bottom-right-radius', width + 'px');
            return;
        }
            
        strip = document.createElement('div');
        $(strip).css({
            overflow: 'hidden',
            height: '1px',
            minHeight: '1px',
            fontSize: '1px',
            backgroundColor: sc || 'transparent',
            borderStyle: 'solid'
        });
    
        pad = {
            T: parseInt($.css(this,'paddingTop'))||0,     R: parseInt($.css(this,'paddingRight'))||0,
            B: parseInt($.css(this,'paddingBottom'))||0,  L: parseInt($.css(this,'paddingLeft'))||0
        };

        if (typeof this.style.zoom != undefined) this.style.zoom = 1; // force 'hasLayout' in IE
        if (!keep) this.style.border = 'none';
        strip.style.borderColor = cc || gpc(this.parentNode);
        cssHeight = $(this).outerHeight();

        for (j in edges) {
            bot = edges[j];
            // only add stips if needed
            if ((bot && (opts.BL || opts.BR)) || (!bot && (opts.TL || opts.TR))) {
                strip.style.borderStyle = 'none '+(opts[j+'R']?'solid':'none')+' none '+(opts[j+'L']?'solid':'none');
                d = document.createElement('div');
                $(d).addClass('jquery-corner');
                ds = d.style;

                bot ? this.appendChild(d) : this.insertBefore(d, this.firstChild);

                if (bot && cssHeight != 'auto') {
                    if ($.css(this,'position') == 'static')
                        this.style.position = 'relative';
                    ds.position = 'absolute';
                    ds.bottom = ds.left = ds.padding = ds.margin = '0';
                    if (expr)
                        ds.setExpression('width', 'this.parentNode.offsetWidth');
                    else
                        ds.width = '100%';
                }
                else if (!bot && $.browser.msie) {
                    if ($.css(this,'position') == 'static')
                        this.style.position = 'relative';
                    ds.position = 'absolute';
                    ds.top = ds.left = ds.right = ds.padding = ds.margin = '0';
                    
                    // fix ie6 problem when blocked element has a border width
                    if (expr) {
                        bw = sz(this,'borderLeftWidth') + sz(this,'borderRightWidth');
                        ds.setExpression('width', 'this.parentNode.offsetWidth - '+bw+'+ "px"');
                    }
                    else
                        ds.width = '100%';
                }
                else {
                    ds.position = 'relative';
                    ds.margin = !bot ? '-'+pad.T+'px -'+pad.R+'px '+(pad.T-width)+'px -'+pad.L+'px' : 
                                        (pad.B-width)+'px -'+pad.R+'px -'+pad.B+'px -'+pad.L+'px';                
                }

                for (i=0; i < width; i++) {
                    w = Math.max(0,getWidth(fx,i, width));
                    e = strip.cloneNode(false);
                    e.style.borderWidth = '0 '+(opts[j+'R']?w:0)+'px 0 '+(opts[j+'L']?w:0)+'px';
                    bot ? d.appendChild(e) : d.insertBefore(e, d.firstChild);
                }
                
                if (fold && $.support.boxModel) {
                    if (bot && noBottomFold) continue;
                    for (c in opts) {
                        if (!opts[c]) continue;
                        if (bot && (c == 'TL' || c == 'TR')) continue;
                        if (!bot && (c == 'BL' || c == 'BR')) continue;
                        
                        common = { position: 'absolute', border: 'none', margin: 0, padding: 0, overflow: 'hidden', backgroundColor: strip.style.borderColor };
                        $horz = $('<div/>').css(common).css({ width: width + 'px', height: '1px' });
                        switch(c) {
                        case 'TL': $horz.css({ bottom: 0, left: 0 }); break;
                        case 'TR': $horz.css({ bottom: 0, right: 0 }); break;
                        case 'BL': $horz.css({ top: 0, left: 0 }); break;
                        case 'BR': $horz.css({ top: 0, right: 0 }); break;
                        }
                        d.appendChild($horz[0]);
                        
                        var $vert = $('<div/>').css(common).css({ top: 0, bottom: 0, width: '1px', height: width + 'px' });
                        switch(c) {
                        case 'TL': $vert.css({ left: width }); break;
                        case 'TR': $vert.css({ right: width }); break;
                        case 'BL': $vert.css({ left: width }); break;
                        case 'BR': $vert.css({ right: width }); break;
                        }
                        d.appendChild($vert[0]);
                    }
                }
            }
        }
    });
};

$.fn.uncorner = function() { 
    if (radius || moz || webkit)
        this.css(radius ? 'border-radius' : moz ? '-moz-border-radius' : '-webkit-border-radius', 0);
    $('div.jquery-corner', this).remove();
    return this;
};

// expose options
$.fn.corner.defaults = {
    useNative: true, // true if plugin should attempt to use native browser support for border radius rounding
    metaAttr:  'data-corner' // name of meta attribute to use for options
};

})(jQuery);

/*
 *
 * Copyright (c) 2006-2008 Sam Collett (http://www.texotela.co.uk)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * 
 * Version 2.1
 * Demo: http://www.texotela.co.uk/code/jquery/checkboxes/
 *
 * $LastChangedDate: 2009-02-07 23:54:23 +0000 (Sat, 07 Feb 2009) $
 * $Rev: 6184 $
 */
;(function(d){d.fn.toggleCheckboxes=function(a,b){a=a||"*";b=b||false;var c=d([]);this.each(function(){var e=d("input[type=checkbox]",this).filter(a).each(function(){this.checked=!this.checked}).filter(":checked");c=e});if(!b){c=this}return c};d.fn.checkCheckboxes=function(a,b){a=a||"*";b=b||false;var c=d([]);this.each(function(){var e=d("input[type=checkbox]",this).filter(a).each(function(){this.checked=true}).filter(":checked");c=e});if(!b){c=this}return c};d.fn.unCheckCheckboxes=function(a,b){a=a||"*";b=b||false;var c=d([]);this.each(function(){var e=d("input[type=checkbox]",this).filter(a).each(function(){this.checked=false}).filter(":not(:checked)");c=e});if(!b){c=this}return c};d.radioCheckboxGroup=function(e,a){a=a||"*";var b="input[type=checkbox]";if(e){b+="[name="+e+"]"}var c=d(b).filter(a);c.click(function(){c.not(this).each(function(){this.checked=false}).end()})}})(jQuery);



function rgb2hex(rgb) {
  if (rgb[0] != '#') {
    rgb = rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))?\)$/);
    function hex(x) {
      return ("0" + parseInt(x).toString(16)).slice(-2);
    }
    return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
  }
  else return rgb;
}


$.extend({
  password: function (length, special) {
    var iteration = 0;
    var password = "";
    var randomNumber;
    if (special == undefined) special = false;
    while (iteration < length) {
      randomNumber = (Math.floor((Math.random() * 100)) % 94) + 33;
      if (!special) {
        if ((randomNumber >= 33) && (randomNumber <= 47)) { continue; }
        if ((randomNumber >= 58) && (randomNumber <= 64)) { continue; }
        if ((randomNumber >= 91) && (randomNumber <= 96)) { continue; }
        if ((randomNumber >= 123) && (randomNumber <= 126)) { continue; }
      }
      iteration++;
      password += String.fromCharCode(randomNumber);
    }
    return password;
  }
});
