/**
 * diamond search
 */
var Diamond = {
	
	_domain : 'http://www.lianhe.org',
	
	_page : 1,
	_pagesize : 20,
	
	_shapeArray : ['圆形','公主方形','祖母绿','方形','女侯爵','椭圆形','发光形','梨形','心形','垫形'],
	_cutArray : ['Ideal','EX','VG','G','Fair'],
	_colorArray : ['D','E','F','G','H','I','J','K','K - Z'],
	_clarityArray : ['FL','IF','VVS1','VVS2','VS1','VS2','SI1','SI2','I1','I2','I3'],
	_polishArray : ['Ideal','EX','VG','G','Fair'],
	_symmetryArray : ['Ideal','EX','VG','G','Fair'],
	
	_shape : '',
	_cut : '',
	_color : '',
	_clarity : '',
	_polish : '',
	_symmetry : '',
	_shopname : '',
	
	_isShowShopList : true,
	
	init : function() {
		View.initShapes();
		View.initCuts();
		View.initColors();
		View.initClarities();
		View.initPolishes();
		View.initSymmetries();
		View.searchDiamon();
		if (this._isShowShopList) View.initShops();
	},
	// change page
	changePage : function(page) {
		this._page = page;
		View.searchDiamon();
	},
	// change shape
	changeShape : function(shape,obj) {
		this._page = 1;
		$(obj).parent().parent().find('li a').removeClass('curItem');
		if (shape != this._shape) {
			this._shape = shape;
			$(obj).addClass('curItem');
		}
		else {
			this._shape = '';
		}
		View.searchDiamon();
	},
	// change cut
	changeCut : function(cut,obj) {
		this._page = 1;
		$(obj).parent().parent().find('li a').removeClass('curItem');
		if (cut != this._cut) {
			this._cut= cut;
			$(obj).addClass('curItem');
		}
		else {
			this._cut = '';
		}
		View.searchDiamon();
	},
	// change color
	changeColor : function(color,obj) {
		this._page = 1;
		$(obj).parent().parent().find('li a').removeClass('curItem');
		if (color != this._color) {
			this._color= color;
			$(obj).addClass('curItem');
		}
		else {
			this._color = '';
		}
		View.searchDiamon();
	},
	// change clarity
	changeClarity : function(clarity,obj) {
		this._page = 1;
		$(obj).parent().parent().find('li a').removeClass('curItem');
		if (clarity != this._clarity) {
			this._clarity= clarity;
			$(obj).addClass('curItem');
		}
		else {
			this._clarity = '';
		}
		View.searchDiamon();
	},
	// change polish
	changePolish : function(polish,obj) {
		this._page = 1;
		$(obj).parent().parent().find('li a').removeClass('curItem');
		if (polish != this._polish) {
			this._polish= polish;
			$(obj).addClass('curItem');
		}
		else {
			this._polish = '';
		}
		View.searchDiamon();
	},
	// change polish
	changeSymmetry : function(symmetry,obj) {
		this._page = 1;
		$(obj).parent().parent().find('li a').removeClass('curItem');
		if (symmetry != this._symmetry) {
			this._symmetry= symmetry;
			$(obj).addClass('curItem');
		}
		else {
			this._symmetry = '';
		}
		View.searchDiamon();
	},
	// change shop
	changeShopName : function(shopname,obj) {
		this._page = 1;
		$(obj).parent().parent().find('li a').removeClass('curItem');
		if (shopname != this._shopname) {
			this._shopname= shopname;
			$(obj).addClass('curItem');
		}
		else {
			this._shopname = '';
		}
		View.searchDiamon();
	}
}