// global JS functions

function isNullEmpty(str)
{
  if ((str == null) || (str == ""))
  {
    return true;
  }
  else
  {
    return false;
  }
}

function rollover(index, inOut, imageRef)
{
	var images = new Array();
	var hovers = new Array();

	// build arrays
	images[0] = "images/buttons/btn_home.gif";
	hovers[0] = "images/buttons/btn_home_over.gif";
	images[1] = "images/buttons/btn_about.gif";
	hovers[1] = "images/buttons/btn_about_over.gif";
	images[2] = "images/buttons/btn_services.gif";
	hovers[2] = "images/buttons/btn_services_over.gif";
	images[3] = "images/buttons/btn_locations.gif";
	hovers[3] = "images/buttons/btn_locations_over.gif";
	images[4] = "images/buttons/btn_contact.gif";
	hovers[4] = "images/buttons/btn_contact_over.gif";

	if (inOut == 'in')
	{
		imageRef.src = hovers[index];
	}
	else
	{
		imageRef.src = images[index];
	}
}

function swapDivBGColor(id, color)
{
  element = document.getElementById(id);
  // event.cancelBubble = true;
  element.style.background = color;
}

function swapPainImages(boxId)
{

    var imageRef = document.getElementById("painImage");
    if (boxId == "neck")
    {
        imageRef.src = "images/neck_pain.jpg";
    }
    else if (boxId == "back")
    {
        imageRef.src = "images/back_pain.jpg";
    }
    else if (boxId == "headache")
    {
        imageRef.src = "images/headache_pain.jpg";
    }
    else if (boxId == "auto")
    {
        imageRef.src = "images/auto_accident.jpg";
    }
}

function newWin(url, pHeight, pWidth)
{
    var myWin = window.open(url, "tinyWindow", 'toolbar=false,resizeable=yes,scrollbars=yes,width=' + pWidth + ',height=' + pHeight);
    myWin.focus();
}

function isNullEmpty(str)
{
  if ((str == null) || (str == ""))
  {
    return true;
  }
  else
  {
    return false;
  }
}

function GetXmlHttpObject(handler)
{
    var objXMLHttp=null
    if (window.XMLHttpRequest)
    {
        objXMLHttp=new XMLHttpRequest()
    }
    else if (window.ActiveXObject)
    {
        objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
    }
    return objXMLHttp
}

function rollover(index, inOut, imageRef)
{
	var images = new Array();
	var hovers = new Array();
	
	// build arrays
	images[0] = "images/buttons/btn_home.gif";
	hovers[0] = "images/buttons/btn_home_over.gif";
	images[1] = "images/buttons/btn_about.gif";
	hovers[1] = "images/buttons/btn_about_over.gif";
	images[2] = "images/buttons/btn_services.gif";
	hovers[2] = "images/buttons/btn_services_over.gif";
	images[3] = "images/buttons/btn_locations.gif";
	hovers[3] = "images/buttons/btn_locations_over.gif";
	images[4] = "images/buttons/btn_contact.gif";
	hovers[4] = "images/buttons/btn_contact_over.gif";
	
	if (inOut == 'in')
	{
		imageRef.src = hovers[index];
	}
	else
	{
		imageRef.src = images[index];
	}
}

function swapDivBGColor(id, color)
{
  element = document.getElementById(id);
  // event.cancelBubble = true;
  element.style.background = color;
}

function swapPainImages(boxId)
{
  
    var imageRef = document.getElementById("painImage");
    if (boxId == "neck")
    {
        imageRef.src = "images/neck_pain.jpg";
    }
    else if (boxId == "back")
    {
        imageRef.src = "images/back_pain.jpg";
    }
    else if (boxId == "headache")
    {
        imageRef.src = "images/headache_pain.jpg";
    }
    else if (boxId == "auto")
    {
        imageRef.src = "images/auto_accident.jpg";
    }
}

function newWin(url, pHeight, pWidth)
{
    var myWin = window.open(url, "tinyWindow", 'toolbar=false,resizeable=yes,scrollbars=yes,width=' + pWidth + ',height=' + pHeight);
}

function isNullEmpty(str)
{
  if ((str == null) || (str == ""))
  {
    return true;
  }
  else
  {
    return false;
  }
}


function updateDiv(divId, content) {
	var theDiv = document.getElementById(divId);
	if (theDiv != null && content != null) {
		theDiv.innerHTML = content;	
	}
}

function validateHPSearch() {
	var formRef = document.findChiroForm;
	var stateDDL = formRef.selectState;
	var cityDDL = formRef.selectCity;
	if (stateDDL.options.selectedIndex == 0 && cityDDL.options.selectedIndex == 0) {
		alert("Please select a state and city.");
		return false;
	} 
	else if (stateDDL.options.selectedIndex == 0 && cityDDL.options.selectedIndex != 0) {
		alert("Please select a state.");
		return false;
	}
	else if (stateDDL.options.selectedIndex != 0 && cityDDL.options.selectedIndex == 0) {
		alert("Please select a city.");
		return false;
	}
	return true;
}

function validateLocationsSearch(ddlRef) {
	alert(ddlRef.options.selectedIndex);
	if (ddlRef.options.selectedIndex == 0) {
		alert("Please select a city.");
		return false;
	} 
	return true;
}
