/*added by amir*/
function popupWindow(name, url) {


		popup = window.open(url, name, 'location=no,menubar=no,toolbar=no,personalbar=no,status=yes,scrollbars=yes,resizable=yes,height=600,width=800');


		popup.focus();
	}

/* enewsletter form validation - English*/
<!--
	// This file contains the data validation JavaScript functions
	// It is included in the HTML pages with forms that need these
	// data validation routines.


// DEFINE VARIABLES

// whitespace characters
var whitespace = " \t\n\r";

/****************************************************************/

// PURPOSE:  Check to see if form has been completed

function formvalidation(aForm)

{
	// Check to make sure that a first name has been entered
	if (isEmpty(aForm.FirstName.value)) {
		alert("Please enter your first name");
		return false;
	}

	// Check to make sure that a last name bas been entered
	if (isEmpty(aForm.LastName.value)) {
		alert("Please enter your last name");
		return false
	}
	
	
	// Check to make sure that a valid email address has been entered
	if (!isEmail(aForm.Email.value, false)) {
		alert("Please enter a valid email address");
		return false;
	}
	
	// Check to make sure that a valid phone number has been entered
	/*if (!isEmail(aForm.Phone.value, false)) {
		alert("Please enter your phone number");
		return false;
	}*/

	// Check to make sure that a date of birth has been entered
	if (!ForceDate(aForm.BirthDay)) {
		alert("Please enter a valid date of birth");
		return false;
	}

// Check to make sure that a gender has been selected
	var genderSet = false;
	for (var i=0; i < aForm.Gender.length; i++) {
		if (aForm.Gender[i].checked) {
			genderSet = true;
			break;
		}
	}

	if (!genderSet) {
		alert("Please select gender.");
		return false;
	}
	
	// Make all the strings safe for entry into the database
	aForm.FirstName.value = sqlSafe(aForm.FirstName.value);
	aForm.LastName.value = sqlSafe(aForm.LastName.value);

	return true; 
}

/****************************************************************/

/* PURPOSE:  Since we are using the single tick mark as the
	string delimiter to construct our SQL queries, a string with
	a tick mark in it will cause a SQL error.  Therefore we replace
	all "'" with "''", which eliminates the possibility of a SQL error.
*/

function sqlSafe (s)
{
	var new_s = s;
	new_s = replaceAll (new_s, "'", "|");
	new_s = replaceAll (new_s, "|", "''");
	new_s = replaceAll (new_s, "\"", "|");
	new_s = replaceAll (new_s, "|", "''");
	return new_s;
}

// Check whether string s is empty.

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

// isEmail (STRING s [, BOOLEAN emptyOK])
// 
// Email address must be of form a@b.c ... in other words:
// * there must be at least one character before the @
// * there must be at least one character before and after the .
// * the characters @ and . are both required
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isEmail (s)
{   if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return defaultEmptyOK;
       else return (isEmail.arguments[1] == true);
   
    // is s whitespace?
    if (isWhitespace(s)) return false;
    
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))

    { i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

// Returns true if string s is empty or 
// whitespace characters only.

function isWhitespace (s)

{   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
	// Check that current character isn't whitespace.
	var c = s.charAt(i);

	if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}

/* PURPOSE:  Returns true if the string is a valid date number.
	A method is passed in (1 = month, 2 = day).  If the string is
	nonnumeric, false is passed back.  If the day in the date string
	is greater than 31, false is returned.  If the month is greater
	than 12, an error is returned.
*/

function isDateNumber(strNum,method)
{
	var str = new String(strNum);
	var i = 0;

	if (isNaN(parseInt(str)) || parseInt(str) < 0) return false;

	if (method == 2)
		if (parseInt(str) > 31)
			return false;
	if (method == 1)
		if (parseInt(str) > 12)
			return false;

	for (i = 0; i < str.length; i++)
		if (str.charAt(i) < '0' || str.charAt(i) > '9')
			return false;


	return true;
}

/****************************************************************/

// Displays an alert box with the passed in string...

function PromptErrorMsg(Field,strError)
{
	alert("You have entered an invalid date for " + strError + ".  Please make sure your date format is in M/D/Y format.");
	Field.focus();
}

/****************************************************************/

/* PURPOSE: Checks to see if the string is a valid date.  A valid
	date is defined as any of the following:

		MM/DD/YY, MM/DD/YYYY, M/D/YY, M/D/YYYY,
		MM-DD-YY, MM-DD-YYYY, M-D-YY, M-D-YYYY
*/

function ForceDate(strDate,strField)
{
	var str = new String(strDate.value);

	if (isWhitespace(str)) {
		return false;
		// if the field is empty, just return false...
	}

	var i = 0, count = str.length, j = 0;
	while ((str.charAt(i) != "/" && str.charAt(i) != "-") && i < count)
		i++;

	if (i == count || i > 2) {
		return false;
	}

	var addOne = false;
	if (i == 2) addOne = true;

	if (!isDateNumber(str.substring(0,i),1)) {
		return false;
	}

	j = i+1;
	i = 0;

	while ((str.charAt(i+j) != "/" && str.charAt(j+i) != "-") && i+j < count)
		i++;

	if (i+j == count || i > 2) {
		return false;
	}

	if (!isDateNumber(str.substring(j,i+j),2)) {
		return false;
	}

	j = i+3;
	i = 0;

	if (addOne) j++;

	while (i+j < count)
		i++;


	if (i != 2 && i != 4) {
		return false;
	}

	if (!isDateNumber(str.substring(j,i+j),3)) {
		return false;
	}

	return true;
}

// -->
/*enewsletter form validation - English ends*/

/* enewsletter form validation - French*/
<!--
	// This file contains the data validation JavaScript functions
	// It is included in the HTML pages with forms that need these
	// data validation routines.


// DEFINE VARIABLES

// whitespace characters
var whitespace = " \t\n\r";

/****************************************************************/

// PURPOSE:  Check to see if form has been completed

function formvalidation_fr(aForm)

{
	// Check to make sure that a first name has been entered
	if (isEmpty(aForm.FirstName.value)) {
		alert("S.V.P. indiquer votre prénom");
		return false;
	}

	// Check to make sure that a last name bas been entered
	if (isEmpty(aForm.LastName.value)) {
		alert("S.V.P. indiquer votre nom");
		return false
	}

	// Check to make sure that a valid email address has been entered
	if (!isEmail(aForm.Email.value, false)) {
		alert("S.V.P. indiquer votre courriel");
		return false;
	}

	// Check to make sure that a date of birth has been entered
	if (!ForceDate(aForm.BirthDay)) {
		alert("S.V.P. indiquer une date valide");
		return false;
	}

	// Check to make sure that a gender has been selected
	var genderSet = false;
	for (var i=0; i < aForm.Gender.length; i++) {
		if (aForm.Gender[i].checked) {
			genderSet = true;
			break;
		}
	}

	if (!genderSet) {
		alert("S.V.P. indiquer le genre");
		return false;
	}

	// Make all the strings safe for entry into the database
	aForm.FirstName.value = sqlSafe(aForm.FirstName.value);
	aForm.LastName.value = sqlSafe(aForm.LastName.value);

	return true; 
}

/****************************************************************/

/* PURPOSE:  Since we are using the single tick mark as the
	string delimiter to construct our SQL queries, a string with
	a tick mark in it will cause a SQL error.  Therefore we replace
	all "'" with "''", which eliminates the possibility of a SQL error.
*/

function sqlSafe (s)
{
	var new_s = s;
	new_s = replaceAll (new_s, "'", "|");
	new_s = replaceAll (new_s, "|", "''");
	new_s = replaceAll (new_s, "\"", "|");
	new_s = replaceAll (new_s, "|", "''");
	return new_s;
}

// Check whether string s is empty.

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

// isEmail (STRING s [, BOOLEAN emptyOK])
// 
// Email address must be of form a@b.c ... in other words:
// * there must be at least one character before the @
// * there must be at least one character before and after the .
// * the characters @ and . are both required
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isEmail (s)
{   if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return defaultEmptyOK;
       else return (isEmail.arguments[1] == true);
   
    // is s whitespace?
    if (isWhitespace(s)) return false;
    
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))

    { i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

// Returns true if string s is empty or 
// whitespace characters only.

function isWhitespace (s)

{   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
	// Check that current character isn't whitespace.
	var c = s.charAt(i);

	if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}

/* PURPOSE:  Returns true if the string is a valid date number.
	A method is passed in (1 = month, 2 = day).  If the string is
	nonnumeric, false is passed back.  If the day in the date string
	is greater than 31, false is returned.  If the month is greater
	than 12, an error is returned.
*/

function isDateNumber(strNum,method)
{
	var str = new String(strNum);
	var i = 0;

	if (isNaN(parseInt(str)) || parseInt(str) < 0) return false;

	if (method == 2)
		if (parseInt(str) > 31)
			return false;
	if (method == 1)
		if (parseInt(str) > 12)
			return false;

	for (i = 0; i < str.length; i++)
		if (str.charAt(i) < '0' || str.charAt(i) > '9')
			return false;


	return true;
}

/****************************************************************/

// Displays an alert box with the passed in string...

function PromptErrorMsg(Field,strError)
{
	alert("You have entered an invalid date for " + strError + ".  Please make sure your date format is in M/D/Y format.");
	Field.focus();
}

/****************************************************************/

/* PURPOSE: Checks to see if the string is a valid date.  A valid
	date is defined as any of the following:

		MM/DD/YY, MM/DD/YYYY, M/D/YY, M/D/YYYY,
		MM-DD-YY, MM-DD-YYYY, M-D-YY, M-D-YYYY
*/

function ForceDate(strDate,strField)
{
	var str = new String(strDate.value);

	if (isWhitespace(str)) {
		return false;
		// if the field is empty, just return false...
	}

	var i = 0, count = str.length, j = 0;
	while ((str.charAt(i) != "/" && str.charAt(i) != "-") && i < count)
		i++;

	if (i == count || i > 2) {
		return false;
	}

	var addOne = false;
	if (i == 2) addOne = true;

	if (!isDateNumber(str.substring(0,i),1)) {
		return false;
	}

	j = i+1;
	i = 0;

	while ((str.charAt(i+j) != "/" && str.charAt(j+i) != "-") && i+j < count)
		i++;

	if (i+j == count || i > 2) {
		return false;
	}

	if (!isDateNumber(str.substring(j,i+j),2)) {
		return false;
	}

	j = i+3;
	i = 0;

	if (addOne) j++;

	while (i+j < count)
		i++;


	if (i != 2 && i != 4) {
		return false;
	}

	if (!isDateNumber(str.substring(j,i+j),3)) {
		return false;
	}

	return true;
}

// -->
/*enewsletter form validation - French ends*/


/*added by amir ends*/

function openWindow(link) {

	newWindow = window.open(link,'StoreListing','location=no,menubar=yes,toolbar=yes,personalbar=no,status=yes,scrollbars=yes,resizable=yes,height=550,width=780');

	newWindow.focus();

}



function isInteger(s)

{

    for (i = 0; i < s.length; i++)

    {   

        // Check that current character is number.

        var c = s.charAt(i);

        if(!((c >= "0") && (c <= "9")))

	{

	        return false;

	}

    }

    return true

}



function isBlank(str) {

		 if ((str != null) && (str != "")) {

			  for (var i=0; i < str.length; i++) {

					var ch = str.charAt(i)

					if ((ch != ' ') && (ch != '\r') && (ch != '\n') && (ch != '\t')) {

						 return false

					}

			  }

		 }



		 return true

}





function isEmail(s) {

	 // there must be >= 1 character before @, so we

	 // start looking at character position 1

	 // (i.e. second character)

	 var i = 1;

	 var sLength = s.length;



	 // look for @

	 while ((i < sLength) && (s.charAt(i) != "@"))

	 { i++

	 }



	 if ((i >= sLength) || (s.charAt(i) != "@")) return false;

	 else i += 2;



	 // look for .

	 while ((i < sLength) && (s.charAt(i) != "."))

	 { i++

	 }



	 // there must be at least one character after the .

	 if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;

	 else return true;

}



function get_screen_X() {

	(document.layers) ? scrX = innerWidth : scrX = document.body.clientWidth;

}



function moveDivs() {

	get_screen_X()

	winWidth = scrX ;

	shiftX = (winWidth - 773)/2



	if (navigator.appName == "Netscape") {

		document.MenuB.left = 42 + shiftX

		document.MenuC.left = 129 + shiftX

		document.MenuD.left = 235 + shiftX

		document.MenuE.left = 318 + shiftX

		document.MenuF.left = 399 + shiftX

		document.MenuG.left = 505 + shiftX

		document.MenuH.left = 581 + shiftX

		document.MenuI.left = 634 + shiftX

		document.MenuJ.left = 698 + shiftX

	} else {

		document.all.MenuB.style.left = 42 + shiftX

		document.all.MenuC.style.left = 129 + shiftX

		document.all.MenuD.style.left = 235 + shiftX

		document.all.MenuE.style.left = 318 + shiftX

		document.all.MenuF.style.left = 399 + shiftX

		document.all.MenuG.style.left = 505 + shiftX

		document.all.MenuH.style.left = 581 + shiftX

		document.all.MenuI.style.left = 634 + shiftX

		document.all.MenuJ.style.left = 698 + shiftX

	}

}



function moveMetDivs() {

	get_screen_X()

	winWidth = scrX ;

	shiftX = (winWidth - 760)/2



	if (navigator.appName == "Netscape") {

		document.MenuB.left = 45 + shiftX

		document.MenuC.left = 130 + shiftX

		document.MenuD.left = 235 + shiftX

		document.MenuE.left = 315 + shiftX

		document.MenuF.left = 395 + shiftX

		document.MenuG.left = 501 + shiftX

		document.MenuH.left = 578 + shiftX

		document.MenuI.left = 628 + shiftX

		document.MenuJ.left = 688 + shiftX

	} else {

		document.all.MenuB.style.left = 45 + shiftX

		document.all.MenuC.style.left = 130 + shiftX

		document.all.MenuD.style.left = 235 + shiftX

		document.all.MenuE.style.left = 315 + shiftX

		document.all.MenuF.style.left = 395 + shiftX

		document.all.MenuG.style.left = 501 + shiftX

		document.all.MenuH.style.left = 578 + shiftX

		document.all.MenuI.style.left = 628 + shiftX

		document.all.MenuJ.style.left = 688 + shiftX

	}

}



	function initMenus() {

	 setTimeout("window.onresize = reDoIt()", 10);

	}



	function reDoIt() {

	    if (navigator.appName == "Netscape") {

		   window.location.reload();

		}

    }



    function callMover() {

     if (navigator.appName == "Netscape") {

      initMenus()

     } else {

      moveDivs()

     }

	}



    function callMetMover() {

     if (navigator.appName == "Netscape") {

      initMenus()

     } else {

      moveMetDivs()

     }

	}



function replace(original,replaceme,replacewith) {

	var tmporiginal = original;

	var lenoriginal = original.length;

	var lenreplaceme = replaceme.length;

	var lenreplacewith = replacewith.length;

	var wposition = original.indexOf(replaceme);

	while (wposition>=0) {

		tmporiginal = tmporiginal.substring(0, wposition) + replacewith + tmporiginal.substring(wposition+lenreplaceme, lenoriginal);

		lenoriginal = tmporiginal.length;

		wposition = tmporiginal.indexOf(replaceme, wposition+lenreplacewith);

	}

	return tmporiginal;

}





function setUrl(url)

{

	if (document.flashmovie != null)

	{

		document.flashmovie.SetVariable('myURL',url);

	}



}
/*UPPER CANADA MALL - redevelopment photos*/
var newwindow;
var wheight = 0, wwidth = 0;

function popitup5(url, title, iwidth, iheight, colour) {
var pwidth, pheight;

if ( !newwindow || newwindow.closed ) {
pwidth=iwidth+30;
pheight=iheight+30;
newwindow=window.open('','htmlname','width=' + pwidth +',height=' +pheight + ',resizable=1,top=50,left=10');
wheight=iheight;
wwidth=iwidth;
}

if (wheight!=iheight || wwidth!=iwidth ) {
pwidth=iwidth+30;
pheight=iheight+90;
newwindow.resizeTo(pwidth, pheight);
wheight=iheight;
wwidth=iwidth;
}

newwindow.document.clear();
newwindow.focus();
newwindow.document.writeln('<html> <head> <title>' + title + '<\/title> <\/head> <body bgcolor= \"' + colour + '\"> <center>');
newwindow.document.writeln('<img src=' + url + ' title=\"' + title + '\" alt=\"' + title + '\" >');
newwindow.document.writeln('<\/center> <\/body> <\/html>');
newwindow.document.close();
newwindow.focus();
}

// Routines to tidy up popup windows when page is left
// Call with an onUnload="tidy5()" in body tag

function tidy5() {
if (newwindow && !newwindow.closed) { newwindow.close(); }
}

// Based on JavaScript provided by Peter Curtis at www.pcurtis.com 


/*UPPER CANADA MALL - redevelopment photos ends*/




// CHA sorting

 function checkInt_1(tf) {
    oldStr=tf.value;
    newStr=removeFirtZeros(checkInts_1(oldStr));
    if(oldStr!=newStr) tf.value=newStr;
  }
  function checkInts_1(str) {
    var validChars='0123456789';
    var lenStr=str.length;
    var res=0;
    var newStr="";
    for(var i=0; i<lenStr; i++) {
      ch1=str.charAt(i);
      res=validChars.indexOf( ch1 );
      if(res>=0) newStr+=ch1;
    }
    return newStr;
  }
  function removeFirtZeros(str) {
    if(str=="0") return "";
    var lenStr=str.length;
    var pos=0;
    for(var i=0; i<lenStr; i++) {
      ch1=str.charAt(i);
      pos=i;
      if(ch1!='0') {
        break;
      }
    }
    return str.substr(pos);
  }
// -----------------------
  function testInt_2(event, tf) {
    if(isIE) {
      str=String.fromCharCode(event.keyCode);
    } else {
      if(event.which==0 || event.which==8 || event.which==13) return true;
      str=String.fromCharCode(event.which);
    }

    if(tf.value.length==0 && str=="0") return false;

    flag=checkChars_2(str);
    return flag;
  }
  function checkChars_2(str) {
    var validChars='0123456789';
    var lenStr=str.length;
    var res=0;
    for(var i=0; i<lenStr; i++) {
      res=validChars.indexOf( str.charAt(i) );
      if(res<0) break;
    }
    if(res<0) return false;
    else return true;
  }

