/**
 * diamond search
 */
var Diamond = {
	
	_domain : 'http://www.lianhe.org',
	
	_page : 1,
	_pagesize : 20,
	
	_shapeArray : ['圆形','公主方形','祖母绿','方形','女侯爵','椭圆形','发光形','梨形','心形','垫形'],
	_cutArray : ['EX','VG','G'],
	_colorArray : ['D','E','F','G','H','I','J','K','K - Z'],
	_clarityArray : ['IF','VVS1','VVS2','VS1','VS2','SI1','SI2'],
	_polishArray : ['EX','VG','G'],
	_symmetryArray : ['EX','VG','G'],
	_shops : '',
	
	_shape : '',
	_cut : '',
	_color : '',
	_clarity : '',
	_polish : '',
	_symmetry : '',
	_shopname : '',
	_weight1 : 0,
	_weight2 : 10,
	_price1: 1000,
	_price2: 1000000,
	_code : '',
	
	_isShowShopList : true,
	_buyLink : '',
	
	init : function() {
		View.initShapes();
		View.initCuts();
		View.initColors();
		View.initClarities();
		View.initPolishes();
		View.initSymmetries();
		View.initWeight();
		View.initPrice();
		if (this._isShowShopList) View.initShops();
		View.searchDiamon();
	},
	// 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();
	},
	// change weight 
	changeWeight : function(weight1,weight2) {
		if (weight1 == this._weight1 && weight2 == this._weight2) return;
		this._page = 1;
		this._weight1 = weight1;
		this._weight2 = weight2;
		View.searchDiamon();
	},
	// change price 
	changePrice : function(price1,price2) {
		if (price1 == this._price1 && price2 == this._price2) return;
		this._page = 1;
		this._price1 = price1;
		this._price2 = price2;
		View.searchDiamon();
	},
	// search code
	searchCode : function() {
		this._code = $('#idSearch').val();
		if (this._code=='') {
			alert('请输入编号');
			$('#idSearch').focus();
			return;
		}
		this._page = 1;
		View.searchDiamon();
	}
}

