var rVet = {

	pic : null,
	
	externalLink : null,
	
	init : function() {
		//object dection
		if (!document.getElementById || !document.getElementsByTagName) { return; }
		this.pic = document.getElementById('pic');
		this.picRotate();
		this.externalLinks();
	},
	
	picRotate : function() {
   
    // random number between 0 and 1, multiplied by 5
    var num = Math.random() * 5;

    // round to nearest whole number, giving us possible
    // values of 0, 1, 2, 3, 4, 5
    num = Math.round(num);

    // assign the src attribute based on num result
    switch (num) {
      case 0:
        this.pic.src = 'images/vet_dog.jpg';
        this.pic.alt = 'Dog with stethoscope';
        break;
      case 1:
        this.pic.src = 'images/puppy.jpg';
        this.pic.alt = 'White puppy';
        break;
      case 2:
        this.pic.src = 'images/parrot.jpg';
        this.pic.alt = 'Blue parrot';
        break;
      case 3:
        this.pic.src = 'images/turtle.jpg';
        this.pic.alt = 'Turtle swimming under water';
        break;
      case 4:
        this.pic.src = 'images/chinchilla.jpg';
        this.pic.alt = 'Chinchilla';
        break;
      case 5:
				this.pic.src = 'images/dog_w_bird.jpg';
        this.pic.alt = 'Dog with parrot on his nose';
        break;
    }
  },
	
	externalLinks : function () {
		var anchors = document.getElementsByTagName("a");
		for (var i=0; i<anchors.length; i++) {
			var anchor = anchors[i];
			if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
				anchor.target = "_blank";
			}
		}
	}
}
rVet.init();