function listMerCatTag(){
	
	var CouponTypeID = parseInt($("#coupontype").val());
	if( CouponTypeID >=1 &&  CouponTypeID <=6 ){
		$("#SMerchants").html("Loading...");
		$("#widgetsubmit").attr("disabled","disabled");
		var arr  = {'act':'list','coupontypeid':CouponTypeID};
		
		$.ajax({
			type: "POST",
			url: "/front/couponwidget.php",
			data: $.param(arr),
			success: function(msg){
				json = eval("("+msg+")");
				if( json.status == true){
					var str = $("<select name='fixid' id='fixid' style='width:250px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'></select>");
					var option = "";
					var title = "";
					$.each(json.data,function(i,t){
						option += "<option value=\"" + t.id + "\">" + t.name + "</option><br>";			  
					});	
				}
				if( CouponTypeID == 1 || CouponTypeID ==2 ){
					title = "<b>Kategorie wählen:</b><br/>";	
				}else if( CouponTypeID == 3 || CouponTypeID ==4 ){
					title = "<b>Händler wählen:</b><br/>";	
			    }else if( CouponTypeID == 5 || CouponTypeID ==6 ){
					title = "<b>Etikett wählen:</b><br/>";		
				}

				$("#SMerchants").html(title + $(str).html(option).parent().html());
				$("#widgetsubmit").attr("disabled","");
			}
		});
	}else{
		$("#SMerchants").html(" ");	
	}
}

function submitcheck(){
    var obj = document.getElementById('form1');
    if( !Validator.Validate(obj,2) ){
        return false;
    }

    $("#widgetsubmit").attr("disabled","disabled");
    $("#result").html('Generieren Gutschein-Widget...');

    var coupontypeid = parseInt($("#coupontype").val());
    var fixid = parseInt($("#fixid").val());
    var widgetsizeid = parseInt($('input[name=widgetsize]:checked').val());
    var couponnum = parseInt($("#couponnum").val());

    var arr  = {'act':'submit','coupontypeid':coupontypeid,'fixid':fixid,'widgetsizeid':widgetsizeid,'couponnum':couponnum};

    $.ajax({
			type: "POST",
			url: "/front/couponwidget.php",
			cache: true,
			data: $.param(arr),
			success: function(msg){
				$("#widgetsubmit").attr("disabled","");
				//json = eval("("+msg+")");
				//var c = "";
				/*if(json.status == true && json.data != null)
				{
					c = json.data;
					c=c.replace(/&nbsp;/g,' ');
					c=c.replace(/&amp;/g,'&');
					c=c.replace(/&#039;/g,'\'');
					c=c.replace(/&quot;/g,'"');
					c=c.replace(/&lt;/g,'<');
					c=c.replace(/&gt;/g,'>');
                }else{
                    alert('Ihre gewählten Gutscheine sind nicht verfügbar, versuchen Sie einen anderen!');
                }
				*/
				if(msg == "")
				{
					alert('Ihre gewählten Gutscheine sind nicht verfügbar, versuchen Sie einen anderen!');
				}
				else
				{
					$("#result").html(msg);
				}
				//$("#result").html(c);
			}
		});

    return false;
}

(function($){
$.fn.extend({
        Scroll:function(opt,callback){
                //参数初始?                if(!opt) var opt={};
				if( opt.style == 1 ){
					var _btnUp = $("#"+ opt.up);
					var _btnDown = $("#"+ opt.down);
					var _this=this.eq(0).find("ul:first");
					var     lineH=_this.find("li:first").height(), 
							line=opt.line?parseInt(opt.line,10):parseInt(this.height()/lineH,10),
							speed=opt.speed?parseInt(opt.speed,10):500; 

					if(line==0) line=1;
					var upHeight=0-line*lineH;
				}else if( opt.style == 2 ){
					var _btnLeft = $("#"+ opt.up);	
					var _btnRight = $("#"+ opt.down);
					var _this=this.eq(0).find("ul:first");
					var     lineW=_this.find("li:first").width(),
							line=opt.line?parseInt(opt.line,10):parseInt(this.width()/lineW,10),
							speed=opt.speed?parseInt(opt.speed,10):500; 
					if(line==0) line=1;
					var upWidth=0-line*lineW;
				}
                //滚动函数
                var scrollUp=function(){
                        _btnUp.unbind("click",scrollUp); 
                        lineH = $("#scrollDiv").find("li:first").height();
                        upHeight=0-line*lineH ;
                        _this.animate({
                                marginTop:upHeight
                        },speed,function(){
                                for(i=1;i<=line;i++){
                                        _this.find("li:first").appendTo(_this);
                                }
                                _this.css({marginTop:0});
                                _btnUp.bind("click",scrollUp); 
                        });

                }
				
				var scrollLeft=function(){
                        _btnLeft.unbind("click",scrollLeft); 
                        lineW = $("#scrollDiv").find("li:first").width();
                        upWidth=0-line*lineW ;
                        _this.animate({
                                marginLeft:upWidth
                        },speed,function(){
                                for(i=1;i<=line;i++){
                                        _this.find("li:first").appendTo(_this);
                                }
                                _this.css({marginLeft:0});
                                _btnLeft.bind("click",scrollLeft); 
                        });

                }
                
                var scrollDown=function(){
                        _btnDown.unbind("click",scrollDown);
                        for(i=1;i<=line;i++){
                                _this.find("li:last").show().prependTo(_this);
                        }
                        lineH = $("#scrollDiv").find("li:first").height();
                        upHeight=0-line*lineH ;
                        _this.css({marginTop:upHeight});
                        _this.animate({
                                marginTop:0
                        },speed,function(){
                                _btnDown.bind("click",scrollDown);
                        });
                }
				 var scrollRight=function(){
                        _btnRight.unbind("click",scrollRight);
                        for(i=1;i<=line;i++){
                                _this.find("li:last").show().prependTo(_this);
                        }
                        lineW = $("#scrollDiv").find("li:first").width();
                        upWidth=0-line*lineW ;
                        _this.css({marginLeft:upWidth});
                        _this.animate({
                                marginLeft:0
                        },speed,function(){
                                _btnRight.bind("click",scrollRight);
                        });
                }
               //Shawphy:自动播放
                //var autoPlay = function(){
                //        if(timer)timerID = window.setInterval(scrollUp,timer);
                //};
                //var autoStop = function(){
                //        if(timer)window.clearInterval(timerID);
                //};
                 //鼠标事件绑定
                //this.hover(autoStop,autoPlay).mouseout();
				if( opt.style == 1 ){
					_btnUp.css("cursor","pointer").click( scrollUp );
					_btnDown.css("cursor","pointer").click( scrollDown );
				}else if( opt.style == 2 ){
					_btnLeft.css("cursor","pointer").click( scrollLeft );
					_btnRight.css("cursor","pointer").click( scrollRight );
				}

        }       
})
})(jQuery);

