
/*open the Rate this page hook into the CNC online surveys */
function openRatePage()
{
		var OpenWindow=window.open("/tools/ratethepage/default.aspx?ref=" + location.href, "newwin", "height=530,width=450,scrollbars=yes,menubar=no,resizable=yes");
		if (OpenWindow.focus) 
			OpenWindow.focus();
}

/* image roll over functionality */
function doRollOverImage(imgName, imgUrl) 
{
    if (document.images && typeof imgUrl != 'undefined')
    {
      
	var control = document.getElementById(imgName);
	if (control!=null)
		control.src = imgUrl;
    }
}

function openWindow(location, height, width)
{
	openWindow(location, height, width, "");
}

function openWindow(location, height, width, options)
{
	var OpenWindow;
	if (options!=null && options.length>1)
		OpenWindow=window.open(location, "newwin" + new Date().getSeconds(),"height=" + height + ",width=" + width + "," + options);

	else
		OpenWindow=window.open(location, "newwin" + new Date().getSeconds(),"height=" + height + ",width=" + width + ",scrollbars=yes,menubar=no,resizable=yes");
	if (OpenWindow.focus) 
		OpenWindow.focus();

}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}



var searchfocus = false;

/* cannot have a submit button on a form within the CMS, so use javascript to submit the form */
function submitSearch()
{

	var control = document.getElementById("q"); 
	var searchterm=control.value;
	searchterm = searchterm.replace(" ", "+");
	searchterm += "&sa=Google+Search&domains=cnc.bc.ca&sitesearch=cnc.bc.ca";
	document.location="http://www.cnc.bc.ca/tools/search/results.shtm?cx=010998674038483767677%3Afdi8egywrpm&cof=FORID%3A11&q=" + searchterm + "&sa=Search#918";
}


/*google search does not work when the enter key is pressed without a form, so handle */
function keyListener(e)
{
	
	if (!searchfocus)
		return true;

	if(!e)
	{
      		//for IE
      		e = window.event;
   	}
	 

	if(e.keyCode==13)
	{
		submitSearch();
		return false; //consume the enter key
	}
}

function CNCBody_onload()
{
	document.onkeydown = keyListener;
}
