var ie4 = false; if(document.all) { ie4 = true; }
function getObject(id) {
	if (ie4) {
		return document.all[id];
	} else {
		return document.getElementById(id);
	}
}

function checkClaimForm(f) {
	var ok= true;
	var things= new Array('name', 'postcode', 'house_number', 'telephone', 'email', 'time_to_call', 'date_of_accident_or_diagnosis', 'type_of_accident', 'description');
	for (var i=0; i< things.length; i++) {
		if (f.elements[things[i]].value== '') {
			ok= false;
		}
	} 
	
	if (!ok) {
		alert('Please fill in all the fields!');
	}
	//var e = document.getElementById(id);
	//e.style.display = 'none';
	return ok;
}
	
	
Date.prototype.getDOY = function() {
	var onejan = new Date(this.getFullYear(),0,1);
	return Math.ceil((this - onejan) / 86400000);
}


/* Functions for old style rollovers */
function rollover(imgID) {
		
  // get the image object we're referring to
  var thisimg = document.getElementById(imgID);
  // and add "_on" to its src
  thisimg.src = thisimg.src.replace(/(\.[a-z0-9]+)$/i,'-h$1');
}
function rollout(imgID) {
  // get the image object we're referring to
  var thisimg = document.getElementById(imgID);
  // and remove "_on" from its src
  thisimg.src = thisimg.src.replace(/-h(\.[a-z0-9]+)$/i,'$1');
}

/* Functions for new style rollovers; these are actual event handlers,
   not just called from an event handler. */
function rollover_handler(e) {
	
  // get the source element in a cross-browser way
  if (window.event) { thisimg = window.event.srcElement;
  } else if (e.target) { thisimg = e.target;
  } else { return;
  }
  thisimg.src = thisimg.src.replace(/(\.[a-z0-9]+)$/i,'-h$1');
}
function rollout_handler(e) {
  // get the source element in a cross-browser way
  if (window.event) { thisimg = window.event.srcElement;
  } else if (e.target) { thisimg = e.target;
  } else { return;
  }
  thisimg.src = thisimg.src.replace(/-h(\.[a-z0-9]+)$/i,'$1');
}

// set the hidden action element in a form
function setProductOrderForm(f, a, i) {
	//alert (document.forms[f].name);
	f= document.forms[f];
	f.elements['action'].value= a;
	f.elements['data'].value= i;
	if (a=='removeItem') {
		if (!confirm('Remove this item?')) {
			return;
		}
	}
	f.submit();
	//alert(document.forms[f].elements['action'].value);
	//alert(document.forms[f].elements['product_id'].value);
}



// Anti spam bot for email
//var lhs = "help";
//var rhs = "mspan.co.uk";
function email_me(lhs, rhs, aClass) {
	// class=\""+aClass+"\"
	document.write("<a href=\"mailto");
	document.write(":" + lhs + "@");
	document.write(rhs + "\" title=\"email: "+lhs+"@"+rhs+"\">" + lhs + "@" + rhs + "<\/a>");
}



function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'none')
e.style.display = 'block';
else
e.style.display = 'none';
}


/* http://www.white-hat-web-design.co.uk/articles/js-fontsize.php */
var min=8;
var max=18;

var els = new Array (2)
els[0]='p';
els[1]='td';
els[2]='div';
els[3]='a';
  
function increaseFontSize() {
   var p;
	
  for(j=0;j<els.length;j++) {
  	p = document.getElementsByTagName(els[j]);
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
      	//alert(p[i].style.fontSize);
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 11;
      }
      if(s!=max) {
         s += 1;
      }
      
      
      p[i].style.fontSize = s+"px";
     }
   }
   //alert(s);
   store('fontSize', s);
}

function setFontSize(s) {
	//alert(s);
	var p;
	
  for(j=0;j<els.length;j++) {
    p = document.getElementsByTagName(els[j]);
    for(i=0;i<p.length;i++) {
      p[i].style.fontSize = s+"px"
    }
    store('fontSize', s);
    //alert(s);
  }
}

function decreaseFontSize() {
  var p;
	
  for(j=0;j<els.length;j++) {
  	p = document.getElementsByTagName(els[j]);
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 11;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }  
  }
   //alert(s);
   store('fontSize', s); 
}

function setFonts() {
	alert(getCookie('fontSize'));
}

function store(data,value) {
  var today = new Date();
  var expires = new Date();
  // set it for a short time
  expires.setTime(today.getTime() + 1000*60*60*24);
  setCookie(data, value, expires);
}

function setCookie(name, value, expire) {
  document.cookie = name + "=" + escape(value)  + ((expire == null) ? "" : ("; expires=" + expire.toGMTString())) + '; path=/';
}

function getCookie(Name) {
	var search = Name + "=";
	if (document.cookie.length > 0) { // if there are any cookies
  	offset = document.cookie.indexOf(search);
  	if (offset != -1) { // if cookie exists
    	offset += search.length;
    	// set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1) end = document.cookie.length;
      return unescape(document.cookie.substring(offset, end))
  	}
	}
	return null;
}

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
	document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") + ( ( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}


// -----------------------------------------
//                  setfocus
// Delayed focus setting to get around IE bug
// Author: Stephen Poley
// wbsite: http://www.xs4all.nl/~sbpoley/webmatters/
// Update Jun 2005: discovered that reason IE wasn't setting focus was
// due to an IE timing bug. Added 0.1 sec delay to fix.
// -----------------------------------------
var glb_vfld;      // retain vfld for timer thread
function setFocusDelayed(vfld)
{
  glb_vfld.focus()
}
function setFocus(vfld)
{
	//alert(vfld.name);
  glb_vfld = vfld;
  setTimeout( 'setFocusDelayed()', 100 );
}

/****************************************************
     Author: Eric King
     Url: http://redrival.com/eak/index.shtml
     This script is free to use as long as this info is left in
     Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
****************************************************/
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=yes,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}