/*
 * fadeSlideShow
 * v.2.0.0
 *
 * Copyright (c) 2010 Pascal Bajorat (http://www.pascal-bajorat.com)
 * Dual licensed under the MIT (below)
 * and GPL (http://www.gnu.org/licenses/gpl.txt) licenses.
 *
 *
 * http://plugins.jquery.com/project/fadeslideshow
 * http://www.pascal-bajorat.com

MIT License

Copyright (c) 2010 Pascal Bajorat

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */


//var ReverseIndex = 0;
jQuery.fn.fadeSlideShow = function (options) {
    return this.each(function () {
        settings = jQuery.extend({
            width: 1000, // default width of the slideshow
            height: 260, // default height of the slideshow
            speed: 'slow', // default animation transition speed
        	PlayText: 'Play', // default play text
            //PauseText: 'Pause', // default pause text
            NextElement: 'fssNext', // default id for next button
            NextElementText: 'Next >', // default text for next button
            PrevElement: 'fssPrev', // default id for prev button
            PrevElementText: '< Prev', // default text for prev button
            ListElement: 'fssList', // default id for image / content controll list

            ListLi: 'fssLi', // default class for li's in the image / content controll 
            ListLiActive: 'fssActive', // default class for active state in the controll list
            addListToId: false, // add the controll list to special id in your code - default false
            ///sallowKeyboardCtrl: true, // allow keyboard controlls left / right / space
            //autoplay: true // autoplay the slideshow
        }, options);



        // set style for wrapper element
        jQuery(this).css({
            width: settings.width,
            height: settings.height,
            position: 'relative',
            overflow: 'hidden'
        });

        // set styles for child element
        jQuery('> *', this).css({
            position: 'absolute',
            width: settings.width,
            height: settings.height
        });

        // count number of slides
        Slides = jQuery('> *', this).length;
        Slides = Slides - 1;
        ActSlide = Slides;
        // Set jQuery Slide short var
        jQslide = jQuery('> *', this);
        // save this
        fssThis = this;
        jQuery('div.slide1').css("display", "block");

    
        jumpTo = function (newIndex) {
        
        
            if (newIndex < 0) { newIndex = Slides; }
            else if (newIndex > Slides) { newIndex = 0; }
            destSlideID =6-newIndex;
            
            if (newIndex >= ActSlide) {
//            $abn_about('#lblText').html('1');
                jQuery('#slide_'+destSlideID , fssThis).fadeIn(settings.speed);
            } else if (newIndex <= ActSlide) {
                      //  $abn_about('#lblText').html('2');
                jQuery('> *:gt(' + newIndex + ')', fssThis).fadeOut(settings.speed);
            }

            // set the active slide
            ActSlide = newIndex;
			$abn_about('#slide_'+destSlideID ).css("display", "block");
			
            if (settings.ListElement) {
                //set active
                jQuery('#' + settings.ListElement + ' li').removeClass(settings.ListLiActive);
                jQuery('#' + settings.ListElement + ' li').eq((Slides - newIndex)).addClass(settings.ListLiActive);
            }        }

        // if list is on render it
        if (settings.ListElement) {
            i = 0;
            li = '';
            while (i <= Slides) {
                if (i == 0) {
                    li = li + '<li class="' + settings.ListLi + i + ' ' + settings.ListLiActive + '"><a href="#" class="listclass" id="' + i + '">' + (i + 1) + '<\/a><\/li>';
                } else {
                    li = li + '<li class="' + settings.ListLi + i + '"><a href="#" class="listclass" id="' + i + '">' + (i + 1) + '<\/a><\/li>';
                }
                i++;
            }
            List = '<ul id="' + settings.ListElement + '">' + li + '<\/ul>';

            // add list to a special id or append after the slideshow
            if (settings.addListToId) {
                jQuery('#' + settings.addListToId).append(List);
            } else {
                jQuery(this).after(List);
            }

            jQuery('#' + settings.ListElement + ' a').bind('click', function () {
            
						//$abn_about('#slide_3').css("display", "block"); 
                       	//$abn_about('#slide_4').css("display", "block");
                        //$abn_about('#slide_5').css("display", "block");
                       	//$abn_about('#slide_1').css("display", "block");
                

                index = jQuery('#' + settings.ListElement + ' a').index(this);
                
                ReverseIndex = Slides - index;

                jumpTo(ReverseIndex);

                return false;
            });
        }

     
        if (settings.NextElement) {
            if (!jQuery('#' + settings.NextElement).css('display')) {
                jQuery(this).after('<a href="#" id="' + settings.NextElement + '">' + settings.NextElementText + '<\/a>');
            }

            jQuery('#' + settings.NextElement).bind('click', function () {
                //$abn_about('#slide_3').css("display", "block"); 
                //$abn_about('#slide_4').css("display", "block");
                //$abn_about('#slide_5').css("display", "block");
 	  
                nextSlide = ActSlide - 1;
				jumpTo(nextSlide);
                return false;
            });
        }

        if (settings.PrevElement) {
            if (!jQuery('#' + settings.PrevElement).css('display')) {
                jQuery(this).after('<a href="#" id="' + settings.PrevElement + '">' + settings.PrevElementText + '<\/a>');
            }

            jQuery('#' + settings.PrevElement).bind('click', function () {
                prevSlide = ActSlide + 1;
                 		



                
                jumpTo(prevSlide);
                		
                       
                return false;
            });
        }


        // start autoplay or set it to false
           });
};

jQuery.noConflict();
var $abn_about = jQuery;
$abn_about(document).ready(function ($) {

    $abn_about('div.home_images').css("display", "none");
    $abn_about('div.slide1').css("display", "none");
    $abn_about('#slideshow').fadeSlideShow();
                    $abn_about('div.home_images').css("display", "block");
                     $abn_about('#slide_4').css("display", "none");
                      $abn_about('#slide_2').css("display", "none"); 
                       $abn_about('#slide_3').css("display", "none");
                        $abn_about('#slide_5').css("display", "none");
                         $abn_about('#slide_6').css("display", "none");
 
    			 //ReverseIndex = Slides - 3;
                   //jumpTo(ReverseIndex);


});

jQuery.noConflict();
var $jc_about = jQuery;
$jc_about(document).ready(
    function ($) {
		
        $jc_about('.listclass').click(
            function () {
            

                //
                if ($jc_about(this).attr('id').search("0") != -1) {
                    $jc_about('div.home_images').css("display", "none");
                }
                else {
                    $jc_about('#slide_1').css("display", "none"); 
                    $jc_about('div.home_images').css("display", "block");
                }
            })
        $jc_about('.header_title').mouseover(
            function () {
                

                if ($jc_about(this).attr('id').search("1") != -1) {
                    ReverseIndex = Slides - 0;
                    $jc_about('#slide_1').css("display", "block");
                    jumpTo(ReverseIndex);
                    $jc_about('div.home_images').css("display", "block");

                }

                else if ($jc_about(this).attr('id').search("2") != -1) {
                    $jc_about('#slide_1').css("display", "none");
                    $jc_about('div.home_images').css("display", "block");
                    $jc_about('#slide_2').css("display", "block");
 
                    ReverseIndex = Slides - 1;
                    jumpTo(ReverseIndex);
                    

                }
                else if ($jc_about(this).attr('id').search("3") != -1) {
                    $jc_about('#slide_1').css("display", "none");
                    $jc_about('#slide_3').css("display", "block");

                    $jc_about('div.home_images').css("display", "block");
                    ReverseIndex = Slides - 2;
                    jumpTo(ReverseIndex);

                }
                else if ($jc_about(this).attr('id').search("4") != -1) {
                    $jc_about('#slide_1').css("display", "none");
                    $jc_about('#slide_4').css("display", "block");

                    $jc_about('div.home_images').css("display", "block");
                    ReverseIndex = Slides - 3;
                    jumpTo(ReverseIndex);

                }
                else if ($jc_about(this).attr('id').search("5") != -1) {
                    $jc_about('#slide_1').css("display", "none");
                    $jc_about('#slide_5').css("display", "block");

                    $jc_about('div.home_images').css("display", "block");
                    ReverseIndex = Slides - 4;
                    jumpTo(ReverseIndex);

                }
                 else if ($jc_about(this).attr('id').search("6") != -1) {
                    $jc_about('#slide_1').css("display", "none");
                    $jc_about('#slide_6').css("display", "block");

                    $jc_about('div.home_images').css("display", "block");
                    ReverseIndex = Slides - 5;
                    jumpTo(ReverseIndex);

                }

               
            })
    });
