jQuery(document).ready(function(){

//all carousel images are hidden by default, add class of first to show first image
if(jQuery('#countrycarousel').length){
		jQuery('#countrycarousel').find('img:eq(0)').addClass("first");
	// hide all and show first content, set the current tab active
		jQuery("#tabbed .tabs").hide();
		
		//check if the request is for a document page
		if(checkUrlForTabs() == 1) {
			jQuery('div.t4').show();
			jQuery("#countryrightnav li.t4 a").addClass('active');
		} else {
			jQuery('div.t1').show();
			jQuery("#countryrightnav li.t1 a").addClass('active');
		}
	
	jQuery('#countrycarousel').cycle({ 
		fx:     'fade', 
		speed:   1200, 
		timeout: 4000,
		activePagerClass: 'activeSlider',
		pager: '#cuntrycarouselnav'
	});
}

jQuery('#countryrightnav li').click(function(){
	var thisClass = this.className.slice(0,2);
	jQuery('#tabbed div.tabs').hide();
	jQuery('#tabbed div.' + thisClass).show();
	jQuery('#countryrightnav li a').removeClass('active');
	jQuery("#countryrightnav li." + thisClass+" a").addClass('active');
	return false;

});
});
	
function checkUrlForTabs()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
		var found = 0;

        hash = hashes[i].split('=');

        if(hash[0] == 'cdp' || hash[0] == 'category' || hash[0] == 'did' || hash[0] == 'dlpage' || hash[0] == 'sortby' || hash[0] == 'dltag')
		{
			found = 1;
		}
    }
    return found;
}

