// JavaScript Document
function OpenGlossary(GlossaryUrl)
{
	if (GlossaryUrl != null)
	{
		OpenWindow(GlossaryUrl, 800);
	}
}

function OpenWindow(url, width)
{
	if (url != null)
	{
		window.open(url,null,"width=" + width + ", status=no,toolbar=no,menubar=no,location=no, scrollbars=yes, resizable=yes");
	}
}
			
function SingleValidatorValidate(val)
{
	if(typeof(ValidatorValidate) != "function")
		return true;
	val.enabled=true;

    val.isvalid = true;
	ValidatorValidate(val);
	Page_IsValid = true;
	val.enabled=false;
	var isValid = val.isvalid;
	val.isvalid = true;
	return isValid;
}

function MultiValidatorsEnable(vals, enabled)
{
	var ss = vals.split(",");
	var valIndex;
	for(valIndex in ss)
	{
		var val = document.all[ss[valIndex]];
		if(typeof(val) == "undefined")
		{
			continue;
		}
		ValidatorEnable(val, enabled);
	}
}

function FieldsEnable(fldIds, valIds, enabled)
{
	//alert(fldIds + " " + enabled);
	var ssFld = fldIds.split(",");
	var ssVal = valIds.split(",");
	var fldId, valId;
	var chkCtrls = new Array();
	
	for(fldId in ssFld)
	{
		var fld = document.all[ssFld[fldId]];
		if(typeof(fld) == "undefined")
			continue;
		if (fld.type == "radio")
		{
			fld.parentElement.disabled = !enabled;
		}
		else if (fld.type == "checkbox" )
		{
		
			// asp.net renders checkboxes with spans during page load but removes them during post back
			if ((fld.parentElement.tagName != null) && (fld.parentElement.tagName.toUpperCase() == "SPAN"))
				fld.parentElement.disabled = !enabled;
		}
		if(enabled)
		{
			fld.disabled = false;
		}
		else
		{
			fld.value = "";
			fld.text = "";
			if(fld.checked)
				fld.checked = false;
			fld.disabled = true;
		}
		if(fld.type == "checkbox")
		{
			if(fld.parentElement.enableyes != undefined)
			{
				//fld.onclick=function(){FieldsEnable(this.controls, this.validators, this.enableyes=="yes");};
				FieldsEnable(fld.parentElement.controls, fld.parentElement.validators, fld.parentElement.enableyes=="yes" && fld.checked);
			}
			//if(typeof(fld.onclick) == "function")
			//	fld.onclick();
		}
	}

	for(valId in ssVal)
	{
		var val = document.all[ssVal[valId]];
		if(typeof(val) == "undefined")
			continue;
		ValidatorEnable(val, enabled);
	}
//	for(i = 0; i < chkCtrls.length; i++)
//	{
//		alert(chkCtrls[i].id);
//		chkCtrls[i].onclick();
//	}
	
}


function FieldOtherEnable(fldIds, enabled)
{
	var ss = fldIds.split(",");
	var fldId;
	for(fldId in ss)
	{
		var fld = document.getElementById(ss[fldId]);
		if(typeof(fld) == "undefined")
		{
			continue;
		}
		if(enabled)
		{
			fld.disabled = false;
		}
		else
		{
			fld.disabled = true;
			fld.value = "";
		}
	}
}

function selectAll(obj){
//alert(obj.name)
var maxN=obj.options.length;	
	for (var i=0; i<maxN; i++){
		obj.options[i].selected = true;			
	}	
}

function selectAllCheck(obj){
	var maxN=obj.length;	
	for (var i=0; i<maxN; i++){
		obj[i].checked = true;			
	}	
}
function show(obj){
	with(obj.parentNode){
		var stage = getAttribute("open");
		if (stage){
			className="clientFieldset";
			setAttribute("open", false);
			obj.innerText = "close";
		}else{
			className="clientFieldset-closed";
			setAttribute("open", true);
			obj.innerText = "show";
		}
	}
}

function showL(obj){
	with(obj.parentNode){
		var stage = getAttribute("open");
		if (stage != ""){
			className="clientFieldset";
			setAttribute("open", "");
			obj.className = "legendMinus";
		}else{
			className="clientFieldset-closed";
			setAttribute("open", true);
			obj.className = "legendPlus";
		}
	}
}

function menuItem(){
	//section=arguments[1].toLowerCase().split("/");
	selection = arguments[2];
	//alert(section[0]);
//		if (window.location.href.toLowerCase().indexOf(section[1])>=0){
	if (selection==channel){
		classSel="Sel";
	}else{
		classSel="";
	}
	menuItemSt = "";
	
	if (mySwitch){
		menuItemSt   = '<td class="menuLeft' + classSel +'">&nbsp;</td>';
	}
	
	menuItemSt += '<td class="menuTop' + classSel +'" align="center"><a href="'+  arguments[1] +'" class="tpnav">' + arguments[0] + '</a></td>';

	if (classSel){
		menuItemSt += '<td class="menuRight' + classSel +'">&nbsp;</td>';
		mySwitch = false;
	}else{
		mySwitch = true;
	}
	document.write(menuItemSt);
}

function MENU(){
	mySwitch = true;

	document.write('<table cellSpacing="0" cellPadding="0" border="0" style="margin-bottom:37px">');
	document.write('	<tr>');
	menuItem('Home', '../portal/home.aspx', 'PORTAL');
	menuItem('My e-Sudbury', '../portal/my_esudbury.aspx', '');
	menuItem('Communities', '../communities/CommunityGroups.aspx', 'COMMUNITIES');
	menuItem('Education', '#', '');
	menuItem('Seniors', '#', '');
	menuItem('Museums', '#', '');
	menuItem('Tourism', '../tourism/tourism_home.aspx', 'TOURISM');

document.write('	</tr>');
	document.write('</table>');
}
function defineMenu(what){
	channel = what;
	}
	
	function showRow(obj){
		var next = obj.getAttribute('nextCl');
		with(obj.parentNode.parentNode.parentNode.nextSibling){
			obj.setAttribute('nextCl',className);
			className=next;
		}
	}
	
STEKS = new Array();

function open_close(id, stek){
	if (id.getAttribute("service")==1){
		id.parentNode.className="closed";
		id.src="images/plusN.gif";
		id.setAttribute("service",0);
	}else{
		if (id.parentElement.nextSibling != null){
			id.parentNode.className="opened";
		}else{
			id.parentNode.className="openedLast";
		}
		id.src="images/minusN.gif";
		id.setAttribute("service",1);
	}
}
function helpF(){
	var COLS2=window.top.document.body.cols;
	c2=COLS2.split(",");
	menu_c=c2[0];
	if (window.top.frames.menu.turnHELP){
		window.top.document.body.cols = menu_c + ",*,1";
		window.top.frames.menu.turnHELP=false;
	}else{
		window.top.document.body.cols = menu_c + ",*,230";
		window.top.frames.menu.turnHELP=true;
	}
}

function treeF(){
path=window.top.frames.mainFrame;
	//alert(path.document.body.cols);
//	path.document.body.cols="1,*";
	if (window.top.TREE){
		path.document.body.cols="1,*";
		window.top.TREE=false;
	}else{
		path.document.body.cols="30%,*";
		window.top.TREE=true;
	}	
}
STEKSMENU = new Array();
		function open_closeMENU(id, stek){
			if (STEKSMENU[stek]==1){
				//id.parentNode.className="topMENU";
				id.className="topMENU";
				STEKSMENU[stek]=0;
			}else{
				//id.parentNode.className="openedMENU";
				id.className="openedMENU";
				STEKSMENU[stek]=1;
			}
}
		function open_closeMENU2(id, stek){
			if (STEKSMENU[stek]==1){
				id.className="mainMenu";
				id.firstChild.className="topMenu";
				STEKSMENU[stek]=0;
			}else{
				id.className="mainMenuOpenned";
				id.firstChild.className="topMenuOpenned";
				STEKSMENU[stek]=1;
			}
}
