/* Dropshadow - begin */
(function($) {
	$.fn.boxShadow = function(xOffset, yOffset, blurRadius, shadowColor) {
		if (!$.browser.msie) return;
		return this.each(function(){
			$(this).css({
				position:	"relative",
				zoom: 		1,
				zIndex:		"2"
			});
			$(this).parent().css({
					position:	"relative"
			});
			
			var div=document.createElement("div");
			$(this).parent().append(div);

			var _top, _left, _width, _height;
			if (blurRadius != 0) {
				$(div).css("filter", "progid:DXImageTransform.Microsoft.Blur(pixelRadius="+(blurRadius)+", enabled='true')");
				_top = 		yOffset-blurRadius-1;
				_left =		xOffset-blurRadius-1;
				_width =		$(this).outerWidth()+1;
				_height =	$(this).outerHeight()+1;
			} else {
				_top = 		yOffset;
				_left =		xOffset;
				_width = 	$(this).outerWidth();
				_height = 	$(this).outerHeight();
			}
			$(div).css({
				top: 			_top,
				left:			_left,
				width:		_width,
				height:		_height,
				background:	shadowColor,
				position:	"absolute",
				zIndex:		1
			});
			
	  });
	};
})(jQuery);
/* Dropshadow - end */
/* Table rows - begin */
jQuery.fn.colorize = function(params) {
	options = {
		altColor: '#e8e9e8',
		bgColor: '#fff',
		hoverColor: '#6d6d6d',
		hoverClass:'rowHover',
		hiliteColor: '#6d6d6d',
		hiliteClass:'rowSelected',
		oneClick: false,
		hover:'row',
		click:'row',
		banColumns: [],
		banRows:[],
		banDataClick:false,
		ignoreHeaders:true,
		nested:false
	};
	jQuery.extend(options, params);

	var colorHandler = {

		addHoverClass: function(){
			this.origColor = this.style.backgroundColor;
			this.style.backgroundColor='';
			jQuery(this).addClass(options.hoverClass);
		},

		addBgHover:function (){
			this.origColor = this.style.backgroundColor;
			this.style.backgroundColor= options.hoverColor;
		},

		removeHoverClass: function(){
			jQuery(this).removeClass(options.hoverClass);
			this.style.backgroundColor=this.origColor;
		},

		removeBgHover: function(){
			  this.style.backgroundColor=this.origColor;
		},

		checkHover: function() {
			if(checkRowBan(this)) return;
			if (!this.onfire) this.hover();
		},

		checkHoverOut: function() {
			if (!this.onfire) this.removeHover();
		},

		highlight: function() {
			if(options.hiliteClass.length>0 || options.hiliteColor != 'none')
			{
				if(checkRowBan(this)) return;
				this.onfire = true;

				if(options.hiliteClass.length>0){
					this.style.backgroundColor='';
					jQuery(this).addClass(options.hiliteClass).removeClass(options.hoverClass);
				}
				else if (options.hiliteColor != 'none') {
			         this.style.backgroundColor= options.hiliteColor;
					if(options.hoverClass.length>0) jQuery(this).removeClass(options.hoverClass);
				}
			}
		},
		stopHighlight: function() {
		    this.onfire = false;
			this.style.backgroundColor = (this.origColor)?this.origColor:'';
			jQuery(this).removeClass(options.hiliteClass).removeClass(options.hoverClass);
		}
	}


	 function  processCells (cells, idx, func) {
		var colCells = getColCells(cells, idx);

		jQuery.each(colCells, function(index, cell2) {
			func.call(cell2);
		});

	    function getColCells (cells, idx) {
			var arr = [];
			for (var i = 0; i < cells.length; i++) {
				if (cells[i].cellIndex == idx)
					arr.push(cells[i]);
			}
			return arr;
		}
	}

	function processAdapter(cells, cell, func) {
		processCells(cells, cell.cellIndex, func);
	}



  var clickHandler = {
	toggleColumnClick : function (cells) {
		var func = (!this.onfire) ? colorHandler.highlight : colorHandler.stopHighlight;
		processAdapter(cells, this, func);
	},

	toggleRowClick: function(cells) {
		row = jQuery(this).parent().get(0);
		if (!row.onfire)
			colorHandler.highlight.call(row);
		else
			colorHandler.stopHighlight.call(row);
	},

     oneClick : function (clicked){
			if(clicked != null) {
				   if (this.isRepeatClick())
				   {
					   this.stopHilite();
					   this.cancel ();
				   }
				   else{
					   this.stopHilite();
					   this.hilite();
				   }
			   }
			   else{
				   this.hilite();
			   }
      },

	   oneColumnClick : function (cells) {
	       var indx = this.cellIndex;
		   function repeat (){
		   	  return (cells.clicked == indx);
		   }
		   Column.handleClick (this, cells, indx, repeat);
	   },

	    oneRowClick  : function (cells) {
	           var row = jQuery(this).parent().get(0);
	           var indx = row.rowIndex;
	           function repeat (){
	                 return (cells.rowClicked == indx);
	            }
	           Row.handleClick (this, cells, row.rowIndex, repeat);
	    },

	    oneColumnRowClick : function (cells) {

				   var indx = this.cellIndex;
				   var row = jQuery(this).parent().get(0);

				   function isRepeatColumn(){
					   return (cells.clicked == indx && cells.rowClicked  == row.rowIndex) ;
				   }

				   function isRepeatRow(){
					   return (cells.rowClicked  == row.rowIndex && this.cellIndex == cells.clicked) ;
				   }

			    Column.handleClick (this, cells,indx, isRepeatColumn);
				Row.handleClick (this, cells,row.rowIndex, isRepeatRow);
           }
	 }

	var Column ={

	      init: function(cell, cells, indx){
			  this.cell = cell;
			  this.cells = cells;
		 	  this.indx = indx;
		  },

		  handleClick: function(cell, cells, indx, func){
              this.init(cell, cells, indx);
              this.isRepeatClick = func;
              clickHandler.oneClick.call (this, cells.clicked);
		  },
	     stopHilite : function(){
	        processCells(this.cells, this.cells.clicked, colorHandler.stopHighlight);
	    },
	    hilite : function(){
	        processAdapter(this.cells, this.cell, colorHandler.highlight);
	        this.cells.clicked  = this.indx;
	    },
	    cancel: function(){
	         this.cells.clicked = null;
	     }
	 }

	var Row ={
	      init: function(cell, cells, indx){
		  		this.cell = cell;
		  		this.cells = cells;
		  		this.indx = indx;
		  },
		  handleClick: function(cell, cells, indx, func){
		        this.init(cell, cells, indx);
		        this.isRepeatClick = func;
		        clickHandler.oneClick.call (this, cells.rowClicked);
		  },
	      stopHilite : function(){
	         colorHandler.stopHighlight.call(clickHandler.tbl.rows[this.cells.rowClicked]); // delete the selected row
	     },
	     hilite : function(){
	          var row = jQuery(this.cell).parent().get(0);
			  if(options.hover=='column')  colorHandler.addBgHover.call (row);
	          colorHandler.highlight.call(row); // the current row is set to select
	          this.cells.rowClicked = this.indx; //the current row is recorded

	     },
	     cancel: function(){
	         this.cells.rowClicked = null;
	     }
	 }

    function isDataCell(){
	     return (this.nodeName == 'TD');
    }

	function checkBan() {
		return (jQuery.inArray(this.cellIndex, options.banColumns) != -1) ;
	}

	function checkRowBan(cell){
			if(options.banRows.length>0){
				var row = jQuery(cell).parent().get(0);
				return jQuery.inArray(row.rowIndex, options.banRows) != -1;
			}
			else
				return false;
	}

	function attachHoverHandler(){
		this.hover = optionsHandler.hover;
		this.removeHover = optionsHandler.removeHover;
	}

	function handleColumnHoverEvents(cell, cells){
		attachHoverHandler.call (cell);
		cell.onmouseover = function() {
			if (checkBan.call(this)) return;
			processAdapter(cells, this, colorHandler.checkHover);
		}
		cell.onmouseout = function() {
			if (checkBan.call(this)) return;
			processAdapter(cells, this, colorHandler.checkHoverOut);
		}
	}

	function handleRowHoverEvents(cell, cells){
		row = jQuery(cell).parent().get(0);
		attachHoverHandler.call (row);
		row.onmouseover = colorHandler.checkHover ;
		row.onmouseout = colorHandler.checkHoverOut ;
	}

	function handleRowColHoverEvents(cell, cells){
		handleRowHoverEvents(cell, cells);
		handleColumnHoverEvents(cell, cells);
	}


	var optionsHandler ={
		setHover: function(){
			if(options.hoverClass.length>0){
				this.hover = colorHandler.addHoverClass;
				this.removeHover = colorHandler.removeHoverClass;
			}
			else{
				this.hover = colorHandler.addBgHover;
				this.removeHover = colorHandler.removeBgHover;
			}
		},

		getRowClick : 	function (){
			if(options.oneClick)
				return clickHandler.oneRowClick;
			else
				return clickHandler.toggleRowClick;
		},

		getColumnClick : 	function (){
			if(options.oneClick)
				return clickHandler.oneColumnClick;
			else
				return clickHandler.toggleColumnClick;
		},
		getRowColClick:function(){
			return clickHandler.oneColumnRowClick;
		}
	}

	var handler = {
		clickFunc : getClickHandler(),
		handleHoverEvents :getHoverHandler()
	};

	function getHoverHandler(){
		if(options.hover=='column')
			return handleColumnHoverEvents;
		else if(options.hover=='cross')
			return handleRowColHoverEvents;
		else
			return handleRowHoverEvents;
	}

	function getClickHandler(){
		if(options.click=='column')
			return optionsHandler.getColumnClick();
		else if(options.click =='cross')
			return optionsHandler.getRowColClick();
		else
			return  optionsHandler.getRowClick();
	}

	return this.each(function() {

		if (options.altColor!='none') {
			var odd, even;
			odd = even =(options.ignoreHeaders)? 'tr:has(td)': 'tr';
			if(options.nested){
				odd  +=  ':nth-child(odd)';
				even += ':nth-child(even)';
			}
			else{
				odd+= ':odd';
				even += ':even';
			}
		     jQuery(this).find(odd).css('background', options.bgColor);
		     jQuery(this).find(even).css('background', options.altColor);
        }

		if(options.columns)
			alert("The 'columns' option is deprecated.\nPlease use the 'click' and 'hover' options instead.");

    	if (jQuery(this).find('thead tr:last th').length > 0)
			 var cells = jQuery(this).find('td, thead tr:last th');
		else
			var cells = jQuery(this).find('td,th');

		cells.clicked = null;

		if (jQuery.inArray('last', options.banColumns) != -1){
			if(this.rows.length>0){
				options.banColumns.push(this.rows[0].cells.length-1);
			}
		}

	    optionsHandler.setHover();
		clickHandler.tbl = this;

		jQuery.each(cells, function(i, cell) {
			 handler.handleHoverEvents (this, cells);
			 $(this).bind("click", function(e) {
				if(checkBan.call(this)) return;
			 	if(options.banDataClick && isDataCell.call(this)) return;
				handler.clickFunc.call(this, cells);
			});
		});
	});
 }
/* Table rows - end */
/* No-spam - begin */
jQuery.fn.nospam = function(settings) {
	settings = jQuery.extend({
		replaceText: false, 	// optional, accepts true or false
		filterLevel: 'normal' 	// optional, accepts 'low' or 'normal'
	}, settings);
	
	return this.each(function(){
		e = null;
		if(settings.filterLevel == 'low') { // Can be a switch() if more levels added
			if($(this).is('a[rel]')) {
				e = $(this).attr('rel').replace('//', '@').replace(/\//g, '.');
			} else {
				e = $(this).text().replace('//', '@').replace(/\//g, '.');
			}
		} else { // 'normal'
			if($(this).is('a[rel]')) {
				e = $(this).attr('rel').split('').reverse().join('').replace('//', '@').replace(/\//g, '.');
			} else {
				e = $(this).text().split('').reverse().join('').replace('//', '@').replace(/\//g, '.');
			}
		}
		if(e) {
			if($(this).is('a[rel]')) {
				$(this).attr('href', 'mailto:' + e);
				if(settings.replaceText) {
					$(this).text(e);
				}
			} else {
				$(this).text(e);
			}
		}
	});
};
/* No-spam - end */
/* Overlay - begin */
(function(c){c.tools=c.tools||{};c.tools.overlay={version:"1.1.2",addEffect:function(e,f,g){b[e]=[f,g]},conf:{top:"10%",left:"center",absolute:false,speed:"normal",closeSpeed:"fast",effect:"default",close:null,oneInstance:true,closeOnClick:true,closeOnEsc:true,api:false,expose:null,target:null}};var b={};c.tools.overlay.addEffect("default",function(e){this.getOverlay().fadeIn(this.getConf().speed,e)},function(e){this.getOverlay().fadeOut(this.getConf().closeSpeed,e)});var d=[];function a(g,k){var o=this,m=c(this),n=c(window),j,i,h,e=k.expose&&c.tools.expose.version;var f=k.target||g.attr("rel");i=f?c(f):null||g;if(!i.length){throw"Could not find Overlay: "+f}if(g&&g.index(i)==-1){g.click(function(p){o.load(p);return p.preventDefault()})}c.each(k,function(p,q){if(c.isFunction(q)){m.bind(p,q)}});c.extend(o,{load:function(u){if(o.isOpened()){return o}var r=b[k.effect];if(!r){throw'Overlay: cannot find effect : "'+k.effect+'"'}if(k.oneInstance){c.each(d,function(){this.close(u)})}u=u||c.Event();u.type="onBeforeLoad";m.trigger(u);if(u.isDefaultPrevented()){return o}h=true;if(e){i.expose().load(u)}var t=k.top;var s=k.left;var p=i.outerWidth({margin:true});var q=i.outerHeight({margin:true});if(typeof t=="string"){t=t=="center"?Math.max((n.height()-q)/2,0):parseInt(t,10)/100*n.height()}if(s=="center"){s=Math.max((n.width()-p)/2,0)}if(!k.absolute){t+=n.scrollTop();s+=n.scrollLeft()}i.css({top:t,left:s,position:"absolute"});u.type="onStart";m.trigger(u);r[0].call(o,function(){if(h){u.type="onLoad";m.trigger(u)}});if(k.closeOnClick){c(document).bind("click.overlay",function(w){if(!o.isOpened()){return}var v=c(w.target);if(v.parents(i).length>1){return}c.each(d,function(){this.close(w)})})}if(k.closeOnEsc){c(document).unbind("keydown.overlay").bind("keydown.overlay",function(v){if(v.keyCode==27){c.each(d,function(){this.close(v)})}})}return o},close:function(q){if(!o.isOpened()){return o}q=q||c.Event();q.type="onBeforeClose";m.trigger(q);if(q.isDefaultPrevented()){return}h=false;b[k.effect][1].call(o,function(){q.type="onClose";m.trigger(q)});var p=true;c.each(d,function(){if(this.isOpened()){p=false}});if(p){c(document).unbind("click.overlay").unbind("keydown.overlay")}return o},getContent:function(){return i},getOverlay:function(){return i},getTrigger:function(){return g},getClosers:function(){return j},isOpened:function(){return h},getConf:function(){return k},bind:function(p,q){m.bind(p,q);return o},unbind:function(p){m.unbind(p);return o}});c.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","),function(p,q){o[q]=function(r){return o.bind(q,r)}});if(e){if(typeof k.expose=="string"){k.expose={color:k.expose}}c.extend(k.expose,{api:true,closeOnClick:k.closeOnClick,closeOnEsc:false});var l=i.expose(k.expose);l.onBeforeClose(function(p){o.close(p)});o.onClose(function(p){l.close(p)})}j=i.find(k.close||".close");if(!j.length&&!k.close){j=c('<div class="close"></div>');i.prepend(j)}j.click(function(p){o.close(p)})}c.fn.overlay=function(e){var f=this.eq(typeof e=="number"?e:0).data("overlay");if(f){return f}if(c.isFunction(e)){e={onBeforeLoad:e}}var g=c.extend({},c.tools.overlay.conf);e=c.extend(true,g,e);this.each(function(){f=new a(c(this),e);d.push(f);c(this).data("overlay",f)});return e.api?f:this}})(jQuery);
/* Overlay - end */
