var nc = jQuery.noConflict();

nc(document).ready(function() {
							
		
		//boxes affichage
		nc("#colB .miniKronik img, #colC .miniKronik img").tooltip({
		   offset: [-10, 2],
		   effect: 'slide',
		   position:'top left'
		  }).dynamic({ bottom: { direction: 'down', bounce: true } });
		
		
		//FAQ
		nc('.faqs dd, .news dd').hide();
		nc('.faqs dt, .news dt').hover(function(){nc(this).addClass('hoverg')},function(){nc(this).removeClass('hoverg')}).click(function(){
		  nc(this).next().slideToggle('normal');
		});
		
		//////////////////////////// 
		//Customisation formulaires
		nc('input[type="text"]').addClass("idle");
		  nc('input[type="text"]').focus(function() {
			  nc(this).removeClass("idle").addClass("focus");
			 
			
			  if (this.value == this.defaultValue){ 
				  this.value = '';
			  }
			  if(this.value != this.defaultValue){
				  this.select();
			  }
			
		  });
		  nc('input[type="text"]').blur(function() {
			  nc(this).removeClass("focus").addClass("idle");
			 if (nc.trim(this.value) == ''){
				  this.value = (this.defaultValue ? this.defaultValue : '');
			  }
		  });
		
		
		//liens externes
		nc('a[rel=externe]').attr('target','_blank'); 



setInterval(function() {
    nc('#proposition').animate({opacity: 0.5,fontSize: "11px"}, 800)
	nc('#proposition').animate({opacity: 1,fontSize: "11px"}, 800)
    }, 1000);

setInterval(function() {
    nc('.vignette_concours').animate({opacity: 0.1}, 200)
	nc('.vignette_concours').animate({opacity: 1}, 200)
    }, 500);


});

//EMAILS
function mail1(){
var e = document.getElementById('mail1');
var x = "skart" + "nak@" + "skartna" + "k.com";
e.innerHTML = x;
e.href = "mailto:" + x;}

function mail2(){
var e = document.getElementById('mail2');
var x = "webm" + "aster@" + "skartna" + "k.com";
e.innerHTML = x;
e.href = "mailto:" + x;}

function mail3(){
var e = document.getElementById('mail3');
var x = "concour" + "s@" + "skartn" + "ak.com";
e.innerHTML = x;
e.href = "mailto:" + x;}

function mail4(){
var e = document.getElementById('mail4');
var x = "book" + "ing@" + "skartn" + "ak.com";
e.innerHTML = x;
e.href = "mailto:" + x;}

function mail5(){
var e = document.getElementById('mail5');
var x = "mai" + "lorder@" + "skartn" + "ak.com";
e.innerHTML = x;
e.href = "mailto:" + x;}

function mail6(){
var e = document.getElementById('mail6');
var x = "inf" + "o@" + "skartn" + "ak.com";
e.innerHTML = x;
e.href = "mailto:" + x;}

function mail7(){
var e = document.getElementById('mail7');
var x = "skart" + "nak@" + "skartna" + "k.com";
e.innerHTML = x;
e.href = "mailto:" + x;}


function demp(){
var e = document.getElementById('demp');
var x = "skart" + "nak@" + "skartna" + "k.com";
e.innerHTML = x;
e.href = "mailto:" + x + "?subject=Demande de partenariat sur Skartnak";}

function demk(){
var e = document.getElementById('demk');
var x = "inf" + "o@" + "skartn" + "ak.com";
e.innerHTML = x;
e.href = "mailto:" + x + "?subject=Demande de chronique sur Skartnak";}

//Fonctions pour le BBCode
TextArea = function (name) {
    this._init(name);
}

TextArea.prototype._init = function (name) {
	this.name = name;
	this.textarea = document.getElementById(this.name);
}

TextArea.prototype.tag = function (bStart,bEnd) {
	this.textarea.focus();
	if (typeof(document.selection) != 'undefined') {
		return this.tagIE(bStart,bEnd);
	} else {
		return this.tagGecko(bStart,bEnd);
	}
}
 
TextArea.prototype.tagIE = function (bStart,bEnd) {
	var range = document.selection.createRange();
	var insText = range.text;
	range.text = bStart + insText + bEnd;
	range = document.selection.createRange();
	if (insText.length == 0) {
		range.move('character', -(bEnd.length));
	} else {
		range.moveStart('character', bStart.length + insText.length + bEnd.length);
	}
	range.select();
}
 
TextArea.prototype.tagGecko = function (bStart,bEnd) {
	var start = this.textarea.selectionStart;
	var end = this.textarea.selectionEnd;
	var insText = this.textarea.value.substring(start, end);
	this.textarea.value = this.textarea.value.substr(0, start) + bStart + insText + bEnd + this.textarea.value.substr(end);
	var pos = insText.length ? start + bStart.length + insText.length + bEnd.length : start + bStart.length;
	this.textarea.selectionStart = pos;
	this.textarea.selectionEnd = pos;
}
 

TextArea.prototype.simpleTag = function (tag) {
	this.tag('['+tag+']','[/'+tag+']');
}

TextArea.prototype.simpleMTag = function (tag) {
	this.tag('['+tag+']','');
}
 
TextArea.prototype.couleur = function (tag) {
	this.tag('['+tag+']','[/color]');
}

TextArea.prototype.contact = function (tag) {
	this.tag(''+tag+'','');
}

TextArea.prototype.url = function (tag,message,message2) {
	rep = prompt(message);
	if (rep.length) this.tag('['+tag+'='+rep+']','[/url]');
}

function Cursor_SetPos( where_, pos_){
  //-- Recup l'Objet
  var Obj = document.getElementById( where_);
  if( Obj){
	  Obj.focus();
	  if( typeof Obj.selectionStart != "undefined"){
		Obj.setSelectionRange( pos_, pos_);
	  }
	  else{ // IE and consort
		  var Chaine = Obj.createTextRange();
		  Chaine.moveStart('character', pos_);
		  //-- Deplace le curseur
		  Chaine.collapse();
		  Chaine.select();
	  }
  }
} 

String.prototype.RLTrim = function ()
{
	return this.replace(/(^\s*)|(\s*$)/g,"");
}

function Check_all(container_id)
{
  var checkboxes = document.getElementById(container_id).getElementsByTagName('input');
  for (var i=0;i<checkboxes.length;i++)
  {
		 if(checkboxes[i].type == 'checkbox')
		 {
			   if(checkboxes[i].checked == true)
					checkboxes[i].checked = false;
			   else
					checkboxes[i].checked = true;
		 }
  }
  return true;
}



//TOOLTIP
(function(f){function p(a,b,c){var h=c.relative?a.position().top:a.offset().top,e=c.relative?a.position().left:a.offset().left,i=c.position[0];h-=b.outerHeight()-c.offset[0];e+=a.outerWidth()+c.offset[1];var j=b.outerHeight()+a.outerHeight();if(i=="center")h+=j/2;if(i=="bottom")h+=j;i=c.position[1];a=b.outerWidth()+a.outerWidth();if(i=="center")e-=a/2;if(i=="left")e-=a;return{top:h,left:e}}function t(a,b){var c=this,h=a.add(c),e,i=0,j=0,m=a.attr("title"),q=n[b.effect],k,r=a.is(":input"),u=r&&a.is(":checkbox, :radio, select, :button, :submit"),
s=a.attr("type"),l=b.events[s]||b.events[r?u?"widget":"input":"def"];if(!q)throw'Nonexistent effect "'+b.effect+'"';l=l.split(/,\s*/);if(l.length!=2)throw"Tooltip: bad events configuration for "+s;a.bind(l[0],function(d){clearTimeout(i);if(b.predelay)j=setTimeout(function(){c.show(d)},b.predelay);else c.show(d)}).bind(l[1],function(d){clearTimeout(j);if(b.delay)i=setTimeout(function(){c.hide(d)},b.delay);else c.hide(d)});if(m&&b.cancelDefault){a.removeAttr("title");a.data("title",m)}f.extend(c,{show:function(d){if(!e){if(m)e=
f(b.layout).addClass(b.tipClass).appendTo(document.body).hide().append(m);else if(b.tip)e=f(b.tip).eq(0);else{e=a.next();e.length||(e=a.parent().next())}if(!e.length)throw"Cannot find tooltip for "+a;}if(c.isShown())return c;e.stop(true,true);var g=p(a,e,b);d=d||f.Event();d.type="onBeforeShow";h.trigger(d,[g]);if(d.isDefaultPrevented())return c;g=p(a,e,b);e.css({position:"absolute",top:g.top,left:g.left});k=true;q[0].call(c,function(){d.type="onShow";k="full";h.trigger(d)});g=b.events.tooltip.split(/,\s*/);
e.bind(g[0],function(){clearTimeout(i);clearTimeout(j)});g[1]&&!a.is("input:not(:checkbox, :radio), textarea")&&e.bind(g[1],function(o){o.relatedTarget!=a[0]&&a.trigger(l[1].split(" ")[0])});return c},hide:function(d){if(!e||!c.isShown())return c;d=d||f.Event();d.type="onBeforeHide";h.trigger(d);if(!d.isDefaultPrevented()){k=false;n[b.effect][1].call(c,function(){d.type="onHide";k=false;h.trigger(d)});return c}},isShown:function(d){return d?k=="full":k},getConf:function(){return b},getTip:function(){return e},
getTrigger:function(){return a}});f.each("onHide,onBeforeShow,onShow,onBeforeHide".split(","),function(d,g){f.isFunction(b[g])&&f(c).bind(g,b[g]);c[g]=function(o){f(c).bind(g,o);return c}})}f.tools=f.tools||{version:"1.2.3"};f.tools.tooltip={conf:{effect:"toggle",fadeOutSpeed:"fast",predelay:0,delay:30,opacity:1,tip:0,position:["top","center"],offset:[0,0],relative:false,cancelDefault:true,events:{def:"mouseenter,mouseleave",input:"focus,blur",widget:"focus mouseenter,blur mouseleave",tooltip:"mouseenter,mouseleave"},
layout:"<div/>",tipClass:"tooltip"},addEffect:function(a,b,c){n[a]=[b,c]}};var n={toggle:[function(a){var b=this.getConf(),c=this.getTip();b=b.opacity;b<1&&c.css({opacity:b});c.show();a.call()},function(a){this.getTip().hide();a.call()}],fade:[function(a){var b=this.getConf();this.getTip().fadeTo(b.fadeInSpeed,b.opacity,a)},function(a){this.getTip().fadeOut(this.getConf().fadeOutSpeed,a)}]};f.fn.tooltip=function(a){var b=this.data("tooltip");if(b)return b;a=f.extend(true,{},f.tools.tooltip.conf,a);
if(typeof a.position=="string")a.position=a.position.split(/,?\s/);this.each(function(){b=new t(f(this),a);f(this).data("tooltip",b)});return a.api?b:this}})(jQuery);
(function(d){var i=d.tools.tooltip;d.extend(i.conf,{direction:"up",bounce:false,slideOffset:10,slideInSpeed:200,slideOutSpeed:200,slideFade:!d.browser.msie});var e={up:["-","top"],down:["+","top"],left:["-","left"],right:["+","left"]};i.addEffect("slide",function(g){var a=this.getConf(),f=this.getTip(),b=a.slideFade?{opacity:a.opacity}:{},c=e[a.direction]||e.up;b[c[1]]=c[0]+"="+a.slideOffset;a.slideFade&&f.css({opacity:0});f.show().animate(b,a.slideInSpeed,g)},function(g){var a=this.getConf(),f=a.slideOffset,
b=a.slideFade?{opacity:0}:{},c=e[a.direction]||e.up,h=""+c[0];if(a.bounce)h=h=="+"?"-":"+";b[c[1]]=h+"="+f;this.getTip().animate(b,a.slideOutSpeed,function(){d(this).hide();g.call()})})})(jQuery);
(function(g){function j(a){var c=g(window),d=c.width()+c.scrollLeft(),h=c.height()+c.scrollTop();return[a.offset().top<=c.scrollTop(),d<=a.offset().left+a.width(),h<=a.offset().top+a.height(),c.scrollLeft()>=a.offset().left]}function k(a){for(var c=a.length;c--;)if(a[c])return false;return true}var i=g.tools.tooltip;i.dynamic={conf:{classNames:"top right bottom left"}};g.fn.dynamic=function(a){if(typeof a=="number")a={speed:a};a=g.extend({},i.dynamic.conf,a);var c=a.classNames.split(/\s/),d;this.each(function(){var h=
g(this).tooltip().onBeforeShow(function(e,f){e=this.getTip();var b=this.getConf();d||(d=[b.position[0],b.position[1],b.offset[0],b.offset[1],g.extend({},b)]);g.extend(b,d[4]);b.position=[d[0],d[1]];b.offset=[d[2],d[3]];e.css({visibility:"hidden",position:"absolute",top:f.top,left:f.left}).show();f=j(e);if(!k(f)){if(f[2]){g.extend(b,a.top);b.position[0]="top";e.addClass(c[0])}if(f[3]){g.extend(b,a.right);b.position[1]="right";e.addClass(c[1])}if(f[0]){g.extend(b,a.bottom);b.position[0]="bottom";e.addClass(c[2])}if(f[1]){g.extend(b,
a.left);b.position[1]="left";e.addClass(c[3])}if(f[0]||f[2])b.offset[0]*=-1;if(f[1]||f[3])b.offset[1]*=-1}e.css({visibility:"visible"}).hide()});h.onBeforeShow(function(){var e=this.getConf();this.getTip();setTimeout(function(){e.position=[d[0],d[1]];e.offset=[d[2],d[3]]},0)});h.onHide(function(){var e=this.getTip();e.removeClass(a.classNames)});ret=h});return a.api?ret:this}})(jQuery);


