/* function loadQuickLinks() {
 $("#quickLinkAjaxContent").load("/a/quicklinkmaker.php");
} */
function showLoadingImage(elementIdName) {
 $("#" + elementIdName).html('<img src="/o/loading.gif" alt="loading new content" />');
}
function showloader() { //let the user know that the map is being worked on
 $("#mapTitle").html('The Friars Map is now loading...  These maps contain a wealth of options for finding places to STAY, things to DO and sights to SEE.  Below the map you can use several search functions.  Also, click, drag and right-mouse-click on the map to access this wealth of other options.  Please let us know if you have any questions about these search features.  Please be patient. Your map will be loaded soon...');
 $("#map").html("loading now . . . ");
}
function showPigList() {
 if($('#pigList').is(":hidden")) {
  document.pigarrow.src="images/UpArrow.gif";
  return !$('#pigList').show('slow'); 
 }
 else {
  document.pigarrow.src="images/DownArrow.gif";
  return !$('#pigList').slideUp();
 }
}
function showRegionList() {
 if($('#regionList').is(":hidden")) {
  document.regionarrow.src="images/UpArrow.gif";
  return !$('#regionList').show('slow'); 
   }
 else {
  document.regionarrow.src="images/DownArrow.gif";
  return !$('#regionList').slideUp();
   }
}
function eli() { 
 if (!document.links) return;
 var anchors = document.links
 for (var i=0; i<anchors.length; i++) { 
  var anchor = anchors[i]; 
  if ((anchor.getAttribute("HREF") || anchor.getAttribute("href")) && (anchor.getAttribute("rel") == "external" || anchor.getAttribute("REL") == "external")) { 
   anchor.target = "_blank"; 
  }
 }
} 
function showOrHideMe(divName, element, displayOn, focusElName) {
 if(displayOn) {
  var el = document.getElementById(divName);
  if(el) {
   el.style.display = "block";
   if(focusElName) {
    document.getElementById(focusElName).focus();
   }
   newFunction = function closeAgain() {return showOrHideMe(divName, element, 0, focusElName);}
  }
 }
 else {
  document.getElementById(divName).style.display = "none";
  newFunction = function openAgain() {return showOrHideMe(divName, element, 1, focusElName);}
 }
 element.onclick = newFunction; 
 element.href = "#";
 return true;
}
function startShowD() {
 var el = document.getElementById("prs");
 if(el) {
  var link = document.getElementById("showAllHref");
  if(link) {
   showD("all", link);
  }
 }
}
// create tabs
function showD(divToShowName, linkClickedEl){
 var contentDivName = "bas";
 var menuDivName = "prs";
 showAllListItemName = "showAllListItem";
 var displayStyle = 'none'
 if (divToShowName == 'all'){
  displayStyle = 'block';
 }
 var contentDivEl = null;
 if (document.getElementById) {
  contentDivEl = document.getElementById(contentDivName);
 } 
 else {
  contentDivEl = document.all[contentDivName];
 }
 if(contentDivEl.childNodes){
  var elGroup = contentDivEl.childNodes;
  for (var i=0;i<elGroup.length; i++) {
   if (elGroup[i].nodeName =='DIV' && elGroup[i].style) {
    if(elGroup[i].parentNode.id == contentDivName) {
     elGroup[i].style.display = displayStyle;
    }
    if (elGroup[i].id == divToShowName) {
     elGroup[i].style.display = 'block';
    }
   }
  }
 }//change the actual href
 if(linkClickedEl != "") {
  var menuDivEl = null;
  if (document.getElementById) {
   menuDivEl = document.getElementById(menuDivName)
  } 
  else {
   menuDivEl = document.all[menuDivName];
  }
  if(menuDivEl.childNodes){
   var elGroup = menuDivEl.getElementsByTagName("li");
   var itemCount = elGroup.length-1;
   if(itemCount == 1) {
    width = "100";
    document.getElementById(showAllListItemName).style.display = "none";   
   }
   else {
    itemCount++;
    var width = Math.floor(100/ (itemCount));
    var lastItemSize = 100 - (width * (itemCount-1));
    if(browserName == "ie") {
     lastItemSize = lastItemSize - 1;
    }
    var newWidth = width;
   }
   for (var i=0;i< elGroup.length; i++) {
    elGroup[i].className = 'm';
    var parentLi = linkClickedEl.parentNode;
    if (elGroup[i] == parentLi) {
     elGroup[i].className = 'ms';
     varCurrentEl = elGroup[i];
     newWidth = lastItemSize;     
    }
    else {
     newWidth = width;
    }
    elGroup[i].style.width = newWidth + "%";
   }
   return true;
  }
 }
}
function setupRemoveDefault() {
 var els = document.getElementsByTagName("input");
 for(var i=0,j=els.length; i<j; i++) {
  if(els[i].type == "text") {
   els[i].onclick = function () {removeDefault(this);}
  }
 }
}
function removeDefault(el) {
 if((!el.rel || el.value == el.rel) && (el.type == "text" || el.type == "")) {     el.rel = el.value;
  el.value = '';
  var elName = el.id;
  el.onblur = function () { if(!el.value) {addDefault(elName);}}
  return true;
 }
}
function addDefault(elName) {
 var el = document.getElementById(elName);
 el.value = el.rel;
}
function pri() {
 startShowD();
 window.print ();
 return false;
}
function jav() {
 var s = "You have javascript enabled.";
 return s;
}
function hideSemanticHeading() {
 document.getElementById("semanticHeading").style.display = "none";
}
function tbPopUp(el) {
/* opens a thickbox pop-up with Iframe for ajaxSection */
 var url = el.href;
 var title = '';
 /*
 var queryArray = url.split("?");
 var query = quaryArray[1];
 var vars = query.split("&"); 
 for (var i=0;i<vars.length;i++) { 
  var pair = vars[i].split("="); 
  if (pair[0] == "ajaxSection") { 
   var ajaxSection = pair[1]; 
  } 
 } 
 */ 
 if (el.title) {
  title = el.title;
 }
 tb_show(title, url + '&amp;TB_iframe=true&amp;height=400&amp;width=530',"");
 return true;
}
function OW(fln){
 PU(fln, 345,435,'vit',false,true,false,false,false);
 return true;
}
function OWp(fln){
 PU(fln, 600,600,'pdf',false,true,false,false,false);
 return true;
}
function OWf(fln){
 PU(fln, 500,500,'forsale',false,true,false,false,false);
 return true;
}
function OWe(fln){
 PU(fln, 800,300,'explanations',true,false,false,false,false);
 return true;
}
function PU (url,x,y,name,sb,rs,st,lt,tb) {
 var win = null;
 var scrollbarstext = 'scrollbars = no,';
 var resizabletext = 'resizable = no,';
 var statustext = 'status = no,';
 var locationtext = 'location = no,';
 var toolbartext = 'toolbar = no,';
 var features = '';
 if (sb == 1){scrollbarstext = 'scrollbars = yes,'}
 if (rs == 1){resizabletext = 'resizable = yes,'}
 if (st == 1){statustext = 'status = yes,'}
 if (lt == 1){locationtext = 'location = yes,'}
 if (tb == 1){toolbartext = 'toolbar = yes,'}
 features = scrollbarstext+resizabletext+statustext;
 features = features + locationtext+toolbartext;
 features = features + 'width = '+x+',height = '+y;
 win = window.open(url, name, features);
}
function RF (f) { //resets a form
 if(document.getElementById) {
  document.getElementById("realname").value = "";
  document.getElementById("address").value = "";
  document.getElementById("code").value = "";
  document.getElementById("city").value = "";
  document.getElementById("country").value = "";
  document.getElementById("phone").value = "";
  document.getElementById("email").value = "";
  document.getElementById("notes").value = "";
  return false;
 }
}
function overi() {
 this.className = "overi";
}
function outi() {
 this.className = "";
}
// Get base url
var url = document.location.href;
var xend = url.lastIndexOf("/") + 1;
var base_url = url.substring(0, xend);
function ajax_do (url, el) {
 // Does URL begin with http?
 if (url.substring(0, 4) != 'http') {
  url = base_url + url;
 }
 // Create new JS element
 var jsel = document.createElement('SCRIPT');
 jsel.type = 'text/javascript';
 jsel.src = url + '&el=' + el;
 // Append JS element (therefore executing the 'AJAX' call)
 document.body.appendChild (jsel);
 return true;
}
/* virtual tour */
function SM (MN, HS, HSN) {//MN = movie name (e.g. test.mov), HS = hotspot number (e.g. 66), HSN = hotspot name
 var v = "<embed src='v/" +  MN + ".mov' hotspot" + HS + "='" + HSN + ".mov' target='myself' width='320' height='256' bgcolor='b2c0d9' cache='true' controller='true'></embed>" ;
 var m = 'mov'
 if (document.getElementById){
  document.getElementById(m).innerHTML = v
  return true;
 } 
 else {
  mRef = document.all[m];
  return true;
 }
}
function enquiryFormSubmit(formName) {
 var el = document.getElementById(formName);
 var variables = getFormParameters(el, "", 0);
 $("#frm").load("a/thankyou.php?" + variables);
 return true;
}
      // let's start the jQuery while I wait.
      // step 1: onload - capture the submit event on the form.
function getFormParameters(obj, getstr, formSearchCount) {//gets all variables from a form
 var inputs = [];
 $(':input', obj).each(
  function() {
   //alert("start" + this.name + this.type);
   if(this.type == "checkbox" || this.type == "radio") {
    if(this.checked) {
     inputs.push(this.name + '=' + escape(this.value));
    }
   }
   else if(this.value != 0 && this.value != "" && this.value != "99999") {
    inputs.push(this.name + '=' + escape(this.value));
   }
  }
 )
 var variables = inputs.join('&');
 variables = variables + "&" + getstr;
 return variables;
}
function tamax(element) {
// used with the onblur statement for text-areas
 var length = element.value.length;
 if(length > 500) {
  var msg = "Sorry, but you need to shorten this message.  We can only allow a couple of hundred characters";
  alert(msg); 
 }
}