var galdenURL = "http://mall.taosteel.com";
function gotoGaldenURL(urlString, notUnescape){
	if(notUnescape){
		//alert(galdenURL + urlString);
		//window.location.href=galdenURL + urlString;
		location.replace(galdenURL + urlString);
	}else{
		window.location.href=galdenURL + unescape(urlString);
	}
}
function openGaldenURL(urlString, notUnescape){
	/*
	var fulls = "left=0,screenX=0,top=0,screenY=0,scrollbars=1";    //定义弹出窗口的参数
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		fulls += ",height=" + ah;
		fulls += ",innerHeight=" + ah;
		fulls += ",width=" + aw;
		fulls += ",innerWidth=" + aw;
		fulls += ",resizable"
	} else {
		fulls += ",resizable"; // 对于不支持screen属性的浏览器，可以手工进行最大化。 manually
	}
	*/
	if(notUnescape){
		window.open(galdenURL + urlString, '_blank');
	}else{
		window.open(galdenURL + unescape(urlString), '_blank');
	}
}
function include_abc(path){     
      var sobj = document.createElement('script'); 
      sobj.type = "text/javascript"; 
      sobj.src = path; 
      var headobj = document.getElementsByTagName('head')[0]; 
      headobj.appendChild(sobj);
}


//回车
$(function(){
	$("#searchText").keydown(function(event){
		if(event.keyCode == 13){
		 //alert('Enter');
		 searchSubmit();
		}
	});
});

function searchSubmit(){
	
	if (searchType=="pro"){
		gotoGaldenURL("/b-0-s/resouceBuy.do?method=queryResource&cxlx=2&keyword=" + escape(escape($("#searchText").val())), true);
	}
	else if (searchType=="shop")
	{
		gotoGaldenURL("/shopinfo.do?tab=wssc&cxlx=4&keyword=" + escape(escape($("#searchText").val())), true);
	}
	else
	{
		
		var txt = $("#searchText").val();
		sendAjax("path=/toSupllyPortalInfo.do&method=querySpuByGdm&gdm="+txt,load_,notfind);   
	}
}

function load_(){
	$("#msg").show().html("搜索数据提交中...").fadeOut(5000);
}
function notfind(obj){
	if(obj.gdm == "close"){
		$("#msg").show().html("该会员没有开通商铺").fadeOut(5000);
		return;
	}
	else if
	(obj.gdm == "notfind"){
		$("#msg").show().html("没有您所查询的淘钢通").fadeOut(5000);
		return;
	}
	gotoGaldenURL("/" + obj.gdm, true);
}


var searchType = "pro";
$(function(){
	//顶部模糊搜索
	$("#chk_pro").click(function(){
		$("#chk_pro").addClass("current");
		$("#chk_shop").removeClass();
		$("#chk_gdm").removeClass();
		$("#searchText").val("螺纹钢");
		searchType = "pro";
	});
	$("#chk_shop").click(function(){
		$("#chk_pro").removeClass();
		$("#chk_gdm").removeClass();
		$("#chk_shop").addClass("current");
		$("#searchText").val("店铺名称");
		searchType = "shop";
	});
	$("#chk_gdm").click(function(){
		$("#chk_pro").removeClass();
		$("#chk_shop").removeClass();
		$("#chk_gdm").addClass("current");
		$("#searchText").val("淘钢通");
		searchType = "gdm";
	});

	$("#searchSubmit").click(searchSubmit);

	
	$("#searchText").focus(function(){
		$(this).val("").css("color","#666");	  
	});

});

