// JavaScript Document

//Common to all pages

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

//Focused popup window
function popWin(url,height,width,toolbar,menubar,locationbar,scroll,resize,status,name) {
			var Browser;
			var spec;
			spec = "status="+status+",toolbar="+toolbar+",menubar="+menubar+",location="+locationbar+",scrollbars="+scroll+",resizable="+resize+",height="+height+",width="+width;
			remote = window.open(url, name, spec);
			remote.focus();
			remote.location.href = url;
			}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//Email this link
function emailPageLink () {
//	document.write ('<a href="mailto:?Subject=Page%20of%20interest%20at%20www.vtsonline.com&body=This page might be of interest: " + urlAddress;</a>');
	var urlAddress = window.location.href;
	var pageName = unescape(document.title);
	document.location = "mailto:?Subject=Page%20of%20interest%20at%20www.vtsonline.com&body=This page might be of interest: " + urlAddress;
}

// Anti-Spam Email Displayer- By JavaScriptKit.com
// Visit JavaScript Kit (http://javascriptkit.com) for this script and more.
// This notice must stay intact for use

var contacts=new Array()
//Specify text and corresponding email address.
//Use [at] and [dot] in place of "@" and "." for anti spam purpose:
contacts[0]=["Click here to e-mail Dr. Newman", "hnewman[at]vtsonline[dot]com"]
contacts[1]=["Dr. Helen Newman", "hnewman[at]vtsonline[dot]com"]
contacts[2]=["Donna Clements", "dclements[at]vtsonline[dot]com"]


//Shannon's new contact script
contacts[3]=["Shannon McKee", "smckee[at]vtsonline[dot]com"]
contacts[4]=["Donna Cadle", "dcadle[at]vtsonline[dot]com"]
contacts[5]=["Peggy Leach", "hnewman[at]vtsonline[dot]com"]
//End Shannon's new contact script



//Specify caption text to display within SELECT menu. Only applicable if you're using the form option:
var dropmenucaption="CONTACT US FORM "

function displaycontact(emailarray, cssclass, displaymethod, extrainfo){
if (displaymethod=="text"){
document.write('<span class="' + cssclass + '">\n')
if (typeof emailarray[0]=="object"){ //if array passed consists of multiple elements
for (i=0; i<emailarray.length; i++){
var seperator=(i<emailarray.length-1)? extrainfo : ""
document.write('<a href="mailto:' + modifyemail(emailarray[i][1])+ '">'+ emailarray[i][0] + '</a>' + seperator)
}
}
else //else if it is a single array element
document.write('<a href="mailto:' + modifyemail(emailarray[1])+ '">'+ emailarray[0] + '</a>')
document.write('</span>')
}
else if (displaymethod=="form"){
document.write('<form>\n')
document.write('<select size="' + extrainfo + '" onChange="jumptooption(this)" class="' + cssclass + '">\n')
document.write('<option value="caption">' + dropmenucaption + '</option>\n')
for (i=0; i<emailarray.length; i++)
document.write('<option value="mailto:' + modifyemail(emailarray[i][1]) +'">' + emailarray[i][0] + ' </option>\n')
document.write('</select></form>\n')
}
}

function modifyemail(emailitem){
var modified=emailitem.replace(/\[at]/gi, "@")
modified=modified.replace(/\[dot]/gi, ".")
return modified
}

function jumptooption(themenu){
if (themenu.options[themenu.selectedIndex].value !="caption")
location=themenu.options[themenu.selectedIndex].value
}

function validate_contactform() {
  if (document.contactform.elements[1].checked==false &&
  document.contactform.elements[2].checked==false &&
  document.contactform.elements[3].checked==false &&
  document.contactform.elements[4].checked==false) {
    alert("Please select the brochure(s) that you would like to receive. Thank you");
    return false;
  }

  var valid = validate_commonform(document.contactform);
  if (valid==false) {
    return false;
  }
  return true;
}

function validate_pricelistform() {
  if (document.pricelistform.elements[1].checked==false &&
  document.pricelistform.elements[2].checked==false &&
  document.pricelistform.elements[3].checked==false &&
  document.pricelistform.elements[4].checked==false) {
    alert("Please select the brochure(s) that you would like to receive. Thank you");
    return false;
  }
  
  var valid = validate_commonform(document.pricelistform);
  if (valid==false) {
    return false;
  }
  return true;
}

function validate_orderform() {
  var valid = validate_commonform(document.orderform);
  if (valid==false) {
    return false;
  }

  if (document.orderform.product01.value.length==0 &&
  document.orderform.product2.value.length==0 &&
  document.orderform.product02.value.length==0 &&
  document.orderform.product03.value.length==0 &&
  document.orderform.product3.value.length==0 &&
  document.orderform.product04.value.length==0 &&
  document.orderform.product05.value.length==0 &&
  document.orderform.product06.value.length==0 &&
  document.orderform.product07.value.length==0 &&
  document.orderform.product08.value.length==0 &&
  document.orderform.product09.value.length==0 &&
  document.orderform.product4.value.length==0 &&
  document.orderform.product10.value.length==0 &&
  document.orderform.product11.value.length==0 &&
  document.orderform.product5.value.length==0 &&
  document.orderform.product12.value.length==0 &&
  document.orderform.product6.value.length==0 &&
  document.orderform.product7.value.length==0 &&
  document.orderform.product13.value.length==0 &&
  document.orderform.product14.value.length==0 &&
  document.orderform.product15.value.length==0 &&
  document.orderform.product16.value.length==0 &&
  document.orderform.product16b.value.length==0 &&
  document.orderform.product16c.value.length==0 &&
  document.orderform.product17.value.length==0 &&
  document.orderform.product18.value.length==0 &&
  document.orderform.product19.value.length==0 &&
  document.orderform.product20.value.length==0 &&
  document.orderform.product21.value.length==0 &&
  document.orderform.product22.value.length==0 &&
  document.orderform.product23.value.length==0)  {
    alert('Please put the number of grafts you would like to order in the corresponding boxes. Thank you.');
    return false;  
  }
  return true;
  
}

function validate_commonform(form) {
if (form.ordered_by.value.length==0 ||
   form.doctor_name.value.length==0 ||
   form.clinic_company.value.length==0 ||
   form.city.value.length==0 ||
   form.state.value.length==0 ||
   form.zip.value.length==0 ||
   form.country.value.length==0 ||
   form.phone.value.length==0) {

  alert('Please fill in all required fields. Thank you.');
  return false;
}
return true;
}

//USAGE INSTRUCTION. displaycontact(1st paramter, "2nd paramter", "3rd paramter", "4th paramter")
//1st parameter: Input the name of the array containing the list of email addresses. To display one single email, input the corresponding array element. 
//2nd parameter: Input the CSS Classname that is to be applied. Enter arbitrary name for none.
//3rd parameter: Input either "form" or "text." Former will display email in drop down menu. Later in plain text. Only "text" mode supports displaying of single email address!
//4th parameter: If in "form" mode, enter an integer to control the height of the <SELECT> tag. If "text" mode, enter any string to act as a divider between each email text. For example "|", "<br>" etc.

//SAMPLE USAGES (uncomment below to see)
//displaycontact(contacts, "textstyle", "text", " | ")

//displaycontact(contacts, "formstyle", "form", "1")

//displaycontact(contacts[2], "textstyle", "text", "")

////////////////////////////////////////////////////////////////

//-->