function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

function validateEmail(source, args)
{
var mystring = args.Value;

// validates an email address
// even one with a ?subject= at the end
// or even one with an apostrophe in the front part

pos2 = mystring.indexOf('?'); 

if (pos2 != -1)
{
mystring = mystring.substring(0, pos2);
}

 if (mystring.search(/^([a-zA-Z0-9_\.\-\'])+\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        //return true;
		args.IsValid = true;
    else
		{
        args.IsValid = false;
        //return false;
		}

}


   function map_popup(arg_winname, arg_winheight, arg_winwidth, arg_areanum, arg_walknum)
    {
    
	var leftPos = 230;
    var topPos = 160;
    
    var page = 'map_popup.aspx?areanum=' + arg_areanum + '&walknum=' + arg_walknum

    var features = 'height=' + arg_winheight + ',width=' + arg_winwidth + ',location=no,menubar=no,resizable=no,scrollbars=yes,' +
      'toolbar=no,status=no,screenX=' + leftPos + ',left='+ leftPos +',screenY=' + topPos + ',top=' + topPos;

    window.open(page, arg_winname, features, false);

    }