$(document).ready(function(){
	if ($("#pageBanner").length) {$("#pageTitle").remove();}
	else {$("#pageTitle").remove().prependTo("#grid_wrapper");}
	
	/*$("#siteFooter").prepend('<a href="https://trustsealinfo.verisign.com/splash?form_file=fdf/splash.fdf&dn=www.travelguard.ca&lang=en" target="_blank"><img id="Verisign" src="/chartisint/internet/CA/en/files/tguardcanada_verisign_tcm2011-332107.jpg"/></a>');*/
		
	// to hide empty flyouts
	$(".flyoutMenu").each(function() { 
       if(!$(this).is(":has(div)")) { $(this).addClass('hideFlyout');}
	 });
	
	// to make flyout transparent
	$(".flyoutMenu").css({'opacity': '0.95'}); 		
	
	$('#siteFooter a').each(function(e){$(this).attr('id','anchor'+e+'');})
		
	
	$('#divTab').attr('class','listView');
	
	$('#gridRight .rightModule ul.bigBulleted').parent().removeClass('rightModule').addClass('rightModule1');
	$('#gridRight .rightModule ul.nonBulleted').parent().removeClass('rightModule').addClass('rightModule2');
	$('#gridRight .rightModule ul.bulleted').parent().removeClass('rightModule').addClass('rightModule3');   
	
	var oldBodyOnLoad = window.onload;
      window.onload = function() {
		checkRes(newRes);
      }
	
	if(!$('#countryFlashWrapper').length)equalHeight($('#gridRight, #gridCenter, #gridLeft'));
	
	// LightBox
	var bodyHTML ='<div id="bg"></div><div id="content"></div>';
	$(bodyHTML).prependTo('body');
	
	$('#bg').click(function(){hideDiv();});	
	$(window).resize(function(){resize();});
	
	             $('#content a').each(function(){
                                        $(this).click(function(e){e.preventDefault();
                                                                    
                                                $(this).children(1).toggle();                                                               
                                        })          
                        });
        
						
	 $('#pageFooter p').addClass('callUs');
	 
	 if ($.browser.msie && $.browser.version.substr(0,1)<7) {
	 	$('#globalNavContainer .flyoutMenu').each(function(){
	 		$('<div class="dvflyout"></div>').appendTo($(this));
	 	});	 	
		$("#globalNavContainer .flyoutMenu .flyoutFirstSection").each(function(e){
			$("#flyoutMenu"+e+" .flyoutFirstSection").appendTo('#flyoutMenu'+e+' .dvflyout');
		});		
	 	$('<iframe class="navIframe" frameborder="0" marginheight="0" marginwidth="0" />').prependTo('#globalNavContainer .flyoutMenu');
	 };
	 
	 $('#bookmarkList a').attr('target','_blank');

});


// Equal Height 
	function equalHeight(group) {
		var tallest = 0;
		group.each(function() {
			var thisHeight = $(this).height();
			if(thisHeight > tallest) {
				tallest = thisHeight;
			}
		});
		group.height(tallest);
	};
 
// Function for lightbox 
function showDiv(url){
	$('#bg').show().css('opacity',0).fadeTo('slow', 0.4); 
	$('#content').show();
	resize();
	$('#content').load(url);
	$('html, body').animate({scrollTop:0},0);
};
function hideDiv(){
	$('#bg').hide();
	$('#content').html('');
	$('#content').hide();	
};
function resize(){
	if($('#bg').css('display')=='block'){
		var bgHght=Math.max($('#body_wrapper').height(), $(document).height())+13+'px';
		$('#bg').css('height',bgHght);
		$('#content').css('left',($(document).width()-$('#content').width())/2);
	}
};
function openUrl(){
	if($('input[name=popSelect]').is(':checked')){$('.popTitle span').removeClass('errorMessage');location.href= $('input[name=popSelect]:checked').val();}
	else{$('.popTitle span').addClass('errorMessage');}
};


