// JavaScript Document
	var addtoLayout=0;						// 0=Horizontal 1 row, 1=Horizontal 2 rows, 2=Vertical, 3=Vertical text only 
	var addtoMethod=1;						// 0=direct link, 1=popup window
	var AddURL = encodeURIComponent(document.location.href);	// this is the page's URL
	var AddTitle = escape(document.title);	// this is the page title

	var signup_email_text = "email address";
    function onNewsLetterClick() {
        if (document.getElementById('signup_email').value == signup_email_text) {
            document.getElementById('signup_email').value = "";
        } 
    }
    function onNewsLetterBlur() {
        if (document.getElementById('signup_email').value == "") {
            document.getElementById('signup_email').value = signup_email_text;
        }
    }


	var onVideoClick = function(id) {
        window.open('video_popup.asp?id=' + id, "productvideo", "menubar=0,location=0,resizable=1,width=660,height=510");
    }
	
	/*Loads the search form*/
	function LoadSearchPanel(){
		 $("#productsearch").load("includes/asp/homepage_search_panel.asp");
	}


	/*latest playscapes projects*/	
    var currentCarouselIndex = 0;
    /**
    * This is the callback function which receives notification
    * when an item becomes the first one in the visible range.
    */
    //function mycarousel_itemVisibleInCallbackAfterAnimation(carousel, item, idx, state) {
    function mycarousel_itemFirstInCallback(carousel, item, idx, state) {
        $.each($("a.selected"), function(i, val) {

        }
        );
        
    };

    /**
    * This is the callback function which receives notification
    * when an item becomes the first one in the visible range.
    */
    function mycarousel_itemLastInCallback(carousel, item, idx, state) {

        $.each($("a.selected"), function(i, val) {
        }
        );


    };

    function updateCurrentImagePointer(idx) {

        //alert(currentCarouselIndex);
    
        $.each($("a.selected"), function(i, val) {
            $(this).removeClass("selected");
        }
        );    
        $('a.change:eq(' + idx + ')').addClass("selected"); 
    }


    function nextButtonClick(carousel) {
        carousel.next();
        //4
        if (currentCarouselIndex < (numItems - 1)) {
            currentCarouselIndex++;

        }
        updateCurrentImagePointer(currentCarouselIndex);
        
        //4
        if (currentCarouselIndex==(numItems - 1)){
			document.getElementById('mycarousel').style.left = "-" + ((numItems - 1) * 202) + "px";
			}
    }

    function prevButtonClick(carousel) {
        carousel.prev();
        if (currentCarouselIndex > 0) {
            currentCarouselIndex--;
        }
        updateCurrentImagePointer(currentCarouselIndex);
        
        if (currentCarouselIndex==(numItems - 2)){
			document.getElementById('mycarousel').style.left = "-" + ((numItems - 2) * 202) + "px";
			}
    }


    /**
    * We use the initCallback callback
    * to assign functionality to the controls
    */
    function mycarousel_initCallback(carousel) {
        jQuery('.jcarousel-control a').bind('click', function() {
            carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
            return false;
        });

        //jQuery('.jcarousel-scroll select').bind('change', function() {
        //    carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
        //    return false;
        //});

        jQuery('#mycarousel-next').bind('click', function() {
            nextButtonClick(carousel);
            return false;
        });

        jQuery('#mycarousel-prev').bind('click', function() {
            prevButtonClick(carousel);
            return false;
        });

       
    };

    $(function() {
        jQuery('#mycarousel').jcarousel({
            scroll: 1,
            animation:0,
            initCallback: mycarousel_initCallback,
            itemFirstInCallback: mycarousel_itemFirstInCallback,
            itemLastInCallback: mycarousel_itemLastInCallback,
            
            // This tells jCarousel NOT to autobuild prev/next buttons
            buttonNextHTML: null,
            buttonPrevHTML: null
        });

        updateCurrentImagePointer(0);
    });

	
	/*homepage new panel*/
	function OnNewsThumbClick(id) {
		$.get("ajax_getnews.asp", { news_id: id, ajax: 'true' }, function(j) {
			$("#updateable_news").html(j);
		})        
	}

	/*site search*/
    var text = "Site Search";
    function onSiteSearchClick() {
        if (document.getElementById('search').value == text) {
            document.getElementById('search').value = "";
        }
    }
    function onSiteSearchBlur() {
        if (document.getElementById('search').value == "") {
            document.getElementById('search').value = text;
        }
    }