// ********************************************************************************************************
// ** General functions                                                                                  **
// ********************************************************************************************************


  function show(id)
    {
     if (document.getElementById)
      {
      obj = document.getElementById(id);
      obj.style.display = '';
      }
    }

  function hide(id)
    {
     if (document.getElementById)
      {
      obj = document.getElementById(id);
      obj.style.display = 'none';
      }
    }



function showhide(id,image)
  {
  if (document.getElementById)
    {
    obj = document.getElementById(id);
    if (obj.style.display == 'none')
      {
      obj.style.display = '';
      document.images[image].src = "iconz/switch.on.gif";
      } 
    else 
      {
      obj.style.display = 'none';
      document.images[image].src = "iconz/switch.off.gif"; 
      }
    }
  }

      

function toggle(id_1,id_2,image)
  {
  if (document.getElementById)
    {
    obj = document.getElementById(id_1);    
    obk = document.getElementById(id_2);
    if (obj.style.display == 'none')
      {
      obj.style.display = '';
      obk.style.display = 'none';
      document.images[image].src = "iconz/switch.off.gif";
      } 
    else 
      {
      obj.style.display = 'none';
      obk.style.display = '';
      document.images[image].src = "iconz/switch.on.gif"; 
      }
    }
  }

      
function showhideToggle(id_1,id_2)
  {
  if (document.getElementById)
    {
    obj = document.getElementById(id_1);
    obk = document.getElementById(id_2);
    obj.style.display = '';
    obk.style.display = 'none';
    }
  }

      
function showhideCat(someClass,image)
  {
  var thisClass = getElementsByClassName(document, "*", someClass);
  // this loops thru the array and sets the style you want
  for (var i=0; i < thisClass.length; i++)
    {
    if (thisClass[i].style.display == 'none')
      {
      thisClass[i].style.display = '';
      //document.images[image].src = "../iconz/arrow.up.gif";
      document.images[image].src = "iconz/switch.on.gif";
      } 
    else 
      {
      thisClass[i].style.display = 'none';
      document.images[image].src = "iconz/switch.off.gif"; 
      //document.images[image].src = "../iconz/arrow.down.gif"; 
      }
    }
  }
      
      
function getElementsByClassName(oElm, strTagName, strClassName)
  {
  var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
  var arrReturnElements = new Array();
  strClassName = strClassName.replace(/-/g, "\-");
  var oRegExp = new RegExp("(^|\s)" + strClassName + "(\s|$)");
  var oElement;
  for(var i=0; i<arrElements.length; i++)
    {
	oElement = arrElements[i];
	if(oRegExp.test(oElement.className))
      {
	  arrReturnElements.push(oElement);
	  }
	}
  return (arrReturnElements)
  }
  
  
      
function autoPrint() 
  {
  window.print();
  window.close();  
  }
  
  
  
  



  
function verify()
  {
  msg = "Are you sure you want to delte this record?";
  return confirm(msg);
  }
  

function verifyPassword()
  {
  msg = "Are you sure you want to reset this password?";
  return confirm(msg);
  }
  
  
function verifyAction(thisAction)
  {
  msg = "Are you sure you want to " + thisAction + "?";
  return confirm(msg);
  }

  
function send()
   {document.form1.submit()}
   
   
   
 
/***********************************************************************************
*
* cookie stuff
*
***********************************************************************************/

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function eraseCookie(name) {
  createCookie(name,"",-1);
}
 

function mailCart(prodID,qty,price)
  {
  var f = readCookie('mailCart');
  var newf = f + '^' + prodID + '~' + qty;
  creatCookie(mailCart,newf,7); 
  } 
 
 
 
 
  
// ********************************************************************************************************
// ** Table row functions                                                                                **
// ********************************************************************************************************
	var arrayOfRolloverClasses = new Array();
	var arrayOfClickClasses = new Array();
	var activeRow = false;
	var activeRowClickArray = new Array();
	
	function highlightTableRow()
	{
		var tableObj = this.parentNode;
		if(tableObj.tagName!='TABLE')tableObj = tableObj.parentNode;

		if(this!=activeRow){
			this.setAttribute('origCl',this.className);
			this.origCl = this.className;
		}
		this.className = arrayOfRolloverClasses[tableObj.id];
		
		activeRow = this;
		
	}
	
	function clickOnTableRow()
	{
		var tableObj = this.parentNode;
		if(tableObj.tagName!='TABLE')tableObj = tableObj.parentNode;		
		
		if(activeRowClickArray[tableObj.id] && this!=activeRowClickArray[tableObj.id]){
			activeRowClickArray[tableObj.id].className='';
		}
		this.className = arrayOfClickClasses[tableObj.id];
		
		activeRowClickArray[tableObj.id] = this;
				
	}
	
	function resetRowStyle()
	{
		var tableObj = this.parentNode;
		if(tableObj.tagName!='TABLE')tableObj = tableObj.parentNode;

		if(activeRowClickArray[tableObj.id] && this==activeRowClickArray[tableObj.id]){
			this.className = arrayOfClickClasses[tableObj.id];
			return;	
		}
		
		var origCl = this.getAttribute('origCl');
		if(!origCl)origCl = this.origCl;
		this.className=origCl;
		
	}
		
	function addTableRolloverEffect(tableId,whichClass,whichClassOnClick)
	{
		arrayOfRolloverClasses[tableId] = whichClass;
		arrayOfClickClasses[tableId] = whichClassOnClick;
		
		var tableObj = document.getElementById(tableId);
		var tBody = tableObj.getElementsByTagName('TBODY');
		if(tBody){
			var rows = tBody[0].getElementsByTagName('TR');
		}else{
			var rows = tableObj.getElementsByTagName('TR');
		}
		for(var no=0;no<rows.length;no++){
			rows[no].onmouseover = highlightTableRow;
			rows[no].onmouseout = resetRowStyle;
			
			if(whichClassOnClick){
				rows[no].onclick = clickOnTableRow;	
			}
		}
		
	}



// datetime parsing and formatting routimes. modify them if you wish other datetime format
function str2dt4 (str_datetime) {
        var re_date = /^(\d+)\/(\d+)\/(\d+)$/;
        if (!re_date.exec(str_datetime))
                return alert("Invalid Datetime format: "+ str_datetime);
        return (new Date (RegExp.$3, RegExp.$1-1, RegExp.$2));
}



function dt2dtstr4 (dt_datetime) {
        return (new String (
                        (dt_datetime.getMonth()+1)+"/"+dt_datetime.getDate()+"/"+dt_datetime.getFullYear()));
}







