function init()
{
	//Detect if browser supports these functions
	if (document.getElementById && document.createElement)
	{	
		document.getElementById("drug-noscript").style.display = "none";
		document.getElementById("drug-script").style.display = "block";
	}
}

function generateRandomFact()
{
	var rand_no = Math.random();
	var facts = new Array();
	var old = "In order to maximize the functionality of this page, please turn on Javascript.<br />[<a href=\"/parents/know-saviez.html\">Le saviez-vous</a>]";
facts[0] = "In 2006, 25% of youth aged 15-24 reported using marijuana in the past year.<br />[<a href=\"/parents/drugs-drogues/research-recherche.html\" title=\"More information - Research\">More information</a>]";
facts[1] = "Teenagers who feel connected to their families are more likely to avoid the dangers of using drugs.<br />[<a href=\"/parents/action-agir/involved-interessez.html\" title=\"More information - Stay Involved in Your Teenager's Life\">More information</a>]";
facts[2] = "In 2006, over 90 percent of seized ecstasy samples that were analyzed by Health Canada also contained another drug. The most common other drug was methamphetamine (30.9%).<br />[<a href=\"/parents/drugs-drogues/ecstasy.html\" title=\"More information - Ecstasy\">More information</a>]";
facts[3] = "In 2004, 29% of youth aged 15-17 reported being a passenger in the car with someone who had used cannabis in the previous 2 hours before driving.<br />[<a href=\"/parents/drugs-drogues/cannabis.html\" title=\"More information - Cannabis\">More information</a>]";
facts[4] = "Illegal cannabis may be contaminated with pesticides or toxic fungi as it is not subject to any health and safety standards.<br />[<a href=\"/parents/drugs-drogues/cannabis.html\" title=\"More information - Cannabis\">More information</a>]";
facts[5] = "In 2006, more than 4,700 young people between the ages of 12 and 17 were charged with a cannabis offence in Canada.<br />[<a href=\"/parents/drugs-drogues/laws-lois.html\" title=\"More information - Drug Laws in Canada\">More information</a>]";
facts[6] = "Marijuana is illegal. It is a crime to possess, sell, grow or give it to someone. Fines, imprisonment and a criminal record that can restrict travel or employment can be the result.<br />[<a href=\"/parents/drugs-drogues/laws-lois.html\" title=\"More information - Drug Laws in Canada\">More information</a>]";
facts[7] = "Parents who talk to their children and monitor their activities reduce the likelihood of their children using drugs.<br />[<a href=\"/parents/action-agir/action-agir.html\" title=\"More information - Take Action\">More information</a>]";

	//Detect if browser supports these functions
	if (document.getElementById && document.createElement)
	{	
		rand_no = Math.round(rand_no * 7);
		document.write(facts[rand_no]);
	}	
	else
	{
		document.write(old);
	}
}

function drugSearch()
{
	var drugName = document.getElementById("drugname").value;
	var result = "";
	
	document.getElementById("drug-result").innerHTML = getResult(drugName);
}

function cleanString(str)
{
	str = str.toLowerCase();
	str = str.replace(/[ ']/g, "");
	
	return str;
}

function getResult(drugName)
{
	var path = "/parents/drugs-drogues/";
	var i = 0;
	var j = 0;
	var result ="";
	
	var arrDrugList = new Array(
	"Cannabis",
	"cannabis.html",
	new Array("acapulco gold","ace","bhang","california sinsemilla","colombian","dope","doobie","ganja","grass","hemp","herb","indian hemp","jamaican","jive","jive sticks","joint","marihuana","marijuana","mary jane","mauie wowie","mexican","panama gold","panama red","pot","ragweed","reefer","sativa","sinse","thai sticks","weed","hashish","hash","hash oil","honey oil","weed oil","hydro","bud","smoke","kush","hippy","chronic","green","stink","mary-jane","jucy","juicy","cannabis"),

	"Cocaine",
	"cocaine.html",
	new Array("c","coke","crack","flake","freebase","nose candy","rock","snow","stardust","powder","soft","maina","wine","white","zip","Henry","Charlie","blow","up","hard","angie","jucy","juicy","cocaine"),
	
	"Ecstasy",
	"ecstasy.html",
	new Array("adam","AKA","e","euphoria","hug drug","M","M&M","MDM","3","4-methylenedioxymethamphetamine","MDMA","rave","x","xtc","the love drug","love drug","the party pill","hug","beans","clarity lover's","Hippy flip","hippie flip","ecstasy"),
	
	"GHB",
	"ghb.html",
	new Array("fantasy","g","gamma hydroxybutyrate","liquid ecstasy","liquid X","grievous bodily harm","organic quaalude","salty water","scoop","soap","easy lay","vita-G","georgia home boy","ghb"),
	
	"Heroin",
	"heroin.html",
	new Array("diacetylmorphine","diamorphine","black tar","dust","H","horse","junk","smack","scag","heroin"),
	
	"Ketamine",
	"ketamine.html",
	new Array("big K","blind","breakfast cereal","cat tranquillizers","horsey P","K","keller","ket","ketalar","ketty","kit-kat","K-rod","lady K","special K","super K","vitamin K","squid","wonk","ketamine"),
	
	"LSD",
	"lsd.html",
	new Array("acid","back breaker","blotter acid","blotters","boomers","cid","dots","mellow yellow","barrels","California sunshine","cube","domes","flats","frogs","lids","wedges","microdot","purple haze","hits","tabs","trips","window pane","yellow sunshine","dot","sid","lsd"),
	
	"Methamphetamine",
	"methamphetamine.html",
	new Array("222","chalk","crank","crystal","crystal meth","glass","hawaiian salt","high speed chicken feed","ice","koolaid","kryptonite","peanut butter","rock candy","sketch","soiks","spooch","stove top","tina","tweak","zip","peach","pink","peanuts","dirt","grit","poor man's cocaine","gingo","ladies","shabu","shards","gak","fast","jib","meth","methamphetamine"),

	"PCP",
	"pcp.html",
	new Array("amoeba","angel dust","animal tranquillizer","Cadillac","CJ","crystal","crystal joint","cyclones","DOA","dead on arrival","elephant tranquillizer","embalming fluid","goon","hog","horse tranquillizer","KJ","Lovely","love boat","mist","peace pill","peace","ozone","rocket fuel","synthetic THC","scuffle","seams","sheet","snorts","super rods","surfer","synthetic marijuana","wack","zombie","mess","pcp"),
	
	"Psilocybin",
	"psilocybin.html",
	new Array("magic mushrooms","mushrooms","mushies","fungus","fungus delight","zoomers","shrooms","fungas","magic","Hippy flip","hippie flip","psilocybin"));

	for(i=2; i < arrDrugList.length; i+=3)
	{
		for(j=0; j < arrDrugList[i].length; j++)
		{
			if(cleanString(drugName) == cleanString(arrDrugList[i][j]))
			{
				result = result + "<strong>" + arrDrugList[i-2] + "</strong> [<a href=\"" + path + arrDrugList[i-1] + "\" title=\"More information - " + arrDrugList[i-2] + "\">More information</a>]<br />";
			}
		}
	}
	
	if(result == "")
	{
		return("<strong>No Match was found</strong><br />[<a href=\"/parents/drugs-drogues/drugs-drogues.html\">Learn more about drugs</a>]");
	}
	else
	{
		return result;
	}
}