﻿function couponPopup(url, name, width, height){
	popwin = this.open(url, name, "width=" + width + ",height=" + height + ",toolbar=no,menubar=no,location=no,scrollbars=no,resize=no,noresize,topmargin=0,marginheight=0,marginwidth=0,leftmargin=0");
	popwin.focus()
}

function mp_fbs_click(u, t)
{
    //u= 'http://www.torontorestaurants.com';
    //t= 'Toronto Restaurants Guide TorontoRestaurants.com';
    window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;
}

function bebo_click()
{
    u=location.href;
    t=document.title;
    window.open('http://www.bebo.com/c/share?Url='+encodeURIComponent(u)+'&Title='+encodeURIComponent(t)+'&MID=8974376238&TUUID=fc7850b8-964c-47bd-8a91-db1d2a5cad3c','sharer','toolbar=0,status=0,width=626,height=436');
    return false;
}

function isValidPostalCode(postalCode) 
{
    postalCode = postalCode.toUpperCase().replace(/^\s*|\s*$/g,'');    
    postalCodeFormatRegex = /^([A-Z][0-9][A-Z])\s?([0-9][A-Z][0-9])$/;
    postalCodeValidityRegex = /^([ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ])\s?([0-9][ABCEGHJKLMNPRSTVWXYZ][0-9])$/;
    
    if (!postalCodeFormatRegex.test(postalCode))
    {
        alert('Postal Code should be entered as one of the following two formats:\n\n m1m 1m1  or  m1m1m1.');
        return false;
    }
    else 
    {
        if (!postalCodeValidityRegex.test(postalCode))
        {
           alert('Postal Code is not valid.');
           return false;
        }
    }
    return true;
}

function ClearEnterInstruction()
{
    var elem = document.getElementById('txtFromAddress');
    if(elem.value == 'Enter Your Address')
    {
        elem.value = '';
    }
}

function RestoreEnterInstruction()
{
    var elem = document.getElementById('txtFromAddress');
    if(elem.value == null || elem.value == '')
    {
        elem.value = 'Enter Your Address';
    }
}
