/*== CUFON FONT REPLACEMENT ==*/
	
	Cufon.replace('.rockwell', 'rockwell');
	Cufon.replace('#imagePlaceholder h3', 'rockwell');
	Cufon.replace('#footer .widget h3', 'rockwell');
	Cufon.replace('.onlineForm h3', 'rockwell');
	Cufon.replace('.onlineForm h4', 'rockwell');
	Cufon.replace('#formsOr', 'rockwell');

/*== END CUFON FONT REPLACEMENT ==*/

/*== TABBED CONTENT ==*/
function tabMove(num) {
	$('.pageTabController a').removeClass('ptcActive');
	$('#ptc'+num+' a').addClass('ptcActive');
	$('.pageTabItem').fadeOut('fast');
	$('#pageTabContent'+num).fadeIn('slow', function() {
		//alert('test');
		if($('body').hasClass('pageid-2')) {
			//alert($('#pageTabContent' + num).height());
			var sideBarHeight = (
								$('#primary').height() +
								$('#secondary').height()
								);
			var aboutHeight = (
								$('#pageTabContent' + num).height() +
								$('#container').height()
								);
			if (aboutHeight > sideBarHeight) 	{
				$('#canvas').css('height',  aboutHeight  );
			}
		}
	});
	//alert($('#pageTabContent' + num).height());
}
/*== END TABBED CONTENT ==*/

/*== DIRECTIONS FUNCTIONS ==*/

function locationClick(num) {
	if (num == '1') {
		$('#sl1').css('display','block');
		$('#sl2').css('display','none');
		$('#slc1').css('background','#fff');
		$('#slc1').css('color','#455C6F');
		$('#slc1').css('padding','0 3px 1px 3px');
		$('#slc2').css('background','#EFEEE0');
		$('#slc2').css('color','#455C6F');
		$('#slc2').css('padding','0 3px 0 3px');
	} else {
		$('#sl1').css('display','none');
		$('#sl2').css('display','block');
		$('#slc1').css('background','#EFEEE0');
		$('#slc1').css('color','#455C6F');
		$('#slc1').css('padding','0 3px 0 3px');
		$('#slc2').css('background','#fff');
		$('#slc2').css('color','#455C6F');
		$('#slc2').css('padding','0 3px 1px 3px');		
	}
}

/*== END DIRECTION FUNCTIONS ==*/

/*== LIGHTBOX FUNCTIONS ==*/

function lightBox() {
     $("#curtain").css("height",$(document).height() + "px");
     $("#curtain").fadeIn("fast");
     $("#lightbox").fadeIn("slow");
}
function closeLightBox() {
     $("#curtain").fadeOut("slow");
     $("#lightbox").fadeOut("fast");
     $("#lightbox").html("");	 
}
function petMedLib() {
	lightBox();
	var html = '<h3>Pet Medical Library<a href="#" onclick="closeLightBox();return false" class="closeLightbox"><img src="http://rainmakerwebdesign.com/dev/wateree/wp-content/themes/sandbox/images/close30.png" alt="X" /></a></h3>';
	html = html + '<h5>Welcome to the pet medical library.... if you need more info please give us a call at 803-432-9084 for Camden location or 803-438-7667 for Elgin location</h5>';
	html = html + '<iframe class="lightboxFrame" src="http://www.veterinarypartner.com/Content.plx?P=EVETLIST&EVetID=3002444" width="100%" height="430" frameborder="0" scrolling="auto">Sorry, it appears your browser does not allow frames.  Frames are necessary to view the pet medical library.</iframe>';
	$('#lightbox').html(html);
}
function showDirections() {
	lightBox();

	var html = '<h3>Get Directions<a href="#" onclick="closeLightBox();return false" class="closeLightbox"><img src="http://rainmakerwebdesign.com/dev/wateree/wp-content/themes/sandbox/images/close30.png" alt="X" /></a></h3>';
	html = html + '<h5>&nbsp;</h5>';
	html = html + '<div id="map_directions">';
	html = html + '<a id="resetMap" href="#" onclick="initialize();return false">Reset Map</a>';
	html = html + '<div class="clear"></div>';
	html = html + '<p><strong><label>To:</label><input type="radio" name="endLoc" id="endLoc1" checked="checked" /> Camden Location <input type="radio" name="endLoc" id="endLoc2" /> Elgin Location</strong></p>';
	html = html + '<p style="font-size:11px;color:#A7B8BF;">Enter your address, zip code, or city/state:<br /><form action"#" onsubmit="calcRoute();return false"><input type="text" id="address" /><input type="submit" value="Get Directions!" /></form></p>';
	html = html + '<div id="map_directions_display"></div>';
	html = html + '</div>';
	html = html + '<ul class="lighboxMapNav">';
	html = html + '<li><a id="ms1" href="#" onclick="switchMap(\'1\');return false" class="mapSwitchActive"><strong>Camden Location</strong><br />500 York Street<br />Camden, SC 29020</a></li>';
	html = html + '<li><a id="ms2" href="#" onclick="switchMap(\'2\');return false"><strong>Elgin Location</strong><br />1223 Pine Street<br />Elgin, SC 29045</a></li>';
	html = html + '</ul>';
	html = html + '<div id="map_canvas"></div>';
	$('#lightbox').html(html);
	initialize();

}

function switchMap(num) {
	$('.lighboxMapNav a').removeClass('mapSwitchActive');
	$('#ms'+num).addClass('mapSwitchActive');
	moveCenter();
	if(num == '1') {
		moveCenter(34.241469, -80.604804);	//camden
	} else {
		moveCenter(34.168718, -80.788304);	//elgin
	}

}

var directionDisplay;
var directionsService = new google.maps.DirectionsService();
var map;

function initialize() {
	$('#map_directions_display').html('');
	directionsDisplay = new google.maps.DirectionsRenderer();
	var start = new google.maps.LatLng(34.241469, -80.604804);
	var myOptions = {
	  zoom:11,
	  mapTypeId: google.maps.MapTypeId.ROADMAP,
	  center: start
	}
	map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	
  var myLatLng = new google.maps.LatLng(34.241469, -80.604804);
  var vetMarker = new google.maps.Marker({
      position: myLatLng,
      map: map
  });
  var myLatLng = new google.maps.LatLng(34.168718, -80.788304);
  var vetMarker = new google.maps.Marker({
      position: myLatLng,
      map: map
  });
  
	directionsDisplay.setMap(map);
	directionsDisplay.setPanel(document.getElementById("map_directions_display"));
}

function calcRoute() {
	if ($('#address').val() == '') {
		alert('Please enter your address...');
	} else {
		if ($('#endLoc1').is(':checked')) {
			var start = '500 York Street, Camden, SC 29020'; //camden
		} else {
			var start = '1223 Pine Street, Elgin, SC 29045'; //elgin
		}
		var end = $('#address').val();
		var request = {
			origin:start, 
			destination:end,
			travelMode: google.maps.DirectionsTravelMode.DRIVING
		};
		directionsService.route(request, function(response, status) {
		  if (status == google.maps.DirectionsStatus.OK) {
			directionsDisplay.setDirections(response);
		  }
		});

	}
}

  function moveCenter(x,y) {
    var center = new google.maps.LatLng(x, y);
    map.setCenter(center);
  }
  
function showStaff(name, num) {
	lightBox();
	var html = '<h3>'+name+'<a href="#" onclick="closeLightBox();return false" class="closeLightbox"><img src="http://rainmakerwebdesign.com/dev/wateree/wp-content/themes/sandbox/images/close30.png" alt="X" /></a></h3>';
	html = html + '<h5>&nbsp;</h5>';
	html = html + '<iframe class="lightboxFrame" src="http://rainmakerwebdesign.com/dev/wateree/?page_id='+num+'" width="100%" height="430" frameborder="0" scrolling="auto">Sorry, it appears your browser does not allow frames.  Frames are necessary to view the pet medical library.</iframe>';
	$('#lightbox').html(html);
}


/*== END LIGHTBOX FUNCTIONS ==*/

/*== IMAGE ROTATION FUNCTIONS ==*/

var activeImage = 0;
function rotateImages() {
	$('#rotateController li').removeClass('rcActive');
	if (activeImage == 3) {
		activeImage = 0;
		$('#imagePlaceholder ul').animate({
			left: '0'
		}, 1800, function() {
			// Animation complete.
		});
	$('#rc1').addClass('rcActive');
	} else {
		activeImage = activeImage + 1;
		$('#rc' + (activeImage+1)).addClass('rcActive');
		$('#imagePlaceholder ul').animate({
			left: '-=1146'
		}, 1800, function() {
			// Animation complete.
		});
	}
	var leftPos = (activeImage * 1146);	
}

function goToImage(num) {
	clearInterval(interval);
	var leftPos = num * 1146;
	$('#rc' + (activeImage+1)).addClass('rcActive');
	$('#imagePlaceholder ul').animate({
		left: '-' + leftPos
	}, 1800, function() {
		// Animation complete.
	});
	activeImage = num;
	interval = setInterval ( "rotateImages()", 5000 );
}

/*== END IMAGE ROTATION FUNCTIONS ==*/

/*== CAMERA FUNCTIONS ==*/

function camMove(num) {
	$('.camController a').removeClass('ccActive');
	$('#cam'+num).addClass('ccActive');
	$('.pageTabItem').fadeOut('fast');
	$('#kennel'+num).fadeIn('slow');
	if ($.browser.msie) {
		showIEMovie(num);
	} else {
		showMovie(num);
	}
}

movieImages = [];
movieImages[1]	= 'http://wateree:usc@70.147.182.102:8240/cgi-bin/video.jpg';
movieImages[2]	= 'http://wateree:usc@70.147.182.102:8241/cgi-bin/video.jpg';
movieImages[3]	= 'http://wateree:mountains@70.147.182.102:8246/cgi-bin/video.jpg';
movieImages[4]	= 'http://wateree:beach@70.147.182.102:8243/cgi-bin/video.jpg';
movieImages[5]	= 'http://wateree:beach@70.147.182.102:8242/cgi-bin/video.jpg';
movieImages[6]	= 'http://wateree:beach@70.147.182.102:8243/cgi-bin/video.jpg';
movieImages[7]	= 'http://wateree:clemson@70.147.182.102:8244/cgi-bin/video.jpg';
movieImages[8]	= 'http://wateree:clemson@70.147.182.102:8247/cgi-bin/video.jpg';

camInterval = '';


function showIEMovie(num) {

}

function showMovie(num) {
	$('.kennelCam').html('');
	clearInterval(camInterval);
	camMovieUpdate(num);
	camInterval = setInterval ( "camMovieUpdate("+num+")", 5000 );
}

function camMovieUpdate(num) {
	var randomNumber = Math.floor(Math.random()*10000000)
	$('#kennel'+num+' .kennelCam').html('<img src="'+movieImages[num]+'?x='+randomNumber+'" alt="" />');

}


/*== CAMERA FUNCTIONS ==*/

/*== IPHONE FIX ==*/
//Hey Apple, position:fixed has been in the CSS spec. since 1998!
$('document').ready(function() {

  if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod')
    {
	 $("#rotateController").css("display", "none");
	 $("#sideSocial").css("display", "none");
    };
});





