﻿function searchClick() {
	        var context = document.getElementById("InputContext").value;
	        var bcata   = document.getElementById("ctl00_ContentPlaceHolder1_SCataDrop").value;
	        if (context !="输入活动关键字" && context.replace("nbsp;", "").length > 0) {
	            if(bcata!=0)
	            {
    	            var href = "/SearchActive_"+bcata+"_" + context.replace("nbsp;", "") + ".htm";
	                this.window.location.href = href;
	            }
	            else
	            {
	                var href = "/ActiveSearch_" + context.replace("nbsp;", "") + ".htm";
	                this.window.location.href = href;
	            }
 
	        }
	        else {
	            document.getElementById("InputContext").value = "输入活动关键字";
	        }
	    }


getSmallCata = function(obj) {
            var bigCata = obj.value;
            $.ajax({
                type: "POST", 
                url: "/getBrandCata.ashx?cataid="+bigCata, //发送请求的地址
                data: "", //发送到服务器的数据
                success: function(json) {
var continents = eval( json );
                    var cataDrop = document.getElementById("ctl00_ContentPlaceHolder1_SCataDrop")
                    for(var i=0;i<continents.length;i++)
                    {
                        if(cataDrop.options[i]==null)
                        {
                             cataDrop.options.add(new Option(continents[i].BrandSCName,continents[i].id));
                        }
                        else
                        {
                            cataDrop.options[i].text = continents[i].BrandSCName; //document.Form1.
                            cataDrop.options[i].value = continents[i].id; //document.Form1.
                        }
                    }
                }
            });

        } 
    jQuery(function($) {
        $('#exponential').show().cycle({
            pause: 1,
            timeout: 4000,
            speed: 800,
            height: 8,
            fx: 'scrollUp'
        });
        $(".br_main dl").mouseover(function() { $(".br_main dl").removeClass("mover"); $(this).addClass("mover") })
        $(".br_slide dl").mouseover(function() { $(".br_slide dl").removeClass("mouseover"); $(this).addClass("mouseover") });
        $(".per_slide dl").mouseover(function() { $(".per_slide dl").removeClass("mouseover"); $(this).addClass("mouseover") });
        $(".per2_slide dl").mouseover(function() { $(".per2_slide dl").removeClass("mouseover"); $(this).addClass("mouseover") });
        $(".blog_img li").mouseover(function() { $(".blog_img li").removeClass("mover"); $(this).addClass("mover") });
        $("#floor dl").mouseover(function() { $("#floor dl").removeClass("mover"); $(this).addClass("mover") });
    })

    $.fn.infiniteCarousel = function() {

        function repeat(str, num) {
            return new Array(num + 1).join(str);
        }

        return this.each(function() {
            var $wrapper = $('> div', this).css('overflow', 'hidden'),
            $slider = $wrapper.find('> ul'),
            $items = $slider.find('> li'),
            $single = $items.filter(':first'),

            singleWidth = $single.outerWidth(),
            visible = Math.ceil($wrapper.innerWidth() / singleWidth), // note: doesn't include padding or border
            currentPage = 1,
            pages = Math.ceil($items.length / visible);


            // 1. Pad so that 'visible' number will always be seen, otherwise create empty items
            if (($items.length % visible) != 0) {
                $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
                $items = $slider.find('> li');
            }

            // 2. Top and tail the list with 'visible' number of items, top has the last section, and tail has the first
            $items.filter(':first').before($items.slice(-visible).clone().addClass('cloned'));
            $items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));
            $items = $slider.find('> li'); // reselect

            // 3. Set the left position to the first 'real' item
            $wrapper.scrollLeft(singleWidth * visible);

            // 4. paging function
            function gotoPage(page) {
                var dir = page < currentPage ? -1 : 1,
                n = Math.abs(currentPage - page),
                left = singleWidth * dir * visible * n;

                $wrapper.filter(':not(:animated)').animate({
                    scrollLeft: '+=' + left
                }, 500, function() {
                    if (page == 0) {
                        $wrapper.scrollLeft(singleWidth * visible * pages);
                        page = pages;
                    } else if (page > pages) {
                        $wrapper.scrollLeft(singleWidth * visible);
                        // reset back to start position
                        page = 1;
                    }

                    currentPage = page;
                });

                return false;
            }

            $wrapper.after('<a class="arrow back"  title="向左">&lt;</a><a class="arrow forward"  title="向右">&gt;</a>');

            // 5. Bind to the forward and back buttons
            $('a.back', this).click(function() {
                return gotoPage(currentPage - 1);
            });

            $('a.forward', this).click(function() {
                return gotoPage(currentPage + 1);
            });

            // create a public interface to move to a specific page
            $(this).bind('goto', function(event, page) {
                gotoPage(page);
            });
        });
    };

    $(document).ready(function() {
        $('.infiniteCarousel').infiniteCarousel();
    });
    
    
    function popupDiv(div_id) 
    {
        var div_obj = $("#"+div_id);
        var windowWidth = document.body.clientWidth;
        var windowHeight = document.body.clientHeight;
        var popupHeight = div_obj.height();
        var popupWidth = div_obj.width();
        
        //添加并显示遮罩层   
//        $("<div id='mask'></div>").addClass("mask")   
//                                  .width(windowWidth + document.body.scrollWidth)
//                                  .height(windowHeight + document.body.scrollHeight)
//                                  .click(function() {hideDiv(div_id); })
//                                  .appendTo("body")
//                                  .fadeIn(200);
        //显示层，可以自定义层
        div_obj.css({"position": "absolute"})
               .animate({left: windowWidth/2-popupWidth/2,
                         top: windowHeight/2-popupHeight/2, opacity: "show" }, "slow");
    }
    
    function hideDiv(div_id) {
        $("#mask").remove();
        $("#" + div_id).animate({left: 0, top: 0, opacity: "hide" }, "slow");
    }