$(document).ready(function(){
	init();
	var page = $('body').attr('id');
	if (page == 'home') {
		homePage();
		rowHeight();
		initializegmap();
	}
	if (page != 'home') columnHeight();
});

function init() {
	Cufon.replace('.ddsmoothmenu ul li a, #right_widget_sidebar h2', { fontFamily: 'adventor', hover: true});
	Cufon.replace('#contact_phone, h1, h2.top_title, #tryptic h2, #row h2, #content h2, h2.archive_title, .single_title', { fontFamily: 'adventor'});
	$('.ddsmoothmenu ul li a:first').css('border-left','1px solid #010044');
	$('.widget:last').css('border-bottom','none').css('padding-bottom','0px');
	$('#articles .post:last').css('border-bottom','none');
	$('.widget_rss .widgettitle a').attr('href', 'http://www.facebook.com/pages/Veterinary-Specialist-Group/190244617686');
	$('.widget_archive ul').prepend('<li><a href="/news/">Latest</a></li>');

};

function homePage() {
	$('.col1 h3:first, .col2 h3:first').css('margin-top','0px');
}

function columnHeight() {
	var l = $('#left_column').height();
	var r = $('#right_column').height();
	var m = 365;
	if (l >= r) {
		h = l;
		h = h - m;
		$('#sub_content').height(h);
	}
}


function rowHeight() {
	var l = $('.col1').height();
	var r = $('.col2').height();
	var m = 0;
	if (l >= r) {
		h = l;
		h = h - m;
		$('.col1').height(h);
		$('.col2').height(h);
	} else {
		h = r;
		h = h - m;
		$('.col1').height(h);
		$('.col2').height(h);
	}
}

// SLIDESHOW CODE

function slideSwitch() {
	// This version of slideSwitch has been adapted to include the 
	// feature to change the text in the accompanying mirror
	
    var $active = $('#slideshow IMG.active');
    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

	var $activeText = $('#slide_links a.active');
	if ( $activeText.length == 0 ) $activeText = $('#slide_links a:last');
	
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');
		
	var $nextText = $('#slide_links a.active').next('a');
	if ( $nextText.length == 0 ) $nextText = $('#slide_links a:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        	$activeText.removeClass('active');
			$nextText.addClass('active');
			Cufon.refresh();
		});
}

$(function() {
	var thisPage = $('body').attr('id');
	if ( thisPage == 'home') {
	    setInterval( "slideSwitch()", 4000 );
	};
});

// END SLIDESHOW
