// JavaScript Document

function doClear(theText) {
     if (theText.value == theText.defaultValue) {
         theText.value = "";
     }
 }
 
function resizeLeft() {
	var hLC = $('.left-col').height();
	$().add('.main-col').css( "min-height", hLC );	
}

$(document).ready(function() {
	var w = $(window).width();
	var h = $(window).height();
	var ratio = (w / h);
	var vML = (w / 2);
	var hML = ((h * 1.42) / 2);
	
	if ( ratio < 1.42 )
	{
		$('.bg-img').removeClass("h-stretch");
		$('.bg-img').addClass("v-stretch");
		$().add('.bg-img').css( "margin-left", -hML );
	}
	else 
	{
		$('.bg-img').removeClass("v-stretch");
		$('.bg-img').addClass("h-stretch");
		$().add('.bg-img').css( "margin-left", -vML );
	}
		
	// Add height of left column to the main column
	resizeLeft();
});

$(window).resize(function() {
	var w = $(window).width();
	var h = $(window).height();
	var ratio = (w / h);
	var vML = (w / 2);
	var hML = ((h * 1.42) / 2);
	
	if ( ratio < 1.42 )
	{
		$('.bg-img').removeClass("h-stretch");
		$('.bg-img').addClass("v-stretch");
		$().add('.bg-img').css( "margin-left", -hML ) ;
	}
	else 
	{
		$('.bg-img').removeClass("v-stretch");
		$('.bg-img').addClass("h-stretch");
		$().add('.bg-img').css( "margin-left", -vML ) ;
	}		
});

 $(document).ready(function() {
	var h = $(window).height();
	var cHeight = (h - 173);
		
	$().add('.product-landing').css( "height", cHeight );
});

$(window).resize(function() {
	var h = $(window).height();
	var cHeight = (h - 173);
		
	$().add('.product-landing').css( "height", cHeight );
});

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 oc(a)
{
    var o = {};
    for(var i=0;i<a.length;i++)
    {
        o[a[i]]='';
    }
    
    return o;
}	

function checkNALanguage(){
    if(google.loader.ClientLocation){
        visitor_country = google.loader.ClientLocation.address.country;
        visitor_countrycode = google.loader.ClientLocation.address.country_code;

        if (visitor_countrycode in oc (['CA','MX','US'])){
            return true;
        }
    }
    
    return false;
}
