function toggleSelected(id) {
	if (document.getElementById(id).style.display == 'none') {
		document.getElementById(id).style.display = 'block';
	}
	else {
		document.getElementById(id).style.display = 'none';
	}
}
function HideContent(d) {
    if(d.length < 1) { return; }
    document.getElementById(d).style.visibility = "hidden";
}
function ShowContent(d) {
    if(d.length < 1) { return; }
    document.getElementById(d).style.visibility = "visible";
}
function ReverseContentDisplay(d) {
    if(d.length < 1) { return; }
    if(document.getElementById(d).style.visibility == "hidden") { document.getElementById(d).style.visibility = "visible"; }
    else { document.getElementById(d).style.visibility = "hidden"; }
}
function KillContent(d) {
    if(d.length < 1) { return; }
    document.getElementById(d).style.display = "none";
}
function DisplayContent(d) {
    if(d.length < 1) { return; }
    document.getElementById(d).style.display = "block";
}

function hideDiv(id)
{
   document.getElementById(id).style.display = 'none';
}

function changeDivBGround(imgName) {
	document.getElementById('container').style.backgroundImage = "url("+imgName+")";
}

function doClear(theText) {
     if (theText.value == theText.defaultValue) {
         theText.value = ""
     }
}

//function to check total number of checkBoxes that are checked in a form
function countChecks(box,form,formName) 
{
    var numCompare = 0;
    var els = document.forms[formName].getElementsByTagName('input');
    for (var i=0; i < els.length; ++i)
    {
    var e = els[i];
    if (e.type == 'checkbox'
    && e.checked)
    ++numCompare;
    }
    //return the number of checked
    //alert('You can only compare up to ' + numCompare + ' care homes at a time');
    if(numCompare > 3)
    {
	    numCompare = numCompare - 1;
	    alert('You can only compare up to ' + numCompare + ' care homes at a time');
	    box.checked = false;
    }
    return numCompare
}

function showHome(HomeID)
{
	document.getElementById(HomeID).style.display = 'block';
}

function hideHome(HomeID)
{
	document.getElementById(HomeID).style.display = 'none';
}

function showFeature(Feature, popup, e)
{
	if(popup == 3){
		var posx = 0;
		var posy = 0;
		if (!e) var e = window.event;
		if (e.pageX || e.pageY) 	{
			posx = e.pageX;
			posy = e.pageY;
		}
		else if (e.clientX || e.clientY) 	{
			posx = e.clientX + document.body.scrollLeft
				+ document.documentElement.scrollLeft;
			posy = e.clientY + document.body.scrollTop
				+ document.documentElement.scrollTop;
		}
		
		document.getElementById('featureshelper3').style.left = posx + "px";
		document.getElementById('featureshelper3').style.top = (posy-15) + "px";
	}
	switch(Feature)
	{
		case 'pets':
			document.getElementById('featureshelper'+popup).innerHTML = '<img src="images/icon_pets.gif" align="left" style="margin-right:5px;">This icon shows whether the selected care home allows you to have your own pets whilst you stay there.';
			break;
		case 'garden':
			document.getElementById('featureshelper'+popup).innerHTML = '<img src="images/icon_flower.gif" align="left" style="margin-right:5px;">This icon shows whether the selected care home has its own private garden for your use.';
			break;
		case 'access':
			document.getElementById('featureshelper'+popup).innerHTML = '<img src="images/icon_diabled.gif" align="left" style="margin-right:5px;">This icon shows whether the selected care home has special disabled access facilities such as ramps and lifts.';
			break;
		case 'diets':
			document.getElementById('featureshelper'+popup).innerHTML = '<img src="images/icon_dine.gif" align="left" style="margin-right:5px;">This icon shows whether the selected care home can cater for your special food or dietary needs.';
			break;
		case 'languages':
			document.getElementById('featureshelper'+popup).innerHTML = '<img src="images/icon_speech.gif" align="left" style="margin-right:5px;">This icon shows whether the selected care home has staff that can speak more than one langauge.';
			break;
		case 'placeofworship':
			document.getElementById('featureshelper'+popup).innerHTML = '<img src="images/icon_cross.gif" align="left" style="margin-right:5px;">This icon shows whether the selected care home has a special place for worship.';
			break;
		case 'activities':
			document.getElementById('featureshelper'+popup).innerHTML = '<img src="images/icon_activities.gif" align="left" style="margin-right:5px;">This icon shows whether the selected care home arranges day trips and other activities.';
			break;
		case "caretype":
			document.getElementById('featureshelper'+popup).innerHTML = 'This is the type of care that is required. "Care Home only" selects care homes that do not provide direct nursing to the patient / resident. "Care Home with Nursing" selects care homes that cater for my specialist needs that require direct nursing.';
			break;
		case "specialcare":
			document.getElementById('featureshelper'+popup).innerHTML = 'This is the specific reason or illness that requires you to have care. If this is not known yet then please select "All Special Care".';
			break;
		case "careduration":
			document.getElementById('featureshelper'+popup).innerHTML = 'This is the amount of time that care is required for. This can vary from a short term stay to a permanent residency.';
			break;
		case "roomtype":
			document.getElementById('featureshelper'+popup).innerHTML = 'This allows you to select whether you require a shared room with or without en-suite facilities.';
			break;
		case "closedcare":
			document.getElementById('featureshelper'+popup).innerHTML = 'A "Close Care Unit" is a seperate part of the care home where more intensive care or closer supervision may take place.';
			break;
			
		default:
			// do nothing;
	}
	
	document.getElementById('featureshelper'+popup).style.display = 'block';

}

function hideFeatures(popup)
{
	document.getElementById('featureshelper'+popup).style.display = 'none';
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.style.backgroundImage=x.oSrc;
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.style.backgroundImage; x.style.backgroundImage=a[i+2];}
}

