// JavaScript Document
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_preswapImage() { //v3.0
  var i,j=0,x,a=MM_preswapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; x.src=a[i+2];}
}
function Isempty(strvalue)
{
	if(strvalue== "")
	{
		return false;
	}
	return true;
}

function submitIt____(form1) {
	if (!Isempty(form1.Name.value))
	{
		alert("Please enter your name!");
		form1.Name.focus();
		form1.Name.select();
		return false;
	}
	if (!Isempty(form1.Title.value))
	{
		alert("Please enter your title!");
		form1.Title.focus();
		form1.Title.select();
		return false;
	}
	if (!Isempty(form1.Organization.value))
	{
		alert("Please enter your organization's name!");
		form1.Organization.focus();
		form1.Organization.select();
		return false;
	}
	if (!Isempty(form1.Phone.value))
	{
		alert("Please enter your phone number!");
		form1.Phone.focus();
		form1.Phone.select();
		return false;
	}
	if (!Isempty(form1.Fax.value))
	{
		alert("Please enter your fax number!");
		form1.Fax.focus();
		form1.Fax.select();
		return false;
	}
	if (!Isempty(form1.Email.value))
	{
		alert("Please enter your email address!");
		form1.Email.focus();
		form1.Email.select();
		return false;
	}
	var VEnter = form1.VEnter.value;
	if (!Isempty(VEnter))
	{
		alert("Please enter the validation code!");
		form1.VEnter.focus();
		form1.VEnter.select();
		return false;
	}
	if (VEnter.length < 4)
	{
		alert("The code is invalid! Please re-enter it.");
		form1.VEnter.focus();
		form1.VEnter.select();
		return false;
	}
	return true;
}
var thisbtn = null;
var thisnav = null;
function navSwitch(navid, onoff){
	if(onoff){
		thisbtn = document.getElementById("btn_" + navid);
		thisnav = document.getElementById("nav_" + navid);
		prevbtnclass = thisbtn.className;
		prevnavclass = thisnav.className;
		thisbtn.className = "leftnav_on";
		if(thisnav.className == "leftnav_link"){
			thisnav.className = "leftnav_link_on";
		}else{
			//thisnav.className = "leftnavsub_link_on";
		}
	}else{
		thisbtn.className = prevbtnclass;
		thisnav.className = prevnavclass;
	}
}

var thistopbtn = null;
var thistopnav = null;
function topnavSwitch(navid, onoff){
	if(onoff){
		thistopbtn = document.getElementById("topbtn_" + navid);
		//thistopnav = document.getElementById("topnav_" + navid);
		prevtopbtnclass = thistopbtn.className;
		//prevtopnavclass = thistopnav.className;
		thistopbtn.className = "topbtn_on_" + navid;
		//thistopnav.className = "topnav_link_on";
	}else{
		thistopbtn.className = prevtopbtnclass;
		//thistopnav.className = prevtopnavclass;
	}
}
function moveCities(){
	var obj = document.getElementById("imgmap");
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	//order is: Kingston, Oshawa, Barrie, Kitchener, Hamilton, Niagara, London, Windsor
	var cityleft = new Array(326, 278, 197, 191, 224, 250, 190, 155, 126);
	var citytop  = new Array(132, 153, 167, 199, 213, 220, 234, 234, 294);
	//var triangletop  = 183;
	var triangleleft = new Array(335, 287, 206, 200, 233, 259, 199, 164, 134);
	var triangletop = new Array(137, 157, 160, 160, 158, 158, 158, 158, 158);
	for(i=0; i<cityleft.length; i++){
		document.getElementById("City_" + i).style.left = (curleft + cityleft[i]) + 'px';
		document.getElementById("City_" + i).style.top = (curtop + citytop[i]) + 'px';
		document.getElementById("Triangle_" + i).style.left = (curleft + triangleleft[i]) + 'px';
		document.getElementById("Triangle_" + i).style.top = (curtop + triangletop[i]) + 'px';
	}
	document.getElementById("Info_main").style.left = (curleft + 357) + 'px';
	document.getElementById("Info_main").style.top = (curtop + 160) + 'px';
}
function cityPopup(cid){
	//document.getElementById("City_" + cid).style.backgroundImage = "url('images/map_rollover_circle.png')";
	document.getElementById("City_" + cid).className = "bullet-city-ro";
	document.getElementById("Triangle_" + cid).style.display = 'block';
	document.getElementById("Info_" + cid).style.display = 'block';
	document.getElementById("Info_main").style.display = 'block';
}
function cityHide(cid){
	//document.getElementById("City_" + cid).style.backgroundImage = "none";
	document.getElementById("City_" + cid).className = "bullet-city";
	document.getElementById("Triangle_" + cid).style.display = 'none';
	document.getElementById("Info_" + cid).style.display = 'none';
	document.getElementById("Info_main").style.display = 'none';
}
var Selectedcity = "Selectcity";
function showContractors(){
	objSelect = document.getElementById("City");
	sel_Index = objSelect.selectedIndex;
	sel_Option = objSelect.options[sel_Index].value;
	document.getElementById(Selectedcity).style.display = 'none';
	document.getElementById(sel_Option).style.display = 'block';
	Selectedcity = sel_Option;
}

curleft = 0;
curtop = 0;

function getPosition(objpos){
	if (objpos.offsetParent) {
		curleft = objpos.offsetLeft;
		curtop = objpos.offsetTop;
		while (objpos = objpos.offsetParent) {
			curleft += objpos.offsetLeft;
			curtop += objpos.offsetTop;
		}
	}
}



function moveDivs(){ 
	
	getPosition(document.getElementById("menubar"));
	var Logo_left = curleft + 675;
	
	getPosition(document.getElementById("bottombar"));
	
	var Logo_top = curtop - 100;
	
	document.getElementById("UALogo").style.left = Logo_left + 'px';
	document.getElementById("UALogo").style.top = Logo_top + 'px';
	
	if( document.getElementById("UALogo1") != null){
		getPosition(document.getElementById("menubar"));
		
		var Logo_left = curleft + 5 ;
		var Logo_top = curtop - 145;
		
		document.getElementById("UALogo1").style.left = Logo_left + 'px';
		document.getElementById("UALogo1").style.top = Logo_top + 'px';
		
    };
	
	if( document.getElementById("UALogo2") != null){
		getPosition(document.getElementById("menubar"));
		
		var Logo_left = curleft + 8;
		var Logo_top = curtop - 95;
		
		document.getElementById("UALogo2").style.left = Logo_left + 'px';
		document.getElementById("UALogo2").style.top = Logo_top + 'px';
		
    };
	
	
	
	
	getPosition(document.getElementById("menubar"));
	var divid_top = curtop + 20;
	
	getPosition(document.getElementById("bottombar"));
	var divid_bottom = curtop;
	
	var height = divid_bottom - divid_top - 150;
	document.getElementById("horzdivide").style.height = height + 'px';
	
	

	
	
	getPosition(document.getElementById("menubar"));
	var T_left = curleft;
	
	getPosition(document.getElementById("bottombar"));
	
	var T_bottom = curtop;
	
	
	
	
	document.getElementById("T_topline").style.left = (T_left) + 'px';
	
	document.getElementById("T_bottomline").style.left = (T_left ) + 'px';
	document.getElementById("T_bottomline").style.top = (T_bottom - 1)+ 'px';
	
	document.getElementById("T_leftline").style.left = (T_left) + 'px';
	document.getElementById("T_leftline").style.height = (T_bottom - 23) + 'px';
	//document.getElementById("T_rightline").style.left = (T_left + 778) + 'px';
	document.getElementById("T_rightline").style.left = (T_left + 783) + 'px';
	document.getElementById("T_rightline").style.height = (T_bottom - 22) + 'px';
	
	
	
	/*
	getPosition(document.getElementById("topbanner"));
	
	var Logo_left1 = curleft - 70;
	var Logo_left2 = curleft + 160;
	var P1_left = curleft + 522;
	var P2_left = curleft - 60;
	var P3_left = curleft + 510;
	var T_left = curleft;
	
	getPosition(document.getElementById("bottombar"));
	
	var P3_top = curtop - 219;
	var T_bottom = curtop + 31;
	
	document.getElementById("Logo1").style.left = Logo_left1 + 'px';
	document.getElementById("Logo2").style.left = Logo_left2 + 'px';
	document.getElementById("Photo1").style.left = P1_left + 'px';
	document.getElementById("Photo2").style.left = P2_left + 'px';
	document.getElementById("Photo3").style.left = P3_left + 'px';
	document.getElementById("Photo3").style.top = P3_top + 'px';
	
	document.getElementById("P1_topline").style.left = (P1_left - 40) + 'px';
	document.getElementById("P1_bottomline").style.left = (P1_left + 246) + 'px';
	document.getElementById("P1_leftline").style.left = P1_left + 'px';
	document.getElementById("P1_rightline").style.left = (P1_left + 256) + 'px';
	
	document.getElementById("P2_topline").style.left = (P2_left - 40) + 'px';
	document.getElementById("P2_bottomline").style.left = (P2_left - 30) + 'px';
	document.getElementById("P2_leftline").style.left = P2_left + 'px';
	
	document.getElementById("P3_topline").style.left = (P3_left + 220) + 'px';
	document.getElementById("P3_topline").style.top = (P3_top - 1) + 'px';
	document.getElementById("P3_bottomline").style.left = (P3_left + 250) + 'px';
	document.getElementById("P3_bottomline").style.top = (P3_top + 219) + 'px';
	document.getElementById("P3_rightline").style.left = (P3_left + 302) + 'px';
	document.getElementById("P3_rightline").style.top = (P3_top - 30) + 'px';
	
	document.getElementById("T_topline").style.left = (T_left - 5) + 'px';
	document.getElementById("T_bottomline").style.left = (T_left - 50) + 'px';
	document.getElementById("T_bottomline").style.top = T_bottom + 'px';
	
	document.getElementById("T_leftline1").style.left = (T_left - 1) + 'px';
	document.getElementById("T_leftline2").style.left = (T_left - 1) + 'px';
	document.getElementById("T_leftline2").style.height = (T_bottom - 310) + 'px';
	document.getElementById("T_rightline1").style.left = (T_left + 767) + 'px';
	document.getElementById("T_rightline1").style.height = (T_bottom - 350) + 'px';
	document.getElementById("T_rightline2").style.left = (T_left + 767) + 'px';
	document.getElementById("T_rightline2").style.top = (T_bottom - 65) + 'px';
*/
}

function moveMembersDivs(){
	
	getPosition(document.getElementById("bottombar"));
	var divid_bottom = curtop;
	
	
	getPosition(document.getElementById("member_photo"));
	var imgH = 0;
	if( document.getElementById("img_photo") != null){
		imgH = document.getElementById("img_photo").height;
	}
	height = divid_bottom - curtop -imgH -190;
	//alert(divid_bottom);
	//alert(curtop);
	//alert(height);
	if(height > 0){
		//document.getElementById("right_space").style.height = height + 'px';
	}
}

function choosePhotos(){
	Totalpics = 10;
	rn1 = Math.floor((Math.random() * Totalpics)) + 1;
	do{
		rn2 = Math.floor((Math.random() * Totalpics)) + 1;
	}while(rn2 == rn1)
	do{
		rn3 = Math.floor((Math.random() * Totalpics)) + 1;
	}while(rn3 == rn1 || rn3 == rn2)
	if(rn1 < 10){
		rn1 = "0" + rn1;
	}
	if(rn2 < 10){
		rn2 = "0" + rn2;
	}
	if(rn3 < 10){
		rn3 = "0" + rn3;
	}
	document.getElementById("Photofile1").src = "images/upper_right_phot/" + rn1 + ".jpg";
	document.getElementById("Photofile2").src = "images/left_phot/" + rn2 + ".jpg";
	document.getElementById("Photofile3").src = "images/bottom_right_phot/" + rn3 + ".jpg";
	
}

function jumpandshowTrade(str){
	self.location.href = "exploretrades.php?q=" + str;
}

function moveDivs______(){ 
	var obj2 = document.getElementById("box");
	if (obj2.offsetParent) {
		curleft = obj2.offsetLeft
		curtop = obj2.offsetTop
		while (obj2 = obj2.offsetParent) {
			curleft += obj2.offsetLeft
			curtop += obj2.offsetTop
		}
	}
	var boxright = curleft + 30;
	var linetop = 55;
	var lineheight = curtop - linetop;
	
	//hlinetop = 400 + 29;

	if(boxright >= boxleft){
		
		document.getElementById("top_L").className = 'topline_l';
		document.getElementById("top_L").style.left = boxleft + 'px';
		document.getElementById("top_L").style.width = (boxright - boxleft) + 'px';
		document.getElementById("top_L").style.display = 'block';
	//	linelength = lineleft - boxright + 2;
	}else{
		document.getElementById("top_L").className = 'topline_lr';
		document.getElementById("top_L").style.left = boxright + 'px';
		document.getElementById("top_L").style.width = (boxleft - boxright) + 'px';
		document.getElementById("top_L").style.display = 'block';
	}
	document.getElementById("top_I").style.left = boxright + 'px';
	document.getElementById("top_I").style.top = linetop + 'px';
	document.getElementById("top_I").style.height = lineheight + 'px';
	document.getElementById("top_I").style.display = 'block';

}
	
	
function submitLogin(form1){
  if (form1.Username.value == "")
  {
    alert("Please enter your name.");
    form1.Username.focus();
    return (false);
  }
  if (form1.Password.value == "")
  {
    alert("Please enter your UA#.");
    form1.Password.focus();
    return (false);
  }
  
  return (true);	
}


var prevSubBg;
function swapSubNavBg(obj){
	if(document.getElementById){
		
		var bl = document.getElementById("sub_"+obj);
		prevSubBg = bl.className;
		 
		bl.className = "members_button_active";
	}
}
function swapSubNavBgRestore(obj){
	if(document.getElementById){
		
		var bl = document.getElementById("sub_"+obj);
		//prevBg = bl.style.className;
		 
		bl.className = prevSubBg;
	}
}

function submitNewTopic(form1){
  if (form1.TopicTitle.value == ""){
	  alert("Title for New Topic can not be blank!");
	  form1.TopicTitle.focus();
	  return (false);
  }
  if (form1.Comment.value == ""){
	  alert("You must enter a comment for this topic");
	  form1.Comment.focus();
	  return (false);
  }
  if(form1.Comment.value.length <=2){
	  alert("Comment too short!");
	  form1.Comment.focus();
	  return (false);
  }
  return (true);	
}

function addComment(form1){
	if(form1.Comment.value == ""){
		alert("Did you forget to write your comment?");
		form1.Comment.focus();
		return (false);
	}
	if(form1.Comment.value.length <=2){
		alert("Comment too short!")
		form1.Comment.focus();
		return (false);
	}
	return (true);
}

function checkChangePass(form1){
	
	var PassOne = form1.PassOne.value;
	var PassTwo = form1.PassTwo.value;
	var re = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])\w{7,}$/;
	var validPassword1 = re.test(PassOne);
	var validPassword2 = re.test(PassTwo);
	
	if(PassOne == ""){
		alert("New Password can not be blank!");
		form1.PassOne.focus();
		return (false);
	}	
	if(!validPassword1){
		alert("New Password must be at least 7 characters long and must\ncontain 1 lowercase letter, 1 uppercase letter, and 1 number.");
		form1.PassOne.focus();
		return (false);
	}	
	if(PassTwo == ""){
		alert("Confirm Password can not be blank!");
		form1.PassTwo.focus();
		return (false);
	}
	if(!validPassword2){
		alert("Confirm Password must be at least 7 characters long and must\ncontain 1 lowercase letter, 1 uppercase letter, and 1 number.");
		form1.PassTwo.focus();
		return (false);
	}
	if(PassOne !== PassTwo){
		alert("New Password and Confirm Password do not match!");
		return (false);
	}
	return (true);
}

//JS function for the Ontario Local Merger section Q&A Section
var initialClickid = "";
function expandCollapse(id)//function that hides and shows Questions on the faq page
{
	element = document.getElementById("id_"+id);
	if(element.className == 'show') {
		element.className = "hide";
		document.getElementById("plusminus_"+id).src = "images/expand_button.jpg";

	}else{
		element.className = "show";
		document.getElementById("plusminus_"+id).src = "images/minimize_button.jpg";

	}
}

function checkBlank(form1)
{
	if(!Isempty(form1.fname.value))
	{
		alert("Name should not be blank");
		return(false);
	}
	return true;
	}
	


