var global_expand = true;

/*
var nbsp = 160;		// non-breaking space char
var node_text = 3;	// DOM text node-type
var emptyString = /^\s*$/ ;
var global_valfield;	// retain valfield for timer thread

// --------------------------------------------
//                  trim
// Trim leading/trailing whitespace off string
// --------------------------------------------

function trim(str)
{
  return str.replace(/^\s+|\s+$/g, '');
}


// --------------------------------------------
//                  setfocus
// Delayed focus setting to get around IE bug
// --------------------------------------------

function setFocusDelayed()
{
  global_valfield.focus();
}

function setfocus(valfield)
{
  // save valfield in global variable so value retained when routine exits
  global_valfield = valfield;
  setTimeout( 'setFocusDelayed()', 100 );
}


// --------------------------------------------
//                  msg
// Display warn/error message in HTML element.
// commonCheck routine must have previously been called
// --------------------------------------------

function msg(fld,     // id of element to display message in
             msgtype, // class to give element ("warn" or "error")
             message) // string to display
{
  // setting an empty string can give problems if later set to a 
  // non-empty string, so ensure a space present. (For Mozilla and Opera one could 
  // simply use a space, but IE demands something more, like a non-breaking space.)
  var dispmessage;
  if (emptyString.test(message)) 
    dispmessage = String.fromCharCode(nbsp);    
  else  
    dispmessage = message;

  var elem = document.getElementById(fld);
  elem.firstChild.nodeValue = dispmessage;  
  
  elem.className = msgtype;   // set the CSS class to adjust appearance of message
}

// --------------------------------------------
//            commonCheck
// Common code for all validation routines to:
// (a) check for older / less-equipped browsers
// (b) check if empty fields are required
// Returns true (validation passed), 
//         false (validation failed) or 
//         proceed (don't know yet)
// --------------------------------------------

var proceed = 2;  

function commonCheck    (valfield,   // element to be validated
                         infofield,  // id of element to receive info/error msg
                         required)   // true if required
{
  if (!document.getElementById) 
    return true;  // not available on this browser - leave validation to the server
  var elem = document.getElementById(infofield);
  if (!elem.firstChild) return true;  // not available on this browser 
  if (elem.firstChild.nodeType != node_text) return true;  // infofield is wrong type of node  

  if (emptyString.test(valfield.value)) {
    if (required) {
      msg (infofield, "error", "ERROR: required");  
//      setfocus(valfield);
      return false;
    }
    else {
      msg (infofield, "warn", "Required");   // OK
      return true;  
    }
  }
  return proceed;
}

// --------------------------------------------
//            validatePresent
// Validate if something has been entered
// Returns true if so 
// --------------------------------------------

function validatePresent(valfield,   // element to be validated
                         infofield ) // id of element to receive info/error msg
{
  var stat = commonCheck (valfield, infofield, true);
  if (stat != proceed) return stat;

  msg (infofield, "warn", "Required");  
  return true;
}

// --------------------------------------------
//               validateEmail
// Validate if e-mail address
// Returns true if so (and also if could not be executed because of old browser)
// --------------------------------------------

function validateEmail  (valfield,   // element to be validated
                         infofield,  // id of element to receive info/error msg
                         required)   // true if required
{
	
  var stat = commonCheck (valfield, infofield, required);
  if (stat != proceed) return stat;
 
  var tfld = trim(valfield.value);  // value of field with whitespace trimmed off
  var email = /^[^@]+@[^@.]+\.[^@]*\w\w$/  ;
  if (!email.test(tfld)) {
    msg (infofield, "error", "ERROR: not a valid e-mail address");
//    setfocus(valfield);
    return false;
  }else{
    msg (infofield, "warn", "Required");	  
  }

  var tfld2 = trim(document.forms.demo.email2.value);	
  var tfld1 = trim(document.forms.demo.email.value);	
  if(tfld1 != tfld2) {	
    msg ("inf_email2", "error", "ERROR: the e-mail addresses do not match");  
//    setfocus(valfield);
    return false;
  }else {
    msg ("inf_email2", "warn", "Required");	  
  }
  
  var email2 = /^[A-Za-z][\w.-]+@\w[\w.-]+\.[\w.-]*[A-Za-z][A-Za-z]$/  ;
  if (!email2.test(tfld)) 
    msg (infofield, "warn", "Unusual e-mail address - check if correct");
  else
    msg (infofield, "warn", "Required");

  return true;
}

function validatePassword  (valfield,   // element to be validated
                         infofield,  // id of element to receive info/error msg
                         required)   // true if required
{
	
  var stat = commonCheck (valfield, infofield, required);
  if (stat != proceed) return stat;

  msg ("inf_password", "warn", "Required");

  var tfld2 = trim(document.forms.demo.password2.value);	
  var tfld1 = trim(document.forms.demo.password.value);	
  if(tfld1 != tfld2) {	
    msg ("inf_password2", "error", "ERROR: passwords do not match");  
//    setfocus(valfield);
    return false;
  }else {
    msg ("inf_password2", "warn", "Required");	  
  }
  
  return true;
}


// --------------------------------------------
//            validateUsername
// Validate telephone number
// Returns true if so (and also if could not be executed because of old browser)
// Permits spaces, hyphens, brackets and leading +
// --------------------------------------------

function validateUsername  (valfield,   // element to be validated
                         infofield,  // id of element to receive info/error msg
                         required)   // true if required
{
  var stat = commonCheck (valfield, infofield, required);
  if (stat != proceed) return stat;

  msg (infofield, "warn", "Required");
 
  var tfld = trim(valfield.value);  // value of field with whitespace trimmed off
  var username = /^\w+$/  ;
  if (!username.test(tfld)) {
    msg (infofield, "error", "ERROR: not a valid username. Must not contain any special characters.");
//    setfocus(valfield);
    return false;
  } else
    msg (infofield, "warn", "Required");	  
  
  return true;
}

// --------------------------------------------
//             validateAge
// Validate person's age
// Returns true if OK 
// --------------------------------------------

function validateAge    (valfield,   // element to be validated
                         infofield,  // id of element to receive info/error msg
                         required)   // true if required
{
  var stat = commonCheck (valfield, infofield, required);
  if (stat != proceed) return stat;

  var tfld = trim(valfield.value);
  var ageRE = /^[0-9]{1,3}$/
  if (!ageRE.test(tfld)) {
    msg (infofield, "error", "ERROR: not a valid age");
//    setfocus(valfield);
    return false;
  }

  if (tfld>=200) {
    msg (infofield, "error", "ERROR: not a valid age");
//    setfocus(valfield);
    return false;
  }

  if (tfld>110) msg (infofield, "warn", "Older than 110: check correct");
  else {
    if (tfld<7) msg (infofield, "warn", "Bit young for this, aren't you?");
    else        msg (infofield, "warn", "Required");
  }
  return true;
}*/

function createVideoTag() {
var tag = "Required";	
var tempTag;
var box;
for (var j = 1; j <= 4; j++) {
  tempTag = "tag" + j;
  box = eval("document.video.tag" + j); 
  if (box.checked == true){
    tag += eval("document.video.tag" + j + ".value");

  }
}
  document.video.tags.value = tag;
}

function expand(s)
{
  var td = s;
  var d = td.getElementsByTagName("div").item(0);

  td.className = "menuHover";
  d.className = "menuHover";
}

function collapse(s)
{
  var td = s;
  var d = td.getElementsByTagName("div").item(0);

  td.className = "menuNormal";
  d.className = "menuNormal";
}

function ajaxFunction(type, mf_mid, offset){

	var ajaxRequest;  // The variable that makes Ajax possible!
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}

	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState==4 || ajaxRequest.readyState=="complete"){
			var ajaxDisplay = document.getElementById('ajaxDiv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}

//	alert("hi");	

    if (type == 'vote'){
  
      var queryString = "?vid=" + mf_mid; 
	  ajaxRequest.open("GET", "vote.php" + queryString, true);
	  ajaxRequest.send(null);
    }	
	
    if (type == 'page'){
  
	  var rowsPerPage = 5;
      var queryString = "?mf_mid=" + mf_mid + "&rowsPerPage=" + rowsPerPage + "&offset=" + offset; 
	  ajaxRequest.open("GET", "comments.php" + queryString, true);
	  ajaxRequest.send(null);
    }	

    if (type == 'expand'){
	  var rowsPerPage;
 	  if (global_expand == true)
	  {
		  rowsPerPage = 5;
		  global_expand = false;
	  }else
	  {
		  rowsPerPage = 3;
		  global_expand = true;		  
	  }
	    
      var queryString = "?mf_mid=" + mf_mid + "&rowsPerPage=" + rowsPerPage;
	  ajaxRequest.open("GET", "comments.php" + queryString, true);
	  ajaxRequest.send(null);

    }		
    if (type == 'hi'){
	  var rowsPerPage;
 	  if (global_expand == true)
	  {
		  rowsPerPage = 5;
		  global_expand = false;
	  }else
	  {
		  rowsPerPage = 3;
		  global_expand = true;		  
	  }
	    
      var queryString = "?mf_mid=" + mf_mid + "&rowsPerPage=" + rowsPerPage;
	  ajaxRequest.open("GET", "test.php" + queryString, true);
	  ajaxRequest.send(null);

    }		
}

function ajaxFunction2(type, mf_mid, offset){

	var ajaxRequest;  // The variable that makes Ajax possible!
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}

	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState==4 || ajaxRequest.readyState=="complete"){
			alert(""+ajaxRequest.responseText);
		}
	}

    if (type == 'vote'){
      var queryString = "?vid=" + mf_mid; 
	  ajaxRequest.open("GET", "vote.php" + queryString, true);
	  ajaxRequest.send(null);
    }	
}

function expand(thistag, tag, text) {
	
   tag.innerHTML = "";
//   styleObj.display='none';
   document.getElementById(thistag).innerHTML = text; 


}


function changeRoundVideos(roundID){
  var link = "./viewVideos.php?rid=" + roundID;
  window.location = link;
}

function changeRoundVideos2(roundID){
  var link = "./winners.php?rid=" + roundID;
  window.location = link;
}

function changeWinnersRoundVideos(roundID){
  var link = "./winners.php?rid=" + roundID;
  window.location = link;
}

	function ShowBlurb(sDivName)
	{
		if (document.getElementById(sDivName))
		{
			document.getElementById(sDivName).style.display = 'block';
		}
	}
	
	function HideBlurb(sDivName)
	{
		if (document.getElementById(sDivName))
		{
			document.getElementById(sDivName).style.display = 'none';
		}		
	}

var regiondb = new Object();
regiondb["Alberta"] = [{value:"Airdrie", text:"Airdrie"},
                      {value:"Brooks", text:"Brooks"},
                      {value:"Calgary", text:"Calgary"},
                      {value:"Camrose", text:"Camrose"},
					  {value:"Cold Lake", text:"Cold Lake"},
					  {value:"Edmonton", text:"Edmonton"},
					  {value:"Fort Saskatchewan", text:"Fort Saskatchewan"},
					  {value:"Grande Prairie", text:"Grande Prairie"},
					  {value:"Leduc", text:"Leduc"},
					  {value:"Lethbridge", text:"Lethbridge"},
					  {value:"Lloydminster", text:"Lloydminster"},
					  {value:"Medicine Hat", text:"Medicine Hat"},
					  {value:"Red Deer", text:"Red Deer"},
					  {value:"Spruce Grove", text:"Spruce Grove"},
					  {value:"St. Albert", text:"St. Albert"},
					  {value:"Wetaskiwin", text:"Wetaskiwin"}];

regiondb["British Columbia"] = [{value:"Abbotsford", text:"Abbotsford"},
{value:"Armstrong", text:"Armstrong"},
{value:"Burnaby", text:"Burnaby"},
{value:"Castlegar", text:"Castlegar"},
{value:"Chilliwack", text:"Chilliwack"},
{value:"Colwood", text:"Colwood"},
{value:"Coquitlam", text:"Coquitlam"},
{value:"Courtenay", text:"Courtenay"},
{value:"Cranbrook", text:"Cranbrook"},
{value:"Dawson Creek", text:"Dawson Creek"},
{value:"Duncan", text:"Duncan"},
{value:"Enderby", text:"Enderby"},
{value:"Fernie", text:"Fernie"},
{value:"Fort St. John", text:"Fort St. John"},
{value:"Grand Forks", text:"Grand Forks"},
{value:"Greenwood", text:"Greenwood"},
{value:"Kamloops", text:"Kamloops"},
{value:"Kelowna", text:"Kelowna"},
{value:"Kimberley", text:"Kimberley"},
{value:"Langley", text:"Langley"},
{value:"Merritt", text:"Merritt"},
{value:"Nanaimo", text:"Nanaimo"},
{value:"Nelson", text:"Nelson"},
{value:"New Westminster", text:"New Westminster"},
{value:"North Vancouver", text:"North Vancouver"},
{value:"Parksville", text:"Parksville"},
{value:"Penticton", text:"Penticton"},
{value:"Port Alberni", text:"Port Alberni"},
{value:"Port Coquitlam", text:"Port Coquitlam"},
{value:"Port Moody", text:"Port Moody"},
{value:"Prince George", text:"Prince George"},
{value:"Prince Rupert", text:"Prince Rupert"},
{value:"Quesnel", text:"Quesnel"},
{value:"Revelstoke", text:"Revelstoke"},
{value:"Richmond", text:"Richmond"},
{value:"Rossland", text:"Rossland"},
{value:"Salmon Arm", text:"Salmon Arm"},
{value:"Smithers", text:"Smithers"},
{value:"Surrey", text:"Surrey"},
{value:"Terrace", text:"Terrace"},
{value:"Trail", text:"Trail"},
{value:"Vancouver", text:"Vancouver"},
{value:"Vernon", text:"Vernon"},
{value:"Victoria", text:"Victoria"},
{value:"White Rock", text:"White Rock"},
{value:"Williams Lake", text:"Williams Lake"}];

regiondb["Manitoba"] = [{value:"Brandon", text:"Brandon"},
{value:"Dauphin", text:"Dauphin"},
{value:"Flin Flon", text:"Flin Flon"},
{value:"Portage la Prairie", text:"Portage la Prairie"},
{value:"Selkirk", text:"Selkirk"},
{value:"Steinbach", text:"Steinbach"},
{value:"Thompson", text:"Thompson"},
{value:"Winkler", text:"Winkler"},
{value:"Winnipeg", text:"Winnipeg"}];

regiondb["New Brunswick"] = [{value:"Bathurst", text:"Bathurst"},
{value:"Campbellton", text:"Campbellton"},
{value:"Dieppe", text:"Dieppe"},
{value:"Edmundston", text:"Edmundston"},
{value:"Fredericton", text:"Fredericton"},
{value:"Miramichi", text:"Miramichi"},
{value:"Moncton", text:"Moncton"},
{value:"Saint John", text:"Saint John"}];

regiondb["Newfoundland and Labrador"] = [{value:"Corner Brook", text:"Corner Brook"},
{value:"Mount Pearl", text:"Mount Pearl"},
{value:"St. Johns", text:"St. Johns"}];

regiondb["Northwest Territories"] = [{value:"Yellowknife", text:"Yellowknife"}];

regiondb["Nova Scotia"] = [{value:"Halifax", text:"Halifax"},
{value:"Sydney", text:"Sydney"},
{value:"Dartmouth", text:"Dartmouth"}];

regiondb["Nunavut"] = [{value:"Iqaluit", text:"Iqaluit"}];

regiondb["Ontario"] = [{value:"Barrie", text:"Barrie"},
{value:"Belleville", text:"Belleville"},
{value:"Brampton", text:"Brampton"},
{value:"County of Brant", text:"County of Brant"},
{value:"Brantford", text:"Brantford"},
{value:"Brockville", text:"Brockville"},
{value:"Burlington", text:"Burlington"},
{value:"Cambridge", text:"Cambridge"},
{value:"Chatham-Kent", text:"Chatham-Kent"},
{value:"Clarence-Rockland", text:"Clarence-Rockland"},
{value:"Cornwall", text:"Cornwall"},
{value:"Dryden", text:"Dryden"},
{value:"Elliot Lake", text:"Elliot Lake"},
{value:"Greater Sudbury", text:"Greater Sudbury"},
{value:"Guelph", text:"Guelph"},
{value:"Hamilton", text:"Hamilton"},
{value:"Kawartha Lakes", text:"Kawartha Lakes"},
{value:"Kenora", text:"Kenora"},
{value:"Kingston", text:"Kingston"},
{value:"Kitchener", text:"Kitchener"},
{value:"Lambton Shores", text:"Lambton Shores"},
{value:"London", text:"London"},
{value:"Mississauga", text:"Mississauga"},
{value:"Niagara Falls", text:"Niagara Falls"},
{value:"Norfolk County", text:"Norfolk County"},
{value:"North Bay", text:"North Bay"},
{value:"Orillia", text:"Orillia"},
{value:"Oshawa", text:"Oshawa"},
{value:"Ottawa", text:"Ottawa"},
{value:"Owen Sound", text:"Owen Sound"},
{value:"Pembroke", text:"Pembroke"},
{value:"Peterborough", text:"Peterborough"},
{value:"Pickering", text:"Pickering"},
{value:"Prince Edward County", text:"Prince Edward County"},
{value:"Port Colborne", text:"Port Colborne"},
{value:"Quinte West", text:"Quinte West"},
{value:"Sarnia", text:"Sarnia"},
{value:"Sault Ste. Marie", text:"Sault Ste. Marie"},
{value:"St. Catharines", text:"St. Catharines"},
{value:"St. Thomas", text:"St. Thomas"},
{value:"Stratford", text:"Stratford"},
{value:"Temiskaming Shores", text:"Temiskaming Shores"},
{value:"Thorold", text:"Thorold"},
{value:"Thunder Bay", text:"Thunder Bay"},
{value:"Timmins", text:"Timmins"},
{value:"Toronto", text:"Toronto"},
{value:"Vaughan", text:"Vaughan"},
{value:"Waterloo", text:"Waterloo"},
{value:"Welland", text:"Welland"},
{value:"Windsor", text:"Windsor"},
{value:"Woodstock", text:"Woodstock"}];

regiondb["Saskatchewan"] = [{value:"Estevan", text:"Estevan"},
{value:"Flin Flon", text:"Flin Flon"},
{value:"Humboldt", text:"Humboldt"},
{value:"Lloydminster", text:"Lloydminster"},
{value:"Melfort", text:"Melfort"},
{value:"Melville", text:"Melville"},
{value:"Moose Jaw", text:"Moose Jaw"},
{value:"North Battleford", text:"North Battleford"},
{value:"Prince Albert", text:"Prince Albert"},
{value:"Regina", text:"Regina"},
{value:"Saskatoon", text:"Saskatoon"},
{value:"Swift Current", text:"Swift Current"},
{value:"Weyburn", text:"Weyburn"},
{value:"Yorkton", text:"Yorkton"}];

regiondb["Yukon"] = [{value:"Whitehorse", text:"Whitehorse"}];

regiondb["Quebec"] = [{value:"Acton Vale", text:"Acton Vale"},
{value:"Alma", text:"Alma"},
{value:"Amos", text:"Amos"},
{value:"Amqui", text:"Amqui"},
{value:"Asbestos", text:"Asbestos"},
{value:"Baie-Comeau", text:"Baie-Comeau"},
{value:"Baie-Saint-Paul", text:"Baie-Saint-Paul"},
{value:"Beauceville", text:"Beauceville"},
{value:"Becancour", text:"Becancour"},
{value:"Bedford", text:"Bedford"},
{value:"Beloeil", text:"Beloeil"},
{value:"Berthierville", text:"Berthierville"},
{value:"Blainville", text:"Blainville"},
{value:"Boisbriand", text:"Boisbriand"},
{value:"Bonaventure", text:"Bonaventure"},
{value:"Bromont", text:"Bromont"},
{value:"Brossard", text:"Brossard"},
{value:"Cabano", text:"Cabano"},
{value:"Candiac", text:"Candiac"},
{value:"Cap-Chat", text:"Cap-Chat"},
{value:"Cap-Sante", text:"Cap-Sante"},
{value:"Carignan", text:"Carignan"},
{value:"Chambly", text:"Chambly"},
{value:"Chandler", text:"Chandler"},
{value:"Charlemagne", text:"Charlemagne"},
{value:"Chateauguay", text:"Chateauguay"},
{value:"Chateau-Richer", text:"Chateau-Richer"},
{value:"Chibougamau", text:"Chibougamau"},
{value:"Coaticook", text:"Coaticook"},
{value:"Cookshire-Eaton", text:"Cookshire-Eaton"},
{value:"Cowansville", text:"Cowansville"},
{value:"Daveluyville", text:"Daveluyville"},
{value:"Degelis", text:"Degelis"},
{value:"Delson", text:"Delson"},
{value:"Deux-Montagnes", text:"Deux-Montagnes"},
{value:"Dolbeau-Mistassini", text:"Dolbeau-Mistassini"},
{value:"Donnacona", text:"Donnacona"},
{value:"Drummondville", text:"Drummondville"},
{value:"East Angus", text:"East Angus"},
{value:"Farnham", text:"Farnham"},
{value:"Fermont", text:"Fermont"},
{value:"Gaspe", text:"Gaspe"},
{value:"Gatineau", text:"Gatineau"},
{value:"Granby", text:"Granby"},
{value:"Hudson", text:"Hudson"},
{value:"Huntingdon", text:"Huntingdon"},
{value:"Joliette", text:"Joliette"},
{value:"Kingsey Falls", text:"Kingsey Falls"},
{value:"Lac-Brome", text:"Lac-Brome"},
{value:"Lachute", text:"Lachute"},
{value:"Lac-Megantic", text:"Lac-Megantic"},
{value:"La Malbaie", text:"La Malbaie"},
{value:"La Pocatiere", text:"La Pocatiere"},
{value:"La Prairie", text:"La Prairie"},
{value:"La Sarre", text:"La Sarre"},
{value:"L'Assomption", text:"L'Assomption"},
{value:"La Tuque", text:"La Tuque"},
{value:"Laval", text:"Laval"},
{value:"Levis", text:"Levis"},
{value:"L'Ile-Perrot", text:"L'Ile-Perrot"},
{value:"Longueuil", text:"Longueuil"},
{value:"Lorraine", text:"Lorraine"},
{value:"Louiseville", text:"Louiseville"},
{value:"Magog", text:"Magog"},
{value:"Malartic", text:"Malartic"},
{value:"Maniwaki", text:"Maniwaki"},
{value:"Mascouche", text:"Mascouche"},
{value:"Matagami", text:"Matagami"},
{value:"Matane", text:"Matane"},
{value:"Mercier", text:"Mercier"},
{value:"Metis-sur-Mer", text:"Metis-sur-Mer"},
{value:"Mirabel", text:"Mirabel"},
{value:"Mont-Joli", text:"Mont-Joli"},
{value:"Mont-Laurier", text:"Mont-Laurier"},
{value:"Montmagny", text:"Montmagny"},
{value:"Montreal - largest city", text:"Montreal - largest city"},
{value:"Mont-Saint-Hilaire", text:"Mont-Saint-Hilaire"},
{value:"Mont-Tremblant", text:"Mont-Tremblant"},
{value:"Murdochville", text:"Murdochville"},
{value:"New Richmond", text:"New Richmond"},
{value:"Nicolet", text:"Nicolet"},
{value:"Normandin", text:"Normandin"},
{value:"Otterburn Park", text:"Otterburn Park"},
{value:"Paspebiac", text:"Paspebiac"},
{value:"Perce", text:"Perce"},
{value:"Pincourt", text:"Pincourt"},
{value:"Pohenegamook", text:"Pohenegamook"},
{value:"Prevost", text:"Prevost"},
{value:"Quebec", text:"Quebec"},
{value:"Repentigny", text:"Repentigny"},
{value:"Richmond", text:"Richmond"},
{value:"Rimouski", text:"Rimouski"},
{value:"Riviere-du-Loup", text:"Riviere-du-Loup"},
{value:"Roberval", text:"Roberval"},
{value:"Rosemere", text:"Rosemere"},
{value:"Rouyn-Noranda", text:"Rouyn-Noranda"},
{value:"Saguenay", text:"Saguenay"},
{value:"Saint-Constant", text:"Saint-Constant"},
{value:"Sainte-Adele", text:"Sainte-Adele"},
{value:"Sainte-Anne-de-Beaupre", text:"Sainte-Anne-de-Beaupre"},
{value:"Sainte-Anne-des-Plaines", text:"Sainte-Anne-des-Plaines"},
{value:"Sainte-Catherine", text:"Sainte-Catherine"},
{value:"Sainte-Julie", text:"Sainte-Julie"},
{value:"Sainte-Therese", text:"Sainte-Therese"},
{value:"Saint-Eustache", text:"Saint-Eustache"},
{value:"Saint-Georges", text:"Saint-Georges"},
{value:"Saint-Hyacinthe", text:"Saint-Hyacinthe"},
{value:"Saint-Jean-sur-Richelieu", text:"Saint-Jean-sur-Richelieu"},
{value:"Saint-Jerome", text:"Saint-Jerome"},
{value:"Saint-Joseph-de-Beauce", text:"Saint-Joseph-de-Beauce"},
{value:"Saint-Lazare", text:"Saint-Lazare"},
{value:"Saint-Lin-Laurentides", text:"Saint-Lin-Laurentides"},
{value:"Saint-Ours", text:"Saint-Ours"},
{value:"Saint-Raymond", text:"Saint-Raymond"},
{value:"Saint-Sauveur", text:"Saint-Sauveur"},
{value:"Saint-Tite", text:"Saint-Tite"},
{value:"Salaberry-de-Valleyfield", text:"Salaberry-de-Valleyfield"},
{value:"Schefferville", text:"Schefferville"},
{value:"Scotstown", text:"Scotstown"},
{value:"Senneterre", text:"Senneterre"},
{value:"Sept-Iles", text:"Sept-Iles"},
{value:"Shawinigan", text:"Shawinigan"},
{value:"Sherbrooke", text:"Sherbrooke"},
{value:"Sorel-Tracy", text:"Sorel-Tracy"},
{value:"Stanstead", text:"Stanstead"},
{value:"Temiscaming", text:"Temiscaming"},
{value:"Terrebonne", text:"Terrebonne"},
{value:"Thetford Mines", text:"Thetford Mines"},
{value:"Thurso", text:"Thurso"},
{value:"Trois-Pistoles", text:"Trois-Pistoles"},
{value:"Trois-Rivieres", text:"Trois-Rivieres"},
{value:"Valcourt", text:"Valcourt"},
{value:"Val-d'Or", text:"Val-d'Or"},
{value:"Varennes", text:"Varennes"},
{value:"Vaudreuil-Dorion", text:"Vaudreuil-Dorion"},
{value:"Victoriaville", text:"Victoriaville"},
{value:"Ville-Marie", text:"Ville-Marie"},
{value:"Warwick", text:"Warwick"},
{value:"Waterville", text:"Waterville"},
{value:"Windsor", text:"Windsor"}];

function setCities(chooser) {
    var newElem;
    var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
    var cityChooser = chooser.form.elements["city"];
    while (cityChooser.options.length) {
        cityChooser.remove(0);
    }
    var choice = chooser.options[chooser.selectedIndex].value;
    var db = regiondb[choice];
    newElem = document.createElement("option");
    newElem.text = "Choose a City:";
    newElem.value = "";
    cityChooser.add(newElem, where);
    if (choice != "") {
        for (var i = 0; i < db.length; i++) {
            newElem = document.createElement("option");
            newElem.text = db[i].text;
            newElem.value = db[i].value;
            cityChooser.add(newElem, where);
        }
    }
}

function Login()
{
	var oBox = document.getElementById('LoginBox');
	if (oBox)
	{
		if (oBox.style.display == 'none')
		{
        	oBox.innerHTML = "\
			<form id='fLogin' method='post' action='./verifylogin.php'> \
    <table><tr> \
            <td>User name: </td> \
            <td><input type='text' name='username' /></td> \
        </tr> \
        <tr> \
            <td>Password: </td> \
            <td><input type='password' name='password' /></td> \
        </tr> \
		<tr> \
		    <td><a href='javascript:Forgot();'>Forgot Password</a></td> \
            <td align='right'><input type='submit' id='btnSubmit' value='Login' /></td> \
        </tr> \
    </table>  \
    </form>";		
			oBox.style.display = 'block';
		}
		else
		{
			oBox.style.display = 'none';
		}
	}
}

function Forgot(type)
{
	var oBox = document.getElementById('LoginBox');
	if (oBox)
	{
//     		alert(""+type);
//		if ((oBox.style.display == 'none')||(type=="1"))
//		{
        	oBox.innerHTML = "\
	<form id='fLogin' method='post' action='./formmail.php?action=p'> \
    <table><tr> \
          <td colspan='2'>Please enter your email address <br>and we'll email you your login info.<br></td> \
        </tr> \
		<tr> \
            <td>Email: </td> \
            <td><input type='text' name='email_password' /></td> \
        </tr> \
		<tr> \
            <td colspan='2' align='right'><input type='submit' id='btnSubmit' value='Login' /></td> \
        </tr> \
    </table>  \
    </form>";		
			oBox.style.display = 'block';
//		}
/*		else
		{
			oBox.style.display = 'none';
		}*/
	}
}

    function openWindow(url, uid) 
    { 
	    if (uid != '')
		  popupWin = window.open('http://www.yummiestmummy.com/' + url,'remote','menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,dependent,width=420,height=590,left=200,top=160');
		else
		  alert("Please Login or Register to Tell-A-Friend.");
    } 
	
function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}	

function addToEmailList() {

var emailList = " ";
var box;
var i = 0;
var totalCost;
var estCost;
for (var j = 1; j <= 13; j++) {
  box = eval("document.myForm.checkbox" + j); 	  
  if (box.checked == true)
  {
      emailList += box.value + ", ";
  }  
}
//alert("Hi"+emailList);
inputEmailList = eval("document.myForm.emailList");    
inputEmailList.value = emailList;
}

var dofade=true;     // ENABLES FADE-IN EFFECT FOR IE4+ AND NS6 ONLY
var center=false;     // CENTERS THE BOX UNER THE MOUSE, OTHERWISE DISPLAYS BOX TO THE RIGHT OF THE MOUSE
var centertext=false; // CENTERS THE TEXT INSIDE THE BOX. YOU CAN'T SIMPLY DO THIS VIA STYLE BECAUSE OF NS4.
                     // OTHERWISE, TEXT IS LEFT-JUSTIFIED. 


////////////////////////////// NO NEED TO EDIT BEYOND THIS POINT //////////////////////////////////////

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

var NS4 = (navigator.appName.indexOf("Netscape")>=0 && !document.getElementById)? true : false;
var IE4 = (document.all && !document.getElementById)? true : false;
var IE5 = (document.getElementById && document.all)? true : false;
var NS6 = (document.getElementById && navigator.appName.indexOf("Netscape")>=0 )? true: false;
var W3C = (document.getElementById)? true : false;
var w_y, w_x, navtxt, boxheight, boxwidth;
var ishover=false;
var isloaded=false;
var ieop=0;
var op_id=0;

function getwindowdims(){
w_y=(NS4||NS6||window.opera)? window.innerHeight : (IE5||IE4)? document.body.clientHeight : 0;
w_x=(NS4||NS6||window.opera)? window.innerWidth : (IE5||IE4)? document.body.clientWidth : 0;
}

function getboxwidth(){
if(NS4)boxwidth=(navtxt.document.width)? navtxt.document.width : navtxt.clip.width;
if(IE5||IE4)boxwidth=(navtxt.style.pixelWidth)? navtxt.style.pixelWidth : navtxt.offsetWidth;
if(NS6)boxwidth=(navtxt.style.width)? parseInt(navtxt.style.width) : parseInt(navtxt.offsetWidth);
}

function getboxheight(){
if(NS4)boxheight=(navtxt.document.height)? navtxt.document.height : navtxt.clip.height;
if(IE4||IE5)boxheight=(navtxt.style.pixelHeight)? navtxt.style.pixelHeight : navtxt.offsetHeight;
if(NS6)boxheight=parseInt(navtxt.offsetHeight);

}

function movenavtxt(x,y){
if(NS4)navtxt.moveTo(x,y);
if(W3C||IE4){
navtxt.style.left=x+'px';
navtxt.style.top=y+'px';
}}

function getpagescrolly(){
if(NS4||NS6)return window.pageYOffset;
if(IE5||IE4)return ietruebody().scrollTop;
}

function getpagescrollx(){
if(NS4||NS6)return window.pageXOffset;
if(IE5||IE4)return ietruebody().scrollLeft;
}

function writeindiv(text){
if(NS4){
navtxt.document.open();
navtxt.document.write(text);
navtxt.document.close();
}
if(W3C||IE4)navtxt.innerHTML=text;
}

//**** END UTILITY FUNCTIONS ****//

function writetxt(text){
if(isloaded){
if(text!=0){
ishover=true;
if(NS4)text='<div class="navtext">'+((centertext)?'<center>':'')+text+((centertext)?'</center>':'')+'</div>';
writeindiv(text);
getboxheight();
if((W3C || IE4) && dofade){
ieop=0;
incropacity();
}}else{
if(NS4)navtxt.visibility="hide";
if(IE4||W3C){
if(dofade)clearTimeout(op_id);
navtxt.style.visibility="hidden";
}
writeindiv('');
ishover=false;
}}}

function incropacity(){
if(ieop<=100){
ieop+=7;
if(IE4 || IE5)navtxt.style.filter="alpha(opacity="+ieop+")";
if(NS6)navtxt.style.MozOpacity=ieop/100;
op_id=setTimeout('incropacity()', 50);
}}

function moveobj(evt){
if(isloaded && ishover){
margin=(IE4||IE5)? 1 : 23;
if(NS6)if(document.height+27-window.innerHeight<0)margin=15;
if(NS4)if(document.height-window.innerHeight<0)margin=10;
//mx=(NS4||NS6)? evt.pageX : (IE5||IE4)? event.clientX : 0;
//my=(NS4||NS6)? evt.pageY : (IE5||IE4)? event.clientY : 0;
if (NS4){
mx=evt.pageX
my=evt.pageY
}
else if (NS6){
mx=evt.clientX
my=evt.clientY
}
else if (IE5){
mx=event.clientX
my=event.clientY
}
else if (IE4){
mx=0
my=0
}

if(NS4){
mx-=getpagescrollx();
my-=getpagescrolly();
}
xoff=(center)? mx-boxwidth/2 : mx+5;
yoff=(my+boxheight+30-getpagescrolly()+margin>=w_y)? -15-boxheight: 30;
movenavtxt( Math.min(w_x-boxwidth-margin , Math.max(2,xoff))+getpagescrollx() , my+yoff+getpagescrolly());
if(NS4)navtxt.visibility="show";
if(W3C||IE4)navtxt.style.visibility="visible";
}}

if(NS4)document.captureEvents(Event.MOUSEMOVE);
document.onmousemove=moveobj;
window.onload=function(){
  navtxt=(NS4)? document.layers['navtxt'] : (IE4)? document.all['navtxt'] : (W3C)? document.getElementById('navtxt') : null;
  getboxwidth();
  getboxheight();
  getwindowdims();
  isloaded=true;
  if((W3C || IE4) && centertext)navtxt.style.textAlign="center";
  if(W3C)navtxt.style.padding='4px';
  if(IE4 || IE5 && dofade)navtxt.style.filter="alpha(opacity=0)";
  }
window.onresize=getwindowdims;
