//script for hiding parts in a webpage
//add by Felix Ho June 13, 2005
//use in: 
//  searchingtips.tpl in /skin1/customer/main/ 
//  master_product.tpl in /skin1/customer/main/
//  page2.tpl in /skin1/customer/signup/
function expand(thistag) 
{
  styleObj = document.getElementById(thistag).style;
  if (styleObj.display == 'none') 
  {
    styleObj.display = '';
  }
  else 
  {
	styleObj.display = 'none';
  }
}

//script for add to bookmark
//add by Felix Ho June 14, 2005
//use in: 
//  head.tpl in /skin1/
function addBookmark(title, url) 
{
  if (window.sidebar) 
  { 	
    window.sidebar.addPanel(title, url,""); 
  } 
  else if (document.all) 
  {	
    window.external.AddFavorite(url, title);	
  } 
  else if (window.opera && window.print) 
  {
    return true;
  }
}

//script used in login
//add by Felix Ho June 14, 2005
//use in: 
//  cust_login_temp.tpl in /skin1/customer/main/

function submitLogin(event,obj)
{ 
  if (event.keyCode == 13)
  {
	document.errorform.submit();
  }
}

//script used for popup window
//add by Felix Ho June 15, 2005
//use in: 
// head.tpl in /skin1/
function NewWindow(mypage,myname,w,h,scroll)
{
  var win = null;
  LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
  TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
  settings = 'height=' + h + ',width=' + w + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',resizable'
  win = window.open(mypage,myname,settings)
}
//script used for font size changing
//add by Felix Ho July 18, 2005
//use in: 
// head.tpl in /skin1/

//Specify affected tags. Add or remove from list:
var tgs = new Array('p','div','td','tr');

//Specify spectrum of different font sizes:
var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
var startSz = 2;

function ts( trgt,inc ) {
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;
	
	sz += inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 6 ) sz = 6;
	startSz = sz;
		
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

	cEl.style.fontSize = szs[ sz ];

	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
	}
}
//serch box validation created by Eric Mar 27, 2009
function clear_box(txtBox)
{
	if (txtBox.value == '-- Search Drugs --') txtBox.value='';
}
//end of serch box validation;
//serch order form submit validation created by Eric Mar 27, 2009
function search_add_cart(order_form)
{
	if (order_form.productid.value==0)
		{alert('Please select a product from the drop-down menu!');}
	else
		{order_form.submit();}
	
}
//end of search order form submit
//serch function, paging script created by Eric Dec 31, 2009
function search_submit(page)
{
	document.searchm.cur_page.value=page;
	document.searchm.submit();
}
//end of search order form submit
