// JavaScript Document
var arr= ['Abdomen','Abortion','Abrasion','Abscess','Ache','Acid reflux','Acupuncture','Acute','Adrenaline','Allergen','Amnesia','Anaesthetic','Analeptic','Analgesic','Anaphylactic shock','Aneurysm','Angina','Antacid','Anthelmintic','Antibiotic','Antibody','Anticoagulant','Anticonvulsant','Antidepressant','Antidiarrhoeal','Antidote','Antiemetic','Antifungal','Antihistamine','Antihypertensive','Anti-inflammatory','Antipruritic','Antipsychotic','Antipyretic','Antirheumatic','Antiseptic','Antiviral','Anus','Anxiety','Anxiolytic','Appendix','Artery','Audiometry','Bacteria','Benign','Benzodiazepines','Beta blocker','Bile','Bile duct','Biopsy','Blackout','Bladder','Blood','Blood count','Blood donation','Blood test','Blood transfusion','Blood vessel','Bone marrow','Bone marrow donation','Bowels','Brain','Breast lump','Bronchodilator','Bypass','C. diff','Caesarean','Carrier','Cataract surgery','Catheter','Cervical smear test','Cervix','Chemotherapy','Cholesterol','Chorionic villus sampling','Chromosome','Chronic','Circumcision','Clinical trial','Colposcopy','Coma','Congenital','Congestion','Constipation','Contagious','Contraindication','Coronary angioplasty','Corticosteroid','Counselling','Craving','Culture','Cyst','Cystoscopy','Cytotoxic','Decongestant','Deficiency','Deformity','Dehydration','Delusions','Dependence','Depression','Dialysis','Diarrhoea','Discharge','Disease','Diurectic','Donor','Dose','Double vision','Drip','Drowsiness','Drug interaction','Eardrum','ECG','Ectopic','EEG','Embolism','Embryo','Emollient','Enema','Enteric-coated tablets','Enzyme','Epidemic','Epidural','Episiotomy','Euthanasia','Expectorant','Expert patient','Express','Fallopian tube','Familial','Fatigue','Fever','Foetus','Gall bladder','Gene','Genetic','Genetic disorder','Genitals','Glucose','Groin','Haematoma','Haemorrhage','Hallucination','Heart','Heart attack','Heart bypass','Heart valve','Heartburn','High blood pressure','Hip replacement','Homeopathy','Hormone replacement therapy','Hot flushes','Hyperactivity','Hysterectomy','Immune system','Immunoglobulin','Incision','Incontinence','Inflammation','Inhaler','Insulin','Intravenous','Invasive','IVF','Jaundice','Joint','Kidney','Larynx','Lesion','Ligaments','Liver','Local anaesthetic','Loss of appetite','Lung','Lymph node','Malabsorption','Malignant','Mastectomy','Mental','Metabolism','Metastasis','Microbiology','Migraine','MMR','Morning sickness','MRI','Nausea','Nodule','Numbness','Obesity','Onset','Origin','Ovaries','Oxygen','Pain','Palpitations','Panic','Paresthesia','Pericardium','Peritoneum','Physiotherapy','Pituitary gland','Placebo','Plasma','Platelet','Prognosis','Psychiatrist','Psychiatry','Psychotherapy','Radiotherapy','Recipient','Red cell','Red eye','Remission','Retina','Rupture','Shock','Smear test','Sneezing','Spinal cord','Spine','Sputum','SSRI','Stem cells','Steroids','Stimulants','Stomach','Stool','Structure','Suffocate','Suppositories','Suture','Swab','Tendon','Testicle','Testosterone','Thyroid','Thyroid gland','Tissue','Tracheostomy','Ulcer','Ultrasound','Ultrasound scan','Urethra','Urinalysis','Urinary catheterisation','Uterus','Vaccination','Vein','Vomit','Wheezing','White cell','X-ray','Abortion','Cuts and grazes','Abscess','Acne','Actinomycosis','Acupuncture','Addison\'s disease','Agoraphobia','Air embolism','Alcohol misuse','Allergies','Hair loss','Altitude sickness','Alzheimer\'s disease','Lazy eye','Periods, absent','Amniocentesis','Amoebiasis','Anaemia','Anaesthesia','Anal fissure','Aneurysm','Angina','Angiography','Angioedema','Ankylosing spondylitis','Anorexia nervosa','Anxiety','Aphasia','Mouth ulcer','Appendicitis','Arthritis','Arthroscopy','Artificial insemination','Asbestosis','Asthma','Astigmatism','Athlete\'s foot','Atrial fibrillation','Autistic spectrum disorder','B12 deficiency','Balanitis','Barium enema','Bell\'s palsy','Biopsy','Bipolar disorder','Birthmarks','Bites','Bleeding gums','Blepharitis','Blisters','Blood groups','Blood transfusion','Blushing','Bone cyst','Botulism','Brain abscess','Brain death','Brain tumour','Breast abscess','Breastfeeding','Breast lump','Breathlessness','Bronchiectasis','Bronchitis','Bulimia','Bunion','Bursitis','Caesarean section','Cancer','Cancer of the bladder','Cancer of the bone','Cancer of the breast, female','Cancer of the cervix','Cancer of the larynx','Cancer of the lung','Cancer of the mouth','Cancer of the ovary','Cancer of the prostate','Cancer of the skin','Cancer of the stomach','Cancer of the testicle','Cancer of the uterus','Thrush','Carpal tunnel syndrome','Cataract surgery','Cavernous sinus thrombosis','Cellulitis','Cerebral palsy','Cerebrovascular disease','Cervical screening test','Chemotherapy','Chickenpox','Chlamydia','Cholesterol','Chorionic Villus sampling','Chronic fatigue syndrome','Cleft lip and palate','Talipes','Coeliac disease','Colic','Colostomy','Colposcopy','Congenital heart disease','Conjunctivitis','Constipation','Coronary angioplasty','Coronary artery bypass','Creutzfeldt-Jakob disease','Crohn\'s disease','Croup','Cushing\'s syndrome','Cystic fibrosis','Cystitis','Cystoscopy','Dandruff','Deep vein thrombosis','Dehydration','Dementia','Dental abscess','Dental decay','Depression','Diabetes','Diabetic retinopathy','Dialysis','Diarrhoea','Dilatation and curettage (D&C)','Diphtheria','Diverticular problems','Double vision','Down\'s syndrome','Dry eye syndrome','Dupuytren\'s contracture','Dysentery','Dyslexia','Dysphagia','Ectopic pregnancy','Ectropion','Eczema (atopic)','Embolism','Encephalitis','Endocarditis','Endometriosis','Endoscopy','Bedwetting','Epidural anaesthesia','Epiglottitis','Epilepsy','Episiotomy','Exophthalmos','Eye injuries','Incontinence, bowel','Febrile convulsions','Fibroids','Floaters','Flu','Boils','Hand, foot and mouth disease','Broken bones','Frostbite','Frozen shoulder','Gallstones','Gangrene','Gastrectomy','Gastroenteritis','Genital herpes','Giardiasis','Glaucoma','Glomerulonephritis','Glucose tolerance test','Glue ear','Goitre','Gout','Guillain-Barre syndrome','Gum disease','Haemophilia','Bad breath','Head lice','Heart attack','Heart block','Heart failure','Heart lung transplant','Heartburn','Hepatitis','Hernia','Cold sore','Hiccup','HIV and AIDS','Homeopathy','Hormone replacement therapy','Huntington\'s disease','Hydrocephalus','Hydronephrosis','Hyperlipidaemia  and lipid-lowering medicines','Blood pressure (high)','Thyroid, over-active','Hypoglycaemia','Thyroid, under-active','Immunisation','Impetigo','Erectile dysfunction','Incontinence, urinary','Indigestion','Glandular fever','Infertility','Ingrown toenail','Insomnia','Irritable bowel syndrome','Irritable hip','Jaundice','Jet lag','Ketosis','Kidney transplant','Knock knee','Kyphosis','Labyrinthitis','Laparoscopy','Laryngitis','Legionnaire\'s disease','Leptospirosis','Leukaemia','Listeriosis','Liver transplant','Back pain','Lumbar puncture','Lyme disease','Lymphoedema','Lymphoma','Malignant melanoma','Malnutrition','Mastectomy','Mastitis','Measles','Ménière’s disease','Meningitis','Menopause','Migraine','Miscarriage','Molluscum contagiosum','Motor neurone disease','MRSA','Multiple myeloma','Multiple sclerosis','Mumps','Munchausen’s syndrome','Muscular dystrophy','Myasthenia gravis','Short-sightedness','Morning sickness','Neuralgia','Neurofibromatosis','Nosebleed','Obesity','Obsessive compulsive disorder','Oedema','Osteoarthritis','Osteomyelitis','Osteopathy','Osteoporosis','Otitis externa','Otitis media','Ovarian cyst','Paget\'s disease','Pancreatitis','Panic disorder','Parkinson\'s disease','Pelvic inflammatory disease','Perforated eardrum','Pericarditis','Peritonitis','Phenylketonuria','Phobias','Pilonidal sinus','Plastic surgery','Pleurisy','Pneumonia','Poliomyelitis','Polycystic ovarian syndrome','Polymyalgia rheumatica','Polyps, nose','Post-traumatic stress disorder','Premenstrual syndrome','Pressure ulcers','Priapism','Prickly heat','Prolapse of the uterus','Prostate disease','Psoriasis','Psychiatry','Psychosis','Puberty','Kidney infection','Q Fever','Quinsy','Rabies','Radiotherapy','Raynaud\'s phenomenon','Rectal examination','Reiter\'s syndrome','Repetitive strain injury','Respiratory distress syndrome','Respiratory tract infection','Retinal detachment','Reye\'s syndrome','Rhesus disease','Rheumatic fever','Rheumatoid arthritis','Rhinitis','Rickets','Ringworm','Rosacea','Roundworm','Rubella','Scabies','Schizophrenia','Sciatica','Scoliosis','Scurvy','Seasonal affective disorder','Septic shock','Shingles','Sick building syndrome','Sickle-cell anaemia','Sinusitis','Sjogren\'s syndrome','Sleep apnoea','Slipped disc','Snoring','Sore throat','Spina bifida','Sprains','Staphylococcal infections','Squint','Streptococcal infections','Stress','Stroke','Subarachnoid haemorrhage','Sudden infant death syndrome','Suicide','Sunburn','Supraventricular tachycardia','Tay-Sachs disease','Tendonitis','Tennis elbow','Tetanus','Thalassaemia','Threadworms','Thrombosis','Tics','Tinnitus','Tonsillitis','Tourette\'s syndrome','Toxic shock syndrome','Toxocariasis','Toxoplasmosis','Tracheostomy','Trachoma','Traction','Transient ischaemic attack','Tremor (essential)','Trichomoniasis','Trigeminal neuralgia','Tuberculosis','Turner\'s syndrome','Typhoid fever','Ulcerative colitis','Ultrasound scan','Urinary catheterization','Urinary tract infection','Uveitis','Vaginismus','Vasectomy','Fainting','Vertigo','Vitiligo','Warts','Watering eye','Earwax','Whiplash','Yellow fever','Spinal muscular atrophy','Anaphylaxis','Macular degeneration','Acoustic neuroma','Clinical trials','Food safety','Children in care','Expert patients','Antenatal health and care','Hospitals, children','Mobile phone safety','Health records','Periods, irregular','Food poisoning','Whooping cough','Adenoids and adenoidectomy','Condoms (male and female)','Combined contraceptive pill','Cancer of the bile duct','Carbon monoxide poisoning','Walk-in Centres','Anaesthetic, local','Ear reshaping','Behcet\'s disease','Body piercing','Cancer of the liver','Slapped cheek syndrome','Peptic ulcer','Vegetative state','PET scan','Travel health','Post-natal depression','Preconception','Pre-eclampsia','Cancer of the kidney','Progestogen-only pill','Restricted growth','Gender dysphoria','Sexually transmitted infections','Smoking (quitting)','Sports injuries','Female sterilisation','Cartilage damage','Charcot-Marie-Tooth disease','Cirrhosis','Contraceptive implants and injections','Coronary heart disease','Corticosteroid (drugs)','Deafblindness','Diaphragms and caps','Drug misuse','Fibromyalgia','Accidents and first aid','Flatulence','Hangover','Hay fever','Self-injury','Emergency contraception','Exercise','Intrauterine device (IUD)','Get the right treatment','Intrauterine system (IUS)','IVF','Liposuction','Malaria','Male contraceptive pill','Marfan syndrome','Head injury','Hypothermia','Cancer of the thyroid','Tuberous sclerosis','Cognitive behavioural therapy','Painkillers','Cancer of the vagina','Anaesthetic, general','Sexual health clinics','Diet','Cancer of the oesophagus','Cancer of the pancreas','Narcolepsy','Natural family planning','Bronchiolitis','Intensive care','Tietze\'s syndrome','Trigger finger','Baker\'s cyst','Hernia, hiatus','Falls','Post-mortem','Blood pressure (low)','Lupus','X-ray','Heat exhaustion and heatstroke','Cold, common','Cough','Headache','Operations','Tests','Ileostomy','Nappy rash','Knee replacement','Restless leg syndrome','Root canal treatment','Scarlet fever','Teething','SARS','Testicular lumps, benign','Visual impairment','Flu jab','Aspergillosis','Cradle cap','Nettle rash','Lactose intolerance','Gonorrhoea','Decongestant drugs','Hearing impairment','MMR','Accident and emergency departments','Bronchodilator drugs','Hip replacement','Breast implants','Anal fistula','Androgen insensitivity syndrome','Chest infection','Anti-inflammatories, non-steroidal','Cosmetic surgery','Ambulance Service','Breast reduction','Cervical spondylosis','Long-sightedness','EEG','Hospitals, discharge','GPs','Wisdom tooth removal','Respite care','Hospitals, admission','Binge eating','Chronic obstructive pulmonary disease','Colour vision deficiency','Blood poisoning','Ejaculation problems','Bladder stones','Carers','Pemphigus vulgaris','Cancer of the colon, rectum or bowel','Lichen planus','Blood donation','Contraception','CT scan','Genetics','MRI scan','Subdural haematoma','Congestive heart failure','Radiation','Epidermolysis bullosa. (EB)','Consent to treatment','Organ donation','Joint hypermobility','Anticoagulant drugs','Kidney failure','Hyperglycaemia','Noonan syndrome','Complaints about NHS services','Pneumococcal infections','Gastroesophageal reflux disease','Patient choice','Evidence-based medicine','Risks and benefits of treatment','Second opinion','Euthanasia','Cancer of the vulva','Periods, painful','Atherosclerosis','Syphilis','Primary biliary cirrhosis','DEXA scan','Catarrh','Corticosteroid preparations (topical)','Eczema (contact dermatitis)','Renin test','Tau protein test','TIBC test','Total protein test','TPMT test','Bicarbonate','CEA test','Chloride test','Differential test','Electrolytes','Blood gases test','Gram stain','Home tests','LDH','Magnesium test','Microalbumin test','Phosphate test','Potassium test','Preoperative tests','Red blood count','Ear infection','Eczema (varicose)','Eczema (discoid)','Emollients','Fungal nail infection','Body odour','Craniosynostosis','Mucositis','Fluoride','Oral thrush','Stings, insect','Bone marrow transplant','Bone marrow donation','Cancer of the breast, male','Leukoplakia','Orthodontics','Bites, snake','Stings, marine creatures','Antifungal drugs','Dental care for babies and children','Out-of-hours services','Diabetes insipidus','Plasma products','Stretch marks','Gynaecologists and obstetricians','Blood tests','Periods','Toothache','Thrush, men','Accidents to children in the home','Bottle feeding','Laxatives','Scars','Contraceptive patch','Babies crying','Kawasaki disease','Itching','Hearing tests','Circumcision','Addictions','Eating disorders','Family support','Mental health','Mental health specialist services','Moles','Tranquillisers','Antidepressant drugs','Psychotherapy','Cytomegalovirus','Jaundice - newborn','Hughes syndrome','Hearing and vision tests for children','Babies, weaning','Antenatal screening','Hepatitis A','Hepatitis B','Physiotherapy','Hepatitis C','Travel sickness','Poisoning','Antihistamine drugs','Complex Regional Pain Syndrome','Asthma - children','Pandemic flu','Avian flu','Hyperhidrosis','Dyspraxia (childhood)','Norovirus','Drink spiking','Rotavirus','Anger management','NHS','Leg ulcer','Bites, insect','Pregnancy','Dystonia','Clostridium difficile','Stillbirth','Ataxia','Pubic lice','Travel Immunisation'];

// Main search box handler
function searchTabHandler(){
	
	var frm = document.frmSitesearch;
	var eleRad;
	
	for (var i=0; i<frm.searchOpt.length; i++)  {
		if (frm.searchOpt[i].checked)  {				
			strSection = frm.searchOpt[i].value		
			
		}
	} 
	
	// Select correct radio
	if(strSection!="undefined"){
		var eleTxt = document.getElementById("txt-search");
		
		switch(strSection){
			case "site":
			$("#txt-search").autocomplete(arr, {minChars: 3,
										max: 20,
										autoFill: false,
										mustMatch: false,
										matchContains: true,
										scrollHeight: 120
			});
			eleTxt.value="Type keyword or phrase here";
			break;
			case "support":
			$("#txt-search").unbind();
			eleTxt.value="Type keyword or phrase here";
			break;
			default:
			$("#txt-search").unbind();
			eleTxt.value="Enter postcode or town";
			break;
		}
		
	}
	
	//now change style of tab
	var liEles = frm.getElementsByTagName("li");
	for (var i=0; i<liEles.length; i++)  {
		liEles[i].className ="";
	}
	eleRad = document.getElementById("liSearch" + strSection)
	eleRad.className = "selected";
}


function clearField(){

	var eleTxt = document.getElementById("txt-search");

	if(eleTxt.value=="Type keyword or phrase here" || eleTxt.value=="Enter postcode or town"){
		eleTxt.value="";
	}
	
}


$(document).ready(function(){
	$("#howTo").hide();
});

function showHowTo()	{
	$("#howTo").show();
}

$(document).ready(function() {
/*
	$("#txt-search").autocomplete(arr, {minChars: 3,
										max: 20,
										autoFill: false,
										mustMatch: false,
										matchContains: true,
										scrollHeight: 120
		});
		
	*/	
});


// Body map rollover

/* Some old-school dreamweaver JS here for legacy reasons */
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.src=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.src; x.src=a[i+2];}
}

function swapBodyKey(strPart, strGender) {
    ele = document.getElementById("bodykey_map_" + strGender);
    ele.src = "/NHSInform/images/bodykey/" + strGender + "_" + strPart + ".jpg";
}

function restoreBodyKey(strPart, strGender)
{
	if(strPart.length>0)
		strPart = "_"+strPart;

    ele = document.getElementById("bodykey_map_" + strGender);
    ele.src = "/NHSInform/images/bodykey/" + strGender+strPart + ".jpg";
}

// preload images first (can run before page is fully loaded)
$(
	function() {
	    // set up rollover
	    $("img.rollover").hover(
			function() {
			    this.src = this.src.replace("_off", "_on");
			},
			function() {
			    this.src = this.src.replace("_on", "_off");
			}
		);
	}
)

/* TEXT SIZE SMALL MEDIUM LARGE STUFF */

$(document).ready(function() {
	var strPageSize = ReadCookie("pagesize");
	if(strPageSize.length>0){
		changeSize(strPageSize);
	}
});

function ReadCookie(cookieName) {
	 var theCookie=""+document.cookie;
	 var ind=theCookie.indexOf(cookieName);
	 if (ind==-1 || cookieName=="") return ""; 
	 var ind1=theCookie.indexOf(';',ind);
	 if (ind1==-1) ind1=theCookie.length; 
	 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}




function changeSize(size){
	
	var arr = new Array();
	arr = document.getElementsByTagName("HTML");
	var ele = arr[0];
	
	var theDate = new Date();
	var oneYearLater = new Date( theDate.getTime() + 8640000 );
	var expiryDate = oneYearLater.toGMTString();
	
	document.cookie = 'pagesize='+size+'; expires='+expiryDate+'; path=/'

	
	if(size=="large"){
			ele.style.fontSize = "75%";
	}
	else if(size=="medium"){
			ele.style.fontSize = "70%";
	}
	else if(size=="small"){
			ele.style.fontSize = "62.5%";
	}

}

// Ensure correct button/form is triggered on enter
/*
jQuery(document).ready(function($) {

    $("#header_0_ctl00_txtSearch").bind('keypress', function(e) {
        if (e.keyCode == 13) {
            $(location).attr('href', '/search-results.aspx?q=' + $("#header_0_ctl00_txtSearch").val());
            return false;
        }
    });

    $("#main_0_keywordTb").bind('keypress', function(e) {       
        if (e.keyCode == 13) {
            $(location).attr('href', '/support-services/search-results.aspx?kwds=' + $("#main_0_keywordTb").val());
            return false;
        }
    });
       

});
*/
