function _gel(a){
	return document.getElementById?document.getElementById(a):null;
}
function _geln(a){
	return document.getElementsByName?document.getElementsByName(a):null;
}
function _gelstn(a){
	return document.getElementsByTagName?document.getElementsByTagName(a):new Array();
}
function getPos(el,sProp) {
	var iPos = 0;
	while (el!=null){
		iPos+=el["offset" + sProp];
		el = el.offsetParent;
	}
	return iPos;
}
function close_option(id){
	_gel(id).style.display='none';
}
function close_options(){
	the_option=the_options.split(",");	
	the_option_num=the_option.length;
	for(var i=0;i<the_option_num-1;i++)
	{
		_gel(the_option[i]).style.display='none';
	}
}

function init_option(the_options){
	the_option=the_options.split(",");	
	the_option_num=the_option.length;
	for(var i=0;i<the_option_num-1;i++)
	{
		_gel(the_option[i]).style.display='none';
	}
}
function show_option(el,id,width,height,left,top){
	var a=_gel(id);
	if (a.style.display=='none')	//显示隐藏层
	{	
		if (left==0 && top==0)		//自动获取坐标
		{
			if((getPos(el,"Left")+350)>window.screen.availWidth){
				left=(window.screen.availWidth-350)+"px";
			}else{
				left=getPos(el,"Left")+"px";
			}
			top=getPos(el,"Top")+el.offsetHeight+2+"px";
		}
		if (width==0)				//设置默认宽度
		{
			width=240;
		}
		if (height==0)				//设置默认高度
		{
			height=100;
		}
		a.style.display='';
		a.style.position="absolute";
		a.style.left=left;
		a.style.top=top;
		a.style.width=width+"px";
		a.style.height=height+"px";
		a.style.backgroundColor="#ffffff";
		a.style.border="2px solid #dedede";
		a.style.zIndex=9996;
		a.style.textAlign="left";
		a.setAttribute("id",id);
		a.style.padding="4px";
		
		the_options_close=the_options.replace(id+",","");
		init_option(the_options_close);					//关闭其他未隐藏的层
	}
}

function select_option_id(id_v,id,name_v,name){
	if(_gel(name)){
		_gel(name).value=name_v;
	}
	if(_gel(id)){
		_gel(id).value=id_v;
	}
}
function search_product()
{
	url = window.location.href;
	urlArr = url.split(".")
	urlP = urlArr[0].replace("richforth","www");
	
	if(_gel("catalog_id").value==""){
		_gel("search_form").action=urlP+".richforth.com/product_search.php?keyword="+_gel("keyword").value+"";
		//_gel("search_form").action="product.php";
		return true;
	}else{
		_gel("search_form").action=urlP+".richforth.com/"+_gel("catalog_id").value+"/product_"+_gel("classid").value+"_1_"+_gel("keyword").value+".shtml";
		//_gel("search_form").action="product.php";
		return true;
	}
}
