//preloading images

function preloader() {
	if (document.getElementById) {
		document.getElementById("preload");
		
	}
}
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}
addLoadEvent(preloader);
// end preloader

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function MM_popupMsg(msg) { //v1.0
  alert(msg);
}
//===================================================================================//
//https://www.webmasterworld.com/forum91/441.htm hideDiv and showDiv; as follows
//<a href="javascript:hideDiv('name')">hide Div name</a>
//<a href="javascript:showDiv('name')">show Div name</a> 
function hideDiv(pass) {
var divs = document.getElementsByTagName('div');
for(i=0;i<divs.length;i++){
if(divs[i].id.match(pass)){//if they are 'see' divs
if (document.getElementById) // DOM3 = IE5, NS6
divs[i].style.visibility="hidden";// show/hide
else
if (document.layers) // Netscape 4
document.layers[divs[i]].display = 'hidden';
else // IE 4
document.all.hideshow.divs[i].visibility = 'hidden';
}
}
}

function showDiv(pass) {
var divs = document.getElementsByTagName('div');
for(i=0;i<divs.length;i++){
if(divs[i].id.match(pass)){
if (document.getElementById)
divs[i].style.visibility="visible";
else
if (document.layers) // Netscape 4
document.layers[divs[i]].display = 'visible';
else // IE 4
document.all.hideshow.divs[i].visibility = 'visible';
}
}
} 
//=================================================================================//
//no right-click possible
function nrcIE(){
if (document.all){return false;}}
function nrcNS(e){
if(document.layers||(document.getElementById&&!document.all)){ 
if (e.which==2||e.which==3){
return false;}}} 
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=nrcNS;
}else{document.onmouseup=nrcNS;document.oncontextmenu=nrcIE;}
document.oncontextmenu=new Function("return false");
//===============================================================================//
//window position and size
//window.moveTo(0,0);
//window.resizeTo(screen.width,screen.height);
//===============================================================================//
//open pop up window

function changePage (loc,winname,size) {
        window.open (loc,winname,size);
        }
//==============================================================================//
//timed [2000 milliseconds here] redirect and erase previous page in history
var sTargetURL = "url";

function doRedirect()
{
    setTimeout( "timedRedirect()", 2*1000 );
}
function timedRedirect()
{
    window.location.replace( sTargetURL );
}
//===========================================================================//
//submit once button implementation
/*
Submit Once form validation- 
� Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit https://dynamicdrive.com
*/
function submitonce(theform){
//if IE 4+ or NS 6+
if (document.all||document.getElementById){
//screen thru every element in the form, and hunt down "submit" and "reset"
for (i=0;i<theform.length;i++){
var tempobj=theform.elements[i]
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
//disable em
tempobj.disabled=true
}
}
}
// <form method="POST" onSubmit="submitonce(this)"> //
//=========================================================================//

//limit number of characters that can be entered in form fields [like zipcodes]
function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);

	}
}
// trims leading and trailing spaces from formfields
function trim(str) {             
                return str.replace(/^\s+|\s+$/g, '');
            }

//Formvalidation for Checkout Dutch customers //

function CheckiDealForm (theform){
  var strMissingFields="";
  var tfld = trim(theform.b_email.value);       //trim leading-trailing spaces from e-mail 1
  var tfld2 = trim(theform.b_email2.value);     //trim leading-trailing spaces from e-mail 2
  var illegalChars = /[\W_]/;                   // allow only letters and numbers in postcode
  var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
  var illegalmail= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
  if(theform.b_first.value   == 0)  strMissingFields += "     Factuuradres: Voornaam/voorletter niet ingevuld.\n";
  if(theform.b_last.value    == 0)  strMissingFields += "     Factuuradres: Achternaam niet ingevuld.\n";
  if(theform.b_addr.value    == 0)  strMissingFields += "     Factuuradres: Adres niet ingevuld.\n";
  if(theform.b_city.value    == 0)  strMissingFields += "     Factuuradres: Stad niet ingevuld.\n";
//if(theform.b_state.value   == "")  strMissingFields += "     Billing: State\n";
  if(theform.b_zip.value     == 0)  strMissingFields += "     Factuuradres: Postcode niet ingevuld.\n"; else
  if(theform.b_zip.value.length<4) strMissingFields += "Postcode moet uit tenminste 4 tekens [cijfers, letters] bestaan. Corrigeer dit om door te kunnen gaan.\n"; else
  if(illegalChars.test(theform.b_zip.value))  strMissingFields += "Postcode kan alleen uit cijfers en/of letters bestaan. Corrigeer dit om door te kunnen gaan.\n";
  if(theform.b_country.value == 0)  strMissingFields += "     Factuuradres: Land niet ingevuld\n";
  if(theform.b_email.value   == 0)  strMissingFields += "     Factuuradres: Email niet ingevuld\n"; else
  if (!emailFilter.test(tfld))  strMissingFields += "Ongeldig E-mail adres!  Corrigeer dit om door te kunnen gaan.\n"; else // checks for illegal characters in adres
  if (theform.b_email.value.match(illegalmail))  strMissingFields += "Ongeldig E-mail adres!   Corrigeer dit om door te kunnen gaan.\n"; else
  if(tfld2   != tfld)  strMissingFields += "E-mailadressen stemmen niet overeen.   Corrigeer dit om door te kunnen gaan.\n";
  if(strMissingFields != "")  alert("Er zitten fouten in uw formulier:\n" + strMissingFields);
  if(strMissingFields != "")  return false;
  return true;
  }

//Formvalidation for Checkout English customers //

function CheckPPForm (theform){
  var strMissingFields="";
  var tfld = trim(theform.b_email.value);       //trim leading-trailing spaces from e-mail 1
  var tfld2 = trim(theform.b_email2.value);     //trim leading-trailing spaces from e-mail 2
  var illegalChars = /[\W_]/;                   // allow only letters and numbers in postcode
  var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
  var illegalmail= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
  if(theform.b_first.value   == 0)  strMissingFields += "     Billing address: No first name or initial ?\n";
  if(theform.b_last.value    == 0)  strMissingFields += "     Billing address: No last name?\n";
  if(theform.b_addr.value    == 0)  strMissingFields += "     Billing address: No address ?\n";
  if(theform.b_city.value    == 0)  strMissingFields += "     Billing address: No city ?\n";
//if(theform.b_state.value   == "")  strMissingFields += "     Billing: State\n";
  if(theform.b_zip.value     == 0)  strMissingFields += "     Billing address: No zip or postcode ?\n"; else
 // if(theform.b_zip.value.length<4) strMissingFields += "Postcode moet uit tenminste 4 tekens [cijfers, letters] bestaan. Corrigeer dit om door te kunnen gaan.\n"; else
 // if(illegalChars.test(theform.b_zip.value))  strMissingFields += "Postcode kan alleen uit cijfers en/of letters bestaan. Corrigeer dit om door te kunnen gaan.\n";
  if(theform.b_country.value == 0)  strMissingFields += "     Billing address: No country ?\n";
  if(theform.b_email.value   == 0)  strMissingFields += "     Billing address: No mail address ?\n"; else
  if (!emailFilter.test(tfld))  strMissingFields += "Invalid E-mail address!  Please correct this to continue.\n"; else // checks for illegal characters in adres
  if (theform.b_email.value.match(illegalmail))  strMissingFields += "Invalid E-mail address!   Please correct this to continue.\n"; else
  if(tfld2   != tfld)  strMissingFields += "Mail addresses are not identical.   Please correct this to continue.\n";
  if(strMissingFields != "")  alert("There are some errors in your form, please correct these to continue:\n" + strMissingFields);
  if(strMissingFields != "")  return false;
  return true;
  }

 //===========================================================================//
 //resize function for highslide iframes//
 function myresize(w, h) {
  var exp = hs.getExpander();
  var args = {
    width: w,
    height: h,
    dX: 0,
    dY: 0
  };
 
  exp.resize(args);
  // move it to center:
 
  var size = hs.getPageSize();
  exp.x.min = Math.round((size.width - exp.x.span) / 2);
  exp.y.min = Math.round((size.height - exp.y.span) / 2);
  hs.setStyles(exp.wrapper, { left: exp.x.min +'px', top: exp.y.min +'px' });
 exp.resize(args);
 
};
//=================================================================//
function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}
function checkVersion()
{
  //var msg = "You're not using Internet Explorer.";
  var ver = getInternetExplorerVersion();

  if ( ver > -1 )
  {
    if ( ver < 7.0 ) 
      alert( 'You\'re using a very outdated copy of Internet Explorer.\nThis site will work mostly OK but you really should upgrade.\n\nThis IE version is unsafe, slow and can have some unforeseen results.' );
     }
  
}


<!-- email - form validation for registering to newsletter and comment form-->
function CheckForm(form)
{

  if (form.name.value == "")
  {
    alert("Please enter your name.");
    form.name.focus();
	return (false);
     }
	 
if (form.email.value == "") 
  { 
  alert("Please enter your email address.");
    form.email.focus();
	return (false);
     }
	 
  if (form.message.value == "")
  {
    alert("Please enter your message.");
    form.message.focus();
    return (false);
  }
  return cap_valid(event);
}
  //------------------------------------------------------------//

function emailCheck (emailStr) {

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

alert("Email address seems incorrect (check @ and .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("This username contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("This domain name contains invalid characters.");
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

alert("The username doesn't seem to be valid.");
return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!");
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The domain name does not seem to be valid.");
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The address must end in a well-known domain or two letter " + "country.");
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
alert("This address is missing a hostname!");
return false;
}

// If we've gotten this far, everything's valid!
return true;
}
		<!-- end page validaton -->
///////////////////////--------------------------------------------/////////////////////////
// create a shorthand function for opening youtube in HighSlide so we don't need to put all this in the opener's onclick

function openYouTube(opener) {
    var returnValue;
    
    // Safari Mobile doesn't have Flash, so we just let the device use the built-in 
    // YouTube viewer.
    
        
    if (/(iPhone|iPod|iPad)/.test(navigator.userAgent)) {
        opener.href = opener.href.replace('/v/', '/watch?v=');
        returnValue = true;        
    }

    else returnValue = hs.htmlExpand(opener, { 
        objectType: 'swf', 
        objectWidth: 480, 
        objectHeight: 385, 
        width: 480, 
        swfOptions: { 
            params: { 
                allowfullscreen: 'true' 
            }
        },
        src: opener.href.replace("watch?", "").replace("=", "/")+'&fs=1&autoplay=1', // convert from Youtube page to movie
        maincontentText: 'You need to upgrade your Flash player'
    });
    
    return returnValue;
};
///-------------------------------------------------------------//////
////////////////Random quote generator ----------------//////////////
var quotes = ["The first thing that is destroyed in the laboratory when a nutrient is isolated from a food, is the delicate web of intelligence that binds the components of food together - <em>Deepak Chopra</em>" , "The Lord hath created medicines out of the earth; and he that is wise will not abhor them - <em>Ecclesiasticus 38:4</em>" , "Foolish the doctor who despises the knowledge acquired by the ancients - <em>Hippocrates</em>", "A wise man should consider that health is the greatest of human blessings, and learn how by his own thought to derive benefit from his illnesses - <em>Hippocrates</em>", "Cure sometimes, treat often, comfort always - <em>Hippocrates</em>", "Everything in excess is opposed to nature - <em>Hippocrates</em>", "If we could give every individual the right amount of nourishment and exercise, not too little and not too much, we would have found the safest way to health - <em>Hippocrates</em>", "Natural forces within us are the true healers of disease - <em>Hippocrates</em>", "Science is the father of knowledge, but opinion breeds ignorance - Hippocrates", "Always laugh when you can. It is cheap medicine - <em>Lord Byron</em>", "Common sense is in medicine the master workman - <em>Peter Latham</em>", "The doctor of the future will give no medicine, but will interest her or his patients in the care of the human frame, in a proper diet, and in the cause and prevention of disease - <em>Thomas Edison</em>", "Health is a state about which medicine has nothing to say - <em>W.H.Auden</em>", "I critique market-based medicine not because I haven't seen its heights but because I've seen its depths - <em>Paul Farmer</em>"];

function getRandomQuote(){
numberOfQuotes = quotes.length;
randNum = Math.floor(Math.random()*numberOfQuotes);
return quotes[randNum];
}
		
