//* swap buttons

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}




//* dropdown



var timeout         = 0;
var closetimer		= 0;
var ddmenuitem      = 0;

function jsddm_open()
{	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');}

function jsddm_close()
{	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{	closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{	if(closetimer)
	{	window.clearTimeout(closetimer);
		closetimer = null;}}

$(document).ready(function()
{
	$('#jsddm > li').bind('mouseover', jsddm_open);
	$('#jsddm > li').bind('mouseout',  jsddm_timer);
	
	});

document.onclick = jsddm_close;





//* slideshow
    var fadeInterval = -1;

    function StartFade()
    {
        if (fadeInterval == -1)
            fadeInterval = setInterval( "slideSwitch()", 3000 );
    }
    
    function StopFade()
    {
        if (fadeInterval != -1)
        {
            clearInterval(fadeInterval);
            fadeInterval = -1;
        }
    }

    function slideSwitch() {
        var $active = $('#slideshow DIV.active');

        if ( $active.length == 0 ) $active = $('#slideshow DIV:last');

        // use this to pull the divs in the order they appear in the markup
        var $next =  $active.next().length ? $active.next()
            : $('#slideshow DIV:first');

        // uncomment (remove //) 3 lines below to pull the divs randomly
        //var $sibs  = $active.siblings();
        //var rndNum = Math.floor(Math.random() * $sibs.length );
        //var $next  = $( $sibs[ rndNum ] );

        $active.addClass('last-active');

        $next.css({opacity: 0.0,display:'block'})
            .addClass('active')
            .animate({opacity: 1}, 1000, function() {
                $active.removeClass('active last-active').css('display','none')
            });
    }
    
    window.onload = function(){
        StartFade();
    }
    
    //* bubble popup
    var popupShown = -1;
    
    function CanPopupShow(index)
    {
        if (popupShown==-1 || index==popupShown)
        {
            popupShown = index;
            return true;
        }
        else
            return false;
    }
    
    function PopupUnShow(index)
    {
        if (index==popupShown)
        {
            return true;
        }
        else
            return false;
    }

    $(document).ready(function(){
      $('area').each(function (index) {
        // options
        var distance = 10;
        var time = 250;
        var hideDelay = 500;

        var hideDelayTimer = null;

        // tracker
        var beingShown = false;
        var shown = false;
        
        //var trigger = $('.trigger', this);
        var popup = $('table.'+this.className);

        // set the mouseover and mouseout on both element
        $('.'+this.className).mouseover(function (e) {
          if (CanPopupShow(index))
          {
              StopFade();
              // stops the hide event if we move from the trigger to the popup element
              if (hideDelayTimer) clearTimeout(hideDelayTimer);

              // don't trigger the animation again if we're being shown, or already visible
              if (beingShown || shown) {
                return;
              } else {
                beingShown = true;

                // reset position of popup box
                popup.css({
                  position: 'relative',
				  width: '338px',
		height: '147px',
                  display: 'block' // brings the popup back in to view
                })

                // (we're using chaining on the popup) now animate it's opacity and position
                .animate({
                  top: '-=' + distance + 'px'
                  
                }, time, 'swing', function() {
                  // once the animation is complete, set the tracker variables
                  beingShown = false;
                  shown = true;
                });
              }
           }
        }).mouseout(function () {
          if (PopupUnShow(index))
          {
              // reset the timer if we get fired again - avoids double animations
              if (hideDelayTimer) clearTimeout(hideDelayTimer);
              
              // store the timer so that it can be cleared in the mouseover if required
              hideDelayTimer = setTimeout(function () {
                hideDelayTimer = null;
                popup.animate({
                  top: '-=' + distance + 'px'}, time, 'swing', function () {
                  StartFade();
                  popupShown=-1;
                  // once the animate is complete, set the tracker variables
                  shown = false;
                  // hide the popup entirely after the effect (opacity alone doesn't do the job)
                  popup.css('display', 'none').animate({top: '+=' + (distance*2) + 'px'}, 0);
                });
              }, hideDelay);
          }
        });
      });
    });
    
	//* colleft

jQuery(document).ready(function(){
var blnOut = true;

if($.browser.msie){
$("#showPanel").click(function(){
if (blnOut)
    $("#colleft").animate({width:"800px"}, 400 );
else
    $("#colleft").animate({width:"0px"}, 400 );
    
blnOut = !blnOut;
});
}else{
$("#showPanel").click(function(){
if (blnOut)
    $("#colleft").css({opacity:"0.0"}).animate({width:"800px",opacity:"1.0"}, 400 );
else
    $("#colleft").animate({width:"0px",opacity:"0.0"}, 400 );
    
blnOut = !blnOut;
});
}
});


	
    //-- switcher --//
    //-- next
    $(document).ready(function(){
        $('a.CatNext_one').bind('click', function(event) {
            event.preventDefault();
            var $active = $('#switcher DIV.active_one');
            if ( $active.length == 0 ) $active = $('#switcher DIV.active_one:last');
            var $next =  $active.next().length ? $active.next() : $('#switcher DIV.active_one:first');
            $active.removeClass('active_one').animate({width:'hide'}, 500, function() {$next.animate({width:'show'}).addClass('active_one');});
        });
    });
    //--previous
    $(document).ready(function(){
        $('a.CatPrev_one').bind('click', function(event) {
            event.preventDefault();
            var $active = $('#switcher DIV.active_one');
            if ( $active.length == 0 ) $active = $('#switcher DIV.active_one:first');
            var $next =  $active.prev().length ? $active.prev() : $('#switcher DIV.active_one:last');
            $active.removeClass('active_one').animate({width:'hide'}, 500, function() {$next.animate({width:'show'}).addClass('active_one');});
        });
    });
	
	//-- switcher --//
    //-- next
    $(document).ready(function(){
        $('a.CatNext_two').bind('click', function(event) {
            event.preventDefault();
            var $active = $('#switcher DIV.active_two');
            if ( $active.length == 0 ) $active = $('#switcher DIV.active_two:last');
            var $next =  $active.next().length ? $active.next() : $('#switcher DIV.active_two:first');
            $active.removeClass('active_two').animate({width:'hide'}, 500, function() {$next.animate({width:'show'}).addClass('active_two');});
        });
    });
    //--previous
    $(document).ready(function(){
        $('a.CatPrev_two').bind('click', function(event) {
            event.preventDefault();
            var $active = $('#switcher DIV.active_two');
            if ( $active.length == 0 ) $active = $('#switcher DIV.active_two:first');
            var $next =  $active.prev().length ? $active.prev() : $('#switcher DIV.active_two:last');
            $active.removeClass('active_two').animate({width:'hide'}, 500, function() {$next.animate({width:'show'}).addClass('active_two');});
        });
    });
	
	//-- switcher --//
    //-- next
    $(document).ready(function(){
        $('a.CatNext_three').bind('click', function(event) {
            event.preventDefault();
            var $active = $('#switcher DIV.active_three');
            if ( $active.length == 0 ) $active = $('#switcher DIV.active_three:last');
            var $next =  $active.next().length ? $active.next() : $('#switcher DIV.active_three:first');
            $active.removeClass('active_three').animate({width:'hide'}, 500, function() {$next.animate({width:'show'}).addClass('active_three');});
        });
    });
    //--previous
    $(document).ready(function(){
        $('a.CatPrev_three').bind('click', function(event) {
            event.preventDefault();
            var $active = $('#switcher DIV.active_three');
            if ( $active.length == 0 ) $active = $('#switcher DIV.active_three:first');
            var $next =  $active.prev().length ? $active.prev() : $('#switcher DIV.active_three:last');
            $active.removeClass('active_three').animate({width:'hide'}, 500, function() {$next.animate({width:'show'}).addClass('active_three');});
        });
    });
	
	//-- switcher --//
    //-- next
    $(document).ready(function(){
        $('a.CatNext_four').bind('click', function(event) {
            event.preventDefault();
            var $active = $('#switcher DIV.active_four');
            if ( $active.length == 0 ) $active = $('#switcher DIV.active_four:last');
            var $next =  $active.next().length ? $active.next() : $('#switcher DIV.active_four:first');
            $active.removeClass('active_four').animate({width:'hide'}, 500, function() {$next.animate({width:'show'}).addClass('active_four');});
        });
    });
    //--previous
    $(document).ready(function(){
        $('a.CatPrev_four').bind('click', function(event) {
            event.preventDefault();
            var $active = $('#switcher DIV.active_four');
            if ( $active.length == 0 ) $active = $('#switcher DIV.active_four:first');
            var $next =  $active.prev().length ? $active.prev() : $('#switcher DIV.active_four:last');
            $active.removeClass('active_four').animate({width:'hide'}, 500, function() {$next.animate({width:'show'}).addClass('active_four');});
        });
    });
