
dayofweek=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");dayofmonth=new Array("","1st","2nd","3rd","4th","5th","6th","7th","8th","9th","10th","11th","12th","13th","14th","15th","16th","17th","18th","19th","20th","21st","22nd","23rd","24th","25th","26th","27th","28th","29th","30th","31st");months=new Array("January","February","March","April","May","June","July","August","September","October","November","December");function theDate(){var mydate=new Date();var year=mydate.getYear();if(year<1000)year+=1900;var day=mydate.getDay();var month=mydate.getMonth();var daym=mydate.getDate();todaysDate="  "+dayofweek[day]+" "+dayofmonth[daym]+" "+months[month]+" "+year;return todaysDate;}
function searchpagevalidate(ref){if(ref.keyword.value!='')
{return true;}
else
{alert('Need a keyword to \nsearch on!');return false;}}
function gotoarticle(sel)
{artID=sel.options[sel.selectedIndex].value;if(artID.length>0){aURL="index.xhtml?articleid="+artID;window.location.href=aURL;}}
function _forum_checkThreadForm(_forum_this){if(_forum_this.forum_topic.value.length==0){alert("You must enter a Title.");return false;}
if(_forum_this.forum_username.value.length==0){alert("You must enter your name to post to the forum.");return false;}
if(_forum_this.forum_body.value.length==0){alert("In order to post you need to enter text into the message.");return false;}
return true;}
function printWindow(){bV=parseInt(navigator.appVersion)
if(bV>=4)window.print()}
function checkNum(id){var checkstr=/^[1-9][0-9]*$/;if(checkstr.test(id.value)){id.value=id.value;}else{alert('You must specify a valid quantity');id.value=1;}}
function showProductStatus(f,itemAttribs,ProductStatus){qty=f.Quantity.value;if((qty=='')||(isNaN(parseInt(qty)))){qty=0;}else{qty=parseInt(qty);if(isNaN(qty)){qty=1;}else if(qty<0){qty=0-qty;}
f.Quantity.value=qty;}
selectAttribs="";for(i=0;i<f.length;i++)
{e=f.elements[i];if(e.name!=null&&e.name.substr(0,7)=="Attrib_"){if(e.type=="select-one")selectAttribs=selectAttribs+e.options[e.selectedIndex].value+",";if(e.type=="hidden")selectAttribs=selectAttribs+e.value+",";}}
selectAttribs=selectAttribs.substr(0,selectAttribs.length-1);for(i=1;i<itemAttribs.length-1;i++){if(itemAttribs[i]==selectAttribs){break;}}
if(ProductStatus[i].STK==0||ProductStatus[i].STK==-1){Avail='Unavailable';}else{Avail=ProductStatus[i].STK;}
f.Availability.value=Avail;if(Avail!='Unavailable'){if(f.PriceIncVAT!=null)f.PriceIncVAT.value=formatNum(ProductStatus[i].PRCinc);if(f.PriceExVAT!=null)f.PriceExVAT.value=formatNum(ProductStatus[i].PRCex);if(f.VAT!=null)f.VAT.value=formatNum(ProductStatus[i].VAT);if(f.TotalIncVAT!=null)f.TotalIncVAT.value=formatNum(f.PriceIncVAT.value*qty);f.Code.value=ProductStatus[i].CID;f.ProductOptionID.value=ProductStatus[i].PID;}else{if(f.PriceIncVAT!=null)f.PriceIncVAT.value="N/A";if(f.PriceExVAT!=null)f.PriceExVAT.value="N/A";if(f.VAT!=null)f.VAT.value="N/A";if(f.TotalIncVAT!=null)f.TotalIncVAT.value="N/A";f.Code.value="N/A";f.ProductOptionID.value="N/A";}}
function checkAvail(f){if(f.Availability.value==""||f.Availability.value=="Unavailable"){alert("   Sorry, this item is not\navailable with the options\n    you have selected.");return false;}else{return true;}}
function formatNum(value){value=""+value
precision=2;width=13;padding="";for(p=0;p<width;p++)padding+=" ";var whole=""+Math.round(value*Math.pow(10,precision));var decPoint=whole.length-precision;if(decPoint!=0){result=whole.substring(0,decPoint);result+=".";result+=whole.substring(decPoint,whole.length);}else{result=whole;}
result=padding+result;result=result.substring(result.length-width,result.length);return result;}