var Nav4 = (document.layers)?true:false;

function sendMe(page){//dummy function, remove this once jsp code is entered
	document.location = page;
}
function selectMe(img, state, num){//used in the product directory to select specific item in the grid
	if(state == "over"){
		if(num == "odd"){document.images[img].src = "../../images/x_odd.gif";}
		else{document.images[img].src = "../../images/x_even.gif";}
	}else{document.images[img].src = "../../images/spacer.gif";}	
}
function openWindow(page,w,h,name){
	var specifics = "resizable=yes,menubar=no,scrollbars=yes,status=no,width=" + w + ",height=" + h;	
	window.open(page,name,specifics);
}
function closeWindow(){
	self.close();
}
function changePageBehind(){
	top.opener.window.location = "privacy_policy.jsp";
	closeWindow();
}
function checkCountry(){
	if(document.forms['myProfile'].elements['homeCountry'].options[1].selected){
		if (document.forms['myProfile'].regStatus[0].checked == true)
		{
			document.forms['myProfile'].action = "can_license.html";
		}
		else
		{
			document.forms['myProfile'].action = "can_license_new.html";
		}
	}else{
		if (document.forms['myProfile'].regStatus[0].checked == true)
		{
			document.forms['myProfile'].action = "us_license.html";
		}
		else
		{
			document.forms['myProfile'].action = "us_license_new.html";
		}
	}
}
function editCourseCheck(){
	if(document.forms['myProfile'].elements['edit'][0].checked){		
		document.forms['myProfile'].action = "edit_course.html";
	}else{
		document.forms['myProfile'].action = "../index.html";
	}
}
function addCourse(){
		document.forms['myProfile'].action = "add_course_new.html";
	}
function addCourseCheck(){
	if(document.forms['myProfile'].elements['add'][0].checked){		
		document.forms['myProfile'].action = "add_course.html";
	}else{
		document.forms['myProfile'].action = "../index.html";
	}
}
function addCourseConfirmation(){
		document.forms['myProfile'].action = "add_course_confirmation.html";
	}
function generateReport()
{
	window.open("ebm_report_result.html","","top=50,left=50,resizable=yes,width=660,height=590");
}
function studentHome()
{
	document.forms['myProfile'].action = "../index.html";
}
function postResume()
{
	document.forms['myProfile'].action = "networking_registration.html";
}
function editLicense()
{
	if(document.forms['myProfile'].elements['homeCountry'].options[1].selected)
	{
		window.location = "can_license_profile.html";
	}
	else
	{
		window.location = "us_license_profile.html";
	}
}
function rld() 
{
	document.location.reload()
}
function showDate(){
	var today = new Date();
	var todaysDate = "";
	var monthArray = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	var month = monthArray[today.getMonth()];
	var day = today.getDate();
	var year = today.getYear();
	if(year > 2000){
		year = "0" + (year - 2000);
	}else{year = "0" + (year - 100);}
		
	
	todaysDate = month + "-" + day + "-" +year;
	document.write(todaysDate);
}

function DisplayYear(PageName)
{
	var d	 = new Date();	
	var year = d.getFullYear();
	var j	 = 0;	
	
	document.write ("<option></option>\n");
	if (PageName == "AddCourse")
	{
		j = 1980;
	}
	else
	{
		j = 1950;
	}
	
	for (i = year; i >= j; i--)
	{
		document.write ('<option value=\"' + i + '\">' + i + '</option>\n');
	} 
}

function DisplayMonth()
{
	var monthArray = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	
	document.write ("<option></option>\n");
	for (i = 0; i < monthArray.length; i++)
	{
		document.write ('<option value=\"' + monthArray[i] + '\">' + monthArray[i] + '</option>\n');
	} 	
}

function gotoCSI()
{
	window.open('https://www.csi.ca/pub/en/abt/div.cgi/abt','','location=yes,directories=yes,menubar=yes,toolbar=yes,titlebar=yes,scrollbars=yes,status=yes,resizable=yes,width=800,height=700');
}

function generateProvinceState()
{
	var MyProfile			= eval(document.forms['myProfile']);
	var provinceArray 		= new Array("Alberta","British Columbia","Manitoba","New Brunswick","Newfoundland","Nova Scotia","Northwest Territories","Nunavut","Ontario","Prince Edward Island","Saskatchewan","Yukon Territory");
	var provinceValueArray 	= new Array("AB","BC","MB","NB","NF","NS","NT","NU","ON","PE","SK","YT");
	var stateArray			= new Array("Alabama","Alaska","Arizona","Arkansas","California","Colorado","Connecticut","Delaware","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","Washington","Washington D.C.","West Virginia","Wisconsin","Wyoming");										
	var stateValueArray		= stateArray;
	
	if (MyProfile.elements['primaryCountry'].options.selectedIndex == 1)
	{	
		MyProfile.elements['primaryProvinceState'].length = 0;
		if (document.layers)
		{
			MyProfile.elements['primaryProvinceState'].length = 12;
		}
		for (i=0; i<provinceArray.length; i++)	
		{
			MyProfile.elements['primaryProvinceState'].options[i] = new Option(provinceArray[i], provinceValueArray[i], 0, 0);
		}
	}
	if (MyProfile.elements['primaryCountry'].options.selectedIndex == 2)
	{	
		MyProfile.elements['primaryProvinceState'].length = 0;
		if (document.layers)
		{
			MyProfile.elements['primaryProvinceState'].length = 50;
		}
		for (i=0; i<stateArray.length; i++)	
		{
			MyProfile.elements['primaryProvinceState'].options[i] = new Option(stateArray[i], stateValueArray[i], 0, 0);
		}
	}
	if (MyProfile.elements['primaryCountry'].options.selectedIndex != 1 && MyProfile.elements['primaryCountry'].options.selectedIndex != 2)
	{
		for(i=MyProfile.elements['primaryProvinceState'].options.length; i>0 ;i--)
		{
			MyProfile.elements['primaryProvinceState'].options[i] = null;
		}
		MyProfile.elements['primaryProvinceState'].options[0] = new Option("Not Applicable", "NA", 1, 1);
	}
}
function overGraph(graphName)
{
	graphTemp = eval(graphName + ".src");
	document.images['graph5'].src = graphTemp;
	return 0;
}

function offGraph(graphName)
{
	graphTemp = eval(graphName + "off.src")
	document.images['graph5'].src = graphTemp;
	return 0;
}

function BuildDiv(DivProperties)
{
	var title = DivProperties[0];
	var content = DivProperties[1];
	var divID = DivProperties[2];
	var tableClass = DivProperties[3];
	var titleCellClass = DivProperties[4];
	var contentCellClass = DivProperties[5];
	var titleClass = DivProperties[6];
	var contentClass = DivProperties[7];
	
	var DivHTML = "";

	if (Nav4)
	{
		DivHTML += "<layer name='" + divID + "' visibility='hide' position='absolute'>";
	}
	else
	{
		DivHTML += "<div id='" + divID + "' style='visibility:hidden;position:absolute'>";
	}
	
	DivHTML += "<table cellpadding='2' cellspacing='0' class='" + tableClass + "'>";
	DivHTML += "<tr>";
	DivHTML += "<td class='" + titleCellClass + "'>";
	DivHTML += "<span class='" + titleClass + "'>";
	DivHTML += title;
	DivHTML += "</span>";
	DivHTML += "</td>";
	DivHTML += "</tr>";
	DivHTML += "<tr>";
	DivHTML += "<td class='" + contentCellClass + "'>";
	DivHTML += "<span class='" + contentClass + "'>";
	DivHTML += content;
	DivHTML += "</span>";
	DivHTML += "</td>";
	DivHTML += "</tr>";
	DivHTML += "</table>"; 

	if (Nav4)
	{
		DivHTML += "</layer>"; 
	}
	else
	{
		DivHTML += "</div>"; 
	}

	document.write(DivHTML); 
}

function showGlossary(e,divID)
{
	if (Nav4)
	{
		var topPos = e.pageY;
		var leftPos = e.pageX;
	}
	else
	{
		if (document.all)
		{
			var topPos = e.clientY + document.documentElement.scrollTop + document.body.scrollTop;
			var leftPos = e.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
		}
		else
		{
			var topPos = e.clientY + window.scrollY;
			var leftPos = e.clientX + window.scrollX;
		}
	}


	if (Nav4)
	{
		document.layers[divID].top = topPos;
		document.layers[divID].left = leftPos;
		document.layers[divID].visibility = "show";
	}
	else
	{
		document.getElementById(divID).style.top = topPos;
		document.getElementById(divID).style.left = leftPos;
		document.getElementById(divID).style.visibility = "visible";
	}
}	

function hideGlossary(e,divID)
{
	if (Nav4)
	{
		document.layers[divID].visibility = "hide";
	}
	else
	{
		document.getElementById(divID).style.visibility = "hidden";
	} 
}
