<!--

function OpenCertDetails()
{
    thewindow =window.open('https://www.thawte.com/cgi/server/certdetails.exe?code=GBWOOD10-3', 'anew',config='height=500,width=600,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
}


function zoom(image)
{
    var url = "showzoomimage.php?image=" + image;

    openWin(url, "zoom", 400, 400);
}

function addToBasket(f)
{
    errors = "The following errors have been found: \n\n";
    valid = true;

    var size = f.length;


    var valid_colour = true;
    var valid_size = true;
    var valid_style = true;
    var product_name = '';

    for(i=0;i<size;i++)
    {
        var field = f[i];
        var nm = field.name;

        if(nm.indexOf("name_arr")==0)
        {
            product_name = field.value;
        }

        if(nm.indexOf("colour")==0)
        {
            if(field.type=='select-one')
            {
                var val = field[field.selectedIndex].value;


                if(val=='')
                {
                    valid_colour = false;
                }
            }
        }


        if(nm.indexOf("size")==0)
        {
            if(field.type=='select-one')
            {
                var val = field[field.selectedIndex].value;

                if(val=='')
                {
                    valid_size = false;
                }
            }
        }

        if(nm.indexOf("style")==0)
        {
            if(field.type=='select-one')
            {
                var val = field[field.selectedIndex].value;

                if(val=='')
                {
                    valid_style = false;
                }
            }
        }

        if(nm.indexOf("quantity")==0)
        {
            var val = field.value;
            if(val>0)
            {
                if(!valid_colour)
                {
                    errors += "Please choose a colour for " + product_name + ".\n";
                    valid = false;
                }


                if(!valid_size)
                {
                    errors += "Please choose a size for " + product_name + ".\n";
                    valid = false;
                }

                if(!valid_style)
                {
                    errors += "Please choose a style for " + product_name + ".\n";
                    valid = false;
                }
            }

            // reset all
            valid_colour = true;
            valid_size = true;
            valid_style = true;
        }


    }

    if (!valid)
    {
        errors += "\nPlease try again";
        alert(errors);
    }
    else
    {
        f.submit();
    }
}

function checkPromo(f)
{
    errors = "The following errors have been found: \n\n";
    valid = true;

    if (f.promo_code.value == "")
    {
        errors += "- promotion code must be completed.\n";
        valid = false;
    }

    if (!valid)
    {
        errors += "\nPlease try again";
        alert(errors);
    }

    return valid;
}

function checkEnquiry(f)
{
    errors = "The following errors have been found: \n\n";
    valid = true;

    if (f.Email.value == "")
    {
        errors += "- Email must be completed.\n";
        valid = false;
    }
    else
    {
        email_errors = validateEmail(f.Email.value);
        if(email_errors != "")
        {
            errors += email_errors;
            valid = false;
        }
    }

    if (f.Enquiry.value == "")
    {
        errors += "- Enquiry must be completed.\n";
        valid = false;
    }

    if (!valid)
    {
        errors += "\nPlease try again";
        alert(errors);
    }

    return valid;
}

function checkCheckoutForm(f)
{
    errors = "The following errors have been found: \n\n";
    valid = true;

    if (f.contact_name.value == "")
    {
        errors += "- Your name must be completed.\n";
        valid = false;
    }

    if (f.email.value == "")
    {
        errors += "- Email must be completed.\n";
        valid = false;
    }
    else
    {
        email_errors = validateEmail(f.email.value);
        if(email_errors != "")
        {
            errors += email_errors;
            valid = false;
        }
    }

    if (f.tel.value == "")
    {
        errors += "- Telephone must be completed.\n";
        valid = false;
    }

    if (f.billing_line1.value == "")
    {
        errors += "- Address must be completed.\n";
        valid = false;
    }

    if (f.billing_town.value == "")
    {
        errors += "- Town must be completed.\n";
        valid = false;
    }

    if (f.billing_postcode.value == "")
    {
        errors += "- Postcode must be completed.\n";
        valid = false;
    }

    if (!valid)
    {
        errors += "\nPlease try again";
        alert(errors);
    }

    return valid;
}

function checkAddressForm(f)
{
    errors = "The following errors have been found: \n\n";
    valid = true;

    if (f.line1.value == "")
    {
        errors += "- Address must be completed.\n";
        valid = false;
    }

    if (f.town.value == "")
    {
        errors += "- Town must be completed.\n";
        valid = false;
    }

    if (f.postcode.value == "")
    {
        errors += "- Postcode must be completed.\n";
        valid = false;
    }

    if (!valid)
    {
        errors += "\nPlease try again";
        alert(errors);
    }

    return valid;
}

function checkCardDetails(f)
{
    errors = "The following errors have been found: \n\n";
    valid = true;

    if (f.cardtype[f.cardtype.selectedIndex].value == "")
    {
        errors += "- cardtype must be completed.\n";
        valid = false;
    }

    if (f.cardno.value == "")
    {
        errors += "- cardno must be completed.\n";
        valid = false;
    }

    if (f.security_no.value == "")
    {
        errors += "- security_no must be completed.\n";
        valid = false;
    }

    if (f.tomonth.value == "" || f.toyear.value == "")
    {
        errors += "- expiry date must be completed.\n";
        valid = false;
    }


    if (!valid)
    {
        errors += "\nPlease try again";
        alert(errors);
    }

    return valid;
}


function validateEmail(email_addr)
{
    if (email_addr == '' && man)
    {
        return '- email_address is mandatory.\n';
    }

    var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
    for (i=0; i<invalidChars.length; i++)
    {
        if (email_addr.indexOf(invalidChars.charAt(i),0) > -1)
        {
            return '- email_address contains invalid characters.\n';
        }
    }

    for (i=0; i<email_addr.length; i++)
    {
        if (email_addr.charCodeAt(i)>127)
        {
            return "- email_address contains non ascii characters.\n";
        }
    }

    var atPos = email_addr.indexOf('@',0);
    if (atPos == -1)
    {
        return '- email_address must contain an @\n';
    }

    if (atPos == 0)
    {
        return '- email_address must not start with @\n';
    }

    if (email_addr.indexOf('@', atPos + 1) > - 1)
    {
        return '- email_address must contain only one @\n';
    }

    if (email_addr.indexOf('.', atPos) == -1)
    {
        return '- email_address must contain a period in the domain name\n';
    }

    if (email_addr.indexOf('@.',0) != -1)
    {
        return '- period must not immediately follow @ in email email_address\n';
    }

    if (email_addr.indexOf('.@',0) != -1)
    {
        return '- period must not immediately precede @ in email email_address\n';
    }

    if (email_addr.indexOf('..',0) != -1)
    {
        return '- two periods must not be adjacent in email email_address\n';
    }

    var suffix = email_addr.substring(email_addr.lastIndexOf('.')+1);
    if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum')
    {
        return '- invalid primary domain in email email_address\n';
    }

    return '';
}


 function openWin(strFile, strName, intWidth, intHeight)
 {
     var strProperties = 'toolbar=no,width=' + Math.round(intWidth) + ',height=' + Math.round(intHeight) + ',left=30,top=150,' + 'status=yes,scrollbars=no,resizable=yes,menubar=no';
     tmpWin = window.open(strFile,strName,strProperties);
     tmpWin.focus();

}


//-->
