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() 
    {
	if (window.name == 'ActPopup') return; // don't save if on popup page
    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;
	    }

/***********************************************************************
*
* 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 of page to display
*			nWidth	-	Width of window
*			nHeight	-	Height of window
*
* Returns:				nothing
*
************************************************************************/

function ShowPopUp(sUrl, nWidth, nHeight)
  	{  
  	if (sUrl.indexOf("http") != 0 &&
  		sUrl.indexOf("/") != 0)
  		{
  		var sBaseHref = GetDocumentBaseHref();
		sUrl = sBaseHref + sUrl;
  		}  
	window.open(sUrl, 'ActPopup', 'width=' + nWidth + ',height=' + nHeight + ',scrollbars, resizable');
	if (!bPageIsLoaded)
		{
		window.location.reload(true);
		}
	return false;
	}

/***********************************************************************
*
* GetDocumentBaseHref	- Returns the href for the <base> element if it is defined
*
* Returns:	base href if defined or empty string
*
************************************************************************/

function GetDocumentBaseHref()
	{
  	var collBase = document.getElementsByTagName("base");
	if (collBase && collBase[0])
		{
		var elemBase = collBase[0];
		if (elemBase.href)
			{
			return elemBase.href;
			}
		}
	return ''; 
	}

/***********************************************************************
*
* DecodeMail		-	decodes the obfuscated mail address in 'contactus' link
*
* Input: 				nothing
*
* Returns:				nothing
*
************************************************************************/

function DecodeMail()
	{
	var nIdx = 0;
	for( ; nIdx < document.links.length; nIdx++ )
		if ( document.links[ nIdx ].name == "contactus" )
		{
		var sOldRef = document.links[ nIdx ].href;

		while( sOldRef.indexOf( " [dot] " ) != -1 )
			sOldRef = sOldRef.replace( " [dot] ", "." );
			
		while( sOldRef.indexOf( " [at] " ) != -1 )
			sOldRef = sOldRef.replace( " [at] ", "@" );
			
		document.links[ nIdx ].href = sOldRef;
		}
	}

/***********************************************************************
*
* HtmlInclude		-	Parses the page for <a href> tags and if any found 
*							with rel="fragment" attribute then create an XMLHTTP
*							request to download the referenced file and insert the
*							file content in place of the referring tag.
*							In case of error just leave it as is.
*
*	NOTE: this function is automatically attached to the onload event handler
*	therefore this processing is done on all pages where this js file is included.
*
* Returns:				nothing
*
* Author:				Zoltan Magyar
*
************************************************************************/

function HtmlInclude() 
	{ 
	var req;
	//
	// Check browser type
	//
	if (typeof(XMLHttpRequest) == "undefined") 	// IE
		{ 
		try 
			{ 
			req = new ActiveXObject("Msxml2.XMLHTTP"); 
			} 
		catch(e) 
			{ 
			try 
				{ 
				req = new ActiveXObject("Microsoft.XMLHTTP"); 
				} 
			catch(e) 										// no luck?
				{ 
				return; 										// nothing to do then
				} 
			} 
		} 
	else 														// Mozzila
		{  
		req = new XMLHttpRequest(); 
		} 
	//
	// Get <a href> tags and iterate on them
	//
	var tags = document.getElementsByTagName("A"); 
	var i; 
	for (i = 0; i < tags.length; i++) 
		{ 
		//
		// Check if we got "fragment" as rel attribute
		//
		if (tags[i].getAttribute("rel") == "fragment") 
			{
			try
				{
				//
				// Try to pull the referenced file from the server
				//
				req.open('GET', tags[i].getAttribute("href"), false); 
				if (document.characterSet) 
					{
					req.overrideMimeType("text/html; charset=" + document.characterSet);
					}
				req.send(null); 
				if (req.status == 200) 					// got the content?
					{ 
					//
					// Replace the reference with the pulled in content
					//
					var span = document.createElement("SPAN"); 
					span.innerHTML = req.responseText; 
					tags[i].parentNode.replaceChild(span, tags[i]);
					} 
				}
			catch(e)											// couldn't pull it from the server (maybe preview)
				{
				return;										// don't do anything then
				}
			} 
		} 
	} 

//
// The following lines will automatically parse all the pages 
// where this script is included by attaching the HtmlInclude
// function to the onload event.
//
if (window.attachEvent) 								// IE 
	{ 
	window.attachEvent("onload", HtmlInclude); 
	} 
else 															// DOM
	{  
	window.addEventListener("load", HtmlInclude, false); 
	}

// START Multiple other info prompt support - V2.50
var formno;
var fieldno;
var docform;

function locatefield(fname){
  formno = '';
  fieldno = '';
  //  (V11) look through all forms 'till one containing field "fname"
  var tf = -1;
  var te = 0;
  var df = document.forms;
  var i = df.length - 1;
  for ( var j = 0; j <= i; j++ )
    {
    var k = df[j].length - 1; 
    for ( var l = 0; l <= k; l++ )
      {
// alert(df[j].elements[l].name);
     if ( df[j].elements[l].name == (fname) ) 
        {
        tf = j;
        te = l;
        }
      }
    }
  if ( tf < 0 )
    {
    alert('Cannot find product form ' + fname);
    return false;
    }
  else
    {
    formno = tf;
    fieldno = te;
    docform = df[tf];
    return true;
    }
}

function stripspecial( prodref ){
// find the form with the order field.
  if (locatefield(prodref))
    {
    docform.elements[fieldno].value = docform.elements[fieldno].value.replace(/[¬\¦]/g, " ");
    } 
} 

function concat( prodref ){
// variables m_country and m_uk will have been set already by 'setotherinfo1' function
// find the form with the order field.
  if (locatefield('O_' + prodref))
   {
    var items = docform.elements[fieldno].value.split(' ¦ ');                     // fetch names
    docform.elements[fieldno].value = '';
    for (var i = 0; i < items.length; i++)   // add in all sub fields
      {
      var names = items[i].split('¬');
      if ( i > 0) docform.elements[fieldno].value += ' ¦ ';
// have to allow for postcode anywhere in the docform
// also allow for where the postcode anywhere buttons are not displayed for any reason

	docform.elements[fieldno].value += names[0] + '¬';

	if (i==0) {
		m_sub =i;
	} else {
		if (docform.elements[fieldno + 2].value == "Click here to get address") {
			if (i<=7) {
				m_sub = i+2;
			} else {
				if (docform.elements[fieldno + 11].value == "Click here to get address (UK only)") {
					m_sub = i+4;
				} else {
					m_sub = i+2;
				}
			}
		} else {
			if (i<=7) {
				m_sub = i;
			} else {
				if (docform.elements[fieldno + 11].value == "Click here to get address (UK only)") {
					m_sub = i+2;
				} else {
					m_sub = i;
				}
			}
		}
	}
	docform.elements[fieldno].value += docform.elements[fieldno + m_sub + 1].value.replace(/[¬\¦]/g, " ");
      }
   } else {
	alert ("We appologise but an error has occurred and we are not able to process this order. Please close down your browser and try again");
	alert ("Contact us on 0845 519 0185, Mon - Fri 9am - 5pm, if you need help");
	return false;
   }
   return true;
}

//function concat( prodref ){
// variables m_country and m_uk will have been set already by 'setotherinfo1' function
// find the form with the order field.
//  if (locatefield('O_' + prodref))
//    {
//    var items = docform.elements[fieldno].value.split(' ¦ ');                     // fetch names
//    docform.elements[fieldno].value = '';
//
//    for (var i = 0; i < items.length; i++)   // add in all sub fields
//      {
//      var names = items[i].split('¬');
//      if ( i > 0) docform.elements[fieldno].value += ' ¦ ';
// have to allow for postcode anywhere in the docform
//	docform.elements[fieldno].value += names[0] + '¬';
//	if (i==0) {m_sub =i;}

// also allow for where the postcode anywhere buttons are not displayed for any reason
//	if (docform.elements[fieldno + 2].value == "Click here to get address") {
//		if (i>0 && i<=7) {m_sub = i+2}
//		if (i>7) {m_sub = i+4}
//	} else {
//		m_sub = i;
//	}

//	docform.elements[fieldno].value += docform.elements[fieldno + m_sub + 1].value.replace(/[¬\¦]/g, " ");
//      }
//    }
//}

// ******************************************************************************************************
//
// Setotherinfo1 sets the order form up to the first post code anywhere button
//
// ******************************************************************************************************

function setotherinfo1(pre, name, size, max, prodname) {
  pre = pre.replace(/&#124;/g, '|');		// fix |
  pre = pre.replace(/&#46;/g, '.');		// fix .		
  pre = pre.replace(/&#123;/g, '{');		// fix {		
  pre = pre.replace(/&#125;/g, '}');		// fix }		
  pre = pre.replace(/&#58;/g, ':');		// fix :		

  var prodref = name.substr(8);			// the product reference part start
  var prodref = prodref.slice(0, -1);		// lose the > char
  var p1 = prodref.indexOf('"');		// end of the text
  var prodvalue = prodref.substr(p1 + 1);	// any additional value text
  prodref = prodref.substring(0, p1);		// the actual prodref 


// Get the destination country from the product name
  m_product = prodname;
  m_product = m_product.replace(/&#38;/g,"&")
  m_product = m_product.replace(/&#40;/g,"(")
  m_product = m_product.replace(/&#41;/g,")")
  m_product = m_product.replace(/&#44;/g,",")
  m_product = m_product.replace(/&#45;/g,"-")

  m_dhl =  0;
  m_dhlair = 0;
  m_dhlroad = 0;
  m_parcelforce = 0;
  m_dhldocument = 0;
  m_hdnl = 0;
  m_bfpo = 0;
  m_dpd = 0;
  m_citylink = 0;

  if (m_product.indexOf("(")> -1) {
	if (m_product.indexOf("DHL") > -1) {
		m_dhl = 1;
		m_country = m_product.substring(4,m_product.indexOf("(")-1).replace(/^\s+|\s+$/g,"");
		if (m_product.toUpperCase().indexOf("AIR SERVICE") > -1) {
			m_dhlair = 1;
		} else if (m_product.toUpperCase().indexOf("EXPRESS DOCUMENT") > -1) {
			m_dhldocument = 1;
		} else {
			m_dhlroad = 1;
		}
	} else if (m_product.indexOf("PARCELFORCE") >-1) {
		m_parcelforce = 1;
		m_country = m_product.substring(12,m_product.indexOf("(")-1).replace(/^\s+|\s+$/g,"");
	} else if (m_product.indexOf("DPD") >-1) {
		m_dpd = 1;
		m_country = m_product.substring(4,m_product.indexOf("(")-1).replace(/^\s+|\s+$/g,"");
	} else if (m_product.indexOf("HOME DELIVERY NETWORK") > -1) {
		m_hdnl = 1;
		m_country = m_product.substring(22,m_product.indexOf("(")-1).replace(/^\s+|\s+$/g,"");
		if (m_product.indexOf("BFPO") > -1) {
			m_bfpo = 1;
		}
	} else if (m_product.toUpperCase().indexOf("CITY LINK") > -1) {
// note that we may have to allow for City link linkletter and citybag services 
		m_citylink = 1;
		m_country = m_product.substring(10,m_product.indexOf("(")-1).replace(/^\s+|\s+$/g,"");
	} else {
		m_country = m_product.substring(0,m_product.indexOf("(")-1).replace(/^\s+|\s+$/g,"");
	}
  } 
  else {
	if (m_product.indexOf("DHL") > -1) {
		m_dhl = 1;
		m_country = m_product.substring(4,m_product.indexOf("-")-1).replace(/^\s+|\s+$/g,"");
		if (m_product.toUpperCase().indexOf("AIR SERVICE") > -1) {
			m_dhlair = 1;
		} else if (m_product.toUpperCase().indexOf("EXPRESS DOCUMENT") > -1) {
			m_dhldocument = 1;
		} else {
			m_dhlroad = 1;
		}
	} else if (m_product.indexOf("PARCELFORCE") >-1) {
		m_parcelforce = 1;
		m_country = m_product.substring(12,m_product.indexOf("-")-1).replace(/^\s+|\s+$/g,"");
	} else if (m_product.indexOf("DPD") >-1) {
		m_dpd = 1;
		m_country = m_product.substring(4,m_product.indexOf("-")-1).replace(/^\s+|\s+$/g,"");
	} else if (m_product.indexOf("HOME DELIVERY NETWORK") >-1) {
		m_hdnl = 1;
		m_country = m_product.substring(22,m_product.indexOf("-")-1).replace(/^\s+|\s+$/g,"");
		if (m_product.indexOf("BFPO") > -1) {
			m_bfpo = 1;
		}
	} else if (m_product.toUpperCase().indexOf("CITY LINK") > -1) {
// note that we may have to allow for City link linkletter and citybag services 
		m_citylink = 1;
		m_country = m_product.substring(10,m_product.indexOf("-")-1).replace(/^\s+|\s+$/g,"");
	} else {
		m_country = m_product.substring(0,m_product.indexOf("-")-1).replace(/^\s+|\s+$/g,"");
	}
  }

  m_country=m_country.toUpperCase()

  if (m_country.indexOf("HIGHLANDS") > -1) {
	m_country = "UNITED KINGDOM";
  }

  if (m_country == "UNITED KINGDOM") {
	m_uk = 1;
  } else {
	m_uk = 0;
  }

// see if a cookie has been created for the collection address and if so populate the collection details with the values in the cookie
  cookiepc = "";
  cookiename = "";
  cookiea1 = "";
  cookiea2 = "";
  cookiect = "";
  cookieph = "";
  cookieem = "";

  var x=readCookie('p2scollection');
  if (x) 
   { 
// parse the cookie into the individual fields
	  var mySplitResult = x.split("#");
// 0 = post code, 1 = name, 2 = address line 1, 3 = address line 2, 4=city/town,5=country,6=phone number
	  cookiepc = mySplitResult[0];
	  cookiename = mySplitResult[1];
	  cookiea1 = mySplitResult[2];
	  cookiea2 = mySplitResult[3];
	  cookiect = mySplitResult[4];
	  cookieco = mySplitResult[5];
	  cookieph = mySplitResult[6];
   }
 // see if simple form
 if (pre.indexOf('|') == -1 ) 
  {
  // alert('Simple ' + name + ' Prodref-' + prodref + '-Value-' + prodvalue + '-');
  document.write(pre + '<INPUT TYPE=text NAME="O_' + prodref + '" ' + prodvalue + ' SIZE="' + size + '" MAXLENGTH="' + max 
                     + '" onchange="stripspecial(\'O_' + prodref + '\')">');
  }
 else
  {        // now have a complex selection
  //  alert('Complex-' + name + '- Prodref-' + prodref + '- Value-' + prodvalue + '-');
  if ( prodvalue == '')			  // we're not bouncing back with an error
    {
    var items = pre.split('|');	  // create default list from prompt text
    var S = ' value="'
    for (var I = 0; I < items.length - 1; I++) S += items[I] + '¬ ¦ '; 
    S += items[items.length - 1] + '¬';
    }
  else
    {
    p1 = prodvalue.indexOf(' VALUE="');    // we've had an error bounce
    var S = prodvalue.slice((p1 + 8), -1); // so extract the old data
    var items = S.split(' ¦ ');            // the items and their data
    S = prodvalue.slice(p1, -1);           // the value="..." substring
    }
 
  document.write('<INPUT TYPE=hidden NAME="O_' + prodref + '"' + S + '" MAXLENGTH="1000">');  // the standard prompt but hidden

// make a table for a nice layout
    document.write('<table border="1" width="580" cellspacing="2" cellpadding="3" class="bookingform" cols="3">')
// now see how many sub fields there are
  for (var I = 0; I < items.length; I++)
    {
    if ( prodvalue == '')
      {				//  simple empty list
      var itemname = items[I];
      var itemvalue = '';

      // test for additional style code
      var itemstyle = '';
      var itemtest = itemname.match(/(.*)\{(.*)\}(.*)/);   // see if there's a {...}
      if ( itemtest != null )
        {
        itemname = itemtest[1] + itemtest[3];
        itemstyle = 'style="' + itemtest[2] + '" ';
        }
      }
    else
      { 
      var itembits = items[I].split('¬');                  // returned list with values
      itemname = itembits[0];
      itemvalue = ' value="' + itembits[1] + '"';

      // test for additional style code
      var itemstyle = '';
      var itemtest = itemname.match(/(.*)\{(.*)\}(.*)/);   // see if there's a {...}
      if ( itemtest != null )
        {
        itemname = itemtest[1] + itemtest[3];
        itemstyle = itemtest[2];
        }

      if ( (itemname.indexOf(':') == -1) && (itembits[1] == '') ) 
        {
        if ( itemstyle != '' ) itemstyle += ';';
        itemstyle += 'background-color: #ff0000';
        }      
      if ( itemstyle != '' ) itemstyle = 'style="' + itemstyle + '" ';
      }

    var fieldsize = size;
    var maxlength = '';
      var sizelook = itemname.match(/^(\d+)\.?(\d*)/);      // look for prefix nn or nn.nn
      if ( sizelook != null)
        {
        itemname = itemname.replace(/^\d+\.?\d*/, '');       // strip out any size / max prefix
        fieldsize = sizelook[1];
        if ( sizelook[2] != '' ) maxlength = ' maxlength="' + sizelook[2] + '"'; 
        }

// translate the short unique codes entered into field names that can be displayed to the user

// *********************** Collection details
      if (itemname.search(/CPC/) > -1)
	{ m_prompt = "Post Code:*";
	  if (m_hdnl==1 || m_dpd==1) {
	    	document.write('<tr><td colspan="3"><b>Where is parcel to be collected from?</b></td></tr>');
	  } else if (m_parcelforce==1) {
		document.write('<tr><td colspan="3"><b>Where is parcel to be collected from? (Enter your home address if self drop option selected)</b></td></tr>');
	  } else if (m_citylink==1) {
// Note that we may have to allow for citylink document services
	    	document.write('<tr><td colspan="3"><b>Where is parcel to be collected from?</b></td></tr>');
	  } else {						// DHL
		 if (m_dhldocument==1) {
			document.write('<tr><td colspan="3"><b>Where is the envelope to be collected from?</b></td></tr>');
		 } else {
		    	document.write('<tr><td colspan="3"><b>Where is parcel to be collected from?</b></td></tr>');
		 }
	  }
	  document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + ' VALUE="' + cookiepc + '"' + ' SIZE="' + fieldsize + '"' + maxlength + '</td>');
      	}

    }
  }
}

function setotherinfo2(pre, name, size, max, prodname) {
  pre = pre.replace(/&#124;/g, '|');		// fix |
  pre = pre.replace(/&#46;/g, '.');		// fix .		
  pre = pre.replace(/&#123;/g, '{');		// fix {		
  pre = pre.replace(/&#125;/g, '}');		// fix }		
  pre = pre.replace(/&#58;/g, ':');		// fix :		

  var prodref = name.substr(8);			// the product reference part start
  var prodref = prodref.slice(0, -1);		// lose the > char
  var p1 = prodref.indexOf('"');		// end of the text
  var prodvalue = prodref.substr(p1 + 1);	// any additional value text
  prodref = prodref.substring(0, p1);		// the actual prodref 

 // see if simple form
 if (pre.indexOf('|') == -1 ) 
  {
  // alert('Simple ' + name + ' Prodref-' + prodref + '-Value-' + prodvalue + '-');
  document.write(pre + '<INPUT TYPE=text NAME="O_' + prodref + '" ' + prodvalue + ' SIZE="' + size + '" MAXLENGTH="' + max 
                     + '" onchange="stripspecial(\'O_' + prodref + '\')">');
  }
 else
  {        // now have a complex selection
  //  alert('Complex-' + name + '- Prodref-' + prodref + '- Value-' + prodvalue + '-');
  if ( prodvalue == '')			  // we're not bouncing back with an error
    {
    var items = pre.split('|');	  // create default list from prompt text
    var S = ' value="'
    for (var I = 0; I < items.length - 1; I++) S += items[I] + '¬ ¦ '; 
    S += items[items.length - 1] + '¬';
    }
  else
    {
    p1 = prodvalue.indexOf(' VALUE="');    // we've had an error bounce
    var S = prodvalue.slice((p1 + 8), -1); // so extract the old data
    var items = S.split(' ¦ ');            // the items and their data
    S = prodvalue.slice(p1, -1);           // the value="..." substring
    }
 
// now see how many sub fields there are
  for (var I = 0; I < items.length; I++)
    {
    if ( prodvalue == '')
      {				//  simple empty list
      var itemname = items[I];
      var itemvalue = '';

      // test for additional style code
      var itemstyle = '';
      var itemtest = itemname.match(/(.*)\{(.*)\}(.*)/);   // see if there's a {...}
      if ( itemtest != null )
        {
        itemname = itemtest[1] + itemtest[3];
        itemstyle = 'style="' + itemtest[2] + '" ';
        }
      }
    else
      { 
      var itembits = items[I].split('¬');                  // returned list with values
      itemname = itembits[0];
      itemvalue = ' value="' + itembits[1] + '"';

      // test for additional style code
      var itemstyle = '';
      var itemtest = itemname.match(/(.*)\{(.*)\}(.*)/);   // see if there's a {...}
      if ( itemtest != null )
        {
        itemname = itemtest[1] + itemtest[3];
        itemstyle = itemtest[2];
        }

      if ( (itemname.indexOf(':') == -1) && (itembits[1] == '') ) 
        {
        if ( itemstyle != '' ) itemstyle += ';';
        itemstyle += 'background-color: #ff0000';
        }      
      if ( itemstyle != '' ) itemstyle = 'style="' + itemstyle + '" ';
      }

    var fieldsize = size;
    var maxlength = '';
      var sizelook = itemname.match(/^(\d+)\.?(\d*)/);      // look for prefix nn or nn.nn
      if ( sizelook != null)
        {
        itemname = itemname.replace(/^\d+\.?\d*/, '');       // strip out any size / max prefix
        fieldsize = sizelook[1];
        if ( sizelook[2] != '' ) maxlength = ' maxlength="' + sizelook[2] + '"'; 
        }

// translate the short unique codes entered into field names that can be displayed to the user

// *********************** Collection details
	if (itemname.search(/CNA/) > -1)  {
	  m_prompt = "Contact Name:*";
	  document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + ' VALUE="' + cookiename + '"' + ' SIZE="' + fieldsize + '"' + maxlength + '</td></tr>');
	  }

      	if (itemname.search(/CA1/) > -1)  {
	  m_prompt = "Address Line 1:*";
	  document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + ' VALUE="' + cookiea1 + '"' + ' SIZE="' + fieldsize + '"' + maxlength + '</td></tr>');
	}

      	if (itemname.search(/CA2/) > -1)  {
	  m_prompt = "Address Line 2:";
	  document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + ' VALUE="' + cookiea2 + '"' + ' SIZE="' + fieldsize + '"' + maxlength + '</td></tr>');
	}

      	if (itemname.search(/CAT/) > -1)  {
	  m_prompt = "City/Town:*";
	  document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + ' VALUE="' + cookiect + '"' + ' SIZE="' + fieldsize + '"' + maxlength + '</td></tr>');
	}

      	if (itemname.search(/CAC/) > -1)  {
	  m_prompt = "Country:";
	  document.write ('<tr><td>' + m_prompt + '</td><td colspan="2"><INPUT readonly ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + ' VALUE="UNITED KINGDOM"' + ' SIZE="' + fieldsize + '"' + maxlength + '</td></tr>');
	}

    	if (itemname.search(/CPH/) > -1)  {
	  	m_prompt = "Phone Number:*";
		if (m_hdnl == 1) {
			document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + ' VALUE="' + cookieph + '"' + ' SIZE="' + fieldsize + '"' + maxlength + '</td><td> Home Delivery network will endeavour to send you a text message with the expected collection time if you enter a mobile phone number here</td></tr>');
		} else {
			document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + ' VALUE="' + cookieph + '"' + ' SIZE="' + fieldsize + '"' + maxlength + '</td></tr>');
		}
	}

// *************** Delivery details
      if (itemname.search(/DPC/) > -1)
	{ m_prompt = "Post Code:*";
		if (m_dhldocument==1) {
			document.write('<tr><td colspan="3"><b>Where is the envelope to be delivered to?</b></td></tr>');
		} else {
			document.write('<tr><td colspan="3"><b>Where is the parcel to be delivered to?</b></td></tr>');
		}
	    document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + itemvalue + ' SIZE="' + fieldsize + '"' + maxlength + '</td>');
    	}

    }
  }
}



function setotherinfo3(pre, name, size, max, prodname) {
  pre = pre.replace(/&#124;/g, '|');		// fix |
  pre = pre.replace(/&#46;/g, '.');		// fix .		
  pre = pre.replace(/&#123;/g, '{');		// fix {		
  pre = pre.replace(/&#125;/g, '}');		// fix }		
  pre = pre.replace(/&#58;/g, ':');		// fix :		

  var prodref = name.substr(8);			// the product reference part start
  var prodref = prodref.slice(0, -1);		// lose the > char
  var p1 = prodref.indexOf('"');		// end of the text
  var prodvalue = prodref.substr(p1 + 1);	// any additional value text
  prodref = prodref.substring(0, p1);		// the actual prodref 
  var m_baseclientmachinedate;

 // see if simple form
 if (pre.indexOf('|') == -1 ) 
  {
  // alert('Simple ' + name + ' Prodref-' + prodref + '-Value-' + prodvalue + '-');
  document.write(pre + '<INPUT TYPE=text NAME="O_' + prodref + '" ' + prodvalue + ' SIZE="' + size + '" MAXLENGTH="' + max 
                     + '" onchange="stripspecial(\'O_' + prodref + '\')">');
  }
 else
  {        // now have a complex selection
  //  alert('Complex-' + name + '- Prodref-' + prodref + '- Value-' + prodvalue + '-');
  if ( prodvalue == '')			  // we're not bouncing back with an error
    {
    var items = pre.split('|');	  // create default list from prompt text
    var S = ' value="'
    for (var I = 0; I < items.length - 1; I++) S += items[I] + '¬ ¦ '; 
    S += items[items.length - 1] + '¬';
    }
  else
    {
    p1 = prodvalue.indexOf(' VALUE="');    // we've had an error bounce
    var S = prodvalue.slice((p1 + 8), -1); // so extract the old data
    var items = S.split(' ¦ ');            // the items and their data
    S = prodvalue.slice(p1, -1);           // the value="..." substring
    }
 
// now see how many sub fields there are
  for (var I = 0; I < items.length; I++)
    {
    if ( prodvalue == '')
      {				//  simple empty list
      var itemname = items[I];
      var itemvalue = '';

      // test for additional style code
      var itemstyle = '';
      var itemtest = itemname.match(/(.*)\{(.*)\}(.*)/);   // see if there's a {...}
      if ( itemtest != null )
        {
        itemname = itemtest[1] + itemtest[3];
        itemstyle = 'style="' + itemtest[2] + '" ';
        }
      }
    else
      { 
      var itembits = items[I].split('¬');                  // returned list with values
      itemname = itembits[0];
      itemvalue = ' value="' + itembits[1] + '"';

      // test for additional style code
      var itemstyle = '';
      var itemtest = itemname.match(/(.*)\{(.*)\}(.*)/);   // see if there's a {...}
      if ( itemtest != null )
        {
        itemname = itemtest[1] + itemtest[3];
        itemstyle = itemtest[2];
        }

      if ( (itemname.indexOf(':') == -1) && (itembits[1] == '') ) 
        {
        if ( itemstyle != '' ) itemstyle += ';';
        itemstyle += 'background-color: #ff0000';
        }      
      if ( itemstyle != '' ) itemstyle = 'style="' + itemstyle + '" ';
      }

    var fieldsize = size;
    var maxlength = '';
      var sizelook = itemname.match(/^(\d+)\.?(\d*)/);      // look for prefix nn or nn.nn
      if ( sizelook != null)
        {
        itemname = itemname.replace(/^\d+\.?\d*/, '');       // strip out any size / max prefix
        fieldsize = sizelook[1];
        if ( sizelook[2] != '' ) maxlength = ' maxlength="' + sizelook[2] + '"'; 
        }

// translate the short unique codes entered into field names that can be displayed to the user


// *************** Delivery details
	if (itemname.search(/DNA/) >-1)  {
	  if (m_bfpo == 1) {
		m_prompt = "Service Number, Rank, Name:*";
	  } else {
		m_prompt = "Contact Name:*";
	  }
	  document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + itemvalue + ' SIZE="' + fieldsize + '"' + maxlength + '></td></tr>')
	}

    	if (itemname.search(/DA1/) >-1)	 {
	  if (m_bfpo == 1) {
		m_prompt = "Unit/Dept/Company/Job:*";
	  } else {
	  	m_prompt = "Address Line 1:*";
	  }
	  document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + itemvalue + ' SIZE="' + fieldsize + '"' + maxlength + '></td></tr>')
	}

      	if (itemname.search(/DA2/) >-1)  {
	  if (m_bfpo == 1) {
		m_prompt = " ";
	  } else {
		  m_prompt = "Address Line 2:";
	  }
    	  document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + itemvalue + ' SIZE="' + fieldsize + '"' + maxlength + '></td></tr>')
	}

      	if (itemname.search(/DAT/) >-1)  {
	  if (m_bfpo == 1) {
		m_prompt = "Unit/Operation Name";
	  } else {
	  	m_prompt = "City/Town:*";
	  }
	  document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + itemvalue + ' SIZE="' + fieldsize + '"' + maxlength + '></td></tr>')
	}

      	if (itemname.search(/DAC/) > -1)  {
	  m_prompt = "Country:";
	  document.write ('<tr><td>' + m_prompt + '</td><td colspan="2"><INPUT readonly ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + ' VALUE="' + m_country + '"' + ' SIZE="' + fieldsize + '"' + maxlength + '</td></tr>');
	}

     	if (itemname.search(/DPH/) > -1)  {
	  m_prompt = "Phone Number:";
	  document.write ('<tr><td>' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + itemvalue + ' SIZE="' + fieldsize + '"' + maxlength + '></td></tr>')
	}

        if (itemname.search(/PWE/) > -1) {
		if (m_dhldocument==1) {
			m_prompt = "Maximum permitted weight of the envelope:";
			itemvalue='0.5';
			document.write('<tr><td colspan="3"><b>Envelope Details</b></td></tr>');
		    	document.write ('<tr><td>' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + ' VALUE="' + itemvalue + '"' + ' READONLY SIZE="' + fieldsize + '"' + maxlength + '> Kg</td></tr>')
		} else {
			m_prompt = "What is the ACTUAL weight of the parcel when packed? *";
			document.write('<tr><td colspan="3"><b>Parcel Details</b></td></tr>');
		    	document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + itemvalue + ' SIZE="' + fieldsize + '"' + maxlength + '> Kg</td></tr>')
		}
        }

        if (itemname.search(/PLE/) > -1) {
		if (m_dhldocument==1) {
			m_prompt = "Maximum permitted length of the envelope:";
			itemvalue='30';
	  		document.write ('<tr><td>' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + ' VALUE="' + itemvalue + '"' + ' READONLY SIZE="' + fieldsize + '"' + maxlength + '> Centimetres</td></tr>');
		} else {
			m_prompt = "What is the LENGTH of the parcel when packed? *";
			document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + itemvalue + ' SIZE="' + fieldsize + '"' + maxlength + '> Centimetres</td></tr>');
		}
	}

        if (itemname.search(/PWI/) > -1) {
		if (m_dhldocument==1) {
			m_prompt = "Maximum permitted width of the envelope:";
			itemvalue='21';
	  		document.write ('<tr><td>' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + ' VALUE="' + itemvalue + '"' + ' READONLY SIZE="' + fieldsize + '"' + maxlength + '> Centimetres</td></tr>');
		} else {
			m_prompt = "What is the WIDTH of the parcel when packed? *";
			document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + itemvalue + ' SIZE="' + fieldsize + '"' + maxlength + '> Centimetres</td></tr>')
      		}
	}

     	if (itemname.search(/PHE/) > -1) {
		if (m_dhldocument==1) {
			m_prompt = "Maximum permitted depth of the envelope:";
			itemvalue='1';
	  		document.write ('<tr><td>' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + ' VALUE="' + itemvalue + '"' + ' READONLY SIZE="' + fieldsize + '"' + maxlength + '> Centimetres</td></tr>');
		} else {
			m_prompt = "What is the HEIGHT of the parcel when packed? *";
	  		document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + itemvalue + ' SIZE="' + fieldsize + '"' + maxlength + '> Centimetres</td></tr>')
      		}
	 }

     	if (itemname.search(/PDE/) > -1)  {
		if (m_dhldocument==1) {
			m_prompt = "Type of documents being sent: *";
		} else {
			m_prompt = "Description of items being delivered: *";
		}
	  	document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + itemvalue + ' SIZE="' + fieldsize + '"' + maxlength + '></td></tr>')
	} 

     	if (itemname.search(/PVA/) > -1) {
		if (m_dhldocument==1) {
			m_prompt = "Nominal value of documents:";
			itemvalue='1';
	  		document.write ('<tr><td>' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + ' VALUE="' + itemvalue + '"' + ' READONLY SIZE="' + fieldsize + '"' + maxlength + '> Pounds</td></tr>');
		} else {
			m_prompt = "Value of Items: *";
	  		document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + itemvalue + ' SIZE="' + fieldsize + '"' + maxlength + '> Pounds</td></tr>')
		}
    	}

    	if (itemname.search(/PRE/) > -1 && m_uk==0)  {
	  	m_prompt = "Reason for export:*";
	  	document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + itemvalue + ' SIZE="' + fieldsize + '"' + maxlength + '></td></tr>')
	}

    	if (itemname.search(/PRE/) > -1 && m_uk==1) {
	  	m_prompt = "Reason for Export:";
	  	document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td colspan="2"><INPUT readonly ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + ' VALUE="Not required for UK delivery"' + ' SIZE="' + fieldsize + '"' + maxlength + '></td></tr>');
	}

    	if (itemname.search(/PSP/) > -1)  {
	  	m_prompt = "Any special instructions?";
	  	document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + itemvalue + ' SIZE="' + fieldsize + '"' + maxlength + '></td></tr>')
	}

    	if (itemname.search(/PCO/) > -1) {
		if (m_dhl==1 || m_hdnl==1 || m_dpd==1 || m_citylink==1) {
			m_prompt = "Preferred collection day: * (Note: suggested date is the earliest date available)";
		} else {
			m_prompt = "Preferred collection/drop off day * (Note: suggested date is the earliest date available)";
		}
		if (m_dhl==1 || m_citylink==1 || m_parcelforce==1) {
			m_prompt1 = "Same day collections available Mon-Fri (exc. non working days) if delivery is booked by 10am";
		} else {
			m_prompt1 = "Next day collections available Mon-Fri (exc. non working days) if delivery is booked by 5pm";
		}
		m_earliestcollect = setcollectdate();
//		document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td colspan="2"><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + ' VALUE="' + m_earliestcollect + '"' + ' SIZE="' + fieldsize + '"' + maxlength + '></td></tr>')
		document.write ('<tr><td><SPAN CLASS="actrequiredcolor">' + m_prompt + '</td><td><INPUT ' + 'TYPE=text NAME="O_' + (I + 1) + '"' + ' VALUE="' + m_earliestcollect + '"' + ' SIZE="' + fieldsize + '"' + maxlength + '></td>' +
			'<td>' + m_prompt1 + '</td></tr>')
     	}

    }
    document.write('</table>');

// If this country has remote areas then set up a hidden frame with the remote areas in html format for later validation
    if (m_dhl == 1) {
	if (countryHasRemoteAreas(m_country)==true) {
		switch (m_country) {
			case "CANARY ISLANDS":
				var URL = "CANARYISLANDS_remoteareasiframefile.html";
				break;
			case "CZECH REPUBLIC": 
				var URL = "CZECHREPUBLIC_remoteareasiframefile.html";
				break;
			case "IRELAND, REPUBLIC OF":
				var URL = "IRELAND_remoteareasiframefile.html";
				break;
			case "KOREA":
				var URL = "SOUTHKOREA_remoteareasiframefile.html";
				break;
			case "NEW ZEALAND":
				var URL = "NEWZEALAND_remoteareasiframefile.html";
				break;
			case "SAUDI ARABIA":
				var URL = "SAUDIARABIA_remoteareasiframefile.html";
				break;
			case "SOUTH AFRICA":
				var URL = "SOUTHAFRICA_remoteareasiframefile.html";
				break;
			case "UNITED STATES OF AMERICA":
				var URL = "USA_remoteareasiframefile.html";
				break;
			default:
				var URL = m_country+"_remoteareasiframefile.html"
		}    
		document.write ('<iframe id="RSIFrame" name="RSIFrame" style="width:0px; height:0px; border: 0px" src="' + URL + '"></iframe>')
	}
    }
  }
}

// Function to set the collection date

function setcollectdate() {
bankhols = new Array(23); 
bankhollimit = 22
bankhols[0]=new Date("12/22/2011");
bankhols[1]=new Date("12/23/2011");
bankhols[2]=new Date("12/26/2011");
bankhols[3]=new Date("12/27/2011");
bankhols[4]=new Date("12/28/2011");
bankhols[5]=new Date("12/29/2011");
bankhols[6]=new Date("12/30/2011");
bankhols[7]=new Date("01/02/2012");
bankhols[8]=new Date("04/06/2012");
bankhols[9]=new Date("04/09/2012");
bankhols[10]=new Date("05/07/2012");
bankhols[11]=new Date("06/04/2012");
bankhols[12]=new Date("06/05/2012");
bankhols[13]=new Date("08/27/2012");
bankhols[14]=new Date("12/20/2012");
bankhols[15]=new Date("12/21/2012");
bankhols[16]=new Date("12/24/2012");
bankhols[17]=new Date("12/25/2012");
bankhols[18]=new Date("12/26/2012");
bankhols[19]=new Date("12/27/2012");
bankhols[20]=new Date("12/28/2012");
bankhols[21]=new Date("12/31/2012");
bankhols[22]=new Date("1/1/2013");

// Courier exclusion dates
courierexclusionlimit = 3;
courierexclusions = new Array(4);
courierexclusions[0] = "DHL";
courierexclusions[1] = "DHL";
courierexclusions[2] = "DHL";
courierexclusions[3] = "DHL";

courierexclusiondates = new Array(4);
courierexclusiondates[0] = new Date("12/7/2010");
courierexclusiondates[1] = new Date("12/8/2010");
courierexclusiondates[2] = new Date("12/9/2010");
courierexclusiondates[3] = new Date("12/10/2010");

// Get the current client machine time so that we can determine later in deliverycheck() how long the user has taken to fill out the 
// form and whether we have gone over a cutoff (10am or 5pm)
m_baseclientmachinedate = new Date();

// First find the first day that the order can be processed by us and then set the 
// earliest collection day accordingly
var m_earliestprocess = new Date(phpscriptTime.toString());

var processday = m_earliestprocess.getDay();	
var m_earliestcollect = new Date();

if (m_dhl==1 || m_citylink==1 || m_parcelforce==1) {
	switch (processday) {
	case 1:
	case 2:
	case 3:
	case 4:						// drop through logic for Monday thru Thursday
		if (phpscriptTime.getHours()<10) {
			m_earliestcollect = new Date(m_earliestprocess.toString());
		} else {
			m_earliestprocess.setDate(m_earliestprocess.getDate()+1)
			m_earliestcollect = new Date(m_earliestprocess.toString());
		}
		break;
	case 5:
		if (phpscriptTime.getHours()<10) {
			m_earliestcollect = new Date(m_earliestprocess.toString());
		} else {
			m_earliestprocess.setDate(m_earliestprocess.getDate()+3)
			m_earliestcollect = new Date(m_earliestprocess.toString());
		}
		break;		
	case 6:
		m_earliestprocess.setDate(m_earliestprocess.getDate()+2)
		m_earliestcollect = new Date(m_earliestprocess.toString());
		break;
	default:
		m_earliestprocess.setDate(m_earliestprocess.getDate()+1)
		m_earliestcollect = new Date(m_earliestprocess.toString())
	}
} else {
	if (phpscriptTime.getHours() > 16) {
		m_earliestprocess.setDate(m_earliestprocess.getDate()+1)
	}
	m_earliestcollect = new Date(m_earliestprocess.toString());

// now find the earliest collection day based on normal working days
	processday = m_earliestprocess.getDay();  

	switch(processday) {
	case 1:
	case 2:
	case 3:
	case 4:
		m_earliestcollect.setDate(m_earliestcollect.getDate()+1)
		break;
	case 5:
		m_earliestcollect.setDate(m_earliestcollect.getDate()+3)
		break;
	case 6:
		m_earliestcollect.setDate(m_earliestcollect.getDate()+2)
		break;
	default:
		m_earliestcollect.setDate(m_earliestcollect.getDate()+1)
	}
}

// now check that the earliest collection day isn't a bank holiday. If so increment the days
for (j=0;j<50;j++) {
	sw_found=false
	if (m_earliestcollect.getDay()==6 || m_earliestcollect.getDay()==0) {
		sw_found=true
	}

	m_tempdate = m_earliestcollect.getDate();
	m_tempmonth = m_earliestcollect.getMonth();
	m_tempfullyear = m_earliestcollect.getFullYear();
	for (i=0; i<=bankhollimit; i++) {
		if (m_tempdate==bankhols[i].getDate() && m_tempmonth==bankhols[i].getMonth() && m_tempfullyear==bankhols[i].getFullYear()) {
			sw_found=true;
			break;  
		}
	}

	if (sw_found==true) {
		m_earliestcollect.setDate(m_earliestcollect.getDate()+1)
	} else {
// add in test for specific courier collection exclusion dates
		for (i=0; i<=courierexclusionlimit ; i++) {		
			if ((m_dhl==1 && courierexclusions[i]=="DHL") ||
  			    (m_parcelforce==1 && courierexclusions[i]=="PARCELFORCE") ||
			    (m_hdnl==1 && courierexclusions[i]=="HDNL") ||
			    (m_dpd==1 && courierexclusions[i]=="DPD")) {
				if (m_tempdate==courierexclusiondates[i].getDate() && m_tempmonth==courierexclusiondates[i].getMonth() && m_tempfullyear==courierexclusiondates[i].getFullYear()) {
					sw_found=true;
					break;  
				}
			}	
		}
// end of addition
		if (sw_found==true) {
			m_earliestcollect.setDate(m_earliestcollect.getDate()+1)
		} else {
			break;
		}
	} 
} 

m_earliestcollect  = m_earliestcollect.getDate()+"/"+(m_earliestcollect.getMonth()+1)+"/"+m_earliestcollect.getFullYear()
return m_earliestcollect
}



// **************************************************************************
// Function to validate entered data against a product
// **************************************************************************

function deliveryCheck(p_prodname, p_prodref) {
	if (concat (p_prodref)) {
	} else {
		return false
	};

// check if this is a DHL delivery
	if (p_prodname.indexOf("DHL") > -1)
	{
		m_dhl = 1;
		m_dhlair = 0;
		m_dhldocument = 0;
		m_dhlroad = 0;
		if (m_product.toUpperCase().indexOf("AIR SERVICE") > -1) {
			m_dhlair = 1;
		} else if (m_product.toUpperCase().indexOf("EXPRESS DOCUMENT") > -1) {
			m_dhldocument = 1;
		} else {
			m_dhlroad = 1;
		}
	} else {
		m_dhl = 0;
	}


// check if this is a Parcelforce Ex delivery
	if (p_prodname.toUpperCase().indexOf("PARCELFORCE") > -1)
	{
		m_parcelforce = 1;
	} else {
		m_parcelforce = 0;
	}

// check if this is a DPD delivery
	if (p_prodname.toUpperCase().indexOf("DPD") > -1)
	{
		m_dpd = 1;
	} else {
		m_dpd = 0;
	}

// check if this is a City Link
	if (p_prodname.toUpperCase().indexOf("CITY LINK") > -1)
	{
		m_citylink = 1;
	} else {
		m_citylink = 0;
	}

// check if this is a Home Delivery Network delivery
	if (p_prodname.toUpperCase().indexOf("HOME DELIVERY NETWORK") > -1)
	{
		m_hdnl = 1;
		if (p_prodname.toUpperCase().indexOf("OVERSIZE") > 1)
		{
			m_hdnloversize = 1;
		} else {
			m_hdnloversize = 0;
		}
		if (p_prodname.toUpperCase().indexOf("BFPO") >1)
		{
			m_bfpo = 1;
		} else {
			m_bfpo = 0;
		}
	} else {
		m_hdnl = 0;
		m_hdnloversize = 0;
		m_bfpo = 0;
	}

// see if the guaranteed collection option has been chosen
// if we wish to suspend guaranteed collections then add test that checks m_guaranteed and puts up error

	m_guaranteed=0;
	m_selfdrop=0;
	m_enhanced=0;
	m_acceptremotecharge=0;
	m_prenoon=0;
	m_pre1030=0;
	m_pre9=0;
	m_satdel=0;
	m_acceptlondonsurcharge=0;
	m_acceptIOWsurcharge=0;

// Parcelforce:
//	Russia: component _1 = collection/dropoff
//	Other than Russia : component _1 = enhanced compensation
//			    component _2 = collection/dropoff
//
	if (m_parcelforce == 1 && m_country == "RUSSIA") {
		var temp=document.getElementsByName("v_"+p_prodref+"_1");
		if (temp[1]) {
			if(temp[1].checked) {
				m_guaranteed = 1;
			}
		}

// see if the self drop option has been chosen
		if (temp[2]) {
			if(temp[2].checked) {
				m_selfdrop = 1;
			}
		}
	}

	if (m_parcelforce == 1 && m_country != "RUSSIA") {
		var temp=document.getElementsByName("v_"+p_prodref+"_1");
		if (temp[0]) {
			if(temp[0].selectedIndex > 0) {
				m_enhanced = 1;
			}	
		}

		var temp=document.getElementsByName("v_"+p_prodref+"_2");
		if (temp[1]) {
			if(temp[1].checked) {
				m_guaranteed = 1;
			}
		}

		if (temp[2]) {
			if(temp[2].checked) {
				m_selfdrop = 1;
			}
		}
	}

// Citylink:
//	component 1=delivery times
	if (m_citylink == 1) {
		var temp=document.getElementsByName("v_"+p_prodref+"_1");
		if (temp[0]) {
			if(temp[0].selectedIndex > 0) {
				m_enhanced = 1;
			}			
		}

		temp=document.getElementsByName("v_"+p_prodref+"_2");
		if (temp[1]) {
			if(temp[1].checked) {
				m_prenoon = 1;
			}
		}
		if (temp[2]) {
			if(temp[2].checked) {
				m_pre1030 = 1;
			}
		}
		if (temp[3]) {
			if(temp[3].checked) {
				m_pre9 = 1;
			}
		}
		if (temp[4]) {
			if(temp[4].checked) {
				m_satdel = 1;
			}
		}

		var temp=document.getElementsByName("v_"+p_prodref+"_3");
		if (temp[1]) {
			if(temp[1].checked) {
				m_acceptlondonsurcharge = 1;
			}
		}
		if (temp[2]) {
			if(temp[2].checked) {
				m_acceptIOWsurcharge = 1;
			}
		}
	}

// DHL:
//		component _1 = collection/dropoff
//		component _2 = Accept remote area surcharge
//

	if (m_dhl == 1) {
		var temp=document.getElementsByName("v_"+p_prodref+"_1");
//		if (temp[1]) {
//			if(temp[1].checked) {
//				m_guaranteed = 1;
//			}
//		}

		if (countryHasRemoteAreas(m_country)==true) {
			var temp=document.getElementsByName("v_"+p_prodref+"_2");
			if (temp[1]) {
				if(temp[1].checked) {
					m_acceptremotecharge = 1;
				}
			}			
		}
	}


// DPD:
//		component_1 = collection/dropoff
//		component_2 = enhanced compensation
	if (m_dpd == 1) {
		var temp=document.getElementsByName("v_"+p_prodref+"_1");
		if (temp[1]) {
			if(temp[1].checked) {
				m_guaranteed = 1;
			}
		}

		var temp=document.getElementsByName("v_"+p_prodref+"_2");
		if (temp[0]) {
			if(temp[0].selectedIndex > 0) {
				m_enhanced = 1;
			}	
		}
	}

// Post code
	var pccollection=document.getElementsByName("O_1");
	test=pccollection[0].value;
	test = test.toUpperCase(); //Change to uppercase
// save for later testing against delivery post code
	m_collectpc = test;

	if (!(validateukpostcodeformat(pccollection[0]))) {return false;}

// check that a delivery is not being picked up from an extended area
	var m_outbound = m_collectpc.substring(0,2);
	var m_zone = m_collectpc.substring(2,4);

	if (!(validatepickupostcode(m_collectpc, m_outbound, m_zone))) {
		alert("Sorry, this service cannot collect from this postcode. Please use a Parcelforce service");
		pccollection[0].focus();
		return false;
	}

// Check for Jersey/Guernsey pickup
	if (m_outbound=="JE") {
		alert ("Sorry - we are not able to collect from an address in Jersey");
		pccollection[0].focus();
		return false;
	}			

	if (m_outbound=="GY") {
		alert ("Sorry - we are not able to collect from an address in Guernsey");
		pccollection[0].focus();
		return false;
	}

// Stop guaranteed collections from extended areas. Only really applies to Parcelforce since the other couriers have already been rejected for these codes
	if (m_guaranteed==1) {
		if (!(validateguaranteedpickup(m_collectpc, m_outbound, m_zone))) {
			alert ("Sorry, we cannot offer a guaranteed collection from this post code.");
			pccollection[0].focus();
			return false;
		}
	}

// Collection contact name.
	var pccollection=document.getElementsByName("O_2");
	if (!(validatename(pccollection[0]))) { return false; }

// Collection address 1.
	var pccollection=document.getElementsByName("O_3");
	if (!(validateaddrline(pccollection[0],1))) { return false; }

// Collection address 2.
	var pccollection=document.getElementsByName("O_4");
	if (!(validateaddrline(pccollection[0],2))) { return false; }

// Collection city/town.
	var pccollection=document.getElementsByName("O_5");
	if (!(validateaddrline(pccollection[0],3))) { return false; }

// Collection Phone number.
	var pccollection=document.getElementsByName("O_7");
	if (!(validatephone(pccollection[0],"M"))) { return false; }

// ************************************ Now delivery details ****************************************************
	var pccollection=document.getElementsByName("O_8");
	test=pccollection[0].value
	m_deliverypc = test.toUpperCase(); //Change to uppercase
	size=m_deliverypc.length;
	while (m_deliverypc.slice(0,1) == " ")
		{m_deliverypc = m_deliverypc.substr(1,size-1);size = m_deliverypc.length}
	while(m_deliverypc.slice(size-1,size)== " ") //Strip trailing spaces
		{m_deliverypc = m_deliverypc.substr(0,size-1);size = m_deliverypc.length}
	pccollection[0].value = m_deliverypc; //write back to form field

	if (size == 0) { // post code must be entered
		if (m_country == "UNITED KINGDOM") {
			alert("Post code must be entered");
			pccollection[0].focus();
			return false;
		} else {
			if (m_country == "IRELAND, REPUBLIC OF") {
				alert("Post code must be entered, even for Ireland. Just enter a Zero if you are sending to an area in Ireland that doesn't use postcodes");
				pccollection[0].focus();
				return false;				

			} else {
				alert("Post code must be entered, even for non UK deliveries");
				pccollection[0].focus();
				return false;
			}
		}
	}

	if (m_bfpo == 1) {
		if (!(validateBFPOpostcodeformat(pccollection[0]))) {return false;}
	} else {
		if (m_country=="UNITED KINGDOM" || 
			m_country =="JERSEY" ||
			m_country =="GUERNSEY") {

			if (!(validateukpostcodeformat(pccollection[0]))) {return false;}

			var m_outbound = m_deliverypc.substring(0,2);
			var m_zone = m_deliverypc.substring(2,4);		
		} else {
			if(!(validateforeignpostcode(m_country, pccollection[0]))) { return false; }
		}
	}

	if (m_country == "UNITED KINGDOM") {
		if (p_prodname.indexOf("ISLANDS") == -1) {
			if (m_hdnl == 1) {		
				if (!(validatehdnldeliverypostcode(m_outbound, m_zone))) {
					alert ("Home Delivery Network cannot deliver to this postcode under this service. Please use the Parcelforce Islands, Highlands & Northern Ireland product " +
					"\rfor delivery to this post code.");
					pccollection[0].focus();
					return false;
				}
			}

			if (m_citylink == 1) {
				if (!(validatecitylinkdeliverypostcode(m_deliverypc, m_outbound, m_zone))) {
					alert ("City Link cannot deliver to this postcode under this service. Please use the Parcelforce Islands, Highlands & Northern Ireland product " +
					"\rfor delivery to this post code.");
					pccollection[0].focus();
					return false;
				}
			}				

			if (m_parcelforce == 1 || m_dhl==1) {		
				if (!(validateislands(m_outbound, m_zone))) {	
					alert ("Please use the Parcelforce Islands, Highlands & Northern Ireland product " +
					"\rfor delivery to this post code.");
					pccollection[0].focus();
					return false;
				}
			}	

			if (m_dhl==1) {
				if (!(validateextraislands(m_outbound, m_zone))) {
					alert ("DHL cannot deliver to this postcode. Please use the Parcelforce Islands, Highlands & Northern Ireland product ");
					pccollection[0].focus();
					return false;
				}

			}
		}

		if (m_outbound=="JE") {
			alert ("Please use the Europe/Channel Islands/Jersey product " +
			"\rfor delivery to this post code.");
			pccollection[0].focus();
			return false;
		}			

		if (m_outbound=="GY") {
			alert ("Please use the Europe/Channel Islands/Guernsey product " +
			"\rfor delivery to this post code.");
			pccollection[0].focus();
			return false;
		}			
	}

	
	if (m_country.substring(0,6)=="JERSEY") {
		if (m_outbound!="JE") {
			alert ("Only JE postcodes are valid for Jersey");
			pccollection[0].focus();
			return false;
		}			
	}
	
	if (m_country.substring(0,8)=="GUERNSEY") {
		if (m_outbound!="GY") {
			alert ("Only GY postcodes are valid for Guernsey");
			pccollection[0].focus();
			return false;
		}				
	}

// Delivery contact name.
	var pccollection=document.getElementsByName("O_9");
	if (!(validatename(pccollection[0]))) { return false; }

// Delivery address 1.
	var pccollection=document.getElementsByName("O_10");
	if (!(validateaddrline(pccollection[0],1))) { return false; }

// Delivery address 2. 
	var pccollection=document.getElementsByName("O_11");
// m_delivaddr2 used in handle response later to check outliers
	m_delivaddr2 = pccollection[0].value
	size = m_delivaddr2.length
	while (m_delivaddr2.slice(0,1) == " ") {
		m_delivaddr2 = m_delivaddr2.substr(1,size-1);size = m_delivaddr2.length
	}
	while(m_delivaddr2.slice(size-1,size)== " ") { //Strip trailing spaces
		m_delivaddr2 = m_delivaddr2.substr(0,size-1);size = m_delivaddr2.length
	}
	m_delivaddr2 = m_delivaddr2.toUpperCase();

	if (!(validateaddrline(pccollection[0],2))) { return false; }

// Delivery city/town.
	var pccollection=document.getElementsByName("O_12");
// m_delivtown used in handle response later to check outliers
	m_delivtown = pccollection[0].value
	size = m_delivtown.length
	while (m_delivtown.slice(0,1) == " ") {
		m_delivtown = m_delivtown.substr(1,size-1);size = m_delivtown.length
	}
	while(m_delivtown.slice(size-1,size)== " ") { //Strip trailing spaces
		m_delivtown = m_delivtown.substr(0,size-1);size = m_delivtown.length
	}
	m_delivtown = m_delivtown.toUpperCase();

	if (!(validateaddrline(pccollection[0],3))) { return false; }

// Delivery Phone number. 
	var pccollection=document.getElementsByName("O_14");
	if (!(validatephone(pccollection[0],"O"))) { return false; }

// ******************************************************************* Now parcel details
// product weight
	if ((m_parcelforce==1 || m_hdnl==1 || m_dpd==1 || m_citylink==1) || (m_dhl==1 && m_dhldocument==0)) {
		pccollection=document.getElementsByName("O_15");

		m_parcelweight=pccollection[0].value;
		size=m_parcelweight.length;
		while (m_parcelweight.slice(0,1) == "0" || m_parcelweight.slice(0,1) == " ") // strip leading zeroes & spaces
			{m_parcelweight = m_parcelweight.substr(1,size-1);size = m_parcelweight.length}	
		while (m_parcelweight.slice(size-1,size)== " ") //Strip trailing spaces
			{m_parcelweight = m_parcelweight.substr(0,size-1);size = m_parcelweight.length}	
		m_parcelweight = Number(m_parcelweight);	
		if (m_parcelweight <= 0) { 
			alert ("Weight of parcel must be entered.");
			pccollection[0].focus();
			return false;
		}

		if (isInteger(m_parcelweight)) {
		} else {
			alert ("The parcel weight must be a whole number of kilograms");
			pccollection[0].focus();
			return false;
		}

// Get the product weight from the product name unless it is a DHL document delivery service in which case the maximum weight is 500 grams
// and cannot be changed by the user so no need to validate
		m_lastpos = m_product.toUpperCase().indexOf("KG")
		m_startpos = m_lastpos
		while(m_product.charAt(m_startpos)!= " ") {
		    m_startpos = m_startpos-1
		}
		var m_productweight = m_product.substring(m_startpos+1, m_lastpos);
// now compare entered weight against maximum for this delivery
		if (m_parcelweight > Number(m_productweight)) { 
			alert ("Weight of parcel is above the maximum of " + m_productweight + "KG for this delivery.");
			pccollection[0].focus();
			return false;
		}
	}

// calculate the maximum dimensions for the parcel. set the default max dimensions
	if ((m_parcelforce==1 || m_hdnl==1 || m_dpd==1 || m_citylink==1) || (m_dhl==1 && m_dhldocument==0)) {
		if (m_dhl==1) {					// dhl
			m_max_len = 120;
			m_max_width = 60;
			m_max_volume = 0.17;
		} else if (m_dpd==1) {			// dpd
			m_max_len = 175;
			m_max_girth = 300;
		} else if (m_citylink==1) {		// Citylink
			m_max_len = 250;
			m_max_width = 100;
		} else if (m_hdnl==1) {			// hdnl
			if (m_hdnloversize==1) {
				m_max_len=225;
			} else {
				m_max_len = 100;	
			}
			m_max_width = 60; 
			m_max_volume = 0.45;
		} else {						// Parcelforce
			m_max_len = 150;	
			m_max_girth = 300; 
			if (m_country=="ARGENTINA" || m_country=="AUSTRALIA" || m_country=="BRAZIL" || 
				m_country=="CHINA" || m_country=="MALAYSIA" || m_country=="NEW ZEALAND" ||
				m_country=="ROMANIA" || m_country=="LATVIA" || m_country=="RUSSIA" ||
				m_country=="UKRAINE" || m_country == "UNITED STATES OF AMERICA" || 
				m_country=="PHILIPPINES" || m_country=="SAUDI ARABIA") {
				m_max_len = 105;
				m_max_girth = 200; 
			}
		}

// Validate parcel length
		pccollection=document.getElementsByName("O_16");

		m_parcellength=pccollection[0].value;
		size=m_parcellength.length;
		while (m_parcellength.slice(0,1) == "0" || m_parcellength.slice(0,1) == " ") // strip leading zeroes & spaces
			{m_parcellength = m_parcellength.substr(1,size-1);size = m_parcellength.length}	
		while (m_parcellength.slice(size-1,size)== " ") //Strip trailing spaces
			{m_parcellength = m_parcellength.substr(0,size-1);size = m_parcellength.length}	
		m_parcellength = Number(m_parcellength);	
	
		if (isInteger(m_parcellength)) {
		} else {
			alert ("The parcel length must be a whole number of CM");
			pccollection[0].focus();
			return false;
		}

		if (m_parcellength <1) {
			alert ("The parcel length must be at least 1cm.");
			pccollection[0].focus();
			return false;
		}

		if (m_parcellength > m_max_len) {
			alert ("The parcel length that you have entered is more than the " + m_max_len + "CM permitted.");
			pccollection[0].focus();
			return false;
		}

// validate parcel width
		pccollection=document.getElementsByName("O_17");

		m_parcelwidth=pccollection[0].value;
		size=m_parcelwidth.length;
		while (m_parcelwidth.slice(0,1) == "0" || m_parcelwidth.slice(0,1) == " ") // strip leading zeroes & spaces
			{m_parcelwidth = m_parcelwidth.substr(1,size-1);size = m_parcelwidth.length}	
		while (m_parcelwidth.slice(size-1,size)== " ") //Strip trailing spaces
			{m_parcelwidth = m_parcelwidth.substr(0,size-1);size = m_parcelwidth.length}	
		m_parcelwidth = Number(m_parcelwidth);	

		if (isInteger(m_parcelwidth)) {
		} else {
			alert ("The parcel width must be a whole number of CM");
			pccollection[0].focus();
			return false;
		}

		if (m_parcelwidth <1) {
			alert ("The parcel width must be at least 1cm.");
			pccollection[0].focus();
			return false;
		}

		if (m_dhl==1 || m_hdnl==1 || m_citylink==1) {
			if (m_parcelwidth > m_max_width) {
				alert ("The parcel width that you have entered is more than the " + m_max_width + "CM permitted.");
				pccollection[0].focus();
				return false;
			}
		} else {		// Parceforce & DPD
			if (m_parcelwidth > m_max_len) {
				alert ("The parcel width that you have entered is more than the " + m_max_len + "CM permitted.");
				pccollection[0].focus();
				return false;
			}
		}

// Validate parcel height
		pccollection=document.getElementsByName("O_18");

		m_parcelheight=pccollection[0].value;
		size=m_parcelheight.length;
		while (m_parcelheight.slice(0,1) == "0" || m_parcelheight.slice(0,1) == " ") // strip leading zeroes & spaces
			{m_parcelheight = m_parcelheight.substr(1,size-1);size = m_parcelheight.length}	
		while (m_parcelheight.slice(size-1,size)== " ") //Strip trailing spaces
			{m_parcelheight = m_parcelheight.substr(0,size-1);size = m_parcelheight.length}	
		m_parcelheight = Number(m_parcelheight);

		if (isInteger(m_parcelheight)) {
		} else {
			alert ("The parcel height must be a whole number of CM");
			pccollection[0].focus();
			return false;
		}

		if (m_parcelheight <1) {
			alert ("The parcel height must be at least 1cm.");
			pccollection[0].focus();
			return false;
		}

		if (m_dhl==1 || m_hdnl==1 || m_citylink==1) {
			if (m_parcelheight > m_max_width) {
				alert ("The parcel height that you have entered is more than the " + m_max_width + "CM permitted.");
				pccollection[0].focus();
				return false;
			}
		} else {		// Parcelforce & DPD
			if (m_parcelheight > m_max_len) {
				alert ("The parcel height that you have entered is more than the " + m_max_len + "CM permitted.");
				pccollection[0].focus();
				return false;
			}
		}

// Validate girth if this is a Parcelforce or DPD delivery
		if (m_parcelforce == 1 || m_dpd==1) {
			var longside = m_parcellength;
			var girth = (m_parcelwidth * 2) + (m_parcelheight * 2)
			if (m_parcelwidth > longside) {longside = m_parcelwidth; girth=(m_parcellength*2)+(m_parcelheight*2)}
			if (m_parcelheight > longside) {longside = m_parcelheight; girth=(m_parcellength*2)+(m_parcelwidth*2)}
			girth = girth + longside
			if (girth>m_max_girth) {
				alert("The girth + the longest side of parcel is " + girth + " centimetres which is greater than the maximum permitted for this delivery of " + m_max_girth + ". See the Frequently Asked Questions for a description of Girth.");
				pccollection=document.getElementsByName("O_16");
				pccollection[0].focus();
				return false;
			}
		}

// Validate dimensional weight for parcelforce,DPD, citylink and non UK DHL deliveries
		if (m_parcelforce == 1 || m_dpd == 1 || m_citylink==1 || (m_dhl == 1 && m_dhldocument==0 && m_country != "UNITED KINGDOM")) {
			if (m_dhl == 1) {
				if (m_dhlair == 1) {
					var dimweight = (m_parcellength * m_parcelwidth * m_parcelheight)/5000;
				} else {
					var dimweight = (m_parcellength * m_parcelwidth * m_parcelheight)/4000;
				}
			} else if (m_dpd==1) {
				var dimweight = (m_parcellength * m_parcelwidth * m_parcelheight)/4000;
			} else if (m_citylink==1) {
				var dimweight = (m_parcellength * m_parcelwidth * m_parcelheight)/6000;
			} else {
				var dimweight = (m_parcellength * m_parcelwidth * m_parcelheight)/5000;
			}

			var highweight = m_parcelweight;
			if (dimweight>highweight) {highweight = dimweight}
			if (highweight > m_productweight) {
				alert ("Dimensional weight of parcel has been calculated as " + highweight + " KG which is greater than the maximum of " + m_productweight +
				"KG permitted for this delivery. See the Frequently Asked Questions for a description of Dimensional Weight.");
				pccollection=document.getElementsByName("O_16");
				pccollection[0].focus();
				return false;
			}
		}

// validate volume for HDNL UK oversize delivery
		if (m_hdnloversize == 1) {
			var volume = ((m_parcellength/100) * (m_parcelwidth/100) * (m_parcelheight/100));
			if (volume > m_max_volume) {
				alert ("The volume of the parcel has been calculated as " + volume + " Metres cubed which is greater than the maximum of " + m_max_volume +
				" Metres cubed permitted for this delivery.");
				pccollection=document.getElementsByName("O_16");
				pccollection[0].focus();
				return false;
			}
		}
	
// validate parcel volume if it is a UK DHL item
		if (m_dhl == 1 && m_dhldocument==0 && m_country == "UNITED KINGDOM") {
			var volume = ((m_parcellength/100) * (m_parcelwidth/100) * (m_parcelheight/100));
			if (volume > m_max_volume) {
				alert ("The volume of the parcel has been calculated as " + volume + " Metres cubed which is greater than the maximum of " + m_max_volume +
				" Metres cubed permitted for this delivery.");
				pccollection=document.getElementsByName("O_16");
				pccollection[0].focus();
				return false;
			}
		}
	}

// Validate item description
	tempcollection=document.getElementsByName("O_19");
	if(!(validatedescription(tempcollection[0]))) {return false;}


// Validate item value
	if ((m_parcelforce==1 || m_hdnl==1 || m_dpd==1 || m_citylink==1) || (m_dhl==1 && m_dhldocument==0)) {
		tempcollection=document.getElementsByName("O_20");
		m_itemvalue = tempcollection[0].value;
		size=m_itemvalue.length;
		while (m_itemvalue.slice(0,1) == "0" || m_itemvalue.slice(0,1) == " ") // strip leading spaces and zeroes
			{m_itemvalue = m_itemvalue.substr(1,size-1);size = m_itemvalue.length}	
		while (m_itemvalue.slice(size-1,size)== " ") //Strip trailing spaces
			{m_itemvalue = m_itemvalue.substr(0,size-1);size = m_itemvalue.length}
		m_itemvalue=Number(m_itemvalue);
		if (isInteger(m_itemvalue)) {
		} else {
			alert ("The item value must be a whole number of £");
			tempcollection[0].focus();
			return false;
		}

		if (m_itemvalue < 1) {
			alert ("Item value must be at least £1");
			tempcollection[0].focus();
			return false;
		}
	}

// Validate reason for export
	tempcollection=document.getElementsByName("O_21");
	if (!(validatereasonforexport(tempcollection[0], m_country))) {return false;}

// Validate special instructions
	tempcollection=document.getElementsByName("O_22");
	if (!(validatespecialinstructions(tempcollection[0]))) {return false;}


// Validate collect date
	tempcollection=document.getElementsByName("O_23");
	m_collectdate=tempcollection[0].value
	if (isDate(m_collectdate)==false){
		tempcollection[0].focus();
		return false;
	}

	var m_currentclientmachinedate = new Date()
	var m_timetofilloutform = m_currentclientmachinedate.getTime() - m_baseclientmachinedate.getTime()
	var m_currenttime = new Date(phpscriptTime.getTime() + m_timetofilloutform)

	var todaytime = m_currenttime.getHours()
	var m_earliestcollect = new Date();

	if (m_dhl==1 || m_citylink==1 || m_parcelforce==1) {
		var processday = m_currenttime.getDay();	

		switch (processday) {
		case 1:
		case 2:
		case 3:
		case 4:						// drop through logic for Monday thru Thursday
			if (todaytime<10) {
				m_earliestcollect=new Date(m_currenttime.toString());
			} else {
				m_currenttime.setDate(m_currenttime.getDate()+1);
				m_earliestcollect = new Date(m_currenttime.toString());
			}
			break;
		case 5:
			if (todaytime<10) {
				m_earliestcollect=new Date(m_currenttime.toString());
			} else {
				m_currenttime.setDate(m_currenttime.getDate()+3);
				m_earliestcollect = new Date(m_currenttime.toString());
			}
			break;		
		case 6:
			m_currenttime.setDate(m_currenttime.getDate()+2);
			m_earliestcollect = new Date(m_currenttime.toString());
			break;
		default:
			m_currenttime.setDate(m_currenttime.getDate()+1);
			m_earliestcollect = new Date(m_currenttime.toString());
		}
	} else {
		if (todaytime > 16) {
			m_currenttime.setDate(m_currenttime.getDate()+1);
			m_earliestcollect = new Date(m_currenttime.toString());
		} else {
			m_earliestcollect=new Date(m_currenttime.toString());
		}

// now find the earliest collection day based on normal working days
		var processday = m_earliestcollect.getDay();  
		switch(processday) {
		case 1:
		case 2:
		case 3:
		case 4:
			m_earliestcollect.setDate(m_earliestcollect.getDate()+1);
			break;
		case 5:
			m_earliestcollect.setDate(m_earliestcollect.getDate()+3);
			break;
		case 6:
			m_earliestcollect.setDate(m_earliestcollect.getDate()+2);
			break;
		default:
			m_earliestcollect.setDate(m_earliestcollect.getDate()+1);
		}
	}

// m_collectdate is the collection date entered by the user 
// m_latestcollectdate (defined later) is the calculated latest collection date
	
// now extract out of the dates the dd,mm,yy and compare	
	var pos1=m_collectdate.indexOf("/")
	var pos2=m_collectdate.indexOf("/",pos1+1)
	var m_collectdd=m_collectdate.substring(0,pos1)
	var m_collectmm=m_collectdate.substring(pos1+1,pos2)
	var m_collectyy=m_collectdate.substring(pos2+1)
	var m_earliestdd=m_earliestcollect.getDate();
	var m_earliestmm=m_earliestcollect.getMonth()+1;
	var m_earliestyy=m_earliestcollect.getFullYear();

	if (Number(m_collectyy)<Number(m_earliestyy) ||
		(Number(m_collectyy)==Number(m_earliestyy) && Number(m_collectmm)<Number(m_earliestmm)) ||
		(Number(m_collectyy)==Number(m_earliestyy) && Number(m_collectmm)==Number(m_earliestmm) && Number(m_collectdd)<Number(m_earliestdd))) {
		alert ("The collection date you have requested is earlier than the earliest possible collection date of " + m_earliestdd + "/" +
				m_earliestmm + "/" + m_earliestyy + "\n\nDHL, City Link and Parcelforce orders for same day collection must be placed by 10am. " + 
				"Next day collection from other couriers must be placed by 5PM");
		tempcollection[0].focus();
		return false;
	}

// The entered collection date must be a day that we will collect and be 
// within 5 working days of the earliest collect date. Take the earliest collect date, 
// add 5 working days to it and then check that this date is later than the entered date
	
	var m_latestcollectdate = new Date()
	m_latestcollectdate.setFullYear(m_earliestyy, m_earliestmm-1, m_earliestdd)

	var m_collectdatedateformat = new Date()
	m_collectdatedateformat.setFullYear(m_collectyy, m_collectmm-1, m_collectdd)

// Check that the collection date isn't a Saturday or a Sunday
	if (m_collectdatedateformat.getDay()==6 || m_collectdatedateformat.getDay()==0) { // Saturday or Sunday??
		alert ("Sorry but we are not able to arrange a collection for a Saturday or Sunday, please select an alternative date")
		tempcollection[0].focus();
		return false;			
	}	

// the collection day must be a Friday if a saturday delivery has been requested
	if (m_citylink==1 && m_satdel==1) {
		if (m_collectdatedateformat.getDay()!=5) {
			alert ("Your collection day must be a Friday if you want a delivery on Saturday. Please change your collection date or remove the saturday delivery option");
			tempcollection[0].focus();
			return false;
		}
	}

// check whether the collection date is one of our bank holidays
	m_tempdate = m_collectdatedateformat.getDate();
	m_tempmonth = m_collectdatedateformat.getMonth();
	m_tempfullyear = m_collectdatedateformat.getFullYear();
	sw_found = false
	for (i=0; i<=bankhollimit; i++) {
		if (m_tempdate==bankhols[i].getDate() && m_tempmonth==bankhols[i].getMonth() && m_tempfullyear==bankhols[i].getFullYear()) {
			sw_found=true;
			break;  
		}
	}
	if (sw_found==true) {
		alert ("Sorry the collection date selected is not available, please select an alternative date");
		tempcollection[0].focus();
		return false;			
	}	

//check whether the collection date is specifically excluded for the courier
	for (i=0; i<=courierexclusionlimit ; i++) {		
		if ((m_dhl==1 && courierexclusions[i]=="DHL") ||
  			(m_parcelforce==1 && courierexclusions[i]=="PARCELFORCE") ||
			(m_hdnl==1 && courierexclusions[i]=="HDNL") ||
			(m_dpd==1 && courierexclusions[i]=="DPD")) {
			if (m_tempdate==courierexclusiondates[i].getDate() && m_tempmonth==courierexclusiondates[i].getMonth() && m_tempfullyear==courierexclusiondates[i].getFullYear()) {
				sw_found=true;
				break;  
			}
		}
	}
	if (sw_found==true) {
		alert ("Sorry the collection date selected is not available, please select an alternative date");
		tempcollection[0].focus();
		return false;			
	}	

// now check that the requested collection date is within 5 working days of the earliest collection date
	for (k=1; k<6; k++) {
		m_latestcollectdate.setDate(m_latestcollectdate.getDate()+1); // increment date
		for (j=0;j<50;j++) { 	// 50 is just arbitary number to make sure that we go around the loop enough times
			sw_found=false;
			if (m_latestcollectdate.getDay()==6 || m_latestcollectdate.getDay()==0) { // Saturday or Sunday??
				sw_found=true
			}

			m_tempdate = m_latestcollectdate.getDate();
			m_tempmonth = m_latestcollectdate.getMonth();
			m_tempfullyear = m_latestcollectdate.getFullYear();
			for (i=0; i<=bankhollimit; i++) {
				if (m_tempdate==bankhols[i].getDate() && m_tempmonth==bankhols[i].getMonth() && m_tempfullyear==bankhols[i].getFullYear()) {
					sw_found=true;
					break;  
				}
			}

			if (sw_found==true) {
				m_latestcollectdate.setDate(m_latestcollectdate.getDate()+1)
			} else {
				break;
			}   
		}
	}

	var m_latestdd=m_latestcollectdate.getDate()
	var m_latestmm=m_latestcollectdate.getMonth()+1
	var m_latestyy=m_latestcollectdate.getFullYear()

	if (Number(m_collectyy)>Number(m_latestyy) ||
		(Number(m_collectyy)==Number(m_latestyy) && Number(m_collectmm)>Number(m_latestmm)) ||
		(Number(m_collectyy)==Number(m_latestyy) && Number(m_collectmm)==Number(m_latestmm) && Number(m_collectdd)>Number(m_latestdd))) {
		alert ("The collection date you have requested is later than the latest possible collection date of " + m_latestdd+"/"+m_latestmm+"/"+m_latestyy);
		tempcollection[0].focus();
		return false;
	}

// Check for DHL remote areas, see previous comment re why portugal is excluded
	if (m_dhl == 1) {
		if (countryHasRemoteAreas(m_country)==true) {
			// get the iFrame to pick up the remote area details
			var oIframe = document.getElementById("RSIFrame");
			var oDoc = oIframe.contentWindow || oIframe.contentDocument;
			if (oDoc.document) {
			       	oDoc = oDoc.document;
			}
			var dataEl = oDoc.getElementById("ZIPS")
			var zipsColl = dataEl.childNodes
			var numZips = zipsColl.length

			// iterate through the collection of zip Names and see if we have the one we are after
			var remotefound = 0;

			switch (m_country) 
			{
			case "IRELAND, REPUBLIC OF":			
  // get the delivery address line 2 and the town to compare against the village returned from the validation file
  				for (var q=0; q<numZips; q++) {
					if (zipsColl[q].nodeType!=1) continue; // it's not an element node, let's skedaddle
					if (m_delivtown.indexOf(zipsColl[q].id) > -1 || m_delivaddr2.indexOf(zipsColl[q].id) > -1) {
						m_temp = m_delivtown.indexOf(zipsColl[q].id);
						if (m_temp > -1) {
							if (m_temp==0) {	// start of string
								if (m_delivtown.length == zipsColl[q].id.length) {
									remotefound = 1;
								} else {
                                    					if (m_delivtown.charAt(zipsColl[q].id.length) == " " || m_delivtown.charAt(zipsColl[q].id.length) == ",") {
                                      						remotefound = 1;
									}
								}
							} else {		// match found but not start of string
								if (m_temp + zipsColl[q].id.length >= m_delivtown.length) {	// end of string
                                    					if (m_delivtown.charAt(m_temp-1) == " " || m_delivtown.charAt(m_temp - 1) == ",") {
                                        					remotefound = 1;
                                    					}
								} else { 	// middle of string
									if ((m_delivtown.charAt(m_temp-1) == " " || m_delivtown.charAt(m_temp-1) == ",") && (m_delivtown.charAt(zipsColl[q].id.length+m_temp) == " " || m_delivtown.charAt(zipsColl[q].id.length+m_temp)==",")) {
                                        					remotefound = 1;
                                    					}
								}
							}
						}

						m_temp = m_delivaddr2.indexOf(zipsColl[q].id);
						if (m_temp > -1) {
							if (m_temp==0) {	// start of string
								if (m_delivaddr2.length == zipsColl[q].id.length) {
									remotefound = 1;
								} else {	// match not at start of address line
									if (zipsColl[q].id.toUpperCase() == "STREET" && m_delivaddr2.toUpperCase() != "STREET") {
									} else {
			                                  			if (m_delivaddr2.charAt(zipsColl[q].id.length) == " " || m_delivaddr2.charAt(zipsColl[q].id.length) == ",") {
			                                      				remotefound = 1;
										}
									}
								}
							} else { 	// match found but not at start of string
								if (zipsColl[q].id.toUpperCase() == "STREET" && m_delivaddr2.toUpperCase() != "STREET") {
								} else {
									if (m_temp + zipsColl[q].id.length >= m_delivaddr2.length) {
			                                  			if (m_delivaddr2.charAt(m_temp-1) == " " || m_delivaddr2.charAt(m_temp-1) == ",") {
											remotefound = 1;
			                                    			}
									} else { // middle of string
										if ((m_delivaddr2.charAt(m_temp-1) == " " || m_delivaddr2.charAt(m_temp-1) == ",") && (m_delivaddr2.charAt(zipsColl[q].id.length+m_temp) == " " || m_delivtown.charAt(zipsColl[q].id.length+m_temp)==",")) {
				                                      			remotefound = 1;
			                                   			}
									}
								}
							}
						}
					}
				}
				break;

			  case "CANADA":
				m_temp = m_deliverypc.substring(0,3) + m_deliverypc.substring(4);
			  	for (var q=0; q<numZips; q++) {
					if (zipsColl[q].nodeType!=1) continue; // it's not an element node, let's skedaddle
					if (zipsColl[q].id == m_temp) {
						remotefound = 1;
					}
			  	}
				break;

			  case "CROATIA":
				m_temp = m_deliverypc.substring(3)
			  	for (var q=0; q<numZips; q++) {
					if (zipsColl[q].nodeType!=1) continue; // it's not an element node, let's skedaddle
					if (zipsColl[q].id == m_temp) {
						remotefound = 1;
					}
			  	}
				break;

			  case "JAPAN":
				m_temp = m_deliverypc.substring(0,3) + m_deliverypc.substring(4);
			  	for (var q=0; q<numZips; q++) {
					if (zipsColl[q].nodeType!=1) continue; // it's not an element node, let's skedaddle
					if (zipsColl[q].id.indexOf("-") == -1) {
						if (zipsColl[q].id == m_temp) {
							remotefound = 1;
						}
					} else {
						m_startofrange = zipsColl[q].id.substring(0,zipsColl[q].id.indexOf("-"))
						m_endofrange = zipsColl[q].id.substring(zipsColl[q].id.indexOf("-")+1)
						if (m_temp>=m_startofrange && m_temp<=m_endofrange) {
							remotefound = 1;
						}
					}
			  	}
				break;

			  case "KOREA":
				m_temp = m_deliverypc.substring(0,3) + m_deliverypc.substring(4);
			  	for (var q=0; q<numZips; q++) {
					if (zipsColl[q].nodeType!=1) continue; // it's not an element node, let's skedaddle
					if (zipsColl[q].id.indexOf("-") == -1) {
						if (zipsColl[q].id == m_temp) {
							remotefound = 1;
						}
					} else {
						m_startofrange = zipsColl[q].id.substring(0,zipsColl[q].id.indexOf("-"))
						m_endofrange = zipsColl[q].id.substring(zipsColl[q].id.indexOf("-")+1)
						if (m_temp>=m_startofrange && m_temp<=m_endofrange) {
							remotefound = 1;
						}
					}
			  	}
				break;

			  case "ARGENTINA":
				m_temp = m_deliverypc.substring(1,5)
			  	for (var q=0; q<numZips; q++) {
					if (zipsColl[q].nodeType!=1) continue; // it's not an element node, let's skedaddle
					if (zipsColl[q].id.indexOf("-") == -1) {
						if (zipsColl[q].id == m_temp) {
							remotefound = 1;
						}
					} else {
						m_startofrange = zipsColl[q].id.substring(0,zipsColl[q].id.indexOf("-"))
						m_endofrange = zipsColl[q].id.substring(zipsColl[q].id.indexOf("-")+1)
						if (m_temp>=m_startofrange && m_temp<=m_endofrange) {
							remotefound = 1;
						}
					}
			  	}
				break;

			  default:
			  	for (var q=0; q<numZips; q++) {
					if (zipsColl[q].nodeType!=1) continue; // it's not an element node, let's skedaddle
					if (zipsColl[q].id.indexOf("-") == -1) {
						if (zipsColl[q].id == m_deliverypc) {
							remotefound = 1;
						}
					} else {
						m_startofrange = zipsColl[q].id.substring(0,zipsColl[q].id.indexOf("-"))
						m_endofrange = zipsColl[q].id.substring(zipsColl[q].id.indexOf("-")+1)
						if (m_deliverypc>=m_startofrange && m_deliverypc<=m_endofrange) {
							remotefound = 1;
						}
					}
			  	}
				break;
			  }

			if (remotefound==1 && m_acceptremotecharge==1) {
				alert ("DHL advise that the destination address that you have specified is in a DHL remote area. You have chosen to accept the DHL surcharge so this will be added to your bill.");
			}
			
			if (remotefound==1 && m_acceptremotecharge==0) {
				alert ("DHL advise that the destination address that you have specified is in a DHL remote area but you have chosen NOT to accept the DHL surcharge. Please either accept the surcharge in the delivery options or chose a Parcelforce delivery.");
				pccollection=document.getElementsByName("v_"+p_prodref+"_2");
				pccollection[0].focus();
				return false;
			}	

			if (remotefound==0 && m_acceptremotecharge==1) {
				document.getElementsByName("v_"+p_prodref+"_2")[0].value=true;
				document.getElementsByName("v_"+p_prodref+"_2")[1].value=false;
			}	

		}	
	}

// validate citylink surcharge areas
	if (m_citylink==1) {
		var m_londonsurchargeapplies = 0;
		var m_IOWsurchargeapplies = 0;
		var m_outbound = m_collectpc.substring(0,2);
		var m_zone = m_collectpc.substring(2,4);
		if (m_outbound=="PO" && Number(m_zone)>=30 && Number(m_zone)<=41) {
			m_IOWsurchargeapplies=1;
		}

		m_outbound = m_collectpc.substring(0,3);
		if (m_outbound=="E1 " || m_outbound=="W1 ") {
			m_londonsurchargeapplies=1;
		}

		m_outbound = m_collectpc.substring(0,4);
		if (m_outbound=="EC1 "||m_outbound=="EC2 "||m_outbound=="EC3 "||m_outbound=="EC4 "||m_outbound=="EC5 "||m_outbound=="SE1 "||m_outbound=="SE11"||m_outbound=="WC1 "||m_outbound=="WC2 "||m_outbound=="SW1 "||m_outbound=="NW1 ") {
			m_londonsurchargeapplies=1;
		}

		var m_outbound = m_deliverypc.substring(0,2);
		var m_zone = m_deliverypc.substring(2,4);
		if (m_outbound=="PO" && Number(m_zone)>=30 && Number(m_zone)<=41) {
			m_IOWsurchargeapplies=1;
		}

		m_outbound = m_deliverypc.substring(0,3);
		if (m_outbound=="E1 "|| m_outbound=="W1 ") {
			m_londonsurchargeapplies=1;
		}

		m_outbound = m_deliverypc.substring(0,4);
		if (m_outbound=="EC1 "||m_outbound=="EC2 "||m_outbound=="EC3 "||m_outbound=="EC4 "||m_outbound=="EC5 "||m_outbound=="SE1 "||m_outbound=="SE11"||m_outbound=="WC1 "||m_outbound=="WC2 "||m_outbound=="SW1 "||m_outbound=="NW1 ") {
			m_londonsurchargeapplies=1;
		}

		if (m_londonsurchargeapplies==0 && m_IOWsurchargeapplies==0) {
			document.getElementsByName("v_"+p_prodref+"_3")[0].value=true;
			document.getElementsByName("v_"+p_prodref+"_3")[1].value=false;
			document.getElementsByName("v_"+p_prodref+"_3")[2].value=false;
		} else if (m_londonsurchargeapplies==1 && m_IOWsurchargeapplies==0) {
			if (m_acceptlondonsurcharge==0) {
				alert ("Citylink advise that a London congestion surcharge applies to this delivery but you have chosen NOT to accept the surcharge. Please either accept the surcharge in the delivery options or chose a Parcelforce delivery.");
				pccollection=document.getElementsByName("v_"+p_prodref+"_3");
				pccollection[0].focus();
				return false;
			} else {
				alert ("Citylink advise that a London congestion surcharge applies to this delivery. You have chosen to accept the surcharge so this will be added to your bill.");
			}
		} else if (m_londonsurchargeapplies==0 && m_IOWsurchargeapplies==1) {
			if (m_acceptIOWsurcharge==0) {
				alert ("Citylink advise that an Isle of Wight surcharge applies to this delivery but you have chosen NOT to accept the surcharge. Please either accept the surcharge in the delivery options or chose a Parcelforce delivery.");
				pccollection=document.getElementsByName("v_"+p_prodref+"_3");
				pccollection[0].focus();
				return false;
			} else {
				alert ("Citylink advise that an Isle of Wight surcharge applies to this delivery. You have chosen to accept the surcharge so this will be added to your bill.");
			}
		} else {
			if (m_acceptIOWsurcharge==0) {
				alert ("Citylink advise that an Isle of Wight surcharge applies to this delivery but you have chosen NOT to accept the surcharge. Please either accept the surcharge in the delivery options or chose a Parcelforce delivery.");
				pccollection=document.getElementsByName("v_"+p_prodref+"_3");
				pccollection[0].focus();
				return false;
			} else {
				alert ("Citylink advise that an Isle of Wight surcharge applies to this delivery. You have chosen to accept the surcharge so this will be added to your bill.");
			}
		}
	}


// see if the delivery post code is the same as the collection post code and error if so
	if (m_collectpc == m_deliverypc) {
		alert ("Collection and Delivery post codes cannot be the same");
		return false;
	}

// Validate quantity against enhanced comp
	tempcollection=document.getElementsByName("Q_" + p_prodref);
	m_quantity=tempcollection[0].value;


	if (m_enhanced == 1 && m_quantity > 1) {
		alert("Sorry, you cannot choose enhanced compensation with more than 1 parcel in the consignment. To opt for enhanced compensation please " + 
			"set the number of parcels in the consignment to 1 and then place orders separately for the additional parcels");
		tempcollection[0].focus();
		return false;
	}

	if (m_hdnl==1 && m_quantity > 20) {
		alert("The maximum number of parcels in a consignment with Home Delivery Network is 20. You will need to place multiple orders if you " + 
			"have more than 20 parcels to deliver");
		tempcollection[0].focus();
		return false;
	}

// validate specified delivery times if citylink and delivery restriction has been requested
	if (m_prenoon == 1) {
		if (!(validateprenoon(m_deliverypc))) {
			alert ("Sorry, Option to deliver before noon is not available for this delivery Post Code, Please choose the standard next day delivery option");
			return false;
		}
	}
	if (m_pre1030 == 1) {
		if (!(validateprenoon(m_deliverypc))) {
			alert ("Sorry, Option to deliver before 10.30am is not available for this delivery Post Code, Please choose the standard next day delivery option");
			return false;
		}
		if (!(validatepre1030(m_deliverypc))) {
			alert ("Sorry, Option to deliver before 10.30am is not available for this delivery Post Code, Please choose an alternative delivery option");
			return false;
		}

	}
	if (m_pre9 == 1) {
		if (!(validateprenoon(m_deliverypc))) {
			alert ("Sorry, Option to deliver before 9am is not available for this delivery Post Code, Please choose the standard next day delivery option");
			return false;
		}
		if (!(validatepre1030(m_deliverypc))) {
			alert ("Sorry, Option to deliver before 9am is not available for this delivery Post Code, Please choose an alternative delivery option");
			return false;
		}
		if (!(validatepre9(m_deliverypc))) {
			alert ("Sorry, Option to deliver before 9am is not available for this delivery Post Code, Please choose an alternative delivery option");
			return false;
		}
	}


// all ok - so now create cookie for collection details
	tempcollection=document.getElementsByName("O_1");
	temp=tempcollection[0].value + "#";
	tempcollection=document.getElementsByName("O_2");
	temp= temp + tempcollection[0].value + "#";
	tempcollection=document.getElementsByName("O_3");
	temp= temp + tempcollection[0].value + "#";
	tempcollection=document.getElementsByName("O_4");
	temp= temp + tempcollection[0].value + "#";
	tempcollection=document.getElementsByName("O_5");
	temp= temp + tempcollection[0].value + "#";
	tempcollection=document.getElementsByName("O_6");
	temp= temp + tempcollection[0].value + "#";
	tempcollection=document.getElementsByName("O_7");
	temp= temp + tempcollection[0].value;
	createCookie("p2scollection",temp,90);

	return true;
}

// **************************************************************************
// Function to validate checkout page 1
// **************************************************************************
function invoicecheck() {
	pccollection=document.getElementsByName("INVOICEFIRSTNAME");
	if (!(validatename(pccollection[0]))) { return false; }	

	pccollection=document.getElementsByName("INVOICELASTNAME");
	if (!(validatename(pccollection[0]))) { return false; }	

	var pccollection=document.getElementsByName("INVOICEPOSTALCODE");
	if (!(validateukpostcodeformat(pccollection[0]))) {return false;}

	pccollection=document.getElementsByName("INVOICEADDRESS1");
	if (!(validateaddrline(pccollection[0],1))) { return false; }

	pccollection=document.getElementsByName("INVOICEADDRESS2");
	if (!(validateaddrline(pccollection[0],2))) { return false; }

	pccollection=document.getElementsByName("INVOICEADDRESS3");
	if (!(validateaddrline(pccollection[0],3))) { return false; }

	pccollection=document.getElementsByName("INVOICEPHONE");
	if (!(validatephone(pccollection[0],"M"))) { return false; }

	var pccollection=document.getElementsByName("INVOICEEMAIL");
	if (!(validateemail(pccollection[0],"M"))) { return false; }
	m_em1=pccollection[0].value.toUpperCase();

//	var pccollection=document.getElementsByName("INVOICEEMAILCONFIRM");
//	if (!(validateemail(pccollection[0], "M"))) { return false; }
//	m_em2=pccollection[0].value.toUpperCase();

// check that the e-mail adress has been entered twice correctly
//	if (m_em1 != m_em2) {
//	  var pccollection=document.getElementsByName("INVOICEEMAIL");
//	  alert("Email addresses must be identical");
//	  pccollection[0].focus();
//	  return false;
//	}

//	var countrycollection=document.getElementsByName("SEPARATESHIP");
//	countrycollection[0].checked = false;

// all ok - so now create cookie for collection details
	tempcollection=document.getElementsByName("INVOICEPOSTALCODE");
	temp=tempcollection[0].value + "#";
	tempcollection=document.getElementsByName("INVOICEFIRSTNAME");
	temp= temp + tempcollection[0].value + "#";
	tempcollection=document.getElementsByName("INVOICELASTNAME");
	temp= temp + tempcollection[0].value + "#";
	tempcollection=document.getElementsByName("INVOICEADDRESS1");
	temp= temp + tempcollection[0].value + "#";
	tempcollection=document.getElementsByName("INVOICEADDRESS2");
	temp= temp + tempcollection[0].value + "#";
	tempcollection=document.getElementsByName("INVOICEADDRESS3");
	temp= temp + tempcollection[0].value + "#";
//	tempcollection=document.getElementsByName("LOCATIONINVOICECOUNTRY");
//	temp= temp + tempcollection[0].value + "#";
	tempcollection=document.getElementsByName("INVOICEPHONE");
	temp= temp + tempcollection[0].value + "#";
	tempcollection=document.getElementsByName("INVOICEEMAIL");
	temp= temp + tempcollection[0].value;
	createCookie("p2sinvoice",temp,90);
	return true;
}

// *********************************************************************************************************************
function isDate(dtStr){
// Declaring valid date character, minimum year and maximum year
	var d = new Date();
	var minYear=d.getFullYear();
	var maxYear=minYear+1;
//	var daysInMonth = DaysArray(12)
	var daysInMonth = new Array(12);
	daysInMonth[1] = 31
	daysInMonth[2] = 29
	daysInMonth[3] = 31
	daysInMonth[4] = 30
	daysInMonth[5] = 31
	daysInMonth[6] = 30
	daysInMonth[7] = 31
	daysInMonth[8] = 31
	daysInMonth[9] = 30
	daysInMonth[10] = 31
	daysInMonth[11] = 30
	daysInMonth[11] = 31


	var pos1=dtStr.indexOf("/")
	var pos2=dtStr.indexOf("/",pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("Collection Date must be in the format: dd/mm/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("The month specified in the Collection date is invalid, must be 01-12")
		return false
	}

	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("The day specified in the collection day is invalid")
		return false
	}


	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}


	if (dtStr.indexOf("/",pos2+1)!=-1 || isInteger1(stripCharsInBag(dtStr, "/"))==false){
		alert("Please enter a valid date")
		return false
	}


	return true
}

function stripCharsInBag(s, bag){
	var i;
	var returnString = "";
// Search through string's characters one by one.
// If character is not in bag, append to returnString.
	for (i = 0; i < s.length; i++){   
	var c = s.charAt(i);
	if (bag.indexOf(c) == -1) returnString += c;
}
	return returnString;
}

function daysInFebruary (year){
// February has 29 days in any year evenly divisible by four,
// EXCEPT for centurial years which are not also divisible by 400.
	return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
	} 
	return this
}

function createAffiliateCookie(p_href) {
	if (p_href.indexOf("?affiliatenetwork=por")>-1) {
		createCookie("p2saffiliate","por",90);
	}
	
	if (p_href.indexOf("?affiliatenetwork=AF")>-1) {
		createCookie("p2saffiliate","AF",90);
	}
	
	if (p_href.indexOf("?affiliatenetwork=clix")>-1) {
		createCookie("p2saffiliate","clix",90);
	}
	return null
}

// ***************************************************
// *
// * Pick up a cookie of a given name if it exists
// *
// ***************************************************
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;
}

// ***************************************************
// *
// * Create a cookie of a given name
// *
// ***************************************************
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 var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

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)$/i;

/* 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. */

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) {
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
return false;
   }
}

// See if "user" is valid 
if (user.match(userPat)==null) {

// user is not 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) {
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) {
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) {
return false;
}

// Make sure there's a host name preceding the domain.
if (len<2) {
return false;
}

// If we've gotten this far, everything's valid!
return true;
}

// ***************************************************
// *
// * validate customer name
// *
// ***************************************************

function validatename(p_object) {
//	test = p_object.value.replace(/'/g,' ');
	test = p_object.value
	size = test.length;
	while (test.slice(0,1) == " ") {
		test = test.substr(1,size-1);size = test.length
	}
	while(test.slice(size-1,size)== " ") { //Strip trailing spaces
		test = test.substr(0,size-1);size = test.length
	}
	p_object.value = test; //write back to form field
	if (test.length==0 || test.length > 30) {
		alert("Name must be entered and be a maximum of 30 characters");
		p_object.focus();
		return false;
	}

	bolValid = true; 
	for (var iLoop=0; iLoop < size; iLoop++)
	{ 
		strCurrentChar = test.substring(iLoop,iLoop+1); 
		if ((strCurrentChar >= 'A' && strCurrentChar <= 'Z') || (strCurrentChar >= 'a' && strCurrentChar <= 'z') || 
			(strCurrentChar >= '0' && strCurrentChar <= '9') || strCurrentChar == '-' ||
			 strCurrentChar == ' ' || strCurrentChar == '.' || strCurrentChar == '/') {
		}
		else {
			bolValid = false; 
		}
	} 

	if(!bolValid) {
		alert("Name contains invalid character. Valid characters are A-Z, 0-9, hyphen, space, period and forward slash");
		p_object.focus();
		return false;
	}

	return true
}

// ***************************************************
// *
// * validate address line
// *
// ***************************************************
function validateaddrline(p_object,p_line) {
//	test=p_object.value.replace(/["',]/g,' ');
	test = p_object.value
	size = test.length
	while (test.slice(0,1) == " ") {
		test = test.substr(1,size-1);size = test.length
	}
	while(test.slice(size-1,size)== " ") { //Strip trailing spaces
		test = test.substr(0,size-1);size = test.length
	}
	p_object.value = test; //write back to form field
	if (p_line == 2) {
		if (test.length > 35) {
			alert("Address line must be a maximum of 35 characters");
			p_object.focus();
			return false;
		}
	} else {
		if (test.length == 0 || test.length > 35) {
			alert("Address line must be entered and be a maximum of 35 characters");
			p_object.focus();
			return false;
		}
	}

	bolValid = true; 
	for (var iLoop=0; iLoop < size; iLoop++)
	{ 
		strCurrentChar = test.substring(iLoop,iLoop+1); 
		if ((strCurrentChar >= 'A' && strCurrentChar <= 'Z') || (strCurrentChar >= 'a' && strCurrentChar <= 'z') || 
			(strCurrentChar >= '0' && strCurrentChar <= '9') || strCurrentChar == '-' ||
			 strCurrentChar == ' ' || strCurrentChar == '.' || strCurrentChar == '/') {
		}
		else {
			bolValid = false; 
		}
	} 

	if(!bolValid) {
		alert("Address line contains invalid character. Valid characters are A-Z, 0-9, hyphen, space, period and forward slash");
		p_object.focus();
		return false;
	}

	return true;
}

// ***************************************************
// *
// * validate item description
// *
// ***************************************************
function validatedescription(p_object) {
	test=p_object.value
	size = test.length
	while (test.slice(0,1) == " ") {
		test = test.substr(1,size-1);size = test.length
	}
	while(test.slice(size-1,size)== " ") { //Strip trailing spaces
		test = test.substr(0,size-1);size = test.length
	}
	p_object.value = test; //write back to form field
	if (test.length == 0 || test.length > 50) {
		alert("Item description must be entered and be a maximum of 50 characters");
		p_object.focus();
		return false;
	}

	bolValid = true; 
	for (var iLoop=0; iLoop < size; iLoop++)
	{ 
		strCurrentChar = test.substring(iLoop,iLoop+1); 
		if ((strCurrentChar >= 'A' && strCurrentChar <= 'Z') || (strCurrentChar >= 'a' && strCurrentChar <= 'z') || 
			(strCurrentChar >= '0' && strCurrentChar <= '9') || strCurrentChar == '-' ||
			 strCurrentChar == ' ' || strCurrentChar == '.' || strCurrentChar == '/') {
		}
		else {
			bolValid = false; 
		}
	} 

	if(!bolValid) {
		alert("Item description contains invalid character. Valid characters are A-Z, 0-9, hyphen, space, period and forward slash");
		p_object.focus();
		return false;
	}

	return true;
}

// ***************************************************
// *
// * validate format of UK post code
// *
// ***************************************************
function validateukpostcodeformat(p_object) {
	test=p_object.value
	test = test.toUpperCase(); //Change to uppercase
	size=test.length;
	while (test.slice(0,1) == " ")
		  {test = test.substr(1,size-1);size = test.length
	}
	while(test.slice(size-1,size)== " ") //Strip trailing spaces
	      {test = test.substr(0,size-1);size = test.length
	}
	p_object.value = test; //write back to form field

	if (size < 6 || size > 8){ //Code length rule
	   alert("Postcode is not valid - wrong length");
	   p_object.focus();
	   return false;
	}

	if (!(isNaN(test.charAt(0)))){ //leftmost character must be alpha character rule
	   alert("Postcode is not valid - cannot start with a number");
	   p_object.focus();
	   return false;
	}

	if (isNaN(test.charAt(size-3))){ //first character of inward code must be numeric rule
	   alert("Postcode is not valid - alpha character in wrong position");
	   p_object.focus();
	   return false;
	}

	if (!(isNaN(test.charAt(size-2)))){ //second character of inward code must be alpha rule
	   alert("Postcode is not valid - number in wrong position");
	   p_object.focus();
	   return false;
	}

	if (!(isNaN(test.charAt(size-1)))){ //third character of inward code must be alpha rule
	   alert("Postcode is not valid - number in wrong position");
	   p_object.focus();
	   return false;
	}

	if (!(test.charAt(size-4) == " ")){//space in position length-3 rule
	   alert("Postcode is not valid - no space or space in wrong position");
	   p_object.focus();
	   return false;
	}

	count1 = test.indexOf(" ");count2 = test.lastIndexOf(" ");
	if (count1 != count2){//only one space rule
		alert("Postcode is not valid - only one space allowed");
		p_object.focus();
		return false;
	}

	bolValid = true; 
	for (var iLoop=0; iLoop < size; iLoop++)
	{ 
		strCurrentChar = test.substring(iLoop,iLoop+1); 
		if ((strCurrentChar >= 'A' && strCurrentChar <= 'Z') || (strCurrentChar >= 'a' && strCurrentChar <= 'z') || 
			(strCurrentChar >= '0' && strCurrentChar <= '9') || strCurrentChar == ' ') {
		}
		else {
			bolValid = false; 
		}
	} 

	if(!bolValid) {
		alert("Post code contains invalid character");
		p_object.focus();
		return false;
	}

	return true;
}

// ***************************************************
// *
// * validate format of BFPO post code
// *
// ***************************************************
function validateBFPOpostcodeformat(p_object) {
	test=p_object.value
	test = test.toUpperCase(); //Change to uppercase
	size=test.length;
	while (test.slice(0,1) == " ")
		  {test = test.substr(1,size-1);size = test.length
	}
	while(test.slice(size-1,size)== " ") //Strip trailing spaces
	      {test = test.substr(0,size-1);size = test.length
	}
	p_object.value = test; //write back to form field

	if (p_object.value.match(/^(BFPO) \d{2,4}$/)) {
	} else {
		alert ("Post code must be of the format BFPO #### where # equals any numeric digit (0-9)");
		p_object.focus();
		return false;			
	}


	return true;
}
// ***************************************************
// *
// * validate email address
// *
// ***************************************************
function validateemail (p_email, p_mode) {
m_email=p_email.value
size = m_email.length;
while (m_email.slice(0,1) == " ")
	  {m_email = m_email.substr(1,size-1);size = m_email.length
}
while(m_email.slice(size-1,size)== " ") //Strip trailing spaces
	  {m_email = m_email.substr(0,size-1);size = m_email.length
}
p_email.value = m_email; //write back to form field

if (p_mode == "O") {
	if (m_email.length > 50) {
		alert("Email address must be a maximum of 50 characters");
		p_email.focus();
		return false;
	}

	if (m_email.length >0) {
		if (!(emailCheck(m_email))) {  
			alert("Email address format is invalid");
			p_email.focus();
			return false
		}
	}
} else {
	if (m_email.length==0 || m_email.length > 50) {
		alert("Email address must be entered and must be a maximum of 50 characters");
		p_email.focus();
		return false;
	}

	if (!(emailCheck(m_email))) {  
		alert("Email address format is invalid");
		p_email.focus();
		return false
	}
}

if (m_email.indexOf('"') >= 0 || m_email.indexOf(' ') >= 0) {
	alert("Invalid character in email address");
	p_email.focus();
	return false;
}

// If we've gotten this far, everything's valid!
return true;
}


// ***************************************************
// *
// * validate phone number
// *
// ***************************************************
function validatephone (p_object, p_mode) {
test=p_object.value
size = test.length;
while (test.slice(0,1) == " ") {
	test = test.substr(1,size-1);size = test.length
}
while(test.slice(size-1,size)== " ") { //Strip trailing spaces
	test = test.substr(0,size-1);size = test.length
}
p_object.value = test; //write back to form field

if (p_mode == "O") {
	if (test.length > 15) {
	   alert("Phone number must be a maximum of 15 characters");
	   p_object.focus();
	   return false;
	}
} else {
	if (test.length == 0 || test.length > 15) {
	   alert("Phone number must be entered and be a maximum of 15 characters");
	   p_object.focus();
	   return false;
	}
}

bolValid = true; 
for (var iLoop=0; iLoop < size; iLoop++)
{ 
	strCurrentChar = test.substring(iLoop,iLoop+1); 
	if ((strCurrentChar >= '0' && strCurrentChar <= '9') || strCurrentChar == ' ' || strCurrentChar == '(' ||
		strCurrentChar == ')' || strCurrentChar == '+') {
	}
	else {
		bolValid = false; 
	}
} 

if(!bolValid) {
	alert("Phone number contains invalid character. Valid characters are 0-9, space, open bracket, close bracket and plus sign");
	p_object.focus();
	return false;
}

return true;
}


// ***************************************************
// *
// * validate reason for export
// *
// ***************************************************
function validatereasonforexport(p_object, p_country) {
test=p_object.value
size = test.length
while (test.slice(0,1) == " ") {
	test = test.substr(1,size-1);size = test.length
}
while(test.slice(size-1,size)== " ") { //Strip trailing spaces
	test = test.substr(0,size-1);size = test.length
}
p_object.value = test; //write back to form field
if (p_country=="UNITED KINGDOM") {
	if (!(test=="Not required for UK delivery" || test.length==0)) {
	   alert ("Reason for export should not be supplied for a UK delivery");
	   p_object.focus();
	   return false;
	}
} else {
	if (test.length<1) {
	   alert ("Reason for export required");
	   p_object.focus();
	   return false;
	}	
	if (test.length>50) {
	   alert ("Reason for export too long, maximum 50 characters allowed");
	   p_object.focus();
	   return false;
	}	   
}

bolValid = true; 
for (var iLoop=0; iLoop < size; iLoop++)
{ 
	strCurrentChar = test.substring(iLoop,iLoop+1); 
	if ((strCurrentChar >= 'A' && strCurrentChar <= 'Z') || (strCurrentChar >= 'a' && strCurrentChar <= 'z') || 
		(strCurrentChar >= '0' && strCurrentChar <= '9') || strCurrentChar == '-' ||
		 strCurrentChar == ' ' || strCurrentChar == '.' || strCurrentChar == '/') {
	}
	else {
		bolValid = false; 
	}
} 

if(!bolValid) {
	alert("Reason for export contains invalid character. Valid characters are A-Z, 0-9, hyphen, space, period and forward slash");
	p_object.focus();
	return false;
}

return true;

}

// ***************************************************
// *
// * validate special instructions
// *
// ***************************************************
function validatespecialinstructions(p_object) {
	test=p_object.value
	size = test.length
	while (test.slice(0,1) == " ") {
		test = test.substr(1,size-1);size = test.length
	}
	while(test.slice(size-1,size)== " ") { //Strip trailing spaces
		test = test.substr(0,size-1);size = test.length
	}
	p_object.value = test; //write back to form field

	if (test.length > 50) {
		alert("Special instructions must be a maximum of 50 characters");
		p_object.focus();
		return false;
	}

	bolValid = true; 
	for (var iLoop=0; iLoop < size; iLoop++)
	{ 
		strCurrentChar = test.substring(iLoop,iLoop+1); 
		if ((strCurrentChar >= 'A' && strCurrentChar <= 'Z') || (strCurrentChar >= 'a' && strCurrentChar <= 'z') || 
			(strCurrentChar >= '0' && strCurrentChar <= '9') || strCurrentChar == '-' ||
			 strCurrentChar == ' ' || strCurrentChar == '.' || strCurrentChar == '/') {
		}
		else {
			bolValid = false; 
		}
	} 
	
	if(!bolValid) {
		alert("Special instructions contains invalid character. Valid characters are A-Z, 0-9, hyphen, space, period and forward slash");
		p_object.focus();
		return false;
	}

	return true;

}

// ***************************************************
// *
// * validate foreign post code
//*
// ***************************************************
function validateforeignpostcode(p_country, p_object) {

	if (p_country=="BELGIUM" || p_country=="LUXEMBOURG" || p_country=="AUSTRIA" || 
		p_country=="HUNGARY" || p_country=="SLOVENIA" || p_country=="BULGARIA" || p_country=="CYPRUS" ||
		p_country=="DENMARK" || p_country=="LATVIA" || p_country=="NORWAY" || p_country=="SWITZERLAND" ||
		p_country=="AUSTRALIA" || p_country=="NEW ZEALAND" || p_country=="PHILIPPINES" || p_country=="SOUTH AFRICA") {
		if (p_object.value.match(/^\d{4}$/)) {
		} else {
			alert ("Post code must be of the format #### where # equals any numeric digit (0-9)");
			p_object.focus();
			return false;			
		}
	}
	
	if (p_country=="FRANCE" || p_country=="GERMANY" || p_country=="TURKEY" ||
		p_country=="SPAIN" || p_country=="ITALY" || p_country=="SWEDEN" ||
		p_country=="GREECE" || p_country=="FINLAND" || p_country=="CZECH REPUBLIC" ||
		p_country=="SLOVAKIA" || p_country=="ESTONIA" || p_country=="MONACO" ||
		p_country=="UKRAINE" || p_country=="UNITED STATES OF AMERICA" || p_country=="MALAYSIA" ||
		p_country=="ISRAEL" || p_country=="MEXICO" || p_country=="MOROCCO" || p_country=="PAKISTAN" ||
		p_country=="SAUDI ARABIA") {
		if (p_object.value.match(/^\d{5}$/)) {
		} else {
			alert ("Post code must be of the format ##### where # equals any numeric digit (0-9)");
			p_object.focus();
			return false;			
		}
	}

	if (p_country=="BELARUS" || p_country=="ROMANIA" || p_country=="RUSSIA" ||
		p_country=="CHINA" || p_country=="SINGAPORE" || p_country=="INDIA") {
		if (p_object.value.match(/^\d{6}$/)) {
		} else {
			alert ("Post code must be of the format ###### where # equals any numeric digit (0-9)");
			p_object.focus();
			return false;			
		}
	}

	if (p_country=="IRELAND, REPUBLIC OF") {
		if (p_object.value.match(/^BT/i)) {
			alert ("BT postcodes are in Northern Ireland. Please use a UK delivery rather than a Republic of Ireland delivery");
			p_object.focus();
			return false;
		}
	}

	if (p_country=="CROATIA") {
		if (p_object.value.match(/^HR-\d{5}$/)) {
		} else {
			alert ("Post code must be of the format HR-##### where # equals any numeric digit (0-9)");
			p_object.focus();
			return false;			
		}
	}
	
	if (p_country=="POLAND") {
		if (p_object.value.match(/^\d{5}$/)) {
		} else {
			alert ("Post code must be of the format ##### where # equals any numeric digit (0-9)");
			p_object.focus();
			return false;		
		}
	}
	
	if (p_country=="PORTUGAL") {
		if (p_object.value.match(/^\d{4}-\d{3}$/)) {
		} else {
			alert ("Post code must be of the format ####-### where # equals any numeric digit (0-9)");
			p_object.focus();
			return false;		
		}
	}	

	if (p_country=="JAPAN") {
		if (p_object.value.match(/^\d{3}-\d{4}$/)) {
		} else {
			alert ("Post code must be of the format ###-#### where # equals any numeric digit (0-9)");
			p_object.focus();
			return false;		
		}
	}	

	if (p_country=="KOREA") {
		if (p_object.value.match(/^\d{3}-\d{3}$/)) {
		} else {
			alert ("Post code must be of the format ###-### where # equals any numeric digit (0-9)");
			p_object.focus();
			return false;		
		}
	}

	if (p_country=="NETHERLANDS") {
		if (p_object.value.match(/^\d{4} [A-Z]{2}$/i) && m_deliverypc.length==7) {
		} else {
			alert ("Post code must be of the format ####^@@ where # equals any numeric digit (0-9), ^ equals space and @ equals any alpha character (a-z)");
			p_object.focus();
			return false;	
		}
	}

	if (p_country=="CANADA") {
		if (p_object.value.match(/^[A-Z]\d[A-Z] \d[A-Z]\d$/i)) {
		} else {
			alert ("Post code must be of the format @#@^#@# where # equals any numeric digit (0-9), ^ equals space and @ equals any alpha character (a-z)");
			p_object.focus();
			return false;	
		}
	}

	if (p_country=="ARGENTINA") {
		if (p_object.value.match(/^[A-Z]\d{4}[A-Z]{3}$/i)) {
		} else {
			alert ("Post code must be of the format @####@@@ where # equals any numeric digit (0-9), ^ equals space and @ equals any alpha character (a-z)");
			p_object.focus();
			return false;	
		}
	}

	if (p_country=="MALTA") {
		if (p_object.value.match(/^[A-Z]{3} \d{4}$/i)) {
		} else {
			alert ("Post code must be of the format @@@^#### where # equals any numeric digit (0-9), ^ equals space and @ equals any alpha character (a-z)");
			p_object.focus();
			return false;	
		}
	}

	return true;
}

// ***************************************************
// *
// * validate fields entered in the product chooser
// *
// ***************************************************

function productchooserV14check() {
	pccollection=document.getElementsByName("MODE");
	m_mode=pccollection[0].value;
	if (m_mode=="Document envelope") { return true;}

	pccollection=document.getElementsByName("COUNTRY");
	m_country=pccollection[0].value

// now see which couriers can collect from this postcode
	pccollection=document.getElementsByName("POSTCODE");
	var m_temp = pccollection[0].value
	size=m_temp.length;
	while (m_temp.slice(0,1) == "0" || m_temp.slice(0,1) == " ") // strip leading zeroes & spaces
		{m_temp = m_temp.substr(1,size-1);size = m_temp.length}	
	while (m_temp.slice(size-1,size)== " ") //Strip trailing spaces
		{m_temp = m_temp.substr(0,size-1);size = m_temp.length}
	if (m_temp.length==0) {
		formsubmit_hdnl = 0;
		formsubmit_dhl = 0;
		formsubmit_dpd = 0;
		formsubmit_fedex = 0;
		formsubmit_pf = 0;
		formsubmit_citylink = 0;
	} else {
		if (!(validateukpostcodeformat(pccollection[0]))) {
			alert("The Postcode entered is not valid");
			pccollection[0].focus();
			return false;
		}

		var m_outbound = pccollection[0].value.substring(0,2);
		var m_zone = pccollection[0].value.substring(2,4);
		var m_collectpc = pccollection[0].value;
// Validatepickupostcode param 1 = HDNL, 2=DHL,3=DPD, 4=FedEX, 5=citylink
// 0 = ok to deliver, 1 = not ok to deliver
		if (validatepickupostcodev14(m_collectpc,m_outbound, m_zone, "1", "0", "0", "0", "0")) {
			formsubmit_hdnl = 0;
		} else {
			formsubmit_hdnl = 1;
		}
		if (validatepickupostcodev14(m_collectpc,m_outbound, m_zone, "0", "1", "0", "0", "0")) {
			formsubmit_dhl = 0;
		} else {
			formsubmit_dhl = 1;
		}
		if (validatepickupostcodev14(m_collectpc,m_outbound, m_zone, "0", "0", "1", "0", "0")) {
			formsubmit_dpd = 0;
		} else {
			formsubmit_dpd = 1;
		}
		formsubmit_fedex = 0;
		if (validatepickupostcodev14(m_collectpc,m_outbound, m_zone, "0", "0", "0", "0", "1")) {
			formsubmit_citylink = 0;
		} else {
			formsubmit_citylink = 1;
		}
		formsubmit_pf = 0;
	}

	pccollection=document.getElementsByName("PARCELLENGTH");
	if (isNaN(pccollection[0].value)) {
		alert ("The parcel length that you have quoted is invalid");
		pccollection[0].focus();
		return false;
	}
	m_parcellength=pccollection[0].value;
	size=m_parcellength.length;
	while (m_parcellength.slice(0,1) == "0" || m_parcellength.slice(0,1) == " ") // strip leading zeroes & spaces
		{m_parcellength = m_parcellength.substr(1,size-1);size = m_parcellength.length}	
	while (m_parcellength.slice(size-1,size)== " ") //Strip trailing spaces
		{m_parcellength = m_parcellength.substr(0,size-1);size = m_parcellength.length}	
	m_parcellength = Number(m_parcellength);	

	if (m_parcellength <1) {
 		alert ("The parcel length must be at least 1cm.");
		pccollection[0].focus();
		return false;
	}

	pccollection=document.getElementsByName("PARCELWIDTH");
	if (isNaN(pccollection[0].value)) {
		alert ("The parcel width that you have quoted is invalid");
		pccollection[0].focus();
		return false;
	}
	m_parcelwidth=pccollection[0].value;
	size=m_parcelwidth.length;
	while (m_parcelwidth.slice(0,1) == "0" || m_parcelwidth.slice(0,1) == " ") // strip leading zeroes & spaces
		{m_parcelwidth = m_parcelwidth.substr(1,size-1);size = m_parcelwidth.length}	
	while (m_parcelwidth.slice(size-1,size)== " ") //Strip trailing spaces
		{m_parcelwidth = m_parcelwidth.substr(0,size-1);size = m_parcelwidth.length}	
	m_parcelwidth = Number(m_parcelwidth);	
	if (m_parcelwidth <1) {
		alert ("The parcel width must be at least 1cm.");
		pccollection[0].focus();
		return false;
	}

	pccollection=document.getElementsByName("PARCELHEIGHT");
	if (isNaN(pccollection[0].value)) {
		alert ("The parcel height that you have quoted is invalid");
		pccollection[0].focus();
		return false;
	}
	m_parcelheight=pccollection[0].value;
	size=m_parcelheight.length;
	while (m_parcelheight.slice(0,1) == "0" || m_parcelheight.slice(0,1) == " ") // strip leading zeroes & spaces
		{m_parcelheight = m_parcelheight.substr(1,size-1);size = m_parcelheight.length}	
	while (m_parcelheight.slice(size-1,size)== " ") //Strip trailing spaces
		{m_parcelheight = m_parcelheight.substr(0,size-1);size = m_parcelheight.length}	
	m_parcelheight = Number(m_parcelheight);
	if (m_parcelheight <1) {
		alert ("The parcel height must be at least 1cm.");
		pccollection[0].focus();
		return false;
	}

return true;
}


// ***************************************************
// *
// * Change the mode of the product chooser
// *
// ***************************************************
function modechange() {
	pccollection=document.getElementsByName("MODE");
	if (pccollection[0].value == "Document envelope") {
		pccollection=document.getElementsByName("WEIGHT");
		pccollection[0].disabled=true;
		pccollection[0].style.background="#C0C0C0";
		pccollection=document.getElementsByName("PARCELLENGTH");
		pccollection[0].disabled=true;
		pccollection[0].style.background="#C0C0C0";	
		pccollection=document.getElementsByName("PARCELWIDTH");
		pccollection[0].disabled=true;
		pccollection[0].style.background="#C0C0C0";	
		pccollection=document.getElementsByName("PARCELHEIGHT");
		pccollection[0].disabled=true;
		pccollection[0].style.background="#C0C0C0";	
	} else {
		pccollection=document.getElementsByName("WEIGHT");
		pccollection[0].disabled=false;
		pccollection[0].style.background="#ffffff";
		pccollection=document.getElementsByName("PARCELLENGTH");
		pccollection[0].disabled=false;
		pccollection[0].style.background="#ffffff";
		pccollection=document.getElementsByName("PARCELWIDTH");
		pccollection[0].disabled=false;
		pccollection[0].style.background="#ffffff";	
		pccollection=document.getElementsByName("PARCELHEIGHT");
		pccollection[0].disabled=false;
		pccollection[0].style.background="#ffffff";	
	}
}

// ***************************************************
// *
// * send the user to the selected form
// *
// ***************************************************
function goform() {
	var formoption=document.getElementsByName("formoption");
	if (formoption[0].value == "None") {
		alert ("No action selected");
		formoption[0].focus();
	}

	if (formoption[0].value == "COLLECTION") {
		window.location = "http://www.parcel2ship.co.uk/noncollection.html";
	}
	if (formoption[0].value == "DELIVERY") {
		window.location = "http://www.parcel2ship.co.uk/nondelivery.html";
	}
	if (formoption[0].value == "DAMAGE") {
		window.location = "http://www.parcel2ship.co.uk/damageclaim.html";
	}
	if (formoption[0].value == "LOSS") {
		window.location = "http://www.parcel2ship.co.uk/lossclaim.html";
	}
	return this;
}

// ***************************************************
// *
// * check whether the selected country has DHL remote areas
// *
// ***************************************************
function countryHasRemoteAreas(p_country) {
	if (p_country=="ARGENTINA" || p_country=="AUSTRALIA" || p_country=="AUSTRIA" || p_country=="BELARUS" || p_country=="BRAZIL" || p_country=="BULGARIA" || 
		p_country=="CANADA" || p_country=="CANARY ISLANDS" || p_country=="CHINA" || p_country=="CROATIA" || p_country=="CZECH REPUBLIC" || 
		p_country=="CYPRUS" || p_country=="DENMARK" || p_country=="ESTONIA" || p_country=="FINLAND" || p_country=="FRANCE" || 
		p_country=="GERMANY" || p_country=="GREECE" || p_country=="HUNGARY" || p_country=="INDIA" || 
		p_country=="IRELAND, REPUBLIC OF" || p_country=="ISRAEL" || p_country=="ITALY" || p_country=="LATVIA" || 
		p_country=="MALAYSIA" || p_country=="MALTA" || p_country=="MEXICO" || p_country=="MOROCCO" || p_country=="NEW ZEALAND" ||
		p_country=="NORWAY" || p_country=="PAKISTAN" || p_country=="PHILIPPINES" || p_country=="POLAND" || p_country=="ROMANIA" ||
		p_country=="RUSSIA" || p_country=="SLOVAKIA" || p_country=="SLOVENIA" || p_country=="SOUTH AFRICA" || p_country=="SWITZERLAND" || 
		p_country=="KOREA" || p_country=="SPAIN" || p_country=="SWEDEN" || p_country=="TURKEY" || p_country=="UKRAINE" || 
		p_country=="UNITED STATES OF AMERICA") {
		return true;
	} else {
		return false;
	}
}

function formSubmitv14(){
    formsubmit_hdnl = 0;
    formsubmit_dhl = 0;
    formsubmit_dpd = 0;
    formsubmit_pf = 0;
    formsubmit_fedex = 0;
    formsubmit_citylink = 0;
    if (productchooserV14check() != false){
		var xmlhttp = xmlReq();
		var theForm = document.forms['quickQuote'];
		var courier = encodeURIComponent(theForm.elements['COURIER'].value);
		var mode = encodeURIComponent(theForm.elements['MODE'].value);
		var country = encodeURIComponent(theForm.elements['COUNTRY'].value);
		var weight = encodeURIComponent(theForm.elements['WEIGHT'].value);
		var length = encodeURIComponent(theForm.elements['PARCELLENGTH'].value);
		var width = encodeURIComponent(theForm.elements['PARCELWIDTH'].value);
		var height = encodeURIComponent(theForm.elements['PARCELHEIGHT'].value);
		var postcode = encodeURIComponent(theForm.elements['POSTCODE'].value);
		var HDNL = encodeURIComponent(formsubmit_hdnl);
		var DHL = encodeURIComponent(formsubmit_dhl);
		var DPD = encodeURIComponent(formsubmit_dpd);
		var PF = encodeURIComponent(formsubmit_pf);		
		var FEDEX = encodeURIComponent(formsubmit_fedex);
		var CITYLINK = encodeURIComponent(formsubmit_citylink);
		var pageURL = encodeURIComponent(location.href);
		var url = '../cgi-bin/productchooserv14.pl?COURIER='+courier+'&MODE='+mode+'&COUNTRY='+country+'&WEIGHT='+weight+'&PARCELLENGTH='+length+'&PARCELWIDTH='+width+'&PARCELHEIGHT='+height+'&POSTCODE='+postcode+'&HDNL='+HDNL+'&DHL='+DHL+'&DPD='+DPD+'&PF='+PF+'&CITYLINK='+CITYLINK+'&REFERRER='+pageURL;
		xmlhttp.open("GET", url);
		
		xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4){
					$('#call-out').hide("slide",{ direction: "up" },50);
					document.getElementById("call-out").innerHTML = xmlhttp.responseText;
					$('#call-out').show("slide", { direction: "down" }, 1000);
			}else{
			}
		};
		xmlhttp.send(null);
		
		
        return false;
    }else{
	}
	return false;	
}

function hideResults(){
	$('#call-out').hide("slide",{ direction: "up" },50);
	return false;
}
function xmlReq(){
	var xmlhttp= null;
	if (window.XMLHttpRequest){
  		// code for IE7+, Firefox, Chrome, Opera, Safari
  		try{
			xmlhttp=new XMLHttpRequest();
		}catch(e){}
  	}else if (window.ActiveXObject){
  		// code for IE6, IE5
		try{
  			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		} catch(e){}
  	}else{
  		alert("Your browser does not support AJAX calls please email");
  	}
	return xmlhttp;
}

// ***************************************************
// *
// * check whether the collection post code is valid for the chosen courier
// *
// ***************************************************
function validatepickupostcode(p_collectpc, p_outbound, p_zone) {
// first do checks that apply to all couriers (apart from Parcelforce)
	if (m_hdnl==1 || m_dhl==1 || m_dpd==1 || m_citylink==1) {
		switch (p_outbound) {
		case "ZE":
		case "BT":
		case "IM":
		case "HS":
			return false;
		case "KA":
			if (Number(p_zone) >=27 && Number(p_zone)<=28) { 
				return false;
			} else {
				break;
			}
		case "TR":
			if (Number(p_zone) >=21 && Number(p_zone)<=25) {
				return false;
			}
		}
	}

	if (m_hdnl==1 || m_dhl==1 || m_dpd==1) {
		switch (p_outbound) {
		case "IV":
		case "KW":
			return false;
		case "PH":
			if (Number(p_zone) >=49 && Number(p_zone)<=50) {
				return false;
			} else {
				break;
			}
		case "PO":
			if (Number(p_zone) >=30 && Number(p_zone)<=41) {
				return false;
			} else {
				break;
			}
		}
	}

	if (m_citylink==1) {
		m_gcode = p_collectpc.substring(0,3);
		if (m_gcode=="G83" || m_gcode=="G84") {
			return false;
		}

		switch(p_outbound) {
		case "KW":
			if ((Number(p_zone)>=1 && Number(p_zone)<=3) || (Number(p_zone)>=5 && Number(p_zone)<=17)) {
				return false;
			}
			break;
		case "PA":
			if ((Number(p_zone) >=20 && Number(p_zone)<=38) || (Number(p_zone) >=41 && Number(p_zone)<=49)) {
				return false;
			}
			if (Number(p_zone) >=60 && Number(p_zone)<=78) {
				return false;
			}
			break;
		case "PH":
			if (Number(p_zone)==17) {
				return false;
			}			
			if ((Number(p_zone) >=19 && Number(p_zone)<=26) || (Number(p_zone) >=30 && Number(p_zone)<=44)) {
				return false;
			}
			if (Number(p_zone) >=49 && Number(p_zone)<=50) {
				return false;
			}
			break;
		case "IV":
			if (Number(p_zone)==2 || Number(p_zone)==36 || Number(p_zone)==63) {
				return false;
			}			
			if ((Number(p_zone) >=4 && Number(p_zone)<=28) || (Number(p_zone) >=30 && Number(p_zone)<=32)) {
				return false;
			}
			if ((Number(p_zone) >=40 && Number(p_zone)<=49) || (Number(p_zone) >=51 && Number(p_zone)<=56)) {
				return false;
			}
			break;
		}
	}

	if (m_hdnl==1) {
		switch (p_outbound) {
			case "AB":
			case "BF":
				return false;
			case "PA":
				if (Number(p_zone) >=20 && Number(p_zone)<=50) {
					return false;
				} 

				if (Number(p_zone) >=60 && Number(p_zone)<=78) {
					return false;
				}
				break;
			case "PH":
				if (Number(p_zone) >=19 && Number(p_zone)<=44) {
					return false;
				} else {
					break;
				}

			case "DD":
				if (Number(p_zone) >=8 && Number(p_zone)<=11) {
					return false;
				}
		}
	}

	if (m_dhl==1 || m_dpd==1) {
		switch (p_outbound) {
			case "AB":
				if (Number(p_zone)==31) {
					return false;
				}

				if (Number(p_zone)>=33 && Number(p_zone)<=38) {
					if (p_collectpc=="AB37 9EX") {
					} else {
						return false;
					}
				}
				
				if (Number(p_zone)==44 || Number(p_zone)==45) {
					return false;
				}

				if (Number(p_zone)>=53 && Number(p_zone)<=56) {
					return false;
				}
				break;
				
			case "PA":
				if (Number(p_zone)>=20 && Number(p_zone)<=49) {
					return false;
				}

				if (Number(p_zone)>=60 && Number(p_zone)<=78) {
					return false;
				}
				break;
				
			case "PH":
				if (Number(p_zone)>=17 && Number(p_zone)<=44) {
					return false;
				}
		}
	}

	if (m_dpd==1) {
		if (p_outbound=="AB" && (Number(p_zone) >=10 && Number(p_zone)<=30)) {
			return false;
		}	
	}

	return true;
}

function validatepickupostcodev14(p_collectpc, p_outbound, p_zone, p_hdnl, p_dhl, p_dpd, p_fedex, p_citylink) {
// first do checks that apply to all couriers (apart from Parcelforce)
	if (p_hdnl==1 || p_dhl==1 || p_dpd==1 || p_fedex==1 || p_citylink==1) {
		switch (p_outbound) {
		case "ZE":
		case "BT":
		case "IM":
		case "HS":
			return false;
		case "KA":
			if (Number(p_zone) >=27 && Number(p_zone)<=28) { 
				return false;
			} else {
				break;
			}
		case "TR":
			if (Number(p_zone) >=21 && Number(p_zone)<=25) {
				return false;
			}
		}
	}

	if (p_hdnl==1 || p_dhl==1 || p_dpd==1) {
		switch (p_outbound) {
		case "IV":
		case "KW":
			return false;
		case "PH":
			if (Number(p_zone) >=49 && Number(p_zone)<=50) {
				return false;
			} else {
				break;
			}
		case "PO":
			if (Number(p_zone) >=30 && Number(p_zone)<=41) {
				return false;
			} else {
				break;
			}
		}
	}

	if (p_citylink==1) {
		m_gcode = p_collectpc.substring(0,3);
		if (m_gcode=="G83" || m_gcode=="G84") {
			return false;
		}

		switch(p_outbound) {
		case "KW":
			if ((Number(p_zone)>=1 && Number(p_zone)<=3) || (Number(p_zone)>=5 && Number(p_zone)<=17)) {
				return false;
			}
			break;
		case "PA":
			if ((Number(p_zone) >=20 && Number(p_zone)<=38) || (Number(p_zone) >=41 && Number(p_zone)<=49)) {
				return false;
			}
			if (Number(p_zone) >=60 && Number(p_zone)<=78) {
				return false;
			}
			break;
		case "PH":
			if (Number(p_zone)==17) {
				return false;
			}			
			if ((Number(p_zone) >=19 && Number(p_zone)<=26) || (Number(p_zone) >=30 && Number(p_zone)<=44)) {
				return false;
			}
			if (Number(p_zone) >=49 && Number(p_zone)<=50) {
				return false;
			}
			break;
		case "IV":
			if (Number(p_zone)==2 || Number(p_zone)==36 || Number(p_zone)==63) {
				return false;
			}			
			if ((Number(p_zone) >=4 && Number(p_zone)<=28) || (Number(p_zone) >=30 && Number(p_zone)<=32)) {
				return false;
			}
			if ((Number(p_zone) >=40 && Number(p_zone)<=49) || (Number(p_zone) >=51 && Number(p_zone)<=56)) {
				return false;
			}
			break;
		}
	}

	if (p_hdnl==1) {
		switch (p_outbound) {
			case "AB":
			case "BF":
				return false;
			case "PA":
				if (Number(p_zone) >=20 && Number(p_zone)<=50) {
					return false;
				} 

				if (Number(p_zone) >=60 && Number(p_zone)<=78) {
					return false;
				}
				break;
			case "PH":
				if (Number(p_zone) >=19 && Number(p_zone)<=44) {
					return false;
				} else {
					break;
				}

			case "DD":
				if (Number(p_zone) >=8 && Number(p_zone)<=11) {
					return false;
				}
		}
	}

	if (p_dhl==1 || p_fedex==1 || p_dpd==1) {
		switch (p_outbound) {
			case "AB":
				if (Number(p_zone)==31) {
					return false;
				}

				if (Number(p_zone)>=33 && Number(p_zone)<=38) {
					if (p_collectpc=="AB37 9EX") {
					} else {
						return false;
					}
				}
				
				if (Number(p_zone)==44 || Number(p_zone)==45) {
					return false;
				}

				if (Number(p_zone)>=53 && Number(p_zone)<=56) {
					return false;
				}
				break;
				
			case "PA":
				if (Number(p_zone)>=20 && Number(p_zone)<=49) {
					return false;
				}

				if (Number(p_zone)>=60 && Number(p_zone)<=78) {
					return false;
				}
				break;
				
			case "PH":
				if (Number(p_zone)>=17 && Number(p_zone)<=44) {
					return false;
				}
		}
	}

	if (p_dpd==1) {
		if (p_outbound=="AB" && (Number(p_zone) >=10 && Number(p_zone)<=30)) {
			return false;
		}	
	}

	return true;
}

// ***************************************************
// *
// * check whether we offer a guaranteed collection from the collection post code
// *
// ***************************************************
function validateguaranteedpickup(p_collectpc, p_outbound, p_zone) {
	if (p_outbound=="IV" || p_outbound=="HS" || p_outbound=="KW" || p_outbound=="ZE" || p_outbound=="BT" || p_outbound=="IM") {
		return false;
	}

	if (p_outbound=="KA" && (Number(p_zone) >=27 && Number(p_zone)<=28)) {
		return false;
	}

	if (p_outbound=="PA" && (Number(p_zone) >=20 && Number(p_zone)<=49)) {
		return false;
	}				

	if (p_outbound=="PA" && (Number(p_zone) >=60 && Number(p_zone)<=78)) {
		return false;
	}			

	if (p_outbound=="PH" && (Number(p_zone) >=17 && Number(p_zone)<=44)) {
		return false;
	}			

	if (p_outbound=="PH" && (Number(p_zone) >=49 && Number(p_zone)<=50)) {
		return false;
	}			

	if (p_outbound=="PO" && (Number(p_zone) >=30 && Number(p_zone)<=41)) {
		return false;
	}			
			
	if (p_outbound=="TR" && (Number(p_zone) >=21 && Number(p_zone)<=25)) {
		return false;
	}			
	return true
}

// ***************************************************
// *
// * check whether the delivery post code is valid for an hdnl collection
// *
// ***************************************************
function validatehdnldeliverypostcode(p_outbound, p_zone){
	if (p_outbound=="IV" || p_outbound=="HS" || p_outbound=="KW" || p_outbound=="ZE" || p_outbound=="BT" || p_outbound=="IM") {
		return false;
	}

	if (p_outbound=="KA" && (Number(p_zone) >=27 && Number(p_zone)<=28)) {
		return false;
	}

	if (p_outbound=="PA" && (Number(p_zone) >=20 && Number(p_zone)<=50)) {
		return false;
	}				

	if (p_outbound=="PA" && (Number(p_zone) >=60 && Number(p_zone)<=78)) {
		return false;
	}			

	if (p_outbound=="PH" && (Number(p_zone) >=19 && Number(p_zone)<=44)) {
		return false;
	}			

	if (p_outbound=="PH" && (Number(p_zone) >=49 && Number(p_zone)<=50)) {
		return false;
	}			

	if (p_outbound=="PO" && (Number(p_zone) >=30 && Number(p_zone)<=41)) {
		return false;
	}			
		
	if (p_outbound=="TR" && (Number(p_zone) >=21 && Number(p_zone)<=25)) {
		return false;
	}			

	if (p_outbound=="AB") {
		return false;
	}

	if (p_outbound=="DD" && (Number(p_zone) >=8 && Number(p_zone)<=11)) {
		return false;
	}

	if (p_outbound=="BF") {
		return false;
	}
	return true;
}

// ***************************************************
// *
// * check whether the delivery post code is valid for a city link delivery
// *
// ***************************************************
function validatecitylinkdeliverypostcode(p_deliverypc, p_outbound, p_zone){
	m_gcode = p_deliverypc.substring(0,3);
	if (m_gcode=="G83" || m_gcode=="G84") {
		return false;
	}

	switch (p_outbound) {
	case "ZE":
	case "BT":
	case "IM":
	case "HS":
		return false;
	case "KA":
		if (Number(p_zone) >=27 && Number(p_zone)<=28) { 
			return false;
		}
		break;
	case "KW":
		if ((Number(p_zone)>=1 && Number(p_zone)<=3) || (Number(p_zone)>=5 && Number(p_zone)<=17)) {
			return false;
		}
		break;
	case "PA":
		if ((Number(p_zone) >=20 && Number(p_zone)<=38) || (Number(p_zone) >=41 && Number(p_zone)<=49)) {
			return false;
		}
		if (Number(p_zone) >=60 && Number(p_zone)<=78) {
			return false;
		}
		break;
	case "PH":
		if (Number(p_zone)==17) {
			return false;
		}			
		if ((Number(p_zone) >=19 && Number(p_zone)<=26) || (Number(p_zone) >=30 && Number(p_zone)<=44)) {
			return false;
		}
		if (Number(p_zone) >=49 && Number(p_zone)<=50) {
			return false;
		}
		break;
	case "TR":
		if (Number(p_zone) >=21 && Number(p_zone)<=25) {
			return false;
		}
		break
	case "IV":
		if (Number(p_zone)==2 || Number(p_zone)==36 || Number(p_zone)==63) {
			return false;
		}			
		if ((Number(p_zone) >=4 && Number(p_zone)<=28) || (Number(p_zone) >=30 && Number(p_zone)<=32)) {
			return false;
		}
		if ((Number(p_zone) >=40 && Number(p_zone)<=49) || (Number(p_zone) >=51 && Number(p_zone)<=56)) {
			return false;
		}
		break;
	}

	return true;
}


function validateislands(p_outbound, p_zone) {
	if (p_outbound=="IV" || p_outbound=="HS" || p_outbound=="KW" || p_outbound=="ZE" || p_outbound=="BT" || p_outbound=="IM") {
		return false;
	}

	if (p_outbound=="KA" && (Number(p_zone) >=27 && Number(p_zone)<=28)) {
		return false;
	}

	if (p_outbound=="PA" && (Number(p_zone) >=20 && Number(p_zone)<=49)) {
		return false;
	}				

	if (p_outbound=="PA" && (Number(p_zone) >=60 && Number(p_zone)<=78)) {
		return false;
	}			

	if (p_outbound=="PH" && (Number(p_zone) >=17 && Number(p_zone)<=44)) {
		return false;
	}			

	if (p_outbound=="PH" && (Number(p_zone) >=49 && Number(p_zone)<=50)) {
		return false;
	}			

	if (p_outbound=="PO" && (Number(p_zone) >=30 && Number(p_zone)<=41)) {
		return false;
	}			
		
	if (p_outbound=="TR" && (Number(p_zone) >=21 && Number(p_zone)<=25)) {
		return false;
	}			
	return true;
}

function validateprenoon(p_postcode) {
	m_outbound = p_postcode.substring(0,2);
	m_zone = p_postcode.substring(2,4);

	switch (m_outbound) {
	case "AB":
		if ((Number(m_zone)>=33 && Number(m_zone)<=38) || (Number(m_zone)>=41 && Number(m_zone)<=45)) {
			return false;
		}
		if (Number(m_zone)>=51 && Number(m_zone)<=56) {
			return false;
		}
		break;
	case "DD":
		if (Number(m_zone)>=8 && Number(m_zone)<=10) {
			return false;
		}
		break;
	case "EH":
		if (Number(m_zone)==38) {
			return false;
		}
		if (Number(m_zone)>=42 && Number(m_zone)<=46) {
			return false;
		}
		break;
	case "FK":
		if (Number(m_zone)==8) {
			return false;
		}
		if (Number(m_zone)>=17 && Number(m_zone)<=21) {
			return false;
		}
		break;
	case "KA":
		if (Number(m_zone)==26) {
			return false;
		}
		break;
	case "KY":
		if (Number(m_zone)==15) {
			return false;
		}
		break;
	case "ML":
		if (Number(m_zone)==12) {
			return false;
		}
		break;
	case "PH":
		if ((Number(m_zone)>=2 && Number(m_zone)<=13) || (Number(m_zone)>=15 && Number(m_zone)<=18)) {
			return false;
		}
		break;
	case "TD":
		if ((Number(m_zone)>=2 && Number(m_zone)<=3) || (Number(m_zone)>=10 && Number(m_zone)<=14)) {
			return false;
		}
	}

	return true;
}

function validatepre1030(p_postcode) {
	m_outbound = p_postcode.substring(0,2);
	m_zone = p_postcode.substring(2,4);	
	switch (m_outbound) {
	case "AB":
		if ((Number(m_zone)>=30 && Number(m_zone)<=32) || (Number(m_zone)==39)) {
			return false;
		}
		break;
	case "DD":
		if ((Number(m_zone)>=1 && Number(m_zone)<=7) || (Number(m_zone)==11)) {
			return false;
		}
		break;
	case "DG":
		if ((Number(m_zone)==4) || (Number(m_zone)>=8 && Number(m_zone)<=9)) {
			return false;
		}
		break;
	case "DL":
		if (Number(m_zone)>=12 && Number(m_zone)<=13) {
			return false;
		}
		break;
	case "EH":
		if ((Number(m_zone)>=18 && Number(m_zone)<=26) || (Number(m_zone)>=31 && Number(m_zone)<=37)) {
			return false;
		}
		if (Number(m_zone)>=39 && Number(m_zone)<=41) {
			return false;
		}
		break;
	case "FK":
		if ((Number(m_zone)==7) || (Number(m_zone)>=9 && Number(m_zone)<=16)) {
			return false;
		}
		break;
	case "IP":
		if (Number(m_zone)==28) {
			return false;
		}
		break;
	case "IV":
		if (Number(m_zone)>=1 && Number(m_zone)<=3) {
			return false;
		}
		break;
	case "KA":
		if ((Number(m_zone)>=5 && Number(m_zone)<=6) || (Number(m_zone)==16)) {
			return false;
		}
		if ((Number(m_zone)>=18 && Number(m_zone)<=23) || (Number(m_zone)>=29 && Number(m_zone)<=30)) {
			return false;
		}
		break;
	case "KY":
		if (Number(m_zone)>=9 && Number(m_zone)<=16) {
			return false;
		}
		break;
	case "LA":
		if ((Number(m_zone)==12) || (Number(m_zone)>=14 && Number(m_zone)<=21)) {
			return false;
		}
		break;
	case "LL":
		if ((Number(m_zone)==41) || (Number(m_zone)>=46 && Number(m_zone)<=49)) {
			return false;
		}
		break;
	case "ML":
		if (Number(m_zone)==11) {
			return false;
		}
		break;
	case "NP":
		if ((Number(m_zone)==16 || Number(m_zone)==18) || (Number(m_zone)>=25 && Number(m_zone)<=26)) {
			return false;
		}
		break;
	case "PA":
		if (Number(m_zone)>=17 && Number(m_zone)<=19) {
			return false;
		}
		break;
	case "PH":
		if (Number(m_zone)==1 || Number(m_zone)==14) {
			return false;
		}
		break;
	case "SA":
		if (Number(m_zone)>=45 && Number(m_zone)<=47) {
			return false;
		}
		break;
	case "TD":
		if (Number(m_zone)==11 || Number(m_zone)==15) {
			return false;
		}
		break;
	case "TR":
		if (Number(m_zone)==93) {
			return false;
		}
		break;
	case "YO":
		if (Number(m_zone)>=15 && Number(m_zone)<=16) {
			return false;
		}
	}
	return true;
}

function validatepre9(p_postcode) {
	g_code = p_postcode.substring(0,3);

	if (g_code=="G33"||g_code=="G42"||g_code=="G43"||g_code=="G44"||g_code=="G45"||g_code=="G46"||g_code=="G60") {
		return false;
	}

	if (g_code=="G62"||g_code=="G63"||g_code=="G64"||g_code=="G65"||g_code=="G66"||g_code=="G67"||g_code=="G68"||g_code=="G69"||g_code=="G70") {
		return false;
	}

	if (g_code=="G78"||g_code=="G81"||g_code=="G82") {
		return false;
	}

	m_outbound = p_postcode.substring(0,2);
	m_zone = p_postcode.substring(2,4);	
	switch (m_outbound) {
	case "AB":
		if ((Number(m_zone)>=14 && Number(m_zone)<=15) || (Number(m_zone)>=22 && Number(m_zone)<=23)) {
			return false;
		}
		break;
	case "BH":
		if (Number(m_zone)>=19 && Number(m_zone)<=20) {
			return false;
		}
		break;
	case "CA":
		if (Number(m_zone)==9 || Number(m_zone)==12 || Number(m_zone)==95) {
			return false;
		}		
		if (Number(m_zone)>=16 && Number(m_zone)<=28) {
			return false;
		}
		break;
	case "CB":
		if (Number(m_zone)==10) {
			return false;
		}
		break;
	case "CF":
		if ((Number(m_zone)==35) || (Number(m_zone)>=42 && Number(m_zone)<=44)) {
			return false;
		}
		break;
	case "CO":
		if ((Number(m_zone)>=5 && Number(m_zone)<=10) || (Number(m_zone)>=13 && Number(m_zone)<=16)) {
			return false;
		}
		break;
	case "DG":
		if (Number(m_zone)>=1 && Number(m_zone)<=10) {
			return false;
		}
		break;
	case "DT":
		if ((Number(m_zone)>=3 && Number(m_zone)<=6) || (Number(m_zone)>=8 && Number(m_zone)<=11)) {
			return false;
		}
		break;
	case "EH":
		if (Number(m_zone)==30 || Number(m_zone)==95 || Number(m_zone)==99) {
			return false;
		}
		if ((Number(m_zone)>=4 && Number(m_zone)<=11) || (Number(m_zone)>=13 && Number(m_zone)<=17)) {
			return false;
		}
		break;
	case "EX":
		if (Number(m_zone)==23 || Number(m_zone)==39) {
			return false;
		}
		if (Number(m_zone)>=31 && Number(m_zone)<=34) {
			return false;
		}
		break;
	case "FK":
		if (Number(m_zone)>=1 && Number(m_zone)<=6) {
			return false;
		}
		break;
	case "GL":
		if (Number(m_zone)==8||Number(m_zone)==54) {
			return false;
		}
		if ((Number(m_zone)>=12 && Number(m_zone)<=13) || (Number(m_zone)>=15 && Number(m_zone)<=16)) {
			return false;
		}
		break;
	case "HR":
		if (Number(m_zone)>=2 && Number(m_zone)<=6) {
			return false;
		}
		break;
	case "HU":
		if (Number(m_zone)==12||Number(m_zone)==18||Number(m_zone)==19) {
			return false;
		}
		break;
	case "IP":
		if ((Number(m_zone)>=12 && Number(m_zone)<=18) || (Number(m_zone)>=25 && Number(m_zone)<=31)) {
			return false;
		}
		break;
	case "KA":
		if (Number(m_zone)>=1 && Number(m_zone)<=17) {
			return false;
		}
		break;
	case "KY":
		if (Number(m_zone)>=1 && Number(m_zone)<=8) {
			return false;
		}
		if (Number(m_zone)==99) {
			return false;
		}
		break;
	case "LA":
		if (Number(m_zone)==10||Number(m_zone)==13||Number(m_zone)==22) {
			return false;
		}
		break;
	case "LD":
		if (Number(m_zone)>=1 && Number(m_zone)<=7) {
			return false;
		}
		break;
	case "LL":
		if ((Number(m_zone)>=23 && Number(m_zone)<=28) || (Number(m_zone)>=30 && Number(m_zone)<=45)) {
			return false;
		}
		if (Number(m_zone)>=51 && Number(m_zone)<=56) {
			return false;
		}
		break;
	case "LN":
		if ((Number(m_zone)>=3 && Number(m_zone)<=5) || (Number(m_zone)>=9 && Number(m_zone)<=13)) {
			return false;
		}
		break;
	case "ME":
		if (Number(m_zone)==11||Number(m_zone)==12) {
			return false;
		}
		break;
	case "ML":
		if (Number(m_zone)>=6 && Number(m_zone)<=10) {
			return false;
		}
		break;
	case "NE":
		if (Number(m_zone)==43 || Number(m_zone)==49) {
			return false;
		}
		if (Number(m_zone)==19) {
			return false;
		}
		break;
	case "NP":
		if (Number(m_zone)==15) {
			return false;
		}
		break;
	case "NR":
		if (Number(m_zone)>=21 && Number(m_zone)<=28) {
			return false;
		}
		break;
	case "PA":
		if (Number(m_zone)>=5 && Number(m_zone)<=16) {
			return false;
		}
		break;
	case "PE":
		if ((Number(m_zone)>=13 && Number(m_zone)<=15) || (Number(m_zone)>=23 && Number(m_zone)<=25)) {
			return false;
		}
		if (Number(m_zone)>=30 && Number(m_zone)<=38) {
			return false;
		}
		break;
	case "PL":
		if ((Number(m_zone)>=23 && Number(m_zone)<=31) || (Number(m_zone)>=33 && Number(m_zone)<=34)) {
			return false;
		}
		break;
	case "PO":
		if (Number(m_zone)>=30 && Number(m_zone)<=41) {
			return false;
		}
		break;
	case "SA":
		if (Number(m_zone)==20) {
			return false;
		}
		if ((Number(m_zone)>=32 && Number(m_zone)<=48) || (Number(m_zone)>=61 && Number(m_zone)<=73)) {
			return false;
		}
		break;
	case "SK":
		if (Number(m_zone)==17) {
			return false;
		}
	case "SY":
		if ((Number(m_zone)>=7&&Number(m_zone)<=8) || (Number(m_zone)>=23&&Number(m_zone)<=25)) {
			return false;
		}
		break;
	case "TD":
		if (Number(m_zone)>=1&&Number(m_zone)<=9) {
			return false;
		}
		break;
	case "TN":
		if (Number(m_zone)==7||Number(m_zone)==32||Number(m_zone)==36) {
			return false;
		}
		if (Number(m_zone)>=17&Number(m_zone)<=19) {
			return false;
		}
		break;
	case "TR":
		if (Number(m_zone)>=1&&Number(m_zone)<=27) {
			return false;
		}
		break;
	case "TS":
		if (Number(m_zone)>=12&&Number(m_zone)<=13) {
			return false;
		}
		break;
	case "YO":
		if ((Number(m_zone)>=13 && Number(m_zone)<=14) || (Number(m_zone)>=42&&Number(m_zone)<=43)) {
			return false;
		}
		if (Number(m_zone)==18||Number(m_zone)==25) {
			return false;
		}
	}
	return true;
}

function validateextraislands(p_outbound, p_zone) {
	if (p_outbound=="AB" && Number(p_zone) == 31) {
		return false;
	}
	
	if (p_outbound=="AB" && (Number(p_zone) >=33 && Number(p_zone)<=38)) {
		return false;
	}

	if (p_outbound=="AB" && (Number(p_zone) >=44 && Number(p_zone)<=45)) {
		return false;
	}

	if (p_outbound=="AB" && (Number(p_zone) >=53 && Number(p_zone)<=56)) {
		return false;
	}
	return true;
}


function createquickquotev14(p_country, p_fromhome, p_courier) {
	document.write('<div id="call-out"></div>');

// WILL HAVE TO CHANGE NEXT LINE TO HAVE CORRECT REFERAL 
	document.write('<form method="post" name="quickQuote" id="quickQuote" action="cgi-bin/productchooserv14.pl" onSubmit="return formSubmitv14()">')
	document.write('<table width="585">')
	if (p_courier=="PARCELFORCE") {
		document.write('<tr><td width="585" height="180"  class="qqparcelforce">')
	} else {
		document.write('<tr width="100%"><td class="qqv13">')
	}
	document.write('<table width="576" border="0"> ')
	document.write('<tr><td height="35"><td></tr>')
	document.write('<tr>')
	document.write('<td width="10" rowspan="4">&nbsp;</td>')
	if (p_courier=="PARCELFORCE") {
		document.write('<td width="474" height="35" class="qqtext"><input type="hidden" name="COURIER" value="Parcelforce">I am sending a: <select name="MODE" onChange="modechange()"><option selected value="Parcel">Parcel</option> <option value="Document envelope">Document envelope</option></select>')
	} else {
		document.write('<td width="474" height="35" class="qqtext"><input type="hidden" name="COURIER" value="Any">I am sending a: <select name="MODE" onChange="modechange()"><option selected value="Parcel">Parcel</option> <option value="Document envelope">Document envelope</option></select>')
	}

	document.write(' To: <select name="COUNTRY" tabindex=1>')
	if (p_country=="NONE") {
		document.write('<option selected value="UNITED KINGDOM">United Kingdom</option><option value="AUSTRALIA">Australia</option><option value="AUSTRIA">Austria</option>')
		document.write('<option value="ARGENTINA">Argentina</option><option value="BELARUS">Belarus</option><option value="BELGIUM">Belgium</option><option value="BRAZIL">Brazil</option>')
		document.write('<option value="BULGARIA">Bulgaria</option><option value="CANADA">Canada</option><option value="CANARY ISLANDS">Canary Islands</option><option value="CHINA">China</option>')
		document.write('<option value="CORSICA">Corsica</option><option value="CROATIA">Croatia</option><option value="CYPRUS">Cyprus</option><option value="CZECH REPUBLIC">Czech Republic</option>')
		document.write('<option value="DENMARK">Denmark</option><option value="ESTONIA">Estonia</option><option value="FINLAND">Finland</option><option value="FRANCE">France</option>')
		document.write('<option value="GERMANY">Germany</option><option value="GREECE">Greece</option><option value="GUERNSEY">Guernsey</option><option value="HONG KONG">Hong Kong</option>')
		document.write('<option value="HUNGARY">Hungary</option><option value="INDIA">India</option><option value="ISRAEL">Israel</option><option value="ITALY">Italy</option>')
		document.write('<option value="JAMAICA">Jamaica</option><option value="JAPAN">Japan</option><option value="JERSEY">Jersey</option><option value="LATVIA">Latvia</option>')
		document.write('<option value="LUXEMBOURG">Luxembourg</option><option value="MALAYSIA">Malaysia</option><option value="MALTA">Malta</option><option value="MEXICO">Mexico</option>')
		document.write('<option value="MONACO">Monaco</option><option value="MOROCCO">Morocco</option><option value="NETHERLANDS">Netherlands</option><option value="NEW ZEALAND">New Zealand</option>')
		document.write('<option value="NORWAY">Norway</option><option value="PAKISTAN">Pakistan</option><option value="PHILIPPINES">Philippines</option><option value="POLAND">Poland</option>')
		document.write('<option value="PORTUGAL">Portugal</option><option value="IRELAND, REPUBLIC OF">Republic of Ireland</option><option value="ROMANIA">Romania</option><option value="RUSSIA">Russia</option>')
		document.write('<option value="SAUDI ARABIA">Saudi Arabia</option><option value="SINGAPORE">Singapore</option><option value="SLOVAKIA">Slovakia</option><option value="SLOVENIA">Slovenia</option>')
		document.write('<option value="SOUTH AFRICA">South Africa</option><option value="SOUTH KOREA">South Korea</option><option value="SPAIN">Spain</option><option value="SWEDEN">Sweden</option>')
		document.write('<option value="SWITZERLAND">Switzerland</option><option value="TURKEY">Turkey</option><option value="UNITED STATES OF AMERICA">USA</option><option value="UKRAINE">Ukraine</option>')
	} else if(p_country=="UNITED KINGDOM") {document.write('<option selected value="UNITED KINGDOM">United Kingdom</option')
	} else if(p_country=="AUSTRALIA") {document.write('<option value="AUSTRALIA">Australia</option>')
	} else if(p_country=="AUSTRIA") {document.write('<option value="AUSTRIA">Austria</option>')
	} else if(p_country=="ARGENTINA") {document.write('<option value="ARGENTINA">Argentina</option>')
	} else if(p_country=="BELARUS") {document.write('<option value="BELARUS">Belarus</option>')
	} else if(p_country=="BELGIUM") {document.write('<option value="BELGIUM">Belgium</option>')
	} else if(p_country=="BULGARIA") {document.write('<option value="BULGARIA">Bulgaria</option>')
	} else if(p_country=="BRAZIL") {document.write('<option value="BRAZIL">Brazil</option>')
	} else if(p_country=="CANADA") {document.write('<option value="CANADA">Canada</option>')
	} else if(p_country=="CANARY ISLANDS") {document.write('<option value="CANARY ISLANDS">Canary Islands</option>')
	} else if(p_country=="CHINA") {document.write('<option value="CHINA">China</option>')
	} else if(p_country=="CORSICA") {document.write('<option value="CORSICA">Corsica</option>')
	} else if(p_country=="CROATIA") {document.write('<option value="CROATIA">Croatia</option>')
	} else if(p_country=="CYPRUS") {document.write('<option value="CYPRUS">Cyprus</option>')
	} else if(p_country=="CZECH REPUBLIC") {document.write('<option value="CZECH REPUBLIC">Czech Republic</option>')
	} else if(p_country=="DENMARK") {document.write('<option value="DENMARK">Denmark</option>')
	} else if(p_country=="ESTONIA") {document.write('<option value="ESTONIA">Estonia</option>')
	} else if(p_country=="FINLAND") {document.write('<option value="FINLAND">Finland</option>')
	} else if(p_country=="FRANCE") {document.write('<option value="FRANCE">France</option>')
	} else if(p_country=="GERMANY") {document.write('<option value="GERMANY">Germany</option>')
	} else if(p_country=="GREECE") {document.write('<option value="GREECE">Greece</option>')
	} else if(p_country=="GUERNSEY") {document.write('<option value="GUERNSEY">Guernsey</option>')
	} else if(p_country=="HONG KONG") {document.write('<option value="HONG KONG">Hong Kong</option>')
	} else if(p_country=="HUNGARY") {document.write('<option value="HUNGARY">Hungary</option>')
	} else if(p_country=="INDIA") {document.write('<option value="INDIA">India</option>')
	} else if(p_country=="ISRAEL") {document.write('<option value="ISRAEL">Israel</option>')
	} else if(p_country=="ITALY") {document.write('<option value="ITALY">Italy</option>')
	} else if(p_country=="JAMAICA") {document.write('<option value="JAMAICA">Jamaica</option>')
	} else if(p_country=="JAPAN") {document.write('<option value="JAPAN">Japan</option>')
	} else if(p_country=="JERSEY") {document.write('<option value="JERSEY">Jersey</option>')
	} else if(p_country=="LATVIA") {document.write('<option value="LATVIA">Latvia</option>')
	} else if(p_country=="LUXEMBOURG") {document.write('<option value="LUXEMBOURG">Luxembourg</option>')
	} else if(p_country=="MALAYSIA") {document.write('<option value="MALAYSIA">Malaysia</option>')
	} else if(p_country=="MALTA") {document.write('<option value="MALTA">Malta</option>')
	} else if(p_country=="MEXICO") {document.write('<option value="MEXICO">Mexico</option>')
	} else if(p_country=="MONACO") {document.write('<option value="MONACO">Monaco</option>')
	} else if(p_country=="MOROCCO") {document.write('<option value="MOROCCO">Morocco</option>')
	} else if(p_country=="NETHERLANDS") {document.write('<option value="NETHERLANDS">Netherlands</option>')
	} else if(p_country=="NEW ZEALAND") {document.write('<option value="NEW ZEALAND">New Zealand</option>')
	} else if(p_country=="NORWAY") {document.write('<option value="NORWAY">Norway</option>')
	} else if(p_country=="PAKISTAN") {document.write('<option value="PAKISTAN">Pakistan</option>')
	} else if(p_country=="PHILIPPINES") {document.write('<option value="PHILIPPINES">Philippines</option>')
	} else if(p_country=="POLAND") {document.write('<option value="POLAND">Poland</option>')
	} else if(p_country=="PORTUGAL") {document.write('<option value="PORTUGAL">Portugal</option>')
	} else if(p_country=="POLAND") {document.write('<option value="POLAND">Poland</option>')
	} else if(p_country=="IRELAND, REPUBLIC OF") {document.write('<option value="IRELAND, REPUBLIC OF">Ireland, Republic Of</option>')
	} else if(p_country=="ROMANIA") {document.write('<option value="ROMANIA">Romania</option>')
	} else if(p_country=="RUSSIA") {document.write('<option value="RUSSIA">Russia</option>')
	} else if(p_country=="SAUDI ARABIA") {document.write('<option value="SAUDI ARABIA">Saudi Arabia</option>')
	} else if(p_country=="SINGAPORE") {document.write('<option value="SINGAPORE">Singapore</option>')
	} else if(p_country=="SLOVAKIA") {document.write('<option value="SLOVAKIA">Slovakia</option>')
	} else if(p_country=="SLOVENIA") {document.write('<option value="SLOVENIA">Slovenia</option>')
	} else if(p_country=="SOUTH AFRICA") {document.write('<option value="SOUTH AFRICA">South Africa</option>')
	} else if(p_country=="SOUTH KOREA") {document.write('<option value="SOUTH KOREA">South Korea</option>')
	} else if(p_country=="SPAIN") {document.write('<option value="SPAIN">Spain</option>')
	} else if(p_country=="SWEDEN") {document.write('<option value="SWEDEN">Sweden</option>')
	} else if(p_country=="SWITZERLAND") {document.write('<option value="SWITZERLAND">Switzerland</option>')
	} else if(p_country=="TURKEY") {document.write('<option value="TURKEY">Turkey</option>')
	} else if(p_country=="UNITED STATES OF AMERICA") {document.write('<option value="UNITED STATES OF AMERICA">USA</option>')
	} else if(p_country=="UKRAINE") {document.write('<option value="UKRAINE">Ukraine</option>')
	}
	document.write('</select><td>')

	if (p_fromhome=="Y") {
		document.write('<td width="82" rowspan="3" align="center"><input name="ACTION" type="image" src="acatalog/GETQUOTE.jpg" tabindex=7/></td>')
	} else {
		document.write('<td width="82" rowspan="3" align="center"><input name="ACTION" type="image" src="GETQUOTE.jpg" tabindex=7/></td>')
	}
	document.write('</tr>')
	document.write('<tr><td  height="35" class="qqtext">')
	document.write(' From Postcode (if known): <input type="text" size = "10" maxlength="10" name="POSTCODE" tabindex=2>')
	document.write(' Weight: <select name="WEIGHT" tabindex=3>')
	document.write('<option selected value="1">1</option><option value="2">2</option>')
	document.write('<option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option>')
	document.write('<option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option>')
	document.write('<option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option>')
	document.write('<option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option>')
	document.write('<option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option>')
	document.write('<option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option>')
	document.write('<option value="27">27</option><option value="28">28</option><option value="29">29</option><option value="30">30</option>')
	document.write('<option value="31">31</option><option value="32">32</option><option value="33">33</option><option value="34">34</option>')
	document.write('<option value="35">35</option><option value="36">36</option><option value="37">37</option><option value="38">38</option>')
	document.write('<option value="39">39</option><option value="40">40</option><option value="41">41</option><option value="42">42</option>')
	document.write('<option value="43">43</option><option value="44">44</option><option value="45">45</option><option value="46">46</option>')
	document.write('<option value="47">47</option><option value="48">48</option><option value="49">49</option><option value="50">50</option>')
	document.write('<option value="51">51</option><option value="52">52</option><option value="53">53</option><option value="54">54</option>')
	document.write('<option value="55">55</option><option value="56">56</option><option value="57">57</option><option value="58">58</option>')
	document.write('<option value="59">59</option><option value="60">60</option><option value="61">61</option><option value="62">62</option>')
	document.write('<option value="63">63</option><option value="64">64</option><option value="65">65</option><option value="66">66</option>')
	document.write('<option value="67">67</option><option value="68">68</option><option value="69">69</option><option value="70">70</option>')
	document.write('</select> Kg</td></tr>')

	document.write('<tr><td height="35"><b><span style="color:white;">Dimensions in Cm: </span></b>')
	document.write('<span class="qqtext">Length: <input type="text" size = "3" maxlength="3" name="PARCELLENGTH" tabindex=4>')
	document.write(' Width: <input type="text" size = "3" maxlength="3" name="PARCELWIDTH" tabindex=5>')
	document.write(' Height: <input type="text" size = "3" maxlength="3" name="PARCELHEIGHT" tabindex=6></span></td></tr>')
	document.write('</table></table></form>')
}

function isInteger(s){return parseInt(s,10)===s;}

function isInteger1(s){
	var i;
	for (i = 0; i < s.length; i++){   
// Check that current character is number.
		var c = s.charAt(i);
		if (((c < "0") || (c > "9"))) return false;
	}
// All characters are numbers.
	return true;
}
