// image preloader
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

// function to prevent right-click menu from appearing
function click(e)
 {
if (document.all)
   { if (event.button == 2)
        { alert('sorry, right-click disabled');
		  return false; } }
if (document.layers)
   { if (e.which == 3)
        { alert('sorry, right-click disabled');
		  return false; } }
 }
if (document.layers) { document.captureEvents(Event.MOUSEDOWN); }
document.onmousedown=click;

// function to build a custom pop-up window
function WinPop(url,name,width,height,bars)
 {
if (! bars) { bars = 'no'; }
var iMyWidth = (screen.width/2) - (width/2);
var iMyHeight = (screen.height/2) - (height/2);
var OpenWindow=window.open(url,name, config="height=" + height + ",width=" + width + ",left=" + iMyWidth + ",top=" + iMyHeight + ",screenx=" + iMyWidth + ",screeny=" + iMyHeight + ",scrollbars=" + bars); }

// function to clean non-numeric characters from qty boxes
function ClnNum(string)
 {
for (var i=0, output='', valid="1234567890"; i<string.length; i++)
    if (valid.indexOf(string.charAt(i)) != -1)
       output += string.charAt(i)
return output;
 }

// function to clean dirty content from text boxes
function ClnTxt(string)
 {
for (var i=0, output='', valid="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ&@_-=!+.,*() "; i<string.length; i++)
    if (valid.indexOf(string.charAt(i)) != -1)
       output += string.charAt(i)
return output;
 }

// alternative function to clean dirty content from text boxes (allows currency characters etc)
function ClnChk(string)
 {
for (var i=0, output='', valid="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-.()*$£€/ "; i<string.length; i++)
    if (valid.indexOf(string.charAt(i)) != -1)
       output += string.charAt(i)
return output;
 }
 
// function to generate unique milliseconds starts (for unique WinPop refs etc)
function GetRandomTime()
 { 
var d = new Date();
var msec = d.getMilliseconds();
var url = "pl" + msec;
return url;
 }	

// dynamic RPC function starts
function DynRPC(url)
 {
var ns4=document.layers; var ie4=document.all; var ns6=document.getElementById&&!document.all;
var FrameURL = "<iframe name='RPCFrame' src='" + url + "' style='width:0; height:0;' frameborder='0' marginwidth='0' marginheight='0'>";
crossobj=ns6? document.getElementById("rpcspace") : document.all.rpcspace
if (ie4||ns6)
   { document.all.rpccontent.innerHTML = FrameURL; }
else if (ns4)
   { document.rpcspace.document.rpccontent.innerHTML = FrameURL; }
 }
 
// tab section toggler - Product Info - starts
function ToggleTabInfo(which)
 {
// declare tab sections
var Tabs = new Array(); Tabs[0] = "details"; Tabs[1] = "specs"; Tabs[2] = "docs"; Tabs[3] = "related";
// hide all non-selected divs
for(x=0; x<Tabs.length; x++)
   { if(Tabs[x] != which)
       { eval("document.all." + Tabs[x] + ".style.display = 'none'"); }
   }
// reveal selected div
eval("document.all." + which + ".style.display = ''");
document.forms[0].search.focus();
 }
// tab section toggler - Product Info - ends			 

// contact form field checker v2
function CheckMailer()
{
var epicfail = 0;

if ((document.enquiry.first_name.value == "") || (document.enquiry.last_name.value == "") || (document.enquiry.company.value == "") || (document.enquiry.address1.value == "") || (document.enquiry.postcode.value == "") || (document.enquiry.phone.value == "") || (document.enquiry.email.value == ""))
  { epicfail = 1;
  }

if (epicfail  > 0)
  { alert("Please complete the following fields before submitting your enquiry: \r\n - full name \r\n - company \r\n - address line 1 \r\n - post code \r\n - telephone numer \r\n - email address");
    return false; }
else
  { return true; }
}
// contact form checker ends