//<!--
//alert ("functions JS Included");

function emailThisPage()
{
    window.open('/emailafriend.asp','','width=542,height=446,toolbar=no,location=no,directories=no,status=no,scrollbars=no,menubar=no,resizable=no,');
}

function checkbid()
{
	TopBid = document.getElementById('TopBid');
	MyBid = document.getElementById('bid');
	if (parseInt(TopBid.value) > parseInt(MyBid.value))
	{
		
		alert("Your bid is not higher than the highest bid");
		return false;
	}
	else
	{
		return true;
	}
}

function getUID()
{

var oDate = new Date;
return (oDate.getUTCMilliseconds()*Math.random(1000));
}
function Genpassword(oElement)
{
		document.getElementById('MyFrame').src = '/_includes/genpassword.asp?element='+oElement;
			
}

function ViewFile(oElement)
{
	oElement = document.getElementById(oElement);
	var URL = oElement.value;
	window.open(oElement.value,'Viewfile','');
}

function UploadFile(URL)
{
	window.open(URL,'Upload','');
}

function toggleView(oElementID)
{
	if (document.getElementById(oElementID).style.display==""){document.getElementById(oElementID).style.display="none";}
	else{document.getElementById(oElementID).style.display="";}
}

function changeSelect(oElementID,iIndex)
{
	document.getElementById(oElementID).selectedIndex = iIndex;
}

function isEmail(field)
{
	return !(field.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)!=-1);
}

function isNumeric(field)
{
	return (field.search(/^[-|+]*\d*.{1}\d*$/)!=-1);}
function toggleStatus(oElementName)
{
	if(document.getElementById(oElementName).disabled == false){document.getElementById(oElementName).disabled = true}
	else{document.getElementById(oElementName).disabled = false}
}



function Decimalise(n) 
{
 var s = "" + Math.round(n * 100) / 100
 var i = s.indexOf('.')
 if (i < 0) return s + ".00"
 var t = s.substring(0, i + 1) + 
 s.substring(i + 1, i + 3)
 if (i + 2 == s.length) t += "0"
 return t
}


function swapImg(oImg)
{
src = oImg.src
if (src.search('on') ==-1){oImg.src =src.replace('_off','_on')}
else {oImg.src=src.replace('_on','_off')} 
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function clearTextBoxText(txtBox){
	txtBox.value = '';
}

function GetPrices(wdsCode,URL){
	window.open("/ProductPrice.asp?WDSNo=" + wdsCode+"&U="+URL, "ProdWin", "height=250,width=600,toolbar=no,location=no,directories=no,status=no")
}
function RingForAQuote(){
	window.open("/ringforaquote.asp", "RingForAQuote", "height=280,width=674,toolbar=no,location=no,directories=no,status=no")
}
function WDSCODEREG(data)
{
alert(data);
Expression = '[\d]{0,}-[\d]{0,}'
var preg = new RegExp(Expression);
if ( data.match(preg))
{
	return true;
}
else
{
	return false;
}
	
}

//<!--
//alert ("functions JS Included");
function validate(oForm,verbose){
//alert("running");
index=0;
var message='';
var loop=1;
var Style;
var validForm=true;
var validField=false;
var oTest;
var nElements=oForm.elements.length;
var formfeedback=oForm.getAttribute("feedback");
while(index<nElements){
oTest=oForm.elements[index];
type=oTest.type;
customScript=oTest.getAttribute("customScript");
name=oTest.getAttribute("name");
field=oTest.value;
fieldfeedback=oTest.getAttribute("feedback");
max=oTest.getAttribute("max");
min=oTest.getAttribute("min");
vtype=oTest.getAttribute("vtype");
vname=oTest.getAttribute("vname");
dField=oTest.getAttribute("dfield");
dValue=oTest.getAttribute("dvalue");
mandatory=oTest.getAttribute("mandatory");
warning=oTest.getAttribute("warning");
validCustom=true;
validFormat=true;
validRange=true;
validChars=true;
validMandatory=true;
validSelect=true;
validRadio=true;
if(customScript!=null){
validCustom=(eval(customScript))}
else{
validCustom='true';
if(dField!=null){
var dVal=eval("document.getElementById('"+dField+"')")
if(dVal.type=='radio'||dVal.type=='select-one'||dVal.type=='checkbox'){
var dStatus =(dValue=='true') 
if(dVal.status==dStatus)
mandatory='true'
else
mandatory='false'}		
else{
if(!isEmpty(dVal.value))
mandatory='true'
else
mandatory='false'}}
switch(type){
case'password':
case'text':
case'textarea':
if(!isEmpty(field))	{
validChars=true;
switch(vtype){
case'text':
field=field.replace(/"/g,"`");
validFormat=true;
break;
case'numeric':
validFormat = (field.search(/^([-|+]){0,1}(\d){0,}(\.){0,1}(\d){0,}$/) !=-1);
break;
case'email':
validFormat=(field.search(/\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)!=-1);
break;
case'url':
validFormat=(field.search(/^((\w+):\/\/)([\w.]+)(\/)?(\S*)$/)!=-1);
break;
case'Date'://uk format
validFormat=(field.search(/(((0[1-9]|[12][0-9]|3[01])([\/])(0[13578]|10|12)([\/])(\d{4}))|(([0][1-9]|[12][0-9]|30)([\/])(0[469]|11)([\/])(\d{4}))|((0[1-9]|1[0-9]|2[0-8])([\/])(02)([\/])(\d{4}))|((29)(\.|-|\/)(02)([\/])([02468][048]00))|((29)([\/])(02)([\/])([13579][26]00))|((29)([\/])(02)([\/])([0-9][0-9][0][48]))|((29)([\/])(02)([\/])([0-9][0-9][2468][048]))|((29)([\/])(02)([\/])([0-9][0-9][13579][26])))$/)!=-1);
//(field.search(/^((mon|tue|wed|thur|fri|sat|sun){1}\w{0,3}(day)?)(\\|\/|\s|.|-)?(1|2|3|)[0-9]((st|nd|rd|th)?){1}(\\|\/|\s|.|-){1}(((jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)(r|((t)?e)|o|y)?(uary|ch|((m)?ber)|il|aust)?)|((1|2)?[0-9])){1}(\\|\/|\s|.|-){1}((19|20)?\d{2})$/)!=-1);
break;
case'Time':
validFormat=(field.search(/^(20|21|22|23|[01]\d|\d)(([:.][0-5]\d){1,2})$/)!=-1);
break;
case'Date/Time':
validFormat=(field.search(/(((0[1-9]|[12][0-9]|3[01])([\/])(0[13578]|10|12)([\/])(\d{4}))|(([0][1-9]|[12][0-9]|30)([\/])(0[469]|11)([\/])(\d{4}))|((0[1-9]|1[0-9]|2[0-8])([\/])(02)([\/])(\d{4}))|((29)(\.|-|\/)(02)([\/])([02468][048]00))|((29)([\/])(02)([\/])([13579][26]00))|((29)([\/])(02)([\/])([0-9][0-9][0][48]))|((29)([\/])(02)([\/])([0-9][0-9][2468][048]))|((29)([\/])(02)([\/])([0-9][0-9][13579][26])))\s(20|21|22|23|[01]\d|\d)(([:.][0-5]\d){1,2})$/)!=-1);
break;
case'filename':
validFormat=(field.search(/^((\\\\[\w]+)|([A-Za-z]:\\))?([(\w|\s)+]+\\)?[\w]+[.{1}](jpg|bmp|gif|jpeg|pdf|doc|xls|mdb|ppt|txt|rtf)$/)!=-1);
break;
case'phone':
validFormat=(field.search(/^\d{4}\s*\d\s*\d{2}\s*\d\s*\d\s*\d{2}$/)!=-1);	
break;	
case'CC':
validFormat=(field.search(/^\d{4}\s*\d{4}\s*\d{4}\s*\d{4}\s*$/)!=-1);
break;	
case'Postcode':
validFormat=(field.search(/^(([A-PR-UWYZ]{1,2}[0-9]{1,2}[ABEHJMNPRVWXY]?)\s?([0-9][ABD-HJLNP-UW-Z]{2})|(GIR)\s?(0AA))$/)!=-1);
break;	
case'password':
//validFormat=(field.search(\w)!=-1);
break;
case 'WDSCODE':
validFormat=(field.search(/[\\d]{0,}-[\\d]{0,}/) !=-1);
break;
default:
validformat = true
break;
}			
switch(vtype){
case'numeric':
if(min!=null){
if(field.length<min){
validRange=false;
msgRange="\nIt is smaller then the minimum allowed value of "+min+"."}}
if(max!=null){
if(field.length>max){
validRange=false;
msgRange="\nIt is larger then the maximum allowed value of "+max+"."}}	
default:
if(min!=null){
if(field.length<min){
validRange=false;
msgRange="\nIt is smaller then the minimum allowed size of "+min+"."}}
if(max!=null){
if(field.length>max){
validRange=false;
msgRange="\nIt is larger then the maximum allowed size of "+max+"." }}}}		
else{
if(mandatory=='true')
validMandatory=false;}	
break;	
case'checkbox':
case'radio':
validRadio=false;
while(index<nElements){
oTest=oForm.elements[index];
if(oTest.name!=name){
index--
break;}
if(mandatory=='true')
validRadio=(validRadio||oTest.status);
else{
validRadio=true
validMandatory=true}
index++}
break;
case'hidden':		
case'button':		
break;
case'select-one':
if((oTest.selectedIndex==-1)||(oTest.value==''))
{
if(mandatory=='true')
validMandatory=false;
else
validMandatory=true;
}
else
validMandatory=true;
break;
default:
break;}}
validField=((validCustom=='true')&&validFormat&&validRange&&validChars&&validMandatory&&validRadio)
if(!validField){
if(formfeedback!='none'||fieldfeedback!=null){
message+='\nYou have not correctly filled in the '+vname+' field.'
if(!validChars)
//message+="\nIt contains invalid characters."
if(!validFormat)
message+="\n'+vname+' is not in the correct format."
if(!validRange)
//message+=msgRange
if(!validRadio)
//message+="\nDoes not have a value selected."
if(!validMandatory)
//message+="\n'+vname+' is a required field and does not appear to contain a value."
if(validCustom!='true')
message+=validCustom}}
if(!validField)
Style='#ff6600';
else
Style='';
switch(type){
case'select-one':
if(oTest.parentElement.tagName!='SPAN'){
var oMySelect=oTest;
var oNewSpan=document.createElement("SPAN");
oMySelect.parentElement.insertBefore(oNewSpan,oMySelect);
var oClone=oMySelect.cloneNode(true);
oNewSpan.insertAdjacentElement("afterbegin",oClone);
oMySelect.removeNode(true);
oClone.selectedIndex =oMySelect.selectedIndex;}
else
oNewSpan=oTest.parentElement
if(!validField)
oNewSpan.style.border="2px solid "+Style;
else
oNewSpan.style.border="none"
break;
default:
oForm.elements[index].style.borderColor=Style;
break;}
validForm=(validForm&&(validField||(warning=='true')))
if((formfeedback=='incremental'||fieldfeedback=='incremental')&&!validField)
break;
index++}
//if(!verbose)
//return true;
if(validForm)
return validForm;
else{
if(formfeedback!='none'||fieldfeedback=='incremental'){
message+='\nPlease correct the appropriate entries and resubmit.'
alert(message)}
return validForm;}}
function isEmpty(str){
if(str.length==0){
return true;}
if(str.search(/\S/)==-1){
return true;}
return false;}

function checkForm(oForm){
var index=0;var oElements=oForm.elements.length;
var formUsed=false;
while(index<oElements){var oTest=oForm.elements[index];var type=oTest.type;
switch(type){
case'text':
case'textarea':	formUsed=(formUsed || !isEmpty(oTest.value));
break;case'checkbox':formUsed=(formUsed || oTest.status);break;case 'select-one':
formUsed=(formUsed || (oTest.selectedIndex==-1)||(oTest.value==''));break;default:
//ignore everything else}
break;}
if(formUsed) break;index++}
if(formUsed)
return true;
else
return false;}
//-->