function str_replace(a, b, str) {
  return str_replace2(str, a, b);
}
function str_replace2(SRs, SRt, SRu) {
//   alert(SRs + " -> " + SRt + " -> " + SRu);
  if(SRs != "undefined"){
    SRRi = SRs.indexOf(SRt);
    SRRr = '';
    if (SRRi == -1) return SRs;
    SRRr += SRs.substring(0,SRRi) + SRu;
    if ( SRRi + SRt.length < SRs.length)
      SRRr += str_replace2(SRs.substring(SRRi + SRt.length, SRs.length), SRt, SRu);
    return SRRr;
  }
}
function onlyNumeric(myVal, authChar){
  var valid = "0123456789" + authChar;

  for (var i=0; i < myVal.length; i++) {
    temp = "" + myVal.substring(i, i+1);
    if (valid.indexOf(temp) == "-1")
      myVal = str_replace(temp, "", myVal);
  }

  return myVal;
}

$(document).ready(function(){
  $(".numeric").blur(function(){
    var aValue = $(this).val();
    aValue = onlyNumeric(aValue,$(this).attr('authchar'));
    
    if(aValue == "")
      aValue = $(this).attr('default');

    $(this).val(aValue);
  });
  $(".numeric").keyup(function(){
    var aValue = $(this).val();
    aValue = onlyNumeric(aValue,$(this).attr('authchar'));

    $(this).val(aValue);
  });
  $(".aDate").keyup(function(){
    var aValue = str_replace("//","/",$(this).val());
    if(aValue.length == 2 || aValue.length == 5)
      aValue = aValue + "/";

    $(this).val(aValue);
  });
  $(".hoverAction").mouseover(function(){
    var name = $(this).attr('src');
    $(this).attr('src',name.split(".")[0] + '-hover.' + name.split(".")[1]);
  });
  $(".hoverAction").mouseleave(function(){
    var name = $(this).attr('src');
    $(this).attr('src',name.split("-hover.")[0] + '.' + name.split(".")[1]);
  });
  $(".divHoverAction").mouseover(function(){
    var name = $(this).css('background-image');
    if(name.indexOf("-hover",0) < 0)
      $(this).css('background-image',name.split(".")[0] + '.' + name.split(".")[1] + '.' + name.split(".")[2] + '-hover.' + name.split(".")[3]);
  });
  $(".divHoverAction").mouseleave(function(){
    var name = $(this).css('background-image');
    $(this).css('background-image',name.split("-hover.")[0] + '.' + name.split(".")[3]);
  });

  $("#bootik_1").fadeIn();
  setTimeout(function(){ diapoBoutique(); },7000);

  function diapoBoutique(){
    if($("#bootik_1").css('display') == "inline")
      var activ = 1;
    else if($("#bootik_2").css('display') == "inline")
      var activ = 2;
    else if($("#bootik_3").css('display') == "inline")
      var activ = 3;

    next = activ + 1;

    if(next == 4) next = 1;
    $("#bootik_" + activ).fadeOut('slow',function(){
      $("#bootik_" + next).fadeIn('slow',function(){
        setTimeout(function(){ diapoBoutique(); },7000);
      });
    });
  }
});

/*
Stylish Select 0.4.1 - $ plugin to replace a select drop down box with a stylable unordered list
http://github.com/sko77sun/Stylish-Select

Requires: jQuery 1.3 or newer

Contributions from Justin Beasley: http://www.harvest.org/ & Anatoly Ressin: http://www.artazor.lv/

Dual licensed under the MIT and GPL licenses.

*/
(function(a){a("html").addClass("stylish-select");Array.prototype.indexOf=function(c,d){for(var b=(d||0);b<this.length;b++){if(this[b]==c){return b}}};a.fn.extend({getSetSSValue:function(b){if(b){a(this).val(b).change();return this}else{return a(this).find(":selected").val()}},resetSS:function(){var b=a(this).data("ssOpts");$this=a(this);$this.next().remove();$this.unbind(".sSelect").sSelect(b)}});a.fn.sSelect=function(b){return this.each(function(){var i={defaultText:"Please select",animationSpeed:0,ddMaxHeight:"",containerClass:""};var l=a.extend(i,b),e=a(this),j=a('<div class="selectedTxt"></div>'),r=a('<div class="newListSelected '+l.containerClass+'"></div>'),z=a('<ul class="newList" style="visibility:hidden;"></ul>'),t=-1,d=-1,m=[],w=false,v=false,x;a(this).data("ssOpts",b);r.insertAfter(e);r.attr("tabindex",e.attr("tabindex")||"0");j.prependTo(r);z.appendTo(r);e.hide();j.data("ssReRender",!j.is(":visible"));if(e.children("optgroup").length==0){e.children().each(function(B){var C=a(this).html();var A=a(this).val();m.push(C.charAt(0).toLowerCase());if(a(this).attr("selected")==true){l.defaultText=C;d=B}z.append(a('<li><a href="JavaScript:void(0);">'+C+"</a></li>").data("key",A))});x=z.children().children()}else{e.children("optgroup").each(function(){var A=a(this).attr("label"),C=a('<li class="newListOptionTitle">'+A+"</li>");C.appendTo(z);var B=a("<ul></ul>");B.appendTo(C);a(this).children().each(function(){++t;var E=a(this).html();var D=a(this).val();m.push(E.charAt(0).toLowerCase());if(a(this).attr("selected")==true){l.defaultText=E;d=t}B.append(a('<li><a href="JavaScript:void(0);">'+E+"</a></li>").data("key",D))})});x=z.find("ul li a")}var o=z.height(),n=r.height(),y=x.length;if(d!=-1){h(d,true)}else{j.text(l.defaultText)}function p(){var B=r.offset().top,A=jQuery(window).height(),C=jQuery(window).scrollTop();if(o>parseInt(l.ddMaxHeight)){o=parseInt(l.ddMaxHeight)}B=B-C;if(B+o>=A){z.css({top:"-"+o+"px",height:o});e.onTop=true}else{z.css({top:n+"px",height:o});e.onTop=false}}p();a(window).bind("resize.sSelect scroll.sSelect",p);function s(){r.css("position","relative")}function c(){r.css("position","static")}j.bind("click.sSelect",function(A){A.stopPropagation();if(a(this).data("ssReRender")){o=z.height("").height();n=r.height();a(this).data("ssReRender",false);p()}a(".newList").not(a(this).next()).hide().parent().css("position","static").removeClass("newListSelFocus");z.toggle();s();x.eq(d).focus()});x.bind("click.sSelect",function(B){var A=a(B.target);d=x.index(A);v=true;h(d);z.hide();r.css("position","static")});x.bind("mouseenter.sSelect",function(B){var A=a(B.target);A.addClass("newListHover")}).bind("mouseleave.sSelect",function(B){var A=a(B.target);A.removeClass("newListHover")});function h(A,E){x.removeClass("hiLite").eq(A).addClass("hiLite");if(z.is(":visible")){x.eq(A).focus()}var D=x.eq(A).html();var C=x.eq(A).parent().data("key");if(E==true){e.val(C);j.text(D);return false}try{e.val(C)}catch(B){e[0].selectedIndex=A}e.change();j.text(D)}e.bind("change.sSelect",function(A){$targetInput=a(A.target);if(v==true){v=false;return false}$currentOpt=$targetInput.find(":selected");d=$targetInput.find("option").index($currentOpt);h(d,true)});function q(A){a(A).unbind("keydown.sSelect").bind("keydown.sSelect",function(D){var C=D.which;v=true;switch(C){case 40:case 39:u();return false;break;case 38:case 37:k();return false;break;case 33:case 36:g();return false;break;case 34:case 35:f();return false;break;case 13:case 27:z.hide();c();return false;break}keyPressed=String.fromCharCode(C).toLowerCase();var B=m.indexOf(keyPressed);if(typeof B!="undefined"){++d;d=m.indexOf(keyPressed,d);if(d==-1||d==null||w!=keyPressed){d=m.indexOf(keyPressed)}h(d);w=keyPressed;return false}})}function u(){if(d<(y-1)){++d;h(d)}}function k(){if(d>0){--d;h(d)}}function g(){d=0;h(d)}function f(){d=y-1;h(d)}r.bind("click.sSelect",function(A){A.stopPropagation();q(this)});r.bind("focus.sSelect",function(){a(this).addClass("newListSelFocus");q(this)});r.bind("blur.sSelect",function(){a(this).removeClass("newListSelFocus")});a(document).bind("click.sSelect",function(){r.removeClass("newListSelFocus");z.hide();c()});j.bind("mouseenter.sSelect",function(B){var A=a(B.target);A.parent().addClass("newListSelHover")}).bind("mouseleave.sSelect",function(B){var A=a(B.target);A.parent().removeClass("newListSelHover")});z.css({left:"0",display:"none",visibility:"visible"})})}})(jQuery);
