
$(document).ready(function() {
  //add on keypress event to forms
  $("form").keypress(function(e) {
    if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
      $(this).find(".addenter").click();
    }
  });

  //open and close editors on admin pages
  $(".toggleeditor").click(function(){
    $("#editor_container").slideToggle('1200');
    return false;
  });

  //add rollover functionality to the contact images
 $(".contactimg").mouseenter(function(e){
    var yOffset = 280;
    var xOffset = -320;
    $("body").append("<p id='profile-box'></p>");
    this_profile = $(this).attr("ref");

    $("#profile-box").html('<div class="profile-text"><img src="' + HTTP_HOST + '/skins/qpharma/images/profiles/' + profiles[this_profile][0].image + '" style="float:left" id="profile-image"/><h2>' + profiles[this_profile][0].name + '<br />' + profiles[this_profile][0].title + '</h2>' + profiles[this_profile][0].text + '</div>');

    $("#profile-box")
	.css("top",(e.pageY - yOffset ) + "px")
	.css("left",(e.pageX + xOffset) + "px")
	.fadeIn("fast");
    }
  );
  $(".contactimg").mouseleave(function(){
     $("#profile-box").remove();
  });

  //start the testimonial fader;
  fadetestimonials();
  fadetestinterval = setInterval( "fadetestimonials()", 7000 );
}); //end onload

var HTTP_HOST = "http://" + window.location.hostname;
if(location.pathname.indexOf('dev') > 0)
  HTTP_HOST += "/dev";
current_test = 0;

function fadetestimonials() {
  current_test = ((current_test*1)+1) >= testimonials.length?0:(current_test*1)+1
   $("#testimonial").fadeOut('slow',function() {
   $("#testimonial").html('<div class="testimonial-text">"' + testimonials[current_test].testimonial + '"</div><div class="testimonial-company">~' + testimonials[current_test].company + '</div>').fadeIn(3000);
   });
}