
function scrollLayer(p_obj_name, p_gap_point) 
{ 
    var start_point, end_point, timer; 
    var limit_point,scroll_amount;

    var obj_layer   = document.getElementById(p_obj_name); 
    
    start_point = parseInt(obj_layer.style.top, 10); 
    
    if ( start_point < p_gap_point )    start_point = p_gap_point;
	
		if(document.documentElement.scrollTop)
    	end_point = document.documentElement.scrollTop + p_gap_point; 
   	else
   		end_point = document.body.scrollTop + p_gap_point; 
    limit_point = parseInt(window.document.body.scrollHeight) - parseInt(obj_layer.offsetHeight) -10; 
    
    if ( end_point > limit_point )  end_point = limit_point; 
    if ( start_point != end_point ) 
    {
        scroll_amount = Math.ceil( Math.abs( end_point - start_point ) / 15 ); 
        obj_layer.style.top = parseInt(start_point, 10) + ( ( end_point < start_point ) ? -scroll_amount : scroll_amount ) + "px"; 
    } 
    
    window.setTimeout ("scrollLayer('" + p_obj_name + "', " + p_gap_point + ");", 1); 
} 

function at_show_new_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );
  c.style.display = "block";
}
function at_show_new()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);
  
  c["at_timeout4"] = setTimeout("document.getElementById('"+p.id+"').className=\"select\"", 500);
  c["at_timeout5"] = setTimeout("at_show_new_aux('"+p.id+"', '"+c.id+"')", 500);
  clearTimeout(c["at_timeout2"]);
  c["at_timeout3"] = setTimeout("at_attach3_new('"+p.id+"','"+c.id+"','none')", 500);
}

function at_hide_new()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child"]);
  clearTimeout(c["at_timeout4"]);
  clearTimeout(c["at_timeout5"]);
  clearTimeout(c["at_timeout3"]);
  c["at_timeout2"] = setTimeout("at_attach3_new('"+p.id+"','"+c.id+"','block');", 500);
}

function at_attach3_new(nparent,nchild,see)
{
  if(nparent!='' && nchild!='')
  {
   var np = document.getElementById(nparent);
   var nc = document.getElementById(nchild);
  }
  else
  {
  }
  if(see=='block')
  {
   if(nc) 
    document.getElementById(nc.id).style.display = 'none';
   if(np)
    if(np.className == "select") np.className = "noselect";
  }
  else
  {
  }
}
function at_attach_new(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);
  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  c["at_timeout2"] = 0;
  c["at_timeout3"] = 0;
  c["at_timeout4"] = 0;
  c["at_timeout5"] = 0;
  c.style.display = "none";
  p.onmouseover = at_show_new;
  p.onmouseout  = at_hide_new;
  c.onmouseover = at_show_new;
  c.onmouseout  = at_hide_new;
}

function top_return()
{
	if(document.frmSearch.keyword.value=="")
	{
	 document.frmSearch.keyword.value="請輸入關鍵字或商品序號";
	}
}
function top_search()
{
	if(document.frmSearch.keyword.value=="請輸入關鍵字或商品序號")
	{
	 alert("請輸入關鍵字或商品序號");
	 return false;
	}

	return true;
}

function load_css(url)
{
	try{
		var scripts = document.getElementsByTagName('link');
		s_len = scripts.length;
		if(s_len > 0) {
			for(var i=0;i<s_len;i++){
				if (scripts[i].href == url) {
					return;
				}	
			}
		}
			newScript = document.createElement("link");
			newScript.setAttribute("type", "text/css");
			newScript.setAttribute("rel", "stylesheet");
			newScript.setAttribute("href", url);
			document.getElementsByTagName('head')[0].appendChild(newScript);
	} catch(e) {
		document.write('<link type="text/css" rel="stylesheet" href="' + url + '" />');
	}
}

