window.onload = initPage;

function initPage() {
  if(document.getElementById('cta_phone')) {
    document.getElementById('cta_phone').onclick = ctaPhoneLink;
  }
  if(document.getElementById('cta_price')) {
    document.getElementById('cta_price').onclick = ctaPriceLink;
  }
  if(document.getElementById('qc_more_info')) {
    document.getElementById('qc_more_info').onclick = selectCheck;
    document.getElementById('qc_consult').onclick = selectCheck;
  }
  externalLinks();
}

function selectCheck() {
  if(this.id == 'qc_more_info') {
    document.getElementById('qc_consult').checked = false;
  } else {
    document.getElementById('qc_more_info').checked = false;
  }
}

function ctaPhoneLink() {
  window.location = 'index.php?view=contact';
  return;
}

function ctaPriceLink() {
  window.location = 'index.php?view=price';
  return;
}

function image_popup(image) {

  var image = image;
  var newLink = image.replace("main", "large");

  window.open(newLink,"","width=1024,height=768,location,menubar");
  
}

function externalLinks() { 
  if (!document.getElementsByTagName) return; 
  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.getAttribute("rel") == "external nofollow" ) 
      anchor.target = "_blank"; 
  } 
}
