var g_Browser = new String();   // for browser-sniffing.
var g_URL = location.href;
var g_HostPrefix = getURLBase();
var button = make_address ("/images/button.gif");
var csic = make_address ("/images/csic.gif");
var csic_url = "http://www.csic.ca";
var affiliates = make_address ("/images/affiliates.jpg");
var affiliates_url = make_address ("/links/affiliates.html");

/* globals for all documents; used for display of email */
strCc = new String("&#99;&#99");
strInfo = new String("&#105;&#110;&#102;&#111;");
strCons = new String("&#99;&#111;&#110;&#115;&#117;&#108;&#116;&#97;&#116;&#105;&#111;&#110;&#115;");
strPrez = new String("&#112;&#114;&#101;&#115;&#105;&#100;&#101;&#110;&#116;");
strUS = new String("&#117;&#115;&#118;&#105;&#115;&#97;&#115;");
strACC = new String("&#97;&#99;&#99;&#111;&#117;&#110;&#116;&#115;");


function spmelly(nme, disp, xtra)
/* 
   Print spam-harvester-unfriendly email addresses.
   Takes 3 required and 1 optional parameter.
   - nme is the user name
   - dom is the domain w/o the dot or top-level domain identifier
     (e.g., '.com'. This gets appended automatically.)
   - disp is the 'display' name of the link e.g., Marketing, Sales, Netron Hotline etc.
   - xtra is any extra things appended to "mailto" href for a pop-up email address, 
     e.g., 'subject=Your Request&body=Forget it'.
*/
{
    var append = "";
	var dom = "icanadadirect";
    if (xtra == null || xtra == "")
    {
        ;
    } else append = "?" + xtra;
    var a = new String('<a href="');
    var clsa = new String('</a>');
    var mail = "mail";
    var to   = String.fromCharCode(0164, 0157, 072);
    var et = String.fromCharCode(0100);
    var tld = new String('&#046;&#099;&#111;&#109;');
    document.write(a + mail + to + nme + et + dom + tld + append + '">');
    document.write(disp);
    document.write(clsa);
}


function getURLBase()
{
   if (window.location.host != "www.icanadadirect.com")
    {
        var re = /icanadadirect/
        var ar = re.exec(g_URL);
        if (ar != null)
        {
            return g_URL.substring(0,ar.index + 13);
        }
    }
    return window.location.protocol + "//" + window.location.host;
} // end of getURLBase


/* Determine the user's browser type/version. */
        
function includeStyleSheet(name) 
{
    g_Browser=navigator.appName;
    var version=navigator.appVersion;
    var ver1=version.substring(0,1);
    var ver2=version.lastIndexOf("MSIE");
    var ver3=version.substring(ver2+5,ver2+6);

    if (g_Browser == "Netscape")
    {
        if (ver1 == 4)
        {
            document.write('<link rel="stylesheet" href="' + name + '_nc4.css" type="text/css">');
        }
        else if (ver1 >= 5)
        {
            // Mozilla or Netscape 7
            document.write('<link rel="stylesheet" href="' + name + '_ie4.css" type="text/css">');
        }
    }

    if (g_Browser == "Microsoft Internet Explorer")
    {
        if (ver1 >= 4)
        {
            document.write('<link rel="stylesheet" href="' + name + '_ie4.css" type="text/css">');
        }
        if (ver3 == 3)
        {
            document.write('<link rel="stylesheet" href="' + name + '_ie3.css" type="text/css">');
        }
    }
}


/*
   Includes the META tags at the top of every html file.
   Loads up the style sheets & favourites icon.
*/
function includeHeaders() {
    document.write('<meta name="description" content="iCanada Direct Immigration Services.">');
    document.write('<meta name="keywords"    content="immigration canada refugee work study">');
    document.write('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
    document.write('<link rel="shortcut icon" href="' + make_address("/images/favicon.ico") + '" type="image/x-icon">  <!-- for IE -->');
    document.write('<link rel="icon" href="' + make_address("/images/favicon.ico") + '" type="image/vnd.microsoft.icon"> <!-- for other browsers -->');
    includeStyleSheet(make_address("/css/body"));
    includeStyleSheet(make_address("/css/lmenu"));
}


/*
    Prints the <td ...> characteristics of the lmenuXXX tables.
    - classname is the name of the .css class for the column.
    - col_link is optional.  It is the link for any text in the table.
    - outside_link is optional.  It is set to 1 if the link is outside the icanadadirect.com domain.
*/
function col_desc(classname, col_link, outside_link) {
    if (col_link == null || col_link == "") 
    {
        return ('<td class="' + classname + '">');
    }
    else 
    {
        var address = make_address (col_link);
        if (document.URL == address)
        {
         // The current row is for the page being displayed now - change row colour and remove link.
            return ('<td class="' + classname + '">');
        }
        else 
        {
            if (outside_link != null && outside_link != 0) 
            {
                address = col_link;
            }
            return ('<td class="' + classname + '" onmouseup="handleMenuClick(event); return true;"><a class="' + classname + '" href="' + address + '">');
      }
   }
}

//---------------------------------------------
// X-Browser Handler for a mouseup that's inside the
// Menu link TD cell, but not exactly on the
// anchor tag. Lets the user click anywhere
// inside the cell and display the item, not just
// inside the anchor.
//---------------------------------------------
function handleMenuClick(e)
{
// Makes the assumption that all menu TD cells 
// generated by function "col_desc"
// have exactly one anchor tag.
    if (!e)
        var e = window.event;

    var element = typeof e.srcElement!='undefined' ? e.srcElement : e.target;
    //
    // If they clicked on the Anchor tag, let it handle the window redirection
    if (element.tagName == "A") 
        return;

    // Only IE has element.all
    var docLinks = typeof element.all!='undefined' ? element.all.tags("A") : element.getElementsByTagName("A");
    //
    // If element contains anchor, display its target
    if (docLinks.length > 0) 
        top.location = docLinks[0].href;
}

// Formats the links to give them the correct address of the server they are on.
function make_address(address, dont_write) {
    var new_address = g_HostPrefix;
    new_address += address;
    if (dont_write == null || dont_write == 0) 
    {
        return new_address;
    }
    else 
    {
        document.write(new_address);
    }
}

// Draws the csic logo.
function csic_logo () {
	document.write('<tr><td><a href="' + csic_url + '" target=\"_blank"><img src="' + csic + '" width="100%" border="0"></a></td></tr>');
}

// Draws the affiliates button.
function affiliates_button () {
	document.write('<tr><td><br><a href="' + affiliates_url + '"><img src="' + affiliates + '" width="188" height="250" border="0"></a></td></tr>');
}

// Draws the green check mark.
function check_mark () {
	document.write('<img src="' + make_address("/images/check_mark.jpg") + '" border="0">');
}

// Prints out the header menu.
function hmenu() {
	document.write('<center>');
    document.write('<table cellspacing="0" cellpadding="0" border="0" width="800" background="' + make_address("/images/backgroundwide.jpg") + '">');
    document.write('<tr>');
    document.write('<td align="center">');
//	document.write('<div id="phone"><img src="' + make_address("/images/phone.gif") + '"></div>');
	document.write('<div id="topright"><div class="twelvePtwhite">');
	document.write('OPEN 24 HOURS/DAY, 7 DAYS/WEEK >>PHONE: 416-887-7382 / 647-435-3315 &nbsp;&nbsp;&nbsp; >>FAX: 647-435-1082</div></div>');
	document.write('</td>');
    document.write('</tr>');
    document.write('<tr>');
    document.write('<td>');
	document.write('<a href="' + make_address("/home.html") + '">');
	document.write('<img src="' + make_address("/images/banner_left.jpg") + '" id="inlineimg1">');
	document.write('<img src="' + make_address("/images/canada-flag.jpg") + '" id="inlineimg">');
	document.write('<img src="' + make_address("/images/banner_right.jpg") + '" id="inlineimg1">');
    document.write('</a>');
	document.write('</td>');
    document.write('</tr>');
    document.write('<tr>');
    document.write('<td>');
	document.write('<div id="navmenu">');
	document.write('<ul>');
	document.write('<li><a href="' + make_address("/home.html") + '" title="Home">HOME</a><li>');
	document.write('<li><a href="' + make_address("/about/") + '" title="About Us">ABOUT US</a><li>');
	document.write('<li><a href="' + make_address("/services/") + '" title="Services">SERVICES</a><li>');
	document.write('<li><a href="' + make_address("/pricing/") + '" title="Pricing">PRICING</a><li>');
	document.write('<li><a href="' + make_address("/customers/") + '" title="Customer Login Page">CUSTOMERS</a><li>');
	document.write('<li><a href="' + make_address("/faq/") + '" title="Frequently Asked Questions">FAQ</a><li>');
	document.write('<li><a href="' + make_address("/screening/") + '" title="Assessment">ASSESSMENT</a><li>');
	document.write('<li><a href="http://blog.icanadadirect.com" target="_blank" title="Blog">BLOG</a><li>');
	document.write('<li><a href="' + make_address("/links/") + '" title="Links">LINKS</a><li>');
	document.write('<li><a href="' + make_address("/about/contact.html") + '" title="Contact Us">CONTACT US</a><li>');
	document.write('<li><a href="' + make_address("/links/affiliates.html") + '" title="Affiliates">AFFILIATES</a><li>');
	document.write('</ul></div>');
	document.write('</td>');
    document.write('</tr>');
    document.write('</table>');
}

// Prints out the left menu for the home page.
function lmenu_home() {
    document.write('<table cellspacing="1" cellpadding="0" border="0" width="100%">');
	csic_logo();
	document.write('<tr>' + col_desc("title") + '<img src="' + button + '" border="0">Home<img src="' + button + '" border="0"></a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/services/") + 'Services</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/pricing/") + 'Pricing</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/customers/") + 'Customers</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/about/") + 'About Us</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/faq/") + 'FAQ</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/links/") + 'Links</a></td></tr>');
	document.write('<tr>' + col_desc("title") + 'New!</td></tr>');
    document.write('<tr>' + col_desc("imnav", "/about/consultants.html") + 'About Consultants</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/screening/") + 'Assessment</a></td></tr>');
	document.write('<tr>' + col_desc("imnav", "http://blog.icanadadirect.com\" target=\"_blank", 1) + 'Blog</a></td></tr>');
	affiliates_button ();
    document.write('</table>');            
}


// Prints out the left menu for the 'about us' page.
function lmenu_about() {
    document.write('<table cellspacing="1" cellpadding="0" border="0" width="100%">');
	csic_logo();
    document.write('<tr>' + col_desc("title") + 'About Us</td></tr>');
    document.write('<tr>' + col_desc("imnav", "/about/") + 'General Info</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "http://blog.icanadadirect.com\" target=\"_blank", 1) + 'Blog</a></td></tr>');
	document.write('<tr>' + col_desc("imnav", "/about/consultants.html") + 'About Consultants</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/about/credentials.html") + 'Credentials</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/about/media.html") + 'Media / Articles</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/about/contact.html") + 'Contact Us</a></td></tr>');
	affiliates_button ();
    document.write('</table>');
}


// Prints out the left menu for the 'services' page.
function lmenu_services() {
    document.write('<table cellspacing="1" cellpadding="0" border="0" width="100%">');
	csic_logo();
    document.write('<tr>' + col_desc("title") + 'Services</td></tr>');
    document.write('<tr>' + col_desc("imnav", "/services/consultations.html") + 'Consultations</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/services/work_permit.html") + 'Work Permits</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/services/study_permit.html") + 'Study Permits</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/services/visitor_visa.html") + 'Visitor Visas</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/services/humanitarian.html") + 'Huanitarian & Compas.</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/services/family.html") + 'Family Sponsorship</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/services/care_giver.html") + 'Care Giver</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/services/business_immigration.html") + 'Business Immigration</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/services/canadian_experience.html") + 'Canadian Experience</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/services/skilled_worker.html") + 'Skilled Worker</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/services/settlement_package.html") + 'Settlement Package</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/services/us_immigration.html") + 'US Immigration Serv.</a></td></tr>');
	affiliates_button ();
    document.write('</table>');
}


// Prints out the left menu for the 'screening' page.
function lmenu_screening() {
    document.write('<table cellspacing="1" cellpadding="0" border="0" width="100%">');
	csic_logo();
    document.write('<tr>' + col_desc("title") + 'Assessment</td></tr>');
	document.write('<tr>' + col_desc("imnav") + 'Questionaires</td></tr>');
    document.write('<tr>' + col_desc("imnav_sub1", "/screening/free.html") + 'Free Screening&trade;</a></td></tr>');
    document.write('<tr>' + col_desc("imnav_sub1", "/screening/detailed.html") + 'Detailed Assessment&trade;</a></td></tr>');
	affiliates_button ();
    document.write('</table>');
}

// Prints out the left menu for the 'faq' page.
function lmenu_faq() {
    document.write('<table cellspacing="1" cellpadding="0" border="0" width="100%">');
	csic_logo();
    document.write('<tr>' + col_desc("title") + 'Faq</td></tr>');
	affiliates_button ();
    document.write('</table>');
}


// Prints out the left menu for the 'customers' page.
function lmenu_customers() {
    document.write('<table cellspacing="1" cellpadding="0" border="0" width="100%">');
	csic_logo();
    document.write('<tr>' + col_desc("title") + 'Customers</td></tr>');
    document.write('<tr>' + col_desc("imnav", "/customers/login.html") + 'Login</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/customers/signup.html") + 'Signup</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/customers/status.html") + 'Profile Status</a></td></tr>');
	affiliates_button ();
    document.write('</table>');
}

// Prints out the left menu for the 'pricing' page.
function lmenu_pricing() {
    document.write('<table cellspacing="1" cellpadding="0" border="0" width="100%">');
	csic_logo();
    document.write('<tr>' + col_desc("title") + 'Pricing</td></tr>');
    document.write('<tr>' + col_desc("imnav", "/pricing/icanadadirect_fees.html") + 'iCanada Direct Fees</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/pricing/government_fees.html") + 'Government Fees</a></td></tr>');
    document.write('<tr>' + col_desc("imnav", "/pricing/payments.html") + 'Online Payments</a></td></tr>');
	affiliates_button ();
    document.write('</table>');
}

// Prints out the left menu for the 'links' page.
function lmenu_links() {
    document.write('<table cellspacing="1" cellpadding="0" border="0" width="100%">');
	csic_logo();
    document.write('<tr>' + col_desc("title") + 'Links</td></tr>');
	document.write('<tr>' + col_desc("imnav", "/links/#news") + 'News Agencies</td></tr>');
	document.write('<tr>' + col_desc("imnav", "/links/#canada") + 'Canada</td></tr>');
	document.write('<tr>' + col_desc("imnav", "/links/#immigration") + 'Immigration</td></tr>');
	document.write('<tr>' + col_desc("imnav", "/links/#financial") + 'Financial Institutions</td></tr>');
	document.write('<tr>' + col_desc("imnav", "/links/affiliates.html") + 'Affiliates</td></tr>');
	affiliates_button ();
    document.write('</table>');
}

// Prints out the footer menu.
function fmenu(modified_date){
    var d_today = new Date();
    var d_moddate = new Date(modified_date);
    var str_moddate = (d_moddate.getMonth()+1) + '/' + d_moddate.getDate() + '/' + d_moddate.getFullYear();
    document.write('<table  border="0" cellpadding="0" cellspacing="0" width="800">');
    document.write('<tr>');
    document.write('<td colspan="3" width="100%">');
    document.write('<img src="' + make_address("/images/canline1.gif") + '" border="0" width="100%" height="50">');
    document.write('</td>');
    document.write('</tr>');
    document.write('<tr>');
    document.write('<td align="right">');
    document.write('<img src="' + make_address("/images/earth.gif") + '" border="5" width="100" height="100">');
    document.write('</td>');
    document.write('<td>');
    document.write('<span class="footnote"><center>');
	document.write('<p>');
	document.write('<a href="' + make_address("/home.html") + '">Home</a> | ');
	document.write('<a href="' + make_address("/about/") + '">About Us</a> | ');
	document.write('<a href="' + make_address("/services/") + '">Services</a> | ');
	document.write('<a href="' + make_address("/pricing/") + '">Pricing</a> | ');
	document.write('<a href="' + make_address("/customers/") + '">Customers</a> | ');
	document.write('<a href="' + make_address("/faq/") + '">FAQ</a> | ');
	document.write('<a href="' + make_address("/screening/") + '">Assessment</a> | ');
	document.write('<a href="http://blog.icanadadirect.com" target="_blank">Blog</a> | ');
	document.write('<a href="' + make_address("/links/") + '">Links</a> | ');
	document.write('<a href="' + make_address("/about/contact.html") + '">Contact Us</a>');
	document.write('</p>');
    document.write('<br>Copyright &copy; iCanada Direct 2005-' + d_today.getFullYear() + '. All rights reserved.&nbsp;&nbsp;');
    document.write('<a href="' + make_address("/privacy.html") + '" target="_top">Privacy</a> / ');
    document.write('<a href="' + make_address("/privacy.html#legal") + '" target="_top">Legal</a> Information.<br>');
    document.write('Page Last Updated on '+ str_moddate + '.<br>');
    document.write('</center></span></td>');
    document.write('<td align="right">');
	document.write('<a href="http://www.tkqlhce.com/click-2742527-10420671" target="_blank">');
    document.write('<img src="' + make_address("/images/plane.jpg") + '" border="2" width="120" height="70" alt="Cheap Flights at westjet.com!">');
	document.write('</a>');
    document.write('</td>');
    document.write('</tr>');
    document.write('</table>');
	document.write('</center>');
}
