//my Footer Spry runner
var datasetName = new Spry.Data.XMLDataSet("XMLsource", "XPathToRepeatingChildNode");
var dsPhones = new Spry.Data.XMLDataSet("contact/contact.xml", "items/item");
// END mySpry

//Product Sections Spry
var dsHistology = new Spry.Data.HTMLDataSet(null, "histoTable",{sortOnLoad:"description",sortOrderOnLoad:"ascending",distinctOnLoad:true,useCache:false});
var dsMicrobiology = new Spry.Data.HTMLDataSet(null, "microTable",{sortOnLoad:"description",sortOrderOnLoad:"ascending",distinctOnLoad:true,useCache:false});
var dsHaematology = new Spry.Data.HTMLDataSet(null, "haemaTable",{sortOnLoad:"description",sortOrderOnLoad:"ascending",distinctOnLoad:true,useCache:false});
var dsCytology = new Spry.Data.HTMLDataSet(null, "cytoTable",{sortOnLoad:"description",sortOrderOnLoad:"ascending",distinctOnLoad:true,useCache:false});
var dsDryStains = new Spry.Data.HTMLDataSet(null, "dryTable",{sortOnLoad:"description",sortOrderOnLoad:"ascending",distinctOnLoad:true,useCache:false});
var dsAcids = new Spry.Data.HTMLDataSet(null, "acidTable",{sortOnLoad:"description",sortOrderOnLoad:"ascending",distinctOnLoad:true,useCache:false});
var dsFixatives = new Spry.Data.HTMLDataSet(null, "fixativeTable",{sortOnLoad:"description",sortOrderOnLoad:"ascending",distinctOnLoad:true,useCache:false});
var dsMountant = new Spry.Data.HTMLDataSet(null, "mountTable",{sortOnLoad:"description",sortOrderOnLoad:"ascending",distinctOnLoad:true,useCache:false});
var datasetName = new Spry.Data.XMLDataSet("XMLsource", "XPathToRepeatingChildNode");
//END productSpry Tables

//MSDS Filter-List
var dsMSDS = new Spry.Data.XMLDataSet("msds/list.xml", "items/item",{sortOnLoad:"@id",sortOrderOnLoad:"ascending",distinctOnLoad:true,useCache:false});
//END MSDS List

function newWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function SelectAll(id)
{
    document.getElementById(id).focus();
    document.getElementById(id).select();
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

//Spry Filter
function FilterData()
{
	var tf = document.getElementById("filterTF");
	if (!tf.value)
	{
		// If the text field is empty, remove any filter
		// that is set on the data set.

		dsMSDS.filter(null);
		return;
	}

	// Set a filter on the data set that matches any row
	// that begins with the string in the text field.

	var regExpStr = tf.value;
	
	if (!document.getElementById("containsCB").checked)
		regExpStr = "^" + regExpStr;

	var regExp = new RegExp(regExpStr, "i");
	
	var filterFunc = function(ds, row, rowNumber)
	{
		var str = row["name"];
		if (str && str.search(regExp) != -1)
			return row;
		return null;
	};

	dsMSDS.filter(filterFunc);
}

function StartFilterTimer()
{
	if (StartFilterTimer.timerID)
		clearTimeout(StartFilterTimer.timerID);
	StartFilterTimer.timerID = setTimeout(function() { StartFilterTimer.timerID = null; FilterData(); }, 100);
}


//Standard MX Codings
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

//Switch ALL DIVS OFF
function switchDiv(div_id)
{
  var style_sheet = getStyleObject(div_id);
  if (style_sheet)
  {
    hideAll();
    changeObjectVisibility(div_id, "visible");
  }
  else 
  {
    alert("sorry, this only works in browsers that do Dynamic HTML");
  }
}

/* <input type="radio" name="form_type" value="ez"
  onClick="switchDiv('ez');">*/

function getStyleObject(objectId) {
  // checkW3C DOM, then MSIE 4, then NN 4.
  //
  if(document.getElementById && document.getElementById(objectId)) {
	return document.getElementById(objectId).style;
   }
   else if (document.all && document.all(objectId)) {  
	return document.all(objectId).style;
   } 
   else if (document.layers && document.layers[objectId]) { 
	return document.layers[objectId];
   } else {
	return false;
   }
}

function changeObjectVisibility(objectId, newVisibility) {
    // first get the object's stylesheet
    var styleObject = getStyleObject(objectId);

    // then if we find a stylesheet, set its visibility
    // as requested
    //
    if (styleObject) {
	styleObject.visibility = newVisibility;
	return true;
    } else {
	return false;
    }
}

function hideAll()
{
   changeObjectVisibility("ez","hidden");
   changeObjectVisibility("full","hidden");
   changeObjectVisibility("superduper","hidden");
}
/*This function simply calls changeObjectVisibility() three times, once to hide each DIV containing a form.

Putting this all together, clicking on a radio button calls switchDiv() which hides all the DIVs, using hideAll(), and then shows the appropriate DIV using changeObjectVisibility(). Clicking on another radio button then hides all the DIVs again and shows the DIV you want. 
*/