// creates a spam-proof mailto link with the email address as the link
function createEmail(username,hostname) {
	var linktext = username + "@" + hostname;
	document.write("<a href=" + "mail" + "to:" + username + "@" + hostname + ">" + linktext + "</a>");
}

// cross browser equivalent to document.GetElementById
function getElement(id) {
	var obj = (document.getElementById ? document.getElementById(id) : document.all[id])
	return obj == null ? false : obj
}

//function for opening a new window
function openNewWindow(url) {
  popupWin = window.open(url, 
    'target01_window',
    'menubar,toolbar,location=false,directories=false,status=false,scrollbars,resizable,dependent,width=800,height=600')
}

//function for re-directing back to the default.aspx page, adding a query string for email
//address, and the newsletter Id
function SignUpNewsletter(queryStringValue, newsletterId)
{
	location.href='default.aspx?signUpNewsletter='  + queryStringValue + '&nid=' + newsletterId;
}

function toggleItemVisibility(divId)
{	
	//Dynamically created javascript function that prevents selecting "Unsure of Intervention" checkbox
	//and other intervention at the same time
	checkInervention();
	if(getElement(divId).style.display == "none")
	{
		getElement(divId).style.display = "block";
	}
	else
	{
		getElement(divId).style.display = "none";
	}
}

function toggleItemVisibilitySetFocus(divId, div2Id)
{
	if(getElement(divId).style.display == "none")
	{
		getElement(divId).style.display = "block";
		getElement(divId).focus();
		getElement(divId).select();
	}
	else
	{
		getElement(divId).style.display = "none";
		getElement(divId).value = "";
	}
}

function duplicateAddressValues(checkBox, intialAddress, copyAddress)
{
    if(checkBox.checked == true)
    {
		getElement(copyAddress + "AddressTextBox").value = getElement(intialAddress + "AddressTextBox").value;
		getElement(copyAddress + "Address2TextBox").value = getElement(intialAddress + "Address2TextBox").value;
		getElement(copyAddress + "CityTextBox").value = getElement(intialAddress + "CityTextBox").value;
		getElement(copyAddress + "ProvinceDropDownList").value = getElement(intialAddress + "ProvinceDropDownList").value;
		getElement(copyAddress + "PostalCodeTextBox").value = getElement(intialAddress + "PostalCodeTextBox").value;
		
		getElement(copyAddress + "AddressTextBox").readOnly = true;
		getElement(copyAddress + "Address2TextBox").readOnly = true;
		getElement(copyAddress + "CityTextBox").readOnly = true;
		getElement(copyAddress + "ProvinceDropDownList").readOnly = true;
		getElement(copyAddress + "PostalCodeTextBox").readOnly = true;
	}
	else
	{
		
		getElement(copyAddress + "AddressTextBox").readOnly = false;
		getElement(copyAddress + "Address2TextBox").readOnly = false;
		getElement(copyAddress + "CityTextBox").readOnly = false;
		getElement(copyAddress + "ProvinceDropDownList").readOnly = false;
		getElement(copyAddress + "PostalCodeTextBox").readOnly = false;
	}
}

function organizationInformationChanged(prefix)
{
	var CEOSameAddressCheckBox = getElement(prefix + 'CeoSameAddressCheckBox');
	var DesignateSameAddressCheckBox = getElement(prefix + 'DesignateSameAddressCheckBox');
	var ContactSameAddressCheckBox = getElement(prefix + 'ContactSameAddressCheckBox');
	
	if(CEOSameAddressCheckBox.checked == true)
	{
		getElement(prefix + 'CEOAddressTextBox').value = getElement(prefix + 'OrganizationAddressTextBox').value;
		getElement(prefix + 'CEOAddress2TextBox').value = getElement(prefix + 'OrganizationAddress2TextBox').value;
		getElement(prefix + 'CEOCityTextBox').value = getElement(prefix + 'OrganizationCityTextBox').value;
		getElement(prefix + 'CEOProvinceDropDownList').value = getElement(prefix + 'OrganizationProvinceDropDownList').value;
		getElement(prefix + 'CEOPostalCodeTextBox').value = getElement(prefix + 'OrganizationPostalCodeTextBox').value;		
		
	}
	if(DesignateSameAddressCheckBox.checked == true)
	{
		getElement(prefix + 'DesignateAddressTextBox').value = getElement(prefix + 'OrganizationAddressTextBox').value;
		getElement(prefix + 'DesignateAddress2TextBox').value = getElement(prefix + 'OrganizationAddress2TextBox').value;
		getElement(prefix + 'DesignateCityTextBox').value = getElement(prefix + 'OrganizationCityTextBox').value;
		getElement(prefix + 'DesignateProvinceDropDownList').value = getElement(prefix + 'OrganizationProvinceDropDownList').value;
		getElement(prefix + 'DesignatePostalCodeTextBox').value = getElement(prefix + 'OrganizationPostalCodeTextBox').value;
	}
	if(ContactSameAddressCheckBox.checked == true)
	{
		getElement(prefix + 'ContactAddressTextBox').value = getElement(prefix + 'OrganizationAddressTextBox').value;
		getElement(prefix + 'ContactAddress2TextBox').value = getElement(prefix + 'OrganizationAddress2TextBox').value;
		getElement(prefix + 'ContactCityTextBox').value = getElement(prefix + 'OrganizationCityTextBox').value;
		getElement(prefix + 'ContactProvinceDropDownList').value = getElement(prefix + 'OrganizationProvinceDropDownList').value;
		getElement(prefix + 'ContactPostalCodeTextBox').value = getElement(prefix + 'OrganizationPostalCodeTextBox').value;		
	
	}
	


}

function openPopUpWindow(content)
{
   var html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><title>Role Definition</title><meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"><meta name=ProgId content=VisualStudio.HTML><meta name=Originator content="Microsoft Visual Studio .NET 7.1"><link href="en/css/global.css" type=text/css rel=stylesheet></head><form><body><table style="POSITION: absolute; TOP: 30px; WIDTH:280px"><tr><td class="currentpage" style="WIDTH:270px"><table style="WIDTH:270px"><tr><td style="WIDTH:270px">' + content + '</td></tr></table></td></tr></table></form></body></html>'
   var popUpWindow;
   popUpWindow = window.open('RoleDefinitionPopUp.htm', 'RoleDefinition', 'status=0,toolbar=0,location=0,menubar=0,directories=0,resizeable=0,scrollbars=1,height=300,width=300,top=200,left=200');
   popUpWindow.document.writeln(html);

}

