var slideShowSpeed = 3000
var crossFadeDuration = 1
var Pic = new Array() 
var numImages=3;
for (i=0; i<numImages; i++)
{
  Pic[i] = "images/slideshow"+(i+1)+".jpg";
}
var t
var j = 0
var p = Pic.length
var preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = Pic[i]
}
function runSlideShow()
{
   if (document.all){
      document.images.SlideShow.style.filter="blendTrans(duration=2)"
      document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
      document.images.SlideShow.filters.blendTrans.Apply()      
   }
   document.images.SlideShow.src = preLoad[j].src
   if (document.all){
      document.images.SlideShow.filters.blendTrans.Play()
   }
   j = j + 1
   if (j > (p-1)) j=0
   if (document.images)
   {
      t = setTimeout('runSlideShow()', slideShowSpeed)
   }
}
function checkOther(postcode)
{
    if(postcode == '0')
    {
        document.all.postcodeSpan.innerHTML = "<input type='text' name='postcodeOther' size='4' class='silverBorder'>";
        document.all.postcodeOther.focus();
    }
    else
    {
        document.all.postcodeSpan.innerHTML = '';
    }
}
function applyCoupon()
{
    var couponCode = document.getElementById('discountCoupon').value;
	location.href='applyVoucher.asp?couponCode='+ couponCode + '&t=' + new Date().getTime();
}
function checkCaptcha()
{
    if(document.all.secPic.value == '')
    {
        alert('Please type the red letters and numbers into the red box above.\nThis is to protect our system from SPAM emails and viruses.');
        document.all.secPic.focus();
        return false;
    }
    if(document.all.name.value == '')
    {
        alert('Please enter your name into the box provided.');
        document.all.name.focus();
        return false;
    }    
    if(document.all.comments.value == '')
    {
        alert("You don't seem to have entered any feedback into the comments box!");
        document.all.comments.focus();
        return false;
    }    
    return true;
}
function link(url, siteID) {
    var baseURL = '';
    if (siteID == 1) {
        baseURL = 'http://www.posmarket.co.nz/' + url;
    }
    else {
        baseURL = 'http://www.posmarket.com.au/' + url;
    }
    location.href = baseURL;
}
function checkEnquiryForm() {
    var customerName = document.all.customerName.value;
    if (customerName != null) { customerName = trimAll(customerName) }
    
    var customerEmail = document.all.customerEmail.value;
    if (customerEmail != null) { customerEmail = trimAll(customerEmail) }
    
    var customerPhone = document.all.customerPhone.value;
    if (customerPhone != null) { customerPhone = trimAll(customerPhone) }
    
    var errorText = 'You seem to be missing some required information:\n';
    error = false;
    if (customerName == '')
    {
        errorText = errorText + '* Your Name\n';
        error = true;
    }
    if (customerEmail == '' && customerPhone == '')
    {
        errorText = errorText + '* Contact Method\n';
        error = true;
    }
    if (error == false)
    {
        document.enquiryBox.submit();
    }
    else
    {
        alert(errorText);
    }
}
function trimAll(sString) {
    while (sString.substring(0, 1) == ' ') {
        sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length - 1, sString.length) == ' ') {
        sString = sString.substring(0, sString.length - 1);
    }
    return sString;
} 