/*
		CSS Browser Selector v0.4.0 (Nov 02, 2010)
		Rafael Lima (http://rafael.adm.br)
		http://rafael.adm.br/css_browser_selector
		License: http://creativecommons.org/licenses/by/2.5/
		Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
		function css_browser_selector(u){var ua=u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1},g='gecko',w='webkit',s='safari',o='opera',m='mobile',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3.6')?g+' ff3 ff3_6':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('blackberry')?m+' blackberry':is('android')?m+' android':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?m+' j2me':is('iphone')?m+' iphone':is('ipod')?m+' ipod':is('ipad')?m+' ipad':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win'+(is('windows nt 6.0')?' vista':''):is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);
$(document).ready(function(){
				
});

	/* ~~~~~~~~~~~~~ browser upgrade ~~~~~~~~~~~~~*/
$(document).ready(function () {
    $(".success").hide();
    $(".error").hide();
    $(".ft_success").hide();
    $(".ft_error").hide();

    $('#close_ie6upgrade').mousedown(function () {
        $('#ie6').slideUp();
        return false;
    });
    $('.popLb').click(function () {
        _buildLightbox();       
        window.scroll(0, 0);
        return false;
    });


    $('a.jsFaceBook').live('click', function () {
        var url = 'http://www.facebook.com/sharer.php?u=' + encodeURIComponent(window.location);
        if ($(this).attr('href') != '#')
            url = 'http://www.facebook.com/sharer.php?u=' + encodeURIComponent($(this).attr('href'));
        window.open(url, 'facebook', 'width=600,height=400');

        if (_gaq != null) {
            _gaq.push(['_trackPageview', '/share/facebook']);
        }

        return false;
    });


});

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//					
// match heights 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//		
		function matchHeight() {
		$('.jsAutoH').css('height', 'auto');
		$('.jsAutoH').each(function() {
			//find max height
			var maxHeight = 0;
			$(this).parent().find('.jsAutoH').each(function() {
				if ($(this).height() > maxHeight)
					maxHeight = $(this).height();
			});
			if ($(this).hasClass('js2Level')) {
				$(this).parent().parent().find('.jsAutoH').each(function() {
					if ($(this).height() > maxHeight)
						maxHeight = $(this).height();
				});
			}
			$(this).css('height', maxHeight + 'px');
		});
	}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//					
// lightbox
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//		
function _buildLightbox() {
	$('body').append('<div id="lightboxOverlay"></div>');
	var sH = $('body').height();
	var sW = $('body').width();
	$("#lightboxOverlay").css('height',sH+'px').css('display','block');
	if ( $.browser.msie) {
		if($.browser.version  <= 6){
			$('#lightboxOverlay').bgiframe(); // js to fix select boxes in IE 6		
		}
	}
	$('#lightboxContent').fadeIn();
	$('#lightboxContent').css('left', (sW / 2) - ($('#lightboxContent').width() / 2));	
	$('#lightboxOverlay').click(function() {
		_destroyLightbox()
	});
	$('#lightboxClose').click(function() {
		_destroyLightbox()
	});		
};


// ------------------------------------------------------------------------------------
function _destroyLightbox() {
	$('#lightboxOverlay').fadeOut(function(){
		$('#lightboxOverlay').remove();
	});
	$('#lightboxContent').fadeOut();
		lightboxStatus = false;	
};

$(window).resize(function() {
	var sH = $('body').height();
	var sW = $('body').width();
	$("#lightboxOverlay").css('height',sH+'px').css('display','block');
	if ( $.browser.msie) {
		if($.browser.version  <= 6){
			$('#lightboxOverlay').bgiframe(); // js to fix select boxes in IE 6		
		}
	}
	$('#lightboxContent').css('left', (sW / 2) - ($('#lightboxContent').width() / 2));	
});



function SendCertContact() {
    var userName = $(".userName").val();
    var userEmail = $(".userEmail").val();
    var userPhone = $(".userPhone").val();

    if (!isValidEmailAddress(userEmail)) {
        $(".error").show();
        $(".error").html("It seems you have entered an incorrect email address - please try again.");
        $(".success").hide();
    } else {
        $.get('/handlers/RequestLocationMap.ashx', { Email: userEmail, Name: userName, Phone: userPhone }, function (data) {
            if (data == "Success") {
                $(".error").hide();
                $(".success").show();
                $(".success").html("Your request has been received - we will be in touch shortly.");

                $(".userPhone").val("");
                $(".userName").val("");
                $(".userEmail").val("");
            } else {
                $(".error").show();
                $(".error").html();
            }
        });
    }
}


function SendFooterContact() {
    var userName = $(".userName").val();
    var userEmail = $(".userEmail").val();  

    if (!isValidEmailAddress(userEmail)) {
        $(".ft_error").show();
        $(".ft_error").html("It seems you have entered an incorrect email address - please try again.");
        $(".ft_success").hide();
    } else {
        $.get('/handlers/EmailSignUp.ashx', { Email: userEmail, Name: userName }, function (data) {
            if (data == "Success") {
                $(".ft_error").hide();
                $(".ft_success").show();
                $(".ft_success").html("You have successfully subscribed to our newsletters. Thank you for your interest!");

                $(".userPhone").val("");
                $(".userName").val("");
                $(".userEmail").val("");
            } else {
                $(".ft_error").show();
                $(".ft_error").html();
            }
        });
    }
}


function isValidEmailAddress(emailAddress) {
    var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    return pattern.test(emailAddress);
};





