function select_country(chk_id) {
	var pl = chk_id.split(",");
	if (pl.length > 1) {
		for (x = 0; x < pl.length; x++) {
			select_country_singular(pl[x]);
		}

	} else {
		select_country_singular(chk_id);

	}
}

function select_country_singular(chk_id) {
	if (document.getElementById('reg_' + chk_id).checked == false) {
		document.getElementById('reg_' + chk_id).checked = true;
	}
}

function uncheckall(formname, fieldname, checkvalue) {
	var objCheckBoxes = document.forms[formname].elements[fieldname];
	if (!objCheckBoxes) {
		alert("Error");
	}

	for (i = 0; i < objCheckBoxes.length; i++) {
		objCheckBoxes[i].checked = checkvalue;
	}

}

function concaturl (url) {
	window.location.href = url;
}

function allchecked(formname, fieldname) {
	var objCheckBoxes = document.forms[formname].elements[fieldname];
	var allChecked = true;
	if (!objCheckBoxes) {
		alert("Error");
	}

	for (i = 0; i < objCheckBoxes.length; i++) {
		if (objCheckBoxes[i].checked != true) {
			allChecked = false;
		}
	}
	if (allChecked) {
		uncheckall(formname,fieldname,false);
	}

}

function selectStartSearch() {

	var selfile = document.searchselector.searchradio;
	for (i=0; i<selfile.length; i++) {
	   if (selfile[i].checked) {
		usefile = selfile[i].value + '.php';
	   }
	}
	window.location=usefile;
}

function populateResourceBox(restype){

	strChosenList = eval("document.search_selector." + restype + ".getAttribute('value')");
	aChosenItems = strChosenList.split("##");
	document.search_selector.search_selector_dropbox.length=0;  // reset the list to 0 length
	for (i=0; i < aChosenItems.length; i++) {
		aItem = aChosenItems[i].split(",,");
		itemdet = new Option(aItem[1],aItem[0]);
		document.search_selector.search_selector_dropbox[i]  = itemdet;
	}

}

function openResult(winurl, win_no) {
	window.open(winurl, win_no,'alwaysRaised, width=600, height=600, scrollbars, menubar, status, resizable');
}
function openReport(winurl, win_no) {
	window.open(winurl, win_no,'alwaysRaised, width=600, height=600, scrollbars, menubar, status, resizable');
}

function evidencelevel() {
	window.open("evidence.php", "evidence",'alwaysRaised, width=400, height=400');
}

function checkalt_comp(type) {
	if (type=='alt') {
		if(document.search_selector.search_sel_alternative.checked == false) {
		   document.search_selector.search_sel_complementary.checked = true;
		}
	} else {
		if(document.search_selector.search_sel_complementary.checked == false) {
		   document.search_selector.search_sel_alternative.checked = true;
		}
	}

}

function helppop(subject,winheight) {
	window.open("help.php?item=" + subject, "help",'alwaysRaised, width=400, height=' + winheight);
}

function helptext(item) {
	var helptext;
	if (item='altcomp') {
		helptext = "Help text for Alternative / complementary tickboxes";
	}
	alert (helptext)
}

function underconst(head) {
	alert (head + "\n\nFeature Not Available\n\nWe are currently developing this part of the website.\n\nPlease come  back later");

}

function help_xx(id) {
   eval('document.all.' + id + '.style.visibility="visible"');
}
function helphide__xx(id) {
   eval('document.all.' + id + '.style.visibility="hidden"');
}
function help(id) {
   eval('document.getElementById("' + id + '").style.visibility="visible"');
}
function helphide(id) {
   eval('document.getElementById("' + id + '").style.visibility="hidden"');
}

function pinklink(itemid){
   eval('document.getElementById("' + itemid + '").style.backgroundColor="#FF00FF"');
}
function bluelink(itemid){
   eval('document.getElementById("' + itemid + '").style.backgroundColor="#000077"');
}
function userlogin(logtype) {
	window.open('login.php' + logtype, 'login','alwaysRaised, width=200, height=200'); //, location, menubar, status');
}

function text_counter(formname,inputname,dispid,maxsize) {
	var currsize = eval(formname + '.' + inputname + '.value.length');
	var remain = (maxsize*1) - (currsize*1);
	eval("document.getElementById('" + dispid + "').innerHTML=" + remain);
}

function resource_talk_opener(itemid) {
	window.open('talk.php?action=result&id=' + itemid);
}

