var $$$ = $.fn;
var sId, iSlideCnt;
var GCounter = 1;

$$$.extend({
  SplitID : function()
  {
    return this.attr('id').split('-').pop();
  },

  Slideshow : {
    Ready : function()
    {
      $('div.tmpSlideshowControl')
	  /*.hover(
          function() {
						$$$.Slideshow.Interrupted = true;
            $(this).addClass('tmpSlideshowControlOn');

            $('div.tmpSlide').hide();
            $('div.tmpSlideshowControl a:first-child').removeClass('slideActive');

            $('div#tmpSlide-' + $(this).SplitID()).show()
            $(this).addClass('slideActive');

          },
          function() {
            $(this).removeClass('tmpSlideshowControlOn');
          }
        )*/
        .click(
          function() {
            $$$.Slideshow.Interrupted = true;
            $('div.tmpSlide').hide();
            $('div.tmpSlideshowControl a:first-child').removeClass('slideActive');
			slideColor =  document.getElementById("slidecolor_" + $(this).SplitID()).value;
			 $('div#tmpSlideshowControl-' + $(this).SplitID() + ' a:first-child').addClass('slideActive');

			 document.getElementById("lastDv").className = document.getElementById("firstDv").className = "";
			 /*$('div#firstDv').removeClass('Rleft'); $('div#firstDv').removeClass('Gleft'); $('div#firstDv').removeClass('Bleft');  $('div#lastDv').removeClass('Rright');  $('div#lastDv').removeClass('Gright'); $('div#lastDv').removeClass('Bright');*/

			  strLeft = slideColor + "left";
			  strRight = slideColor + "right";
				
			  $('div#firstDv').addClass(strLeft);
			  $('div#lastDv').addClass(strRight);


            $('div#tmpSlide-' + $(this).SplitID()).show();
			if (iSlideCnt != parseInt($(this).SplitID()))
				GCounter = parseInt($(this).SplitID())+ 1;
			else 
				GCounter = 1;

			try{
				clearTimeout(sId);
				if($(this).SplitID() != 1)
				sId = setTimeout('$("div#tmpSlide-'+ $(this).SplitID()+'").hide();$$$.Slideshow.Ready();$(\'div#tmpSlideshowControl-' + $(this).SplitID() + ' a:first-child\').removeClass(\'slideActive\');', 5000);
				else
				sId = setTimeout('$("div#tmpSlide-'+ $(this).SplitID()+'").hide();$$$.Slideshow.Ready();', 5000);
			}catch(err){
		}
			

        $(this).addClass('slideActive');
		//var strUrl = document.getElementById("url_" + ($(this).SplitID()-1)).value; //document.frmBanner.action = strUrl;  //document.frmBanner.submit();
      }
     );
      this.Counter = GCounter;
      this.Interrupted = false;
      this.Transition();
    },

    Transition : function()
    {
      if (this.Interrupted) {
        return;
      }

      this.Last = this.Counter - 1;

      if (this.Last < 1) {
        this.Last = iSlideCnt;
      }

      $('div#tmpSlide-' + this.Last).fadeOut(
        'slow',
        function() {
          $('div#tmpSlideshowControl-' + $$$.Slideshow.Last + ' a:first-child').removeClass('slideActive');
          $('div#tmpSlideshowControl-' + $$$.Slideshow.Counter + ' a:first-child').addClass('slideActive');

		slideColor =  document.getElementById("slidecolor_" + $$$.Slideshow.Counter).value;
		
		 document.getElementById("lastDv").className = document.getElementById("firstDv").className = "";
		
		  strLeft = slideColor + "left";
		  strRight = slideColor + "right";
			
          $('div#firstDv').addClass(strLeft);
          $('div#lastDv').addClass(strRight);

          $('div#tmpSlide-' + $$$.Slideshow.Counter).fadeIn('slow');
          $$$.Slideshow.Counter++;

          if ($$$.Slideshow.Counter > iSlideCnt) {
            $$$.Slideshow.Counter = 1;
          }

          setTimeout('$$$.Slideshow.Transition();', 5000);
        }
      );
    }
  }
});

$(document).ready(
  function() {
    $$$.Slideshow.Ready();
  }
);

function fnTrans(sFlag){
	return;
	if(sFlag == 1){
	document.getElementById("tranfBg").style.display ="block";
	}else{
	document.getElementById("tranfBg").style.display ="none";
	}
}
