var paramFlase = { borderBottomColor: '#C00000', borderLeftColor: '#C00000',borderRightColor: '#C00000', borderTopColor: '#C00000', color: '#C00000' };
var paramTrue = { borderBottomColor: '#5C8700', borderLeftColor: '#5C8700',borderRightColor: '#5C8700', borderTopColor: '#5C8700', color: '#5C8700' };

(function($) {
	$.fn.ClearTypeFadeTo = function(options) {
		if (options)
			$(this)
				.show()
				.each(function() {
					if (jQuery.browser.msie) {
						// Save the original background color
						$(this).attr('oBgColor', $(this).css('background-color'));
						// Set the bgColor so that bold text renders correctly (bug with IE/ClearType/bold text)
						$(this).css({'background-color': (options.bgColor ? options.bgColor : '#fff') })
					}
				})
				.fadeTo(options.speed, options.opacity, function() {
					if (jQuery.browser.msie) {
						// ClearType can only be turned back on if this is a full fade in or
						// fade out. Partial opacity will still have the problem because the
						// filter style must remain. So, in the latter case, we will leave the
						// background color and 'filter' style in place.
						if (options.opacity == 0 || options.opacity == 1) {
							// Reset the background color if we saved it previously
							$(this).css({ 'background-color': $(this).attr('oBgColor') }).removeAttr('oBgColor');
							// Remove the 'filter' style to restore ClearType functionality.
							$(this).get(0).style.removeAttribute('filter');
						}
					}
					if (options.callback != undefined) options.callback();
				});
	};

	$.fn.ClearTypeFadeIn = function(options) {
		if (options)
			$(this)
				.css({ opacity: 0 })
				.ClearTypeFadeTo({ speed: options.speed, opacity: 1, callback: options.callback });
	};

	$.fn.ClearTypeFadeOut = function(options) {
		if (options)
			$(this)
				.css({ opacity: 1 })
				.ClearTypeFadeTo({ speed: options.speed, opacity: 0, callback: options.callback });
	};
})(jQuery);

(function($) {
	$.extend($.fx.step,{
	    backgroundPosition: function(fx) {
            if (fx.state === 0 && typeof fx.end == 'string') {
                var start = $.curCSS(fx.elem,'backgroundPosition');
                start = toArray(start);
                fx.start = [start[0],start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0],end[2]];
                fx.unit = [end[1],end[3]];
			}
            var nowPosX = [];
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];           
            fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];
            
           function toArray(strg){
               strg = strg.replace(/left|top/g,'0px');
               strg = strg.replace(/right|bottom/g,'100%');
               strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
               var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
               return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
           }
        }
	});
})(jQuery);

jQuery.fn.extend({
  scrollTo : function(speed, easing) {
    return this.each(function() {
      var targetOffset = $(this).offset().top;
      $('html,body').animate({scrollTop: targetOffset}, speed, easing);
    });
  }
});

function is_array(mixed_var) {
	return (mixed_var instanceof Array || mixed_var instanceof Object);
}

$(document).ready(function(){
	$().bind("mousemove",function(e) {
		mouseX = e.pageX;
		mouseY = e.pageY;
		$("#mousepos").html(mouseX+" "+mouseY);
	});
});

// Fonction tooltip qui recupere le contenue d'un DIV qui a l'ID de l'�l�ment qui appelle suivi de '_texte'
function tooltip(el,pos,width,contenu) {
	
	$('#hey_tools').stop();
	$('#hey_tools').hide();

	var h_top = $(el).offset().top+$(el).outerHeight(true);
	var h_left = $(el).offset().left;
	
	if (width != 0) {
		$('#hey_tools').css("width", width+"px");
	}
		
	$('#hey_tools').css("top", h_top+'px');
	$('#hey_tools').css("left", h_left+'px');
	
	// Insertion du contenue
	if (contenu) {
		$('.tooltip_content').html(contenu);
	} else {
		$('.tooltip_content').html($("#"+$(el).attr('id')+"_texte").html());
	}
	
	if (pos == "top") {
		$('#hey_tools')
			.css("top", $(el).offset().top-$('#hey_tools').outerHeight(true)+'px')
			.css("left", $(el).offset().left-($('#hey_tools').outerWidth(true)/2)+($(el).outerWidth(true)/2)+'px');
		// Placement de la fleche
		$('#hey_tool_fleche img').attr("src", "themes/default/images/bulle/bulles_fleche_bottom.png");
		$('#hey_tool_fleche')
			.css("margin-left", ($('#hey_tools').outerWidth(true)/2)-14+'px')
			.css("margin-top", $('#hey_tools').outerHeight(true)-12+"px");
		$('#hey_tools').hide().dequeue().show();
	} else if (pos == "bottom") {
		$('#hey_tools')
			.css("top", $(el).offset().top+$(el).outerHeight(true)+'px')
			.css("left", $(el).offset().left-($('#hey_tools').outerWidth(true)/2)+($(el).outerWidth(true)/2)+'px');
		// Placement de la fleche
		$('#hey_tool_fleche img').attr("src", "themes/default/images/bulle/bulles_fleche_top.png");
		$('#hey_tool_fleche')
			.css("margin-left", ($('#hey_tools').outerWidth(true)/2)-14+'px')
			.css("margin-top", "-26px");
		$('#hey_tools').hide().dequeue().show();
	} else if (pos == "left") {
		$('#hey_tools')
			.css("top", $(el).offset().top-($('#hey_tools').outerHeight(true)/2)+($(el).outerHeight(true)/2)+'px')
			.css("left", $(el).offset().left-$('#hey_tools').outerWidth(true)+'px');
		// Placement de la fleche
		$('#hey_tool_fleche img').attr("src", "themes/default/images/bulle/bulles_fleche_right.png");
		$('#hey_tool_fleche')
			.css("margin-left", ($('#hey_tools').outerWidth(true))-11+'px')
			.css("margin-top", ($('#hey_tools').outerHeight(true)/2)-18+"px");
		$('#hey_tools').hide().dequeue().show();
	} else if (pos == "right") {
		$('#hey_tools')
			.css("top", $(el).offset().top-($('#hey_tools').outerHeight(true)/2)+($(el).outerHeight(true)/2)+'px')
			.css("left", $(el).offset().left+$(el).outerWidth(true)+'px');
		// Placement de la fleche
		$('#hey_tool_fleche img').attr("src", "themes/default/images/bulle/bulles_fleche_left.png");
		$('#hey_tool_fleche')
			.css("margin-left", '-18px')
			.css("margin-top", ($('#hey_tools').outerHeight(true)/2)-18+"px");
		$('#hey_tools').hide().dequeue().show();
	} 	
	
	$(el).mouseout(function() {
		tooltip_disapear();
	});
}
function tooltip_disapear() {
	if ($('#hey_tools').css("opacity") != 0)$('#hey_tools').dequeue().hide();
}

(function($){
	$.fn.jNice = function(options){
		
		var self = this;
		var safari = $.browser.safari; /* We need to check for safari to fix the input:text problem */
		/* Apply document listener */
		$(document).mousedown(checkExternalClick);
		/* each form */
		return this.each(function(){
			$('input:submit, input:reset, input:button', this).each(ButtonAdd);
			$('button').focus(function(){ $(this).addClass('jNiceFocus')}).blur(function(){ $(this).removeClass('jNiceFocus')});
			$('input:text:visible, input:password', this).each(TextAdd);
			/* If this is safari we need to add an extra class */
			/*
			if (safari){
				$('.jNiceInputWrapper').each(function(){
					alert($(this).width());
					$(this).addClass('jNiceSafari').find('input').css('width', $(this).width()+11);
				});
			}
			*/
			$('input:checkbox', this).each(CheckAdd);
			$('input:radio', this).each(RadioAdd);
			$('select', this).each(function(index){ SelectAdd(this, index); });
			/* Add a new handler for the reset action */
			$(this).bind('reset',function(){var action = function(){ Reset(this); }; window.setTimeout(action, 10); });
			$('.jNiceHidden').css({opacity:0});
		});		
	};/* End the Plugin */

	var Reset = function(form){
		var sel;
		$('.jNiceSelectWrapper select', form).each(function(){sel = (this.selectedIndex<0) ? 0 : this.selectedIndex; $('ul', $(this).parent()).each(function(){$('a:eq('+ sel +')', this).click();});});
		$('a.jNiceCheckbox, a.jNiceRadio', form).removeClass('jNiceChecked');
		$('input:checkbox, input:radio', form).each(function(){if(this.checked){$('a', $(this).parent()).addClass('jNiceChecked');}});
	};

	var RadioAdd = function(){
		if (!$(this).hasClass('hide')) {
			var $input = $(this).addClass('jNiceHidden').wrap('<span class="jRadioWrapper jNiceWrapper"></span>');
			var $wrapper = $input.parent();
			var $a = $('<span class="jNiceRadio"></span>');
			$wrapper.prepend($a);
			/* Click Handler */
			$a.click(function(){
					var $input = $(this).addClass('jNiceChecked').siblings('input').attr('checked',true);
					/* uncheck all others of same name */
					$('input:radio[name="'+ $input.attr('name') +'"]').not($input).each(function(){
						$(this).attr('checked',false).siblings('.jNiceRadio').removeClass('jNiceChecked');
					});
					return false;
			});
			$input.click(function(){
				if(this.checked){
					var $input = $(this).siblings('.jNiceRadio').addClass('jNiceChecked').end();
					/* uncheck all others of same name */
					$('input:radio[name="'+ $input.attr('name') +'"]').not($input).each(function(){
						$(this).attr('checked',false).siblings('.jNiceRadio').removeClass('jNiceChecked');
					});
				}
			}).focus(function(){ $a.addClass('jNiceFocus'); }).blur(function(){ $a.removeClass('jNiceFocus'); });
	
			/* set the default state */
			if (this.checked){ $a.addClass('jNiceChecked'); }
		}
	};

	var CheckAdd = function(){
		var $input = $(this).addClass('jNiceHidden').wrap('<span class="jRadioWrapper jNiceWrapper"></span>');
		var $wrapper = $input.parent().append('<span class="jNiceCheckbox"></span>');
		/* Click Handler */
		var $a = $wrapper.find('.jNiceCheckbox').click(function(){
				var $a = $(this);
				var input = $a.siblings('input')[0];
				if (input.checked===true){
					input.checked = false;
					$a.removeClass('jNiceChecked');
				}
				else {
					input.checked = true;
					$a.addClass('jNiceChecked');
				}
				return false;
		});
		$input.click(function(){
			if(this.checked){ $a.addClass('jNiceChecked'); 	}
			else { $a.removeClass('jNiceChecked'); }
		}).focus(function(){ $a.addClass('jNiceFocus'); }).blur(function(){ $a.removeClass('jNiceFocus'); });
		
		/* set the default state */
		if (this.checked){$('.jNiceCheckbox', $wrapper).addClass('jNiceChecked');}
	};

	var TextAdd = function(){
		var $input = $(this).addClass('jNiceInput').wrap('<div class="jNiceInputWrapper"><div class="jNiceInputInner"></div></div>');
		var $wrapper = $input.parents('.jNiceInputWrapper');
		$input.focus(function(){ 
			$wrapper.addClass('jNiceInputWrapper_hover');
		}).blur(function(){
			$wrapper.removeClass('jNiceInputWrapper_hover');
		});
	};

	var ButtonAdd = function(){
		var value = $(this).attr('value');
		$(this).replaceWith('<button id="'+ this.id +'" name="'+ this.name +'" type="'+ this.type +'" class="'+ this.className +'" value="'+ value +'"><span><span>'+ value +'</span></span>');
	};

	/* Hide all open selects */
	var SelectHide = function(){
			$('.jNiceSelectWrapper ul:visible').hide();
	};

	/* Check for an external click */
	var checkExternalClick = function(event) {
		if ($(event.target).parents('.jNiceSelectWrapper').length === 0) { SelectHide(); }
	};

	var SelectAdd = function(element, index){
		var $select = $(element);
		index = index || $select.css('zIndex')*1;
		index = (index) ? index : 0;
		/* First thing we do is Wrap it */
		$select.wrap($('<div class="jNiceWrapper"></div>').css({zIndex: 100-index}));
		var width = $select.width();
		$select.addClass('jNiceHidden').after('<div class="jNiceSelectWrapper"><div><span class="jNiceSelectText"></span><span class="jNiceSelectOpen"></span></div><ul></ul></div>');
		var $wrapper = $(element).siblings('.jNiceSelectWrapper').css({width: width +'px'});
		$('.jNiceSelectText, .jNiceSelectWrapper ul', $wrapper).width( width - $('.jNiceSelectOpen', $wrapper).width());
		/* IF IE 6 */
		if ($.browser.msie && jQuery.browser.version < 7) {
			$select.after($('<iframe src="javascript:\'\';" marginwidth="0" marginheight="0" align="bottom" scrolling="no" tabIndex="-1" frameborder="0"></iframe>').css({ height: $select.height()+4 +'px' }));
		}
		/* Now we add the options */
		SelectUpdate(element);
		/* Apply the click handler to the Open */
		$('div', $wrapper).click(function(){
			var $ul = $(this).siblings('ul');
			if ($ul.css('display')=='none'){ SelectHide(); } /* Check if box is already open to still allow toggle, but close all other selects */
			$ul.slideToggle();
			var offSet = ($('a.selected', $ul).offset().top - $ul.offset().top);
			$ul.animate({scrollTop: offSet});
			return false;
		});
		/* Add the key listener */
		$select.keydown(function(e){
			var selectedIndex = this.selectedIndex;
			switch(e.keyCode){
				case 40: /* Down */
					if (selectedIndex < this.options.length - 1){ selectedIndex+=1; }
					break;
				case 38: /* Up */
					if (selectedIndex > 0){ selectedIndex-=1; }
					break;
				default:
					return;
					break;
			}
			$('ul a', $wrapper).removeClass('selected').eq(selectedIndex).addClass('selected');
			$('span:eq(0)', $wrapper).html($('option:eq('+ selectedIndex +')', $select).attr('selected', 'selected').text());
			return false;
		}).focus(function(){ $wrapper.addClass('jNiceFocus'); }).blur(function(){ $wrapper.removeClass('jNiceFocus'); });
	};

	var SelectUpdate = function(element){
		var $select = $(element);
		var $wrapper = $select.siblings('.jNiceSelectWrapper');
		var $ul = $wrapper.find('ul').find('li').remove().end().hide();
		$('option', $select).each(function(i){
			$ul.append('<li><a href="#" index="'+ i +'">'+ this.text +'</a></li>');
		});
		/* Add click handler to the a */
		$ul.find('a').click(function(){
			$('a.selected', $wrapper).removeClass('selected');
			$(this).addClass('selected');	
			/* Fire the onchange event */
			if ($select[0].selectedIndex != $(this).attr('index') && $select[0].onchange) { $select[0].selectedIndex = $(this).attr('index'); $select[0].onchange(); }
			$select[0].selectedIndex = $(this).attr('index');
			$('span:eq(0)', $wrapper).html($(this).html());
			$ul.hide();
			return false;
		});
		/* Set the defalut */
		$('a:eq('+ $select[0].selectedIndex +')', $ul).click();
	};

	var SelectRemove = function(element){
		var zIndex = $(element).siblings('.jNiceSelectWrapper').css('zIndex');
		$(element).css({zIndex: zIndex}).removeClass('jNiceHidden');
		$(element).siblings('.jNiceSelectWrapper').remove();
	};

	/* Utilities */
	$.jNice = {
			SelectAdd : function(element, index){ 	SelectAdd(element, index); },
			SelectRemove : function(element){ SelectRemove(element); },
			SelectUpdate : function(element){ SelectUpdate(element); }
	};/* End Utilities */

	/* Automatically apply to any forms with class jNice */
	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
	if (!ie6) { $(function(){ $('form').jNice(); }); }
	
})(jQuery);

(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);
(function($){$.scrollTo=function(a,b){return $('html,body').scrollTo(a,b)};$.fn.scrollTo=function(e,f){f=$.extend({axis:'y',speed:1},f||{});if(f.axis.length!=2)f.queue=false;if(f.queue)f.speed=Math.ceil(f.speed/2);return this.each(function(){var d=$(this),t=e,k,l,u={};switch(typeof t){case'string':if(/^([+-]=)?\d+(px)?$/.test(t))break;t=$(t,this);case'object':k=$(t).offset()}$.each(f.axis.split(''),parse);animate(f.onAfter);function parse(i,a){var b=a=='x'?'Left':'Top',p=b.toLowerCase();var c='scroll'+b;u[c]=k?k[p]+(d.is('html,body')?0:d[0][c]-d.offset()[p]):t;if(f.margin&&typeof t=='object')u[c]-=parseInt($(t).css('margin'+b))||0;if(!i&&f.queue){if(d[0][c]!=u[c])animate(f.onAfterFirst);delete u[c]}};function animate(a){d.animate(u,f.speed,f.easing,a)}})}})(jQuery);
(function($){var f={elements:'img',itemSize:{height:200,width:200},view:null,navigators:null,navigationMode:'s',speed:600,wrappers:'simple',circular:false,easing:'linear',axis:'x',margin:true,start:null,setWidth:false};function wrap(a,b,c){switch(b){case'crop':a=a.wrap('<div class="jq-ss-crop">').parent().css('overflow','hidden');case'resize':return a.css(c);case'simple':return a.wrap('<div class="jq-ss-simple">').parent();case'link':if(a.is('img'))return a;default:return a}};$.fn.scrollShow=function(e){e=$.extend({},f,e);return this.each(function(){var d=this,$v=e.view?$(e.view,this):this,$e=$(e.elements,$v),l=$e.length,q=0;$.each(e.wrappers.split(/\s*,\s*/),function(i,a){$e=wrap($e,a,e.itemSize)});$e.css(e.itemSize);if(!e.navigators){e.navigators='';e.navigationMode='r'}if(e.navigators.constructor!=Array)e.navigators=[e.navigators];$.each(e.navigationMode.split(''),function(i,b){switch(b.charAt(0)){case's':$(e.navigators[i],d).eq(0).bind('click',{dir:-1},sequential).end().eq(1).bind('click',{dir:+1},sequential);break;case'r':var c=$(e.navigators[i]||$e,d),r=$e.length/c.length;if(r===Infinity)return;c.each(function(a){$(this).bind('click',{pos:Math.floor(r*a)},random)});break}});(function(a,w){var b=(a.width()+attrs('margin')+attrs('padding')+attr('border'));do w-=b;while(w>0&&l--);if(!e.setWidth)return;do{a=a.parent();if(a[0]==$v[0])return}while(a.length>1);a.width(b*$e.length)})($e,$v.width());if(e.start!=null)random(e.start);function attrs(a){return attr(a+'Left')+attr(a+'Right')};function attr(a){return parseInt($e.css(a))||0};function sequential(a){a.data.pos=q+a.data.dir;return random(a)};function random(a){var b=typeof a=='number'?a:a.data.pos;if(b<0)b=q==0&&e.circular?l:0;else if(b>l)b=q==l&&e.circular?0:l;$v.stop().scrollTo($e[b],e);q=b;return false}})}})(jQuery);

/*
### jQuery FCKEditor Plugin v1.30 - 2009-03-16 ###
* http://www.fyneworks.com/ - diego@fyneworks.com
* Dual licensed under the MIT and GPL licenses:
*   http://www.opensource.org/licenses/mit-license.php
*   http://www.gnu.org/licenses/gpl.html
###
Project: http://jquery.com/plugins/project/FCKEditor/
Website: http://www.fyneworks.com/jquery/FCKEditor/
*/
/*
USAGE: $('textarea').fck({ path:'/path/to/fck/editor/' }); // initialize FCK editor
ADVANCED USAGE: $.fck.update(); // update value in textareas of each FCK editor instance
*/

/*# AVOID COLLISIONS #*/
if(window.jQuery) (function($){
/*# AVOID COLLISIONS #*/

$.extend($, {
fck:{
 waitFor: 10,// in seconds, how long should we wait for the script to load?
 config: { Config: {} }, // default configuration
 path: '/fckeditor/', // default path to FCKEditor directory
 editors: [], // array of editor instances
 loaded: false, // flag indicating whether FCK script is loaded
 intercepted: null, // variable to store intercepted method(s)
 
 // utility method to read contents of FCK editor
 content: function(i, v){
  //try{
				//if(window.console) console.log(['fck.content',arguments]);
   var x = FCKeditorAPI.GetInstance(i);
				//if(window.console) console.log(['fck.content','x',x]);
				// Look for textare with matching name for backward compatibility
				if(!x){
					x = $('#'+i.replace(/\./gi,'\\\.')+'')[0];
				//if(window.console) console.log(['fck.content','ele',x]);
					if(x) x = FCKeditorAPI.GetInstance(x.id);
				};
				if(!x){
					alert('FCKEditor instance "'+i+'" could not be found!');
					return '';
				};
				if(v) x.SetHTML(v);
				//if(window.console) console.log(['fck.content','x',x.GetXHTML]);
   return x.GetXHTML(true);
  //}catch(e){ return 'OOPS!'; };
 }, // fck.content function
 
 // inspired by Sebastián Barrozo <sbarrozo@b-soft.com.ar>
 setHTML: function(i, v){
  if(typeof i=='object'){
   v = i.html;
   i = i.InstanceName || i.instance;
  };
  return $.fck.content(i, v);
 },
 
 // utility method to update textarea contents before ajax submission
 update: function(){
			// Ignore missing editors
  $.fck.clean();
  // Update contents of all instances
  var e = $.fck.editors;
  //if(window.console) console.log(['fck.update',e]);
  for(var i=0;i<e.length;i++){
   var ta = e[i].textarea;
   //if(window.console) console.log(['fck.update','ta',ta]);
   var ht = $.fck.content(e[i].InstanceName);
   //if(window.console) console.log(['fck.update','ht',ht]);
   ta.val(ht).filter('textarea').text(ht);
   if(ht!=ta.val())
    alert('Critical error in FCK plugin:'+'\n'+'Unable to update form data');
  }
  //if(window.console) console.log(['fck.update','done']);
 }, // fck.update
 
 // utility method to non-existing instances from memory
 clean: function(){
  //if(window.console) console.log(['fck.clean',$.fck.editors]);
			var a = $.fck.editors, b = {}, c = [];
  //if(window.console) console.log(['fck.clean','a',a]);
			$.each(a, function(){
   //if(window.console) console.log(['fck.clean','a - id',this.InstanceName]);
   if($('#'+this.InstanceName.replace(/\./gi,'\\\.')+'').length>0)
				 b[this.InstanceName] = this;
			});
  //if(window.console) console.log(['fck.clean','b',b]);
			$.each(b, function(){ c[c.length] = this; });
  //if(window.console) console.log(['fck.clean','c',c]);
			$.fck.editors = c;
  //if(window.console) console.log(['fck.clean',$.fck.editors]);
 }, // fck.clean
 
 // utility method to create instances of FCK editor (if any)
 create: function(option){
			// Create a new options object
  var o = $.extend({}/* new object */, $.fck.config || {}, option || {});
  // Normalize plugin options
  $.extend(o, {
   selector: (o.selector || 'textarea.fck, textarea.fckeditor'),
   BasePath: (o.path || o.BasePath || $.fck.path)
  });
  // Find fck.editor-instance 'wannabes'
  var e = $(o.e);
  if(!e.length>0) e = $(o.selector);
  if(!e.length>0) return;
			// Accept settings from metadata plugin
			o = $.extend({}, o,
				($.meta ? e.data()/*NEW metadata plugin*/ :
				($.metadata ? e.metadata()/*OLD metadata plugin*/ : 
				null/*metadata plugin not available*/)) || {}
			);
  // Load script and create instances
  if(!$.fck.loading && !$.fck.loaded){
   $.fck.loading = true;
   $.getScript(
    o.BasePath+'fckeditor.js',
    function(){ $.fck.loaded = true; }
   );
  };
  // Start editor
  var start = function(){//e){
   if($.fck.loaded){
    //if(window.console) console.log(['fck.create','start',e,o]);
    $.fck.editor(e,o);
   }
   else{
    //if(window.console) console.log(['fck.create','waiting for script...',e,o]);
    if($.fck.waited<=0){
     alert('jQuery.fckeditor plugin error: The FCKEditor script did not load.');
    }
    else{
     $.fck.waitFor--;
     window.setTimeout(start,1000);
    };
   }
  };
  start(e);
  // Return matched elements...
  return e;
 },
 
 // utility method to integrate this plugin with others...
 intercept: function(){
  if($.fck.intercepted) return;
  // This method intercepts other known methods which
  // require up-to-date code from FCKEditor
  $.fck.intercepted = {
   ajaxSubmit: $.fn.ajaxSubmit || function(){}
  };
  $.fn.ajaxSubmit = function(){
				//if(window.console) console.log(['fck.intercepted','$.fn.ajaxSubmit',$.fck.editors]);
   $.fck.update(); // update html
   return $.fck.intercepted.ajaxSubmit.apply( this, arguments );
  };
			// Also attach to conventional form submission
			//$('form').submit(function(){
  // $.fck.update(); // update html
  //});
 },
 
 // utility method to create an instance of FCK editor
 editor: function(e /* elements */, o /* options */){
  //if(window.console) console.log(['fck.editor','OPTIONS',o]);
  o = $.extend({}, $.fck.config || {}, o || {});
  // Default configuration
  $.extend(o,{
   Width: (o.width || o.Width || '100%'),
   Height: (o.height || o.Height|| '500px'),
   BasePath: (o.path || o.BasePath || $.fck.path),
   ToolbarSet: (o.toolbar || o.ToolbarSet || 'Default'),
   Config: (o.config || o.Config || {})
  });
  // Make sure we have a jQuery object
  e = $(e);
  //if(window.console) console.log(['fck.editor','E',e,o]);
  if(e.size()>0){
   // Local array to store instances
   var a = $.fck.editors;// || [];
   // Go through objects and initialize fck.editor
   e.each(
    function(i,t){
						if((t.tagName||'').toLowerCase()!='textarea')
							return alert(['An invalid parameter has been passed to the $.fckeditor.editor function','tagName:'+t.tagName,'name:'+t.name,'id:'+t.id].join('\n'));
     
     var T = $(t);// t = element, T = jQuery
     if(!t.fck/* not already installed */){
							t.id = t.id || 'fck'+($.fck.editors.length+1);
							t.name = t.name || t.id;
      var n = a.length;
							// create FCKeditor instance
      //if(window.console) console.log(['fck.editor','new FCKeditor',t.id,t]);
      a[n] = new FCKeditor(t.id);
							// Apply inline configuration
      //if(window.console) console.log(['fck.editor','Apply inline configuration',o]);
      $.extend(a[n], o, o.Config || {});
							// Start FCKeditor
      a[n].ReplaceTextarea();
							// Store reference to original element
      a[n].textarea = T;
							// Store reference to FCKeditor in element
      //if(window.console) console.log(['fck.editor','Store reference to FCKeditor in element',a[n]]);
      t.fck = a[n];
     };
    }
   );
   // Store editor instances in global array
   //if(window.console) console.log(['fck.editor','Store editor instances in global array',a]);
   $.fck.editors = a;
   //if(window.console) console.log(['fck.editor','$.fck.editors',$.fck.editors]);
				// Remove old non-existing editors from memory
				$.fck.clean();
  };
  // return jQuery array of elements
  return e;
 }, // fck.editor function
 
 // start-up method
 start: function(o/* options */){
  // Attach itself to known plugins...
			$.fck.intercept();
			// Create FCK editors
  return $.fck.create(o);
 } // fck.start
 
} // fck object
//##############################

});
//extend $
//##############################


$.extend($.fn, {
fck: function(o){
 //(function(opts){ $.fck.start(opts); })($.extend(o || {}, {e: this}));
 $.fck.start($.extend(o || {}, {e: this}));
}
});
//extend $.fn
//##############################

/*# AVOID COLLISIONS #*/
})(jQuery);


/*# AVOID COLLISIONS #*/
(function($) {

jQuery.fn.pngFix = function(settings) {

	// Settings
	settings = jQuery.extend({
		blankgif: 'blank.gif'
	}, settings);

	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

	if (jQuery.browser.msie && (ie55 || ie6)) {

		//fix images with png-source
		jQuery(this).find("img[src$=.png]").each(function() {

			jQuery(this).attr('width',jQuery(this).width());
			jQuery(this).attr('height',jQuery(this).height());

			var prevStyle = '';
			var strNewHTML = '';
			var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : '';
			var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : '';
			var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : '';
			var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : '';
			var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : '';
			var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : '';
			if (this.style.border) {
				prevStyle += 'border:'+this.style.border+';';
				this.style.border = '';
			}
			if (this.style.padding) {
				prevStyle += 'padding:'+this.style.padding+';';
				this.style.padding = '';
			}
			if (this.style.margin) {
				prevStyle += 'margin:'+this.style.margin+';';
				this.style.margin = '';
			}
			var imgStyle = (this.style.cssText);

			strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt;
			strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;
			strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;';
			strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');';
			strNewHTML += imgStyle+'"></span>';
			if (prevStyle != ''){
				strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>';
			}

			jQuery(this).hide();
			jQuery(this).after(strNewHTML);

		});

		// fix css background pngs
		jQuery(this).find("*").each(function(){
			var bgIMG = jQuery(this).css('background-image');
			if (jQuery(this).hasClass("nopngfix") == false) {
				if(bgIMG.indexOf(".png")!=-1){
					var iebg = bgIMG.split('url("')[1].split('")')[0];
					jQuery(this).css('background-image', 'none');
					jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "', sizingMethod='scale')";
				}
			}
		});
		
		//fix input with png-source
		jQuery(this).find("input[src$=.png]").each(function() {
			var bgIMG = jQuery(this).attr('src');
			jQuery(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + bgIMG + '\', sizingMethod=\'scale\');';
   		jQuery(this).attr('src', settings.blankgif)
		});
	
	}
	
	return jQuery;

};

})(jQuery);

(function($){
	$.fn.positionCenter = function(options) {
		var pos = {
			sTop : function() {
				return window.pageYOffset || document.documentElement && document.documentElement.scrollTop ||	document.body.scrollTop;
			},
			wHeight : function() {
				return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body.clientHeight;
			}
		};
		return this.each(function(index) {
			if (index == 0) {
				var $this = $(this);
				var elHeight = $this.outerHeight();
				var elTop = pos.sTop() + (pos.wHeight() / 2) - (elHeight / 2);
				$this.css({
					position: 'absolute',
					margin: '0',
					top: elTop,
					left: (($(window).width() - $this.outerWidth()) / 2) + 'px'
				});
			}
		});
	};
})(jQuery);

