function product(_obj,data){
	//alert($.JSON.encode(data))
	if(data.success&&data.items.length>0){
		var ret = [];
		var tpl = '<div id="item">'+
		  '<div id="img"><img src="../{small}" width="75" height="100" border="0"></div>'+
		  '<div id="info">'+
			'<div id="name" title="{name}">{name}</div>'+
			'<div id="brand" title="{brand}"><strong>Brand：</strong>{brand}</div>'+
			'<div id="brand"><strong>Price：</strong><span class="red">${price}</span></div>'+
			'<div id="brand"></div>'+
			'<div id="more"><a href="{url}"></a></div>'+
		  '</div>'+
		'</div>';
		$.each(data.items,function(i,n){
			ret.push(tpl.format(n));
		});
		_obj.html('<div class="clear"></div>'+ret.join('')+'<div class="clear"></div>');
		var page = _obj.next();
		page.find('a:eq(0)').attr('href',data.First);
		page.find('a:eq(1)').attr('href',data.Prev);
		page.find('a:eq(2)').attr('href',data.Next);
		page.find('a:eq(3)').attr('href',data.Last);
		page.find('strong:eq(0)').html(data.CurrentPage);
		page.find('strong:eq(1)').html(data.PageCount);
		page.find('strong:eq(2)').html(data.RecordCount);
		page.find('input#page').attr('value',data.CurrentPage);
	}else{
		_obj.html('<div class="empty">No Content</div>');
		_obj.next().find('div').hide();
	}
}
function product1(data){
	product(this,data);
}
function product2(data){
	product(this.parent().parent().parent().prev(),data);
}
var remote = function(data){
	var _obj = this[0];
	if(!_obj.error) _obj.error=$('#error');
	_obj.error.removeClass(data.success?'wrong':'right');
	_obj.error.addClass(data.success?'right':'wrong').attr('title',data.msg).html('&nbsp;');
	_obj.error.html(data.msg);
	_obj.datatype = String(data.success);
	_obj.msg = data.msg;
}
$(document).ready(function(){
	$('.product #items').scrollable({size:5}).circular().mousewheel().autoscroll({
		steps    : 5,
		interval : 3000
	});
	$('#register').click(function(){
		location.href="register.asp";
		return false;
	});
	$('#agree').click(function(){
		location.href="register.asp?action=yes";
		return false;
	});
	$('#disagree').click(function(){
		location.href="index.asp";
		return false;
	});
	$.formValidator.initConfig({formid:"form1",onerror:function(msg){}});
	$("#username").formValidator({
		onshow      : "Please enter a user name",
		onfocus     : "User name 6-16 characters",
		oncorrect   : "The user name can be registered"
	}).inputValidator({
		min         : 6,
		max         : 16,
		onerror     : "Enter your user name illegal"
	}).ajaxValidator({
	    type        : "post",
		url         : "../ajax/ajax.asp",
		datatype    : "json",
		data        : "action=test",
		success     : function(data){
			return data.success;
		},
		buttons    : $("#OKRegister"),
		error      : function(){alert("The server does not return data, may be the server is busy, please try again");},
		onerror    : "The user name is not available, please replace the user name",
		onwait     : "Please wait ..."
	});
	$("#password1").formValidator({
		onshow      : "Please enter your password",
		onfocus     : "Password can not be empty",
		oncorrect   : "Password legal"
	}).inputValidator({
		min         : 1,
		empty       : {
			leftempty  : false,
			rightempty : false,
			emptyerror : "Password on both sides can not be empty symbols"
		},
		onerror     : "Password can not be empty, make sure that"
	});
	$("#password2").formValidator({
		onshow      : "Please enter Re-type password",
		onfocus     : "The two passwords must be consistent",
		oncorrect   : "Password consistent"
	}).inputValidator({
		min         : 1,
		empty       : {
			leftempty  : false,
			rightempty : false,
			emptyerror : "Repeat your password can not be empty symbols on both sides of"
		},
		onerror     : "Repeat password can not be empty, make sure that"
	}).compareValidator({
		desid       : "password1",
		operateor   : "=",
		onerror     : "2 times inconsistent password, make sure that"
	});
	$("#email").formValidator({
		onshow      : "Please enter E-mail",
		onfocus     : "E-mail 6-100 characters",
		oncorrect   : "Enter the correct"
		//defaultvalue: "@",
		//forcevalid  : true
	}).inputValidator({
		min         : 6,
		max         : 100,
		onerror     : "Enter your e-mail the length of Africa and France"
	}).regexValidator({
		regexp      : "^([\\w-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([\\w-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$",
		onerror     : "Enter your e-mail format is not correct"
	});
	
	$("#txtCustomerID").formValidator({
		onshow      : "Please enter a user name",
		onfocus     : "User name 6-16 characters",
		oncorrect   : "The user name can be registered"
	}).inputValidator({
		min         : 6,
		max         : 16,
		onerror     : "Enter your user name illegal"
	})
	$("#txtPassword").formValidator({
		onshow      : "Please enter your password",
		onfocus     : "Password can not be empty",
		oncorrect   : "Password legal"
	}).inputValidator({
		min         : 1,
		empty       : {
			leftempty  : false,
			rightempty : false,
			emptyerror : "Password on both sides can not be empty symbols"
		},
		onerror     : "Password can not be empty, make sure that"
	});
});