//热销商品
function hotSearch(categoryValue,value){
	window.location.href='/index.shtml?method=productSearch&categoryType='+categoryValue+'&hotFlag=0&hotValue='+encodeURI(encodeURI(value))+'&time='+new Date().getTime();
}

//人气排行
function categorySearchByReal(categoryType,value){
	url = "/index.shtml?method=productSearch&categoryType="+categoryType;
	url +="&realFlag=0&realValue="+value+"&time="+new Date().getTime();
	window.location.href=url;
}

//热门造型
function mindImportant(value,categoryType){
   var node = $("#other"+value);
   var productClassId = $("#productClassId").val(); //分类
   var purposeValue = $("#purposeFlag").val();		//种色
   var materialValue = $("#materialFlag").val();	//尺寸
   var priceValue = $("#priceFlag").val();			//价格
   var otherValue = $("#otherFlag").val();			//其他
   var priceValue = $("#priceFlag").val();			//价格
   
   var url = '/index.shtml?method=productSearch&categoryType='+categoryType+'&mindFlag=0&mindActiveX='+value+'&mindValue='+encodeURI(encodeURI(node.attr("title")));
   if(productClassId != '' && productClassId != undefined){
 		url += "&productClassId="+productClassId;
   }
   if(purposeValue != '' && purposeValue != undefined){
 		url += "&purposeFlag="+purposeValue;
 	}
 	if(materialValue != '' && materialValue != undefined){
 		url += "&materialFlag="+materialValue;
 	}
 	if(priceValue != '' && priceValue != undefined){
 		url += "&priceFlag="+priceValue;
 	}
 	if(otherValue != '' && otherValue != undefined){
 		url += "&otherFlag="+otherValue;
 	}
    if(priceValue != '' && priceValue != undefined){
 		url += "&priceFlag="+priceValue;
 	}
  	url += '&time='+new Date().getTime();
   	window.location.href=url;
}
//热门种色
function purposeImportant(value,categoryType){
   var node = $("#other"+value);
   var productClassId = $("#productClassId").val(); //分类
   var mindValue = $("#mindFlag").val();			//造型
   var materialValue = $("#materialFlag").val();	//尺寸
   var priceValue = $("#priceFlag").val();			//价格
   var otherValue = $("#otherFlag").val();			//其他
   var priceValue = $("#priceFlag").val();			//价格
   
   var url = '/index.shtml?method=productSearch&categoryType='+categoryType+'&purposeFlag=0&purposeActiveX='+value+'&purposeValue='+encodeURI(encodeURI(node.attr("title")));
   if(productClassId != '' && productClassId != undefined){
 		url += "&productClassId="+productClassId;
   }
   if(mindValue != '' && mindValue != undefined){
 		url += "&mindFlag="+mindValue;
   }
   if(materialValue != '' && materialValue != undefined){
 		url += "&materialFlag="+materialValue;
   }
   if(priceValue != '' && priceValue != undefined){
 		url += "&priceFlag="+priceValue;
   }
   if(otherValue != '' && otherValue != undefined){
 		url += "&otherFlag="+otherValue;
   }
   if(priceValue != '' && priceValue != undefined){
 		url += "&priceFlag="+priceValue;
   }
   url += '&time='+new Date().getTime();
   window.location.href=url;   
}


//产品造型
function mindSearch(value){
   var node = $("#"+value);
   var categoryValue = $("#categoryType").val();
   var productClassId = $("#productClassId").val(); //分类
   var purposeValue = $("#purposeFlag").val();		//种色
   var materialValue = $("#materialFlag").val();	//尺寸
   var priceValue = $("#priceFlag").val();			//价格
   var otherValue = $("#otherFlag").val();			//其他
   var priceValue = $("#priceFlag").val();			//价格
   
   var url = '/index.shtml?method=productSearch&categoryType='+categoryValue+'&mindFlag=0&mindActiveX='+value+'&mindValue='+encodeURI(encodeURI(node.html()));
   if(productClassId != '' && productClassId != undefined){
 		url += "&productClassId="+productClassId;
   }
   if(purposeValue != '' && purposeValue != undefined){
 		url += "&purposeFlag="+purposeValue;
 	}
 	if(materialValue != '' && materialValue != undefined){
 		url += "&materialFlag="+materialValue;
 	}
 	if(priceValue != '' && priceValue != undefined){
 		url += "&priceFlag="+priceValue;
 	}
 	if(otherValue != '' && otherValue != undefined){
 		url += "&otherFlag="+otherValue;
 	}
    if(priceValue != '' && priceValue != undefined){
 		url += "&priceFlag="+priceValue;
 	}
  	url += '&time='+new Date().getTime();
   	window.location.href=url;
}
//产品种色
function purposeSearch(value){
   var node = $("#"+value);
   var categoryValue = $("#categoryType").val();
   var productClassId = $("#productClassId").val(); //分类
   var mindValue = $("#mindFlag").val();			//造型
   var materialValue = $("#materialFlag").val();	//尺寸
   var priceValue = $("#priceFlag").val();			//价格
   var otherValue = $("#otherFlag").val();			//其他
   var priceValue = $("#priceFlag").val();			//价格
   
   var url = '/index.shtml?method=productSearch&categoryType='+categoryValue+'&purposeFlag=0&purposeActiveX='+value+'&purposeValue='+encodeURI(encodeURI(node.html()));
   if(productClassId != '' && productClassId != undefined){
 		url += "&productClassId="+productClassId;
   }
   if(mindValue != '' && mindValue != undefined){
 		url += "&mindFlag="+mindValue;
   }
   if(materialValue != '' && materialValue != undefined){
 		url += "&materialFlag="+materialValue;
   }
   if(priceValue != '' && priceValue != undefined){
 		url += "&priceFlag="+priceValue;
   }
   if(otherValue != '' && otherValue != undefined){
 		url += "&otherFlag="+otherValue;
   }
   if(priceValue != '' && priceValue != undefined){
 		url += "&priceFlag="+priceValue;
   }
   url += '&time='+new Date().getTime();
   window.location.href=url;   
}

//产品尺寸
function materialSearch(value){
   var node = $("#"+value);
   var categoryValue = $("#categoryType").val();
   var productClassId = $("#productClassId").val(); //分类
   var mindValue = $("#mindFlag").val();			//造型
   var purposeValue = $("#purposeFlag").val();		//尺寸
   var priceValue = $("#priceFlag").val();			//价格
   var otherValue = $("#otherFlag").val();			//其他
   var priceValue = $("#priceFlag").val();			//价格
   
   var url = '/index.shtml?method=productSearch&categoryType='+categoryValue+'&materialFlag=0&materialActiveX='+value+'&materialValue='+encodeURI(encodeURI(node.html()));
   if(productClassId != '' && productClassId != undefined){
 		url += "&productClassId="+productClassId;
   }
   if(mindValue != '' && mindValue != undefined){
 		url += "&mindFlag="+mindValue;
   }
   if(purposeValue != '' && purposeValue != undefined){
 		url += "&purposeFlag="+purposeValue;
   }
   if(priceValue != '' && priceValue != undefined){
 		url += "&priceFlag="+priceValue;
   }
   if(otherValue != '' && otherValue != undefined){
 		url += "&otherFlag="+otherValue;
   }
   if(priceValue != '' && priceValue != undefined){
 		url += "&priceFlag="+priceValue;
   }
   url += '&time='+new Date().getTime();
   window.location.href=url; 
}

//其他
function otherSearch(value){
   var node = $("#"+value);
   var categoryValue = $("#categoryType").val();
   var productClassId = $("#productClassId").val(); //分类
   var purposeValue = $("#purposeFlag").val();		//种色
   var materialValue = $("#materialFlag").val();	//尺寸
   var priceValue = $("#priceFlag").val();			//价格
   var mindValue = $("#mindFlag").val();			//造型
   var priceValue = $("#priceFlag").val();			//价格
   
   var url = '/index.shtml?method=productSearch&categoryType='+categoryValue+'&otherFlag=0&otherActiveX='+value+'&otherValue='+encodeURI(encodeURI(node.html()));
   if(productClassId != '' && productClassId != undefined){
 		url += "&productClassId="+productClassId;
   }
   if(purposeValue != '' && purposeValue != undefined){
 		url += "&purposeFlag="+purposeValue;
 	}
 	if(materialValue != '' && materialValue != undefined){
 		url += "&materialFlag="+materialValue;
 	}
 	if(priceValue != '' && priceValue != undefined){
 		url += "&priceFlag="+priceValue;
 	}
 	if(mindValue != '' && mindValue != undefined){
 		url += "&mindFlag="+mindValue;
    }
    if(priceValue != '' && priceValue != undefined){
 		url += "&priceFlag="+priceValue;
 	}
  	url += '&time='+new Date().getTime();
   	window.location.href=url;
}

//市场售价
function priceSearch(value){
   var node = $("#"+value);
   var categoryValue = $("#categoryType").val();
   var productClassId = $("#productClassId").val(); //分类
   var purposeValue = $("#purposeFlag").val();		//种色
   var materialValue = $("#materialFlag").val();	//尺寸
   var priceValue = $("#priceFlag").val();			//价格
   var mindValue = $("#mindFlag").val();			//造型
   var otherValue = $("#otherFlag").val();			//其他
   
   var url = '/index.shtml?method=productSearch&categoryType='+categoryValue+'&priceFlag=0&priceActiveX='+value+'&priceValue='+encodeURI(encodeURI(node.html()));
   if(productClassId != '' && productClassId != undefined){
 		url += "&productClassId="+productClassId;
   }
   if(purposeValue != '' && purposeValue != undefined){
 		url += "&purposeFlag="+purposeValue;
 	}
 	if(materialValue != '' && materialValue != undefined){
 		url += "&materialFlag="+materialValue;
 	}
 	if(priceValue != '' && priceValue != undefined){
 		url += "&priceFlag="+priceValue;
 	}
 	if(mindValue != '' && mindValue != undefined){
 		url += "&mindFlag="+mindValue;
    }
    if(otherValue != '' && otherValue != undefined){
 		url += "&otherFlag="+otherValue;
 	}
  	url += '&time='+new Date().getTime();
   	window.location.href=url;
}

//热门搜索词
function keywordSearch(value){
   var node = $("#"+value);
   window.location.href='/index.shtml?method=productSearch&keywordFlag=0&keywordActiveX='+value+'&keywordValue='+encodeURI(encodeURI(node.val()))+'&time='+new Date().getTime();
}

//热门分类
function hotcategory(value){
   var node = $("#"+value);
   window.location.href='/index.shtml?method=productSearch&keywordFlag=0&keywordActiveX='+value+'&keywordValue='+encodeURI(encodeURI(node.html()))+'&time='+new Date().getTime();
}

//属性搜索 推荐 最新 热门
function propertySearch(value){
   var categoryValue = $("#categoryType").val();
   var productClassId = $("#productClassId").val(); //分类
   var purposeValue = $("#purposeFlag").val();		//种色
   var materialValue = $("#materialFlag").val();	//尺寸
   var priceValue = $("#priceFlag").val();			//价格
   var mindValue = $("#mindFlag").val();			//造型
   var otherValue = $("#otherFlag").val();			//其他
   
   var url = '/index.shtml?method=productSearch&propertyFlag=0&propertyValue='+value;
   
   if(categoryValue != '' && categoryValue != undefined){
 		url += "&categoryType="+categoryValue;
   }
   if(productClassId != '' && productClassId != undefined){
 		url += "&productClassId="+productClassId;
   }
   if(purposeValue != '' && purposeValue != undefined){
 		url += "&purposeFlag="+purposeValue;
 	}
 	if(materialValue != '' && materialValue != undefined){
 		url += "&materialFlag="+materialValue;
 	}
 	if(priceValue != '' && priceValue != undefined){
 		url += "&priceFlag="+priceValue;
 	}
 	if(mindValue != '' && mindValue != undefined){
 		url += "&mindFlag="+mindValue;
    }
    if(otherValue != '' && otherValue != undefined){
 		url += "&otherFlag="+otherValue;
 	}
  	url += '&time='+new Date().getTime();
   	window.location.href=url;
}

function propertySearchT(value,categoryValue){
   var productClassId = $("#productClassId").val(); //分类
   var purposeValue = $("#purposeFlag").val();		//种色
   var materialValue = $("#materialFlag").val();	//尺寸
   var priceValue = $("#priceFlag").val();			//价格
   var mindValue = $("#mindFlag").val();			//造型
   var otherValue = $("#otherFlag").val();			//其他
   
   var url = '/index.shtml?method=productSearch&propertyFlag=0&propertyValue='+value;
   
   if(categoryValue != '' && categoryValue != undefined){
 		url += "&categoryType="+categoryValue;
   }
   if(productClassId != '' && productClassId != undefined){
 		url += "&productClassId="+productClassId;
   }
   if(purposeValue != '' && purposeValue != undefined){
 		url += "&purposeFlag="+purposeValue;
 	}
 	if(materialValue != '' && materialValue != undefined){
 		url += "&materialFlag="+materialValue;
 	}
 	if(priceValue != '' && priceValue != undefined){
 		url += "&priceFlag="+priceValue;
 	}
 	if(mindValue != '' && mindValue != undefined){
 		url += "&mindFlag="+mindValue;
    }
    if(otherValue != '' && otherValue != undefined){
 		url += "&otherFlag="+otherValue;
 	}
  	url += '&time='+new Date().getTime();
   	window.location.href=url;
}


//首页搜索
function indexSearch(){
	var fieldNode = $("select[@id='field'] option[@selected]"); 
	var searchNode = $("#searchValue");
	if(searchNode.val() == '' || searchNode.val() == undefined || searchNode.val() == '请输入关键词'){
		alert('请输入搜索关键词');
		return ;
	}
	window.location.href='/index.shtml?method=productSearch&fieldValue='+fieldNode.val()+'&searchFlag=0&searchValue='+encodeURI(encodeURI(searchNode.val()))+'&time='+new Date().getTime();
}

//高级搜索
function expertSearch(){
	var expertValue = $("#expert_keyword").val();
	var categoryNode = $("select[@id='expert_category'] option[@selected]"); 
	var natureNode = $("select[@id='expert_nature'] option[@selected]"); 
	var natureValueNode = $("select[@id='natureValue'] option[@selected]"); 
	var min = $("#min_price").val();
	var max = $("#max_price").val();
	if(expertValue == '' || expertValue == undefined){
		alert('请输入搜索关键词');
		return ;
	}
	
	var url = '/index.shtml?method=productSearch&categoryValue='+categoryNode.val()+'&natureValue='+natureNode.val()+'&minValue='+min+'&maxValue='+max+'&expertFlag=0&expertValue='+encodeURI(encodeURI(expertValue));
	if(natureValueNode.val() != '' && natureValueNode != undefined){
		url += '&siftValue='+encodeURI(encodeURI(natureValueNode.val()));
	}
	url += '&time='+new Date().getTime();
	
	window.location.href=url;
}

function expertChange(){
	var natureNode = $("select[@id='expert_nature'] option[@selected]"); 
	var spanNode = $("#nature_span");
	if(natureNode.val() != '' && natureNode != undefined){
		//加载筛选词
		$.ajax({
			type: "POST",
				url: "/index.shtml?method=sift"+"&time="+new Date().getTime(),
				data:"type="+natureNode.val(),
				dataType:"json",
				async:false,
					success: function(msg){ 						
						if(msg == ''){
						
						}else{
						
						    var select = $("<select id='natureValue' name='natureValue'></select>");
														
							//根据返回的json 添加到HTML中
							for(var i=0; i<msg.length; i++) {
							  $("<option value='"+msg[i].name+"'>"+msg[i].name+"</option>").appendTo(select);	
							}
							spanNode.html("");
							select.appendTo(spanNode);
						}
				 	} 
		});
	}else{
		spanNode.html("");
	}
}

//价格排序
function sortSearch(value){
 	var categoryType = $("#categoryType").val();
 	var mindValue = $("#mindFlag").val();
 	var purposeValue = $("#purposeFlag").val();
 	var materialValue = $("#materialFlag").val();
 	var priceValue = $("#priceFlag").val();
 	var otherValue = $("#otherFlag").val();
 	var keywordValue = $("#keywordFlag").val();
 	var searchValue = $("#searchFlag").val();
 	var fieldValue = $("#fieldValue").val();
 	var propertyFlag = $("#propertyFlag").val();
    var expertFlag = $("#expertFlag").val();
 	var categoryValue = $("#categoryValue").val();
 	var natureValue = $("#natureValue").val();
 	var minValue = $("#minValue").val();
 	var maxValue = $("#maxValue").val();
 	//var hotValue = $("#hotFlag").val();
 	var productClassId = $("#productClassId").val();
 	
 	url = "/index.shtml?method=productSearch&categoryType="+categoryType;
 	
 	if(mindValue != '' && mindValue != undefined){
 		url += "&mindFlag="+mindValue;
 	}
 	if(purposeValue != '' && purposeValue != undefined){
 		url += "&purposeFlag="+purposeValue;
 	}
 	if(materialValue != '' && materialValue != undefined){
 		url += "&materialFlag="+materialValue;
 	}
 	if(priceValue != '' && priceValue != undefined){
 		url += "&priceFlag="+priceValue;
 	}
 	if(otherValue != '' && otherValue != undefined){
 		url += "&otherFlag="+otherValue;
 	}
 	if(keywordValue != '' && keywordValue != undefined){
 		url += "&keywordFlag="+keywordValue;
 	}
 	
 	if(propertyFlag != '' && propertyFlag != undefined){
 		url += "&propertyFlag="+propertyFlag;
 	}
 	if(fieldValue != '' && fieldValue != undefined && searchValue != '' && searchValue != undefined){
 		url += "&searchFlag="+searchValue+"&fieldValue="+fieldValue;
 	}
 	
 	if(expertFlag != '' && expertFlag != undefined && categoryValue != undefined && natureValue != undefined && minValue != undefined && maxValue != undefined){
 		url += "&expertFlag="+expertFlag+"&categoryValue="+categoryValue+"&natureValue="+natureValue+"&minValue="+minValue+"&maxValue="+maxValue;
 	}
 	
 	//if(hotValue != '' && hotValue != undefined){
 	//	url += "&hotFlag="+hotValue;
 	//}
 	
 	if(productClassId != '' && productClassId != undefined){
 		url += "&productClassId="+productClassId;
 	}
 	
 	
 	url +="&sortFlag=0&sortValue="+value+"&time="+new Date().getTime();
	window.location.href=url;
}


//创建时间排序
function dateSearch(value){
 	var categoryType = $("#categoryType").val();
 	var mindValue = $("#mindFlag").val();
 	var purposeValue = $("#purposeFlag").val();
 	var materialValue = $("#materialFlag").val();
 	var priceValue = $("#priceFlag").val();
 	var otherValue = $("#otherFlag").val();
 	var keywordValue = $("#keywordFlag").val();
 	var searchValue = $("#searchFlag").val();
 	var fieldValue = $("#fieldValue").val();
 	var expertFlag = $("#expertFlag").val();
 	var categoryValue = $("#categoryValue").val();
 	var natureValue = $("#natureValue").val();
 	var minValue = $("#minValue").val();
 	var maxValue = $("#maxValue").val();
 	var propertyFlag = $("#propertyFlag").val();
 	var productClassId = $("#productClassId").val();
 	
 	//var hotValue = $("#hotFlag").val();
 	
 	
 	url = "/index.shtml?method=productSearch&categoryType="+categoryType;
 	
 	if(mindValue != '' && mindValue != undefined){
 		url += "&mindFlag="+mindValue;
 	}
 	if(purposeValue != '' && purposeValue != undefined){
 		url += "&purposeFlag="+purposeValue;
 	}
 	if(materialValue != '' && materialValue != undefined){
 		url += "&materialFlag="+materialValue;
 	}
 	if(priceValue != '' && priceValue != undefined){
 		url += "&priceFlag="+priceValue;
 	}
 	if(otherValue != '' && otherValue != undefined){
 		url += "&otherFlag="+otherValue;
 	}
 	if(keywordValue != '' && keywordValue != undefined){
 		url += "&keywordFlag="+keywordValue;
 	}
 	if(propertyFlag != '' && propertyFlag != undefined){
 		url += "&propertyFlag="+propertyFlag;
 	}
 	if(fieldValue != '' && fieldValue != undefined && searchValue != '' && searchValue != undefined){
 		url += "&searchFlag="+searchValue+"&fieldValue="+fieldValue;
 	}
 	if(expertFlag != '' && expertFlag != undefined && categoryValue != undefined && natureValue != undefined && minValue != undefined && maxValue != undefined){
 		url += "&expertFlag="+expertFlag+"&categoryValue="+categoryValue+"&natureValue="+natureValue+"&minValue="+minValue+"&maxValue="+maxValue;
 	}
 	//if(hotValue != '' && hotValue != undefined){
 	//	url += "&hotFlag="+hotValue;
 	//}
 	if(productClassId != '' && productClassId != undefined){
 		url += "&productClassId="+productClassId;
 	}
 	url +="&dateFlag=0&dateValue="+value+"&time="+new Date().getTime();
	window.location.href=url;
}

//点击率
function realSearch(value){
 	var categoryType = $("#categoryType").val();
 	var mindValue = $("#mindFlag").val();
 	var purposeValue = $("#purposeFlag").val();
 	var materialValue = $("#materialFlag").val();
 	var priceValue = $("#priceFlag").val();
 	var otherValue = $("#otherFlag").val();
 	var keywordValue = $("#keywordFlag").val();
 	var searchValue = $("#searchFlag").val();
 	var fieldValue = $("#fieldValue").val();
 	var expertFlag = $("#expertFlag").val();
 	var categoryValue = $("#categoryValue").val();
 	var natureValue = $("#natureValue").val();
 	var minValue = $("#minValue").val();
 	var maxValue = $("#maxValue").val();
 	var propertyFlag = $("#propertyFlag").val();
	//var hotValue = $("#hotFlag").val();
	var productClassId = $("#productClassId").val();
	
 	url = "/index.shtml?method=productSearch&categoryType="+categoryType;
 	
 	if(mindValue != '' && mindValue != undefined){
 		url += "&mindFlag="+mindValue;
 	}
 	if(purposeValue != '' && purposeValue != undefined){
 		url += "&purposeFlag="+purposeValue;
 	}
 	if(materialValue != '' && materialValue != undefined){
 		url += "&materialFlag="+materialValue;
 	}
 	if(priceValue != '' && priceValue != undefined){
 		url += "&priceFlag="+priceValue;
 	}
 	if(otherValue != '' && otherValue != undefined){
 		url += "&otherFlag="+otherValue;
 	}
 	if(keywordValue != '' && keywordValue != undefined){
 		url += "&keywordFlag="+keywordValue;
 	}
 	if(propertyFlag != '' && propertyFlag != undefined){
 		url += "&propertyFlag="+propertyFlag;
 	}
 	if(fieldValue != '' && fieldValue != undefined && searchValue != '' && searchValue != undefined){
 		url += "&searchFlag="+searchValue+"&fieldValue="+fieldValue;
 	}
 	if(expertFlag != '' && expertFlag != undefined && categoryValue != undefined && natureValue != undefined && minValue != undefined && maxValue != undefined){
 		url += "&expertFlag="+expertFlag+"&categoryValue="+categoryValue+"&natureValue="+natureValue+"&minValue="+minValue+"&maxValue="+maxValue;
 	}
 	//if(hotValue != '' && hotValue != undefined){
 	//	url += "&hotFlag="+hotValue;
 	//}
 	if(productClassId != '' && productClassId != undefined){
 		url += "&productClassId="+productClassId;
 	}
 	url +="&realFlag=0&realValue="+value+"&time="+new Date().getTime();
	window.location.href=url;
}



//select跳转
function skipMethod(value){
	var categoryType = $("#categoryType").val();
	if(value == 1){
		window.location.href='/index/productList/'+categoryType+'.html';
	}else if(value == 2){
		sortSearch('asc');
	}else if(value == 3){
		sortSearch('desc')
	}else if(value == 4){
		dateSearch('desc');
	}else if(value == 5){
		realSearch('desc');
	}
}

