//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)
}

// code for rotating images
var interval = 5; // delay between rotating images (in seconds)
var random_display = 0; // 0 = no, 1 = yes
interval *= 1000;

var image_index = 0;
image_list = new Array();
image_list[image_index++] = new imageItem("images/banner1.gif");
image_list[image_index++] = new imageItem("images/banner2.jpg");
image_list[image_index++] = new imageItem("images/banner3.gif");
//image_list[image_index++] = new imageItem("http://javascript.internet.com/img/image-cycler/04.jpg");
var number_of_image = image_list.length;
function imageItem(image_location) {
this.image_item = new Image();
this.image_item.src = image_location;
}
function get_ImageItemLocation(imageObj) {
return(imageObj.image_item.src)
}
function generate(x, y) {
var range = y - x + 1;
return Math.floor(Math.random() * range) + x;
}
function getNextImage() {
if (random_display) {
image_index = generate(0, number_of_image-1);
}
else {
image_index = (image_index+1) % number_of_image;
}
var new_image = get_ImageItemLocation(image_list[image_index]);
return(new_image);
}
function rotateImage(place) {
var new_image = getNextImage();
document[place].src = new_image;
var recur_call = "rotateImage('"+place+"')";
setTimeout(recur_call, interval);
}
//end of code for rotating images
//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
function search_submit(page)
{
	document.searchm.cur_page.value=page;
	document.searchm.submit();
}
//end of search order form submit
	  
