document.write('<div id="ClientLocation_1" style="height: 600px; width: 100%; text-align: center;position: absolute; display:none;">');
document.write('<div id="ClientLocation_2" style="background: #cc0000; padding: 10px; margin: 200px auto 0px auto; width: 300px; height: 35px; color: #FFFFFF; font: bold 24px Arial; border-left: 2px solid #cc0000; border-right: 2px solid #cc0000;">Shopping from Canada?</div>');
document.write('<div id="ClientLocation_3" style="background: #ffffff; padding: 10px; margin: 0px auto; width: 300px; height: 200px; border-right: 2px solid #cc0000; border-bottom: 5px solid #cc0000; border-left: 2px solid #cc0000;"><img src="/assets/images/PartSelectCanadaLogo.gif" width="213" height="40" />');
document.write('<p style="text-align: left;font:14px Arial; ">We have a site just for Canadians, with prices in Canadian dollars and no duty or fees. All orders from PartSelect.ca will ship from within Canada.</p>');
document.write('<p><a href="http://www.partselect.ca/?source=relocation" style="font: bold 18px Arial;">Shop PartSelect.ca</a></p>');
document.write('<p><a href="#" OnClick="document.getElementById(\'ClientLocation_1\').style.display = \'none\';" style="font: bold 18px Arial;">Stay at PartSelect.com</a></p>');
document.write('</div>');
document.write('</div>');



function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function clientLocation()
{
    var clientCountry = readCookie("clientCountry");

    if(clientCountry == null)
    {
        if(google.loader.ClientLocation )
        {
            try {clientCountry = google.loader.ClientLocation.address.country_code;}
            catch (err) {clientCountry == "US";}
            
            if(clientCountry == "CA")
            {
                document.getElementById("ClientLocation_1").style.display = 'block';
            }
            createCookie("clientCountry", "US", null);
        }
    }
}