function $(id) {
	if (document.getElementById(id)) {
		return document.getElementById(id);
		};
	};

function toggleCats() {
	if ($('catsshow').style.display == 'none')	{
		$('catsshown').style.display = 'none';
		$('catsshow').style.display = 'block';	
		} else {
			$('catsshown').style.display = 'block';
			$('catsshow').style.display = 'none';
			};
	};
	
function askUs() {
	hideLayers();
	if (document.forms.askq) {
		document.forms.askq.subj.value = $('medicament').innerHTML;
		};
	$('queform').style.display = 'block';
	};
	
function DontAskUs(refr) {
	$('queform').style.display = 'none';
	if (refr) {
		window.location.href = window.location.href;
		};
	};
	
function getCoords(e) {
	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;
			}; 	
	a = new Array(posx,posy);
	return a;
	};
	
function showLicence(e,t,h) {
	hideLayers();
	$('showlicence').style.display = 'block';
	$('licenceimg').src = t.href;
	coords = getCoords(e);
	coords[1] = coords[1] - h - 60;
	$('showlicence').style.top = coords[1]+'px';
	$('showlicence').style.left = coords[0]+'px';
	$('licenceimg').style.height = h+'px';
	$('licenceimg').onload = function () {
		$('showlicence').style.width = ($('licenceimg').width+33)+'px';
		};
	};
	
function showContacts(e) {
	hideLayers();
	$('contform').style.display = 'block';
	};
	
function checkContacts() {
	form = document.forms.cont;
	inputs = form.getElementsByTagName('input');
	for (i=0;i<inputs.length;i++) {
		inputs[i].className = inputs[i].className.replace(' checkme','');
		};
	form.cque.className = 'wide';
	emailRegExp = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.([a-z]){2,6})$/;
	if (form.cname.value != '' && form.csubj.value != '' && form.cque.value != '' && emailRegExp.test(form.cmail.value)) {
		form.submit();
		} else {
			if (form.cname.value == '') {form.cname.className += ' checkme';};
			if (form.csubj.value == '') {form.csubj.className += ' checkme';};
			if (form.cque.value == '') {form.cque.className += ' checkme';};
			if (!emailRegExp.test(form.cmail.value)) {form.cmail.className += ' checkme';};
			};
	};
	
function hideLayers() {
	var layers = new Array('contmap','contform','queform','showlicence');
	for (i=0;i<layers.length;i++) {
		if ($(layers[i])) {
			$(layers[i]).style.display = 'none';
			};
		};
	};
	
function showMap() {
	hideLayers();
	$('contmap').style.display = 'block';
	map = $('contmap').getElementsByTagName('img')[0];	
	$('contmap').style.width = (map.width + 33) + 'px';
	};
	
function checkEmpty(warning) {
	if ($('srchqry').value=='') {
		alert(warning);
		} else {
			document.forms.search.submit();
			};
	};

	
function suggest() {
	$('search_sugg').innerHTML = '';
	qry = $('srchqry').value;
	$('search_sugg_table').style.display = 'none';
	if (qry.length<2) {
		return;
		};
	var row;
	var list = '';
	for (i in products) {
		
		row = products[i];
		if (row.toLowerCase().indexOf(qry.toLowerCase())!=-1) {
			list += '<li><a href="?'+i+'">'+row.toLowerCase().replace(qry.toLowerCase(),'<strong>'+qry+'</strong>')+'</a></li>';
			};
		};

	if (list.length>0) {
		$('search_sugg').innerHTML = list;
		$('search_sugg_table').style.display = 'block';
		};

	};
