//图片控制
function fixImage(i, w, h)
{
	var ow = i.width;
	var oh = i.height;
	var rw = w / ow;
	var rh = h / oh;
	var r = Math.min(rw, rh);
	if (w == 0 && h == 0)
	{
		r = 1;
	} else if (w == 0)
	{
		r = rh < 1 ? rh : 1;
	} else if (h == 0)
	{
		r = rw < 1 ? rw : 1;
	}
	if (ow != 0 && oh != 0)
	{
		i.width = ow * r;
		i.height = oh * r;
	} else
	{
		var __method = this, args = $A(arguments);
		window.setTimeout(function()
		{
			fixImage.apply(__method, args);
		}, 200);
	}
	i.onload = function() { }
}

function search()
{
	if (event.keyCode == 13)
	{
		location.href("search.html?keyword=" + $("#searchBox").val());
	}
}



function MaxImage(i, w, h)
{
	var ow = i.width;
	var oh = i.height;
	var rw = w / ow;
	var rh = h / oh;
	var r = Math.max(rw, rh)
	if (w == 0 && h == 0)
	{
		r = 1;
	} else if (w == 0)
	{
		r = rh < 1 ? rh : 1;
	} else if (h == 0)
	{
		r = rw < 1 ? rw : 1;
	}
	if (ow != 0 && oh != 0)
	{
		i.width = ow * r;
		i.height = oh * r;
	} else
	{
		var __method = this, args = $A(arguments);
		window.setTimeout(function()
		{
			MaxImage.apply(__method, args);

		}, 200)

	}
	i.onload = function() { }
}

//推荐最新新闻产品图片显示隐藏
function display_new(obj)
{ 
	if(obj.checked){
	document.all.focus_tr.style.display = "";
	}
	else{
	document.all.focus_tr.style.display = "none";
	}
}
//栏目推荐产品
function display_recommend(obj)
{ 
	if(obj.checked){
		document.all.recommend_tr.style.display = "";
	}
	else{
		document.all.recommend_tr.style.display = "none";
	}
}
//点击切换Ele显示隐藏
function SwitchEle(id)
{
	if ($("#" + id).css("display")=="none")
	{
		$("#" + id).show();
	}
	else
	{
		$("#" + id).hide();	
	}
}

function SwitchClass(cl)
{
	$(".SecondTr").hide();
	if ($("." + cl).css("display") == "none")
	{
		$("." + cl).show();
	} 
	else
	{
		$("." + cl).hide();
	}
}

Function.prototype.getMultiline = function()
{
	var lines = new String(this);
	lines = lines.substring(lines.indexOf("/*\r\n") + 4, lines.lastIndexOf("*/"));
	return lines;
}

String.prototype.trimAll = function()
{
	return this.replace(/(^\s*)|(\s*)|(\s*$)/g, "");
};

String.prototype.replacePlus = function()
{
	return this.replace(/\+/,"");
};


/*标签切换方法 end*/

function changetab(para, para2)//para为当前点击标签，para2为总的标签数
{
	for (var i = 1; i <= para2; i++)//设置其他标签样式
	{
		if (i != para)
		{
			$("#content" + i).css("display", "none");
			$("#tab" + i).removeClass("one");
			//$("#tab"+i).addClass("");
		}
	}
	$("#content" + para).css("display", "");
	//$("#tab"+para).removeClass("");
	$("#tab" + para).addClass("one");
}


function addDate(obj)
{
	$(obj).prev("input").val($(obj).val());
}
