var email = "enquiries"
var domain = "bestmoveproperties.co.uk"
var eml_val = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

function addToFavorites() {
var title="Best Move Properties";
var urlAddress="http://www.bestmoveproperties.co.uk";
if (window.sidebar) { 
window.sidebar.addPanel(title, self.location.href,""); 
} else if( document.all ) {
window.external.AddFavorite(self.location.href, title);
} else if( window.opera && window.print ) {
return true;
}
}

function checkit(thisForm) {
if (thisForm.name.value=="") {
alert("Please supply your name.");
thisForm.name.focus();
thisForm.name.select();
return false;
}

if (thisForm.details.value=="") {
alert("Please supply a few details.");
thisForm.details.focus();
thisForm.details.select();
return false;
}

if (eml_val.test(thisForm.email.value) &! thisForm.email.value=="") {
thisForm.submit();
return true; }
else {
alert("Please supply a valid e-mail address.");
thisForm.email.focus();
thisForm.email.select();
return false;
}
}


var currentSize = 76;
var currentAlign = "justify";

function setFontSize(ev, percentage, prevent)
{
    if (document.getElementsByTagName) {
	currentSize = percentage;
	document.getElementsByTagName("body")[0].style.fontSize = currentSize + '%';

	if (window.event) {
	    window.event.returnValue = false;
	} else {
	    ev.preventDefault();
	}
    }
}

function decreaseFontSize(ev)
{
    setFontSize(ev, currentSize / 1.13, true);
    window.location.href = window.location.href;
}

function defaultFontSize(ev)
{
    setFontSize(ev, 76, true);
    window.location.href = window.location.href;
}

function increaseFontSize(ev)
{
    setFontSize(ev, currentSize * 1.13, true);
}

function setTextAlign(ev, alignment, prevent)
{
    if (document.getElementsByTagName) {
	currentAlign = alignment
	for( var x = 0; x < document.getElementsByTagName("p").length; x++ ) {
	document.getElementsByTagName("p")[x].style.textAlign = currentAlign;
}
	for( var x = 0; x < document.getElementsByTagName("dl").length; x++ ) {
	document.getElementsByTagName("dl")[x].style.textAlign = currentAlign;
}
	if (window.event) {
	    window.event.returnValue = false;
	} else {
	    ev.preventDefault();
	}
    }
}

function leftalignText(ev)
{
    setTextAlign(ev, 'left', true);
}
function justifyText(ev)
{
    setTextAlign(ev, 'justify', true);
}

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alt") == -1 && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  var size = readCookie("size");
  var align = readCookie("align");
  setActiveStyleSheet(title);
  if (size) setFontSize(e, size, false);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
  createCookie("size", currentSize, 365);
  createCookie("align", currentAlign, 365);
}

function swapimage(imgname, imgtitle) {
var newimg = document.getElementById("midimg");
if ((navigator.userAgent.indexOf("MSIE") != -1) && (navigator.userAgent.indexOf("Opera") == -1)) {
	newimg.style.filter="progid:DXImageTransform.Microsoft.Fade(Overlap=1.00);";
	newimg.filters[0].apply();
	newimg.src=imgname;
	newimg.title=imgtitle;
	newimg.alt=imgtitle;
	newimg.filters[0].play();
	}
else
	newimg.src=imgname;
}

function swapimage1(imgname, imgtitle) {
var newimg = document.getElementById("midimg1");
if ((navigator.userAgent.indexOf("MSIE") != -1) && (navigator.userAgent.indexOf("Opera") == -1)) {
	newimg.style.filter="progid:DXImageTransform.Microsoft.Fade(Overlap=1.00);";
	newimg.filters[0].apply();
	newimg.src=imgname;
	newimg.title=imgtitle;
	newimg.alt=imgtitle;
	newimg.filters[0].play();
	}
else
	newimg.src=imgname;
}
