function validateForm(form) { //This is the name of the function
if (form.searchfield.value == "") { //This checks to make sure the field is not empty
   alert("Please enter a search word or phrase."); //Informs user of empty field
   form.searchfield.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }
else {
    var out="";
    var e=document.ThisForm;
    out += e.searchfield.value;
    out += " ";
    out += e.shop.value;
    document.ThisForm.SS.value=out;
   document.ThisForm.submit();
}
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function validateContactForm(contact) { //This is the name of the function
if (contact.aa_salutation.value == "") { //This checks to make sure the field is not empty
   alert("Please enter your salutation."); //Informs user of empty field
   contact.aa_salutation.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }


if (contact.a_surname.value == "") { //This checks to make sure the field is not empty
   alert("Please enter your name."); //Informs user of empty field
   contact.a_surname.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }


if (contact.b_address1.value == "") { //This checks to make sure the field is not empty
   alert("Please enter your address."); //Informs user of empty field
   contact.b_address1.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }

if (contact.c_postcode.value == "") { //This checks to make sure the field is not empty
   alert("Please enter your postcode."); //Informs user of empty field
   contact.c_postcode.focus( ); //This focuses the cursor on the empty field
   return false; //This prevents the form from being submitted
   }
}


var bPageIsLoaded = false;
/***********************************************************************
*
* setCookie -        Generic Set Cookie routine
*
* Input: sName         -        Name of cookie to create
*         sValue         -        Value to assign to the cookie
*         sExpire -        Cookie expiry date/time (optional)
*
* Returns: null
*
************************************************************************/

function setCookie(sName, sValue, sExpire) 
    {
    var sCookie = sName + "=" + escape(sValue) +"; path=/";        // construct the cookie
    if (sExpire)
            {
            sCookie += "; expires=" + sExpire.toGMTString();        // add expiry date if present
            }
    document.cookie = sCookie;                                        // store the cookie
    return null;
    }

/***********************************************************************
*
* getCookie        -        Generic Get Cookie routine
*
* Input: sName        -        Name of cookie to retrieve
*
* Returns:                Requested cookie or null if not found
*
************************************************************************/

function getCookie(sName) 
    {
    var sCookiecrumbs = document.cookie.split("; ");         // break cookie into crumbs array
    var sNextcrumb
    for (var i=0; i < sCookiecrumbs.length; i++) 
        {
        sNextcrumb = sCookiecrumbs[i].split("=");        // break into name and value
        if (sNextcrumb[0] == sName)                        // if name matches
            {
             return unescape(sNextcrumb[1]);                 // return value
            }
        }
        return null;
    }

/***********************************************************************
*
* saveReferrer -        Saves the referrer to a Cookie
*
* Input:                 nothing
*
* Returns:                null
*
************************************************************************/

function saveReferrer() 
    {
    var bSetCookie = false;
    if (parent.frames.length == 0)                                        // No FrameSet
                {
                bSetCookie = true;
                }
    else                                                                                                                // FrameSet in use
                {
                var bCatalogFrameSet = false;
                for (var nFrameId = parent.frames.length; nFrameId > 0; nFrameId--)
                        {
                        if (parent.frames[nFrameId - 1].name == 'CatalogBody')        // Catalog FrameSet used
                                {
                                bCatalogFrameSet = true;
                                break;
                                }
                        }
                if (bCatalogFrameSet)                                                        // Catalog FrameSet
                        {
                        if (window.name=='CatalogBody')                        // and this is the CatalogBody frame
                                {
                                bSetCookie = true;
                                }
                        }
                else                                                                                                        // Not Catalog FrameSet
                        {
                        bSetCookie = true;
                        }
                }
    if (bSetCookie)
                {
                var sUrl = document.URL;
                var nHashPos = sUrl.lastIndexOf("#");                // Look for URL anchor
                if (nHashPos > 0)                                                                        // if it exists
                    {
                    sUrl = sUrl.substring(0,nHashPos);                // then remove it
                    }
                setCookie("ACTINIC_REFERRER", sUrl);                // Emulates HTTP_REFERER
                }
            return null;
            }
    
saveReferrer();                                                // For v6 only, should be in templates for v7

/***********************************************************************
*
* CreateArray        creates an array with n elements
*
* Input: n        -        number of elements
*
* Returns:                the created array
*
************************************************************************/

function CreateArray(n)
        {
        this.length = n;
        for (var i=1; i <= n; i++)                                                        // for all ns
                {
                this[i] = new Section();                                                // create a section structure
                }
        return this;                                                                                        // return the created array
        }

/***********************************************************************
*
* Section        -        creates the section structure for raw section lists
*
* Input:                                 nothing
*
* Returns:                                nothing
************************************************************************/

function Section()
        {
        this.sURL = null;
        this.sName = null;
        this.sImage = null;
        this.nImageWidth = null;
        this.nImageHeight= null;
        this.nSectionId        = null;
        this.pChild = null;
        }
        
/***********************************************************************
*
* SwapImage                        -        swaps an image to the alternative
*
* Input:        sName                -        name of the image
*
*                        sAltImage        -        filename of the alternative image
*
************************************************************************/

function SwapImage(sName, sAltImage)
        {
        var nCount = 0;
        document.aSource = new Array;                                                // array for images
        if (document[sName] != null)                                                // if image name exists
                {
                document.aSource[nCount++] = document[sName];        // store image
                if(null == document[sName].sOldSrc)
                        {
                        document[sName].sOldSrc = document[sName].src;        // store image source
                        }
                document[sName].src = sAltImage;                                // change image source to alternative
                }
        }

/***********************************************************************
*
* RestoreImage                -        restores an image to the original
*
* Input:                                 nothing
*
* Returns:                                nothing
************************************************************************/

function RestoreImage()
        {
        var nCount, aSource = document.aSource;
        if (aSource != null)                                                                        // if array of images exists
                {
                for(nCount=0; nCount < aSource.length; nCount++)        // restore all images
                        {
                        if ((aSource[nCount] != null) &&
                                (aSource[nCount].sOldSrc != null))        // if we stored something for this image
                                {
                                aSource[nCount].src = aSource[nCount].sOldSrc;        // restore the original image
                                }
                        }
                }
        }

/***********************************************************************
*
* PreloadImages                -        restores an image to the original
*
* Input:                                 nothing
*
* Returns:                                nothing
*
************************************************************************/

function PreloadImages()
        {
        bPageIsLoaded = true;
        if(document.images)
                {
                if(!document.Preloaded)                                                        // preload array defined?
                        {
                        document.Preloaded = new Array();                // no, define it
                        }
                var nCounter , nLen = document.Preloaded.length, saArguments = PreloadImages.arguments;
                for(nCounter = 0; nCounter < saArguments.length; nCounter++)        // iterate through arguments
                        {
                        document.Preloaded[nLen] = new Image;
                        document.Preloaded[nLen++].src = saArguments[nCounter];
                        }
           }
        }
        
/***********************************************************************
*
* ShowPopUp                -        creates pop up window
*
* Input: sUrl                -        URL o page to display
*                        nWidth        -        Width of window
*                        nHeight        -        Height of window
*
* Returns:                                nothing
*
************************************************************************/

function ShowPopUp(sUrl, nWidth, nHeight)
          {  
        window.open(sUrl, 'ActPopup', 'width=' + nWidth + ',height=' + nHeight + ',scrollbars, resizable');
        if (!bPageIsLoaded)
                {
                window.location.reload(true);
                }
        }
