if (document.images) {
 var pic1 = new Image(953,479);
 var pic2 = new Image(953,479);
 var pic3 = new Image(953,479);
 var pic4 = new Image(953,479);
 var pic5 = new Image(953,479);
 var pic6 = new Image(953,479);
 var pic7 = new Image(953,479);

 var pic1Src="http://www.doctorvenessa.com/images/neck-bg.jpg"; 
 var pic2Src="http://www.doctorvenessa.com/images/football-bg.jpg"; 
 var pic3Src="http://www.doctorvenessa.com/images/family-bg.jpg"; 
 var pic4Src="http://www.doctorvenessa.com/images/pushup-bg.jpg"; 
 var pic5Src="http://www.doctorvenessa.com/images/yoga-bg.jpg"; 
 var pic6Src="http://www.doctorvenessa.com/images/surfer-bg.jpg"; 
 var pic7Src="http://www.doctorvenessa.com/images/running-bg.jpg"; 
}

function externalLinks() {
 if (! document.getElementsByTagName ) return;
 var isIE = (document.documentElement.getAttribute("style") == document.documentElement.style);
 var anchors = document.getElementsByTagName("a");
 for (var i=anchors.length-1; i>=0; i--) {
  if(anchors[i].getAttribute("href") && anchors[i].getAttribute("rel") == "external"){
   if(isIE)
    anchors[i].setAttribute("onclick",new Function("window.open(this.href); return false;"));
   else
    anchors[i].setAttribute("onclick","window.open(this.href); return false;");
  }
 }
}

function changeBackground(imageNum) {
 imageNum++;
 if (imageNum > 7) {
  imageNum = 1;
 }
 el = document.getElementById('content');
 el.style.background = "url("+eval("pic"+imageNum+"Src")+") no-repeat 14px top";
 
 if(window.location.pathname == "/index.php" || window.location.pathname == "/") {
  setTimeout("changeBackground(" + imageNum + ")",5000);
 }
}

function init() {
 var startNum=Math.floor(Math.random()*7);
 changeBackground(startNum);

 externalLinks();

 if (window.location.pathname == "/index.php" || window.location.pathname == "/") {
  if (document.images) {
   pic1.src=pic1Src;
   pic2.src=pic1Src;
   pic3.src=pic1Src;
   pic4.src=pic1Src;
   pic5.src=pic1Src;
   pic6.src=pic1Src;
   pic7.src=pic1Src;
  }
 }
}

$(document).ready(function() {

 init();

 $("#reason").change(function() {
  var message_index;
  message_index = $("#reason").val();
  if (message_index == "Request an Appointment") {
   //Request an appointment - show appointment fields
   $("#appointmentDateLabel").show();
   $("#appointmentDate").show();
   $("#appointmentTimeLabel").show();
   $("#appointmentTime").show();
   $("#patientTypeLabel").show();
   $("#patientType").show();
  } else {
   //Question or comment - hide appointment fields         
   $("#appointmentDateLabel").hide();
   $("#appointmentDate").hide();
   $("#appointmentTimeLabel").hide();
   $("#appointmentTime").hide();
   $("#patientTypeLabel").hide();
   $("#patientType").hide();
  }
 }); 

});

