function AddBasket(StockID) {
    var Fail;
    var Msg;
    var ConfirmMsg;
    Fail = false;
    Msg = "";
    ConfirmMsg = "Are you sure you want to add this product to your basket without";

    try { if (document.getElementById("ctl00_ContentPlaceHolder1_ctl00_SizeDropDown").options.length > 1) { if (document.getElementById("ctl00_ContentPlaceHolder1_ctl00_SizeDropDown").value == "") { Fail = true; Msg = Msg + "Please select a colour\n" } } } catch (err) { };
    try { if (document.getElementById("ctl00_ContentPlaceHolder1_ctl00_ColourDropDown").options.length > 1) { if (document.getElementById("ctl00_ContentPlaceHolder1_ctl00_ColourDropDown").value == "") { Fail = true; Msg = Msg + "Please select a option\n" } } } catch (err) { };
    try { if (document.getElementById("ctl00_ContentPlaceHolder1_ctl00_StyleDropDown").options.length > 1) { if (document.getElementById("ctl00_ContentPlaceHolder1_ctl00_StyleDropDown").value == "") { Fail = true; Msg = Msg + "Please select a option\n" } } } catch (err) { };

    if (Fail == true) {
        alert(Msg);
    }
    else {

        try { if (document.getElementById("BASKET_haspersonalisation").checked == false) { ConfirmMsg = ConfirmMsg + " Engraving and" } } catch (err) { };

        if (ConfirmMsg != "Are you sure you want to add this product to your basket without") {
            ConfirmMsg = ConfirmMsg.slice(0, ConfirmMsg.length - 4);
            if (window.confirm(ConfirmMsg)) {
                __doPostBack("ADDTOBASKET", "");
            }
        } else {
            __doPostBack("ADDTOBASKET", "");
        }
    }
}
function imposeMaxLength(Object, MaxLen) {
    return (Object.value.length <= MaxLen);
}
function toggleColour(row, colour) {
    row.style.backgroundColor = colour;
}

function toggleRow(id) {
    var row = document.getElementById("row" + id);
    var current = row.style.display;
    switch (current) {
        case "":
            row.style.display = "none";
            break
        case "none":
            row.style.display = "";
    }
}

function ClearMapSearch() {
    if (document.getElementById('MapSearch').value == 'enter place name...') {
        document.getElementById('MapSearch').value = '';
    }
}
function GoHover() {
    document.getElementById('SearchProducts').src = '/userpages/images/buttons/go2_hover.jpg';
}
function Go() {
    document.getElementById('SearchProducts').src = '/userpages/images/buttons/go2.jpg';
}
function DisableEnableLinks(xHow) {
    objLinks = document.getElementById("InfoBoxDesc").getElementsByTagName("a");
    for (i = 0; i < objLinks.length; i++) {
        objLinks[i].disabled = xHow;
        //link with onclick
        if (objLinks[i].onclick && xHow) {
            objLinks[i].onclick = new Function("return false;" + objLinks[i].onclick.toString().getFuncBody());
        }
        //link without onclick
        else if (xHow) {
            objLinks[i].onclick = function () { return false; }
        }
        //remove return false with link without onclick
        else if (!xHow && objLinks[i].onclick.toString().indexOf("function(){return false;}") != -1) {
            objLinks[i].onclick = null;
        }
        //remove return false link with onclick
        else if (!xHow && objLinks[i].onclick.toString().indexOf("return false;") != -1) {
            strClick = objLinks[i].onclick.toString().getFuncBody().replace("return false;", "")
            objLinks[i].onclick = new Function(strClick);
        }
    }
}

String.prototype.getFuncBody = function () {
    var str = this.toString();
    str = str.replace(/[^{]+{/, "");
    str = str.substring(0, str.length - 1);
    str = str.replace(/\n/gi, "");
    if (!str.match(/\(.*\)/gi)) str += ")";
    return str;
} 

function SetSortBy(varSortValue) {
    var strPrefix = "?";
    var URL = RemoveQuery("SortBy");

    if (URL.substring(0, 1) == "?") { strPrefix = "&"; }
    location.href = "productlist.aspx" + URL + strPrefix + 'SortBy=' + varSortValue;
}

function SetProdsPerPage(varValue) {
    var strPrefix = "?";
    var URL = RemoveQuery("PP");
    if (URL.substring(0, 1) == "?") { strPrefix = "&"; }
    location.href = "productlist.aspx" + URL + strPrefix + 'PP=' + varValue;
}
function RemoveQuery(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    var URL = "";
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0].toString().toLowerCase() != variable.toString().toLowerCase()) {
            URL = URL + '&' + pair[0] + '=' + pair[1];
        }
    }
    if (URL.toString().substring(0, 1) == '&') {
        URL = '?' + URL.toString().substring(1, URL.toString().length);
    }
    return URL;
}

function returnMaps(varMapType) {
    location.href = "/osmapsearch.aspx?f1=os maps&searchstring=" + document.getElementById("MapSearch").value + "&maptype=" + varMapType;
    return false;    
}
function ShowThumb(varThumb) {
    var Image1;
    var Image2;
    var ImgHref;
    ImgHref = document.getElementById("MainImage").href;
    Image1 = document.getElementById("imgMain").src;
    Image2 = document.getElementById("imgThumb" + varThumb).src.replace("_Small", "_Large");
    document.getElementById("imgMain").src = Image2;
    ImgHref = ImgHref.substring(0,ImgHref.length-1);
    ImgHref = ImgHref + varThumb;
    document.getElementById("MainImage").href = ImgHref;

}

function AddToBasketList(PID) {
    var Qty = document.getElementById("Qty_" + PID).value;

    AjaxGetData("/basket/AddProductToBasket.aspx?ProductID=" + PID + '&Qty=' + Qty, AjaxHandler_AddToBasket);

    document.getElementById("ProductListAdded_" + PID).style.display = '';
    document.getElementById("Qty_" + PID).value = 1;
    SetTimer(PID)
}
function SetTimer(PID) {
    setTimeout(function () { document.getElementById("ProductListAdded_" + PID).style.display = 'none' }, 3000);
}
// function will loop through all input tags and create
// url string from checked checkboxes
function GetAdditionalProducts(StockID) {
    var Qty = document.getElementById("Qty_" + StockID).value
	var counter = 0;  // counter for checked checkboxes
	var i       = 0;  // loop variable
	var url     = ''; // final url string
	// get a collection of objects with the specified 'input' TAGNAME
	var input_obj = document.getElementsByTagName('input');
	// loop through all collected objects
	for (i=0; i < input_obj.length; i++){
		// if input object is checkbox and checkbox is checked then ...
		if (input_obj[i].type == 'checkbox' && input_obj[i].checked == true){
			// ... increase counter and concatenate checkbox value to the url string
			counter++;
			url = url + ', ' + input_obj[i].value;
		}
    }

	// display url string or message if there is no checked checkboxes
    if (counter > 0) {
        // remove first '&' from the generated url string
        url = url.substr(1);
        // display final url string
        setTimeout(function () {
            window.location = '/basket/addmultipletobasket.aspx?StockID=' + StockID + '&Stock_Qty=' + Qty + '&AddProductID=' + url
        }, 0);
    } else {
        //FIREFOX DOES NOT LIKE &AMP;
        setTimeout(function () {
            window.location = '/basket/addmultipletobasket.aspx?StockID=' + StockID + '&Stock_Qty=' + Qty; 
        }, 0);
        
    }
}

function PostSingleProduct(StockID) {
    var Qty = document.getElementById("Qty_" + StockID).value
    window.location = '/basket/addmultipletobasket.aspx?StockID=' + StockID + '&amp;Stock_Qty=' + Qty;
}
    
function showhide(id) {
    if (document.getElementById) {
        obj = document.getElementById(id);
        if (obj.style.display == "none") {
            obj.style.display = "block";
            document.getElementById("Arrow").src = '/userpages/images/buttons/Basket_ArrowUp.jpg';
        }
        else {
            obj.style.display = "none";
            document.getElementById("Arrow").src = '/userpages/images/buttons/Basket_Arrow.jpg';
        }
    }
}
function ValidateLogin() {
    alert("validation here");
}
function setShipping(varID) {
    self.location.href = "/basket/basket.aspx?ShippingID=" + varID;
}

function SetShippingWrapper(varID) {
    try {
        document.getElementById("ShippingDisplayInfo_" + varID).style.display = "";
        document.getElementById("ShippingWrapper_" + varID).setAttribute("class", "ShippingWrapperBorder");
    }
    catch (e) { }
}

function popUp(URL, width, height, scroll) {
    var settings
    settings = "width=" + width + ",height=" + height + ",scrollbars=" + scroll + ",toolbar=no";
    popwin = window.open(URL, "FAFSPORT", settings);
    popwin.focus();
}

function ShowChangePasswords() {
    if (document.getElementById("ctl00_ContentPlaceHolder1_ChangePassword").checked == true) {
        document.getElementById("ChangePassword").style.display = 'block';
        document.getElementById("ChangePasswordC").style.display = 'block';
    } else {
        document.getElementById("ChangePassword").style.display = 'none';
        document.getElementById("ChangePasswordC").style.display = 'none';
    }
}

function ValidateEditMyDetails() {
    var sMsg = '';
    if (document.getElementById("ctl00_ContentPlaceHolder1_TitleEdit").value == '') { sMsg = sMsg + 'Please enter your title.\n'; }
    if (document.getElementById("ctl00_ContentPlaceHolder1_FirstName").value == '') { sMsg = sMsg + 'Please enter your first name.\n'; }
    if (document.getElementById("ctl00_ContentPlaceHolder1_Surname").value == '') { sMsg = sMsg + 'Please enter your surname.\n'; }
    if (document.getElementById("ctl00_ContentPlaceHolder1_Address1").value == '') { sMsg = sMsg + 'Please enter the first line of your address.\n'; }
    if (document.getElementById("ctl00_ContentPlaceHolder1_Town").value == '') { sMsg = sMsg + 'Please enter your town/city.\n'; }
    if (document.getElementById("ctl00_ContentPlaceHolder1_Postcode").value == '') { sMsg = sMsg + 'Please enter your postcode.\n'; }
    if (document.getElementById("ctl00_ContentPlaceHolder1_Email").value == '') { sMsg = sMsg + 'Please enter your email address.\n'; }
    if (document.getElementById("ctl00_ContentPlaceHolder1_Telephone").value == '') { sMsg = sMsg + 'Please enter your telephone number.\n'; }
    if (sMsg == '') { return true; } else { alert(sMsg); return false; }
}

function ShowOther() {
    if (document.getElementById("ctl00_ContentPlaceHolder1_TitleEdit").value == 'Other') {
        document.getElementById("OtherDescription").style.display = 'block';
    } else {
        document.getElementById("OtherDescription").style.display = 'none';
    }
}

function ShowIntrests() {
    if (document.getElementById("ctl00_ContentPlaceHolder1_CheckBox1").checked == true) {
        document.getElementById("Intrests").style.display = 'block';
    } else {
        document.getElementById("Intrests").style.display = 'none';
    }
}

function ShowInfo(strObj, strMsg) {
    HideInfo();
    document.getElementById('Tab' + strObj).src = '/userpages/images/static/Tab_' + strObj + '.jpg';
    document.getElementById('InfoBox' + strObj).style.display = 'block';
}
function ShowInfo2(strObj, strMsg) {
    HideInfo();
    document.getElementById('Tab' + strObj).src = '/userpages/images/static/Tab_' + strObj + '.jpg';
    document.getElementById('InfoBox' + strObj).style.display = 'block';
    window.location.hash = "description";
}
function ShowInfo3(strObj, strMsg) {
    HideInfo3();
    document.getElementById('Tab' + strObj).src = '/userpages/images/static/Tab_' + strObj + '.jpg';
    document.getElementById('InfoBox' + strObj).style.display = 'block';
}
function ShowInfo4(strObj, strMsg) {
    HideInfo3();
    document.getElementById('Tab' + strObj).src = '/userpages/images/static/Tab_' + strObj + '.jpg';
    document.getElementById('InfoBox' + strObj).style.display = 'block';
    window.location.hash = "description";
}
function ShowInfo5(strObj, strMsg) {
    HideInfo3();
    document.getElementById('Tab' + strObj).src = '/userpages/images/static/Tab_' + strObj + '.jpg';
    document.getElementById('InfoBox' + strObj).style.display = 'block';
    window.location.hash = "description";
}
function ShowInfo6(strObj, strMsg) {
    HideInfo4();
    document.getElementById('Tab' + strObj).src = '/userpages/images/static/Tab_' + strObj + '.jpg';
    document.getElementById('InfoBox' + strObj).style.display = 'block';
}
function HideInfo() {
    document.getElementById('TabDesc').src = '/userpages/images/static/Tab_Desc_Grey.jpg';
    document.getElementById('TabBuy').src = '/userpages/images/static/Tab_Buy_Grey.jpg';
    document.getElementById('TabManu').src = '/userpages/images/static/Tab_Manu_Grey.jpg';
    document.getElementById('TabSpec').src = '/userpages/images/static/Tab_Spec_Grey.jpg';
    document.getElementById('TabRevi').src = '/userpages/images/static/Tab_Revi_Grey.jpg';
    document.getElementById('InfoBoxRevi').style.display = 'none';
    document.getElementById('InfoBoxDesc').style.display = 'none';
    document.getElementById('InfoBoxBuy').style.display = 'none';
    document.getElementById('InfoBoxManu').style.display = 'none';
    document.getElementById('InfoBoxSpec').style.display = 'none';
}
function HideInfo3() {
    document.getElementById('TabDesc').src = '/userpages/images/static/Tab_Desc_Grey.jpg';
    document.getElementById('TabOptions').src = '/userpages/images/static/Tab_Options_Grey.jpg';
    document.getElementById('TabManu').src = '/userpages/images/static/Tab_Manu_Grey.jpg';
    document.getElementById('TabSpec').src = '/userpages/images/static/Tab_Spec_Grey.jpg';
    document.getElementById('TabRevi').src = '/userpages/images/static/Tab_Revi_Grey.jpg';
    document.getElementById('InfoBoxRevi').style.display = 'none';
    document.getElementById('InfoBoxDesc').style.display = 'none';
    document.getElementById('InfoBoxOptions').style.display = 'none';
    document.getElementById('InfoBoxManu').style.display = 'none';
    document.getElementById('InfoBoxSpec').style.display = 'none';
}

function HideInfo4() {
    document.getElementById('TabDesc').src = '/userpages/images/static/Tab_Desc_Grey.jpg';
    document.getElementById('TabManu').src = '/userpages/images/static/Tab_Manu_Grey.jpg';
    document.getElementById('TabSpec').src = '/userpages/images/static/Tab_Spec_Grey.jpg';
    document.getElementById('TabRevi').src = '/userpages/images/static/Tab_Revi_Grey.jpg';
    document.getElementById('InfoBoxRevi').style.display = 'none';
    document.getElementById('InfoBoxDesc').style.display = 'none';
    document.getElementById('InfoBoxManu').style.display = 'none';
    document.getElementById('InfoBoxSpec').style.display = 'none';
}
function CheckSearch(e) {
    if (e.keyCode == 13) {
        searchProducts();
    }    
}

function searchProducts() {
    var searchString = document.getElementById("SearchBox").value;
    searchString = searchString.replace(/&/gi, "");
    location.href = "/productlist.aspx?searchstring=" + searchString;
    return false;
}
function searchBrands() {
    location.href = "/productlist.aspx?f6=" + document.getElementById("Brands").value;
    return false;
}
function AjaxHandler_AddToBasket() {

    try {
        //readyState of 4 or 'complete' represents  
        //that data has been returned  
        if (req.readyState == 4 || req.readyState == 'complete') {
            //Item Added to basket
            try {
                document.getElementById("ProductAdded").style.display = '';
                document.getElementById("AddQty").value = '';
            }
            catch (ex) { }
            GetMiniBasket();
        }
    }
    catch (e) {
        alert('Error in Ajax respone:' + req.readyState);
    }

}

function GetMiniBasket() {
    AjaxGetData("/userpages/basketwebservice.aspx", AjaxHandler);
}

function AjaxGetData(url, responseHandler) {
    if (window.XMLHttpRequest) {
        // browser has native support for XMLHttpRequest object          
        req = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        // try XMLHTTP ActiveX (Internet Explorer) version          
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (req) {
        req.onreadystatechange = responseHandler;
        req.open('get', url, true);
        req.setRequestHeader("If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT");
        req.setRequestHeader("Cache-Control", "no-cache");
        req.setRequestHeader("content-type", "application/x-www-form-urlencoded");
        req.send('');
    }
    else { alert('Your browser does not seem to support XMLHttpRequest.'); }
}

function AjaxHandler() {

    try {
        //readyState of 4 or 'complete' represents  
        //that data has been returned  
        if (req.readyState == 4 ||
            req.readyState == 'complete') {
            document.getElementById('MiniBasket').innerHTML = req.responseText;
        }
    }
    catch (e) {
        alert('Error in Ajax respone:' + req.readyState);
    }
}

//created for accessories - doesnt work with multiple ID's
//onclick="ChangeAccessoryBg('Accessory_{CS_Product_ID}');"
var Clicks = 0;
function ChangeAccessoryBg(varObj) {
    document.getElementById(varObj).style.backgroundColor = '#000000';
    Clicks = Clicks + 1;
    if (Clicks == 2) {ChangeAccessoryBgBack(varObj);Clicks = 0;} 
}

function ChangeAccessoryBgBack(varObj) {
    document.getElementById(varObj).style.backgroundColor = '#ffffff';
}

function ShowText(varObj) {
    document.getElementById(varObj).style.display = 'block';
}
function HideText(varObj) {
    document.getElementById(varObj).style.display = 'none';
}


/****************left nav*****************/

function ShowLeftMenu(varID) {
    try {
        document.getElementById(varID).style.display = 'block';
    }
    catch (e) {}
}

function HideLeftMenu(varID) {
    try {
        document.getElementById(varID).style.display = 'none';
    }
    catch (e) { }
}

function AjaxHandler_Notes() {

    try {
        //readyState of 4 or 'complete' represents  
        //that data has been returned  
        if (req.readyState == 4 ||
            req.readyState == 'complete') {
            document.getElementById('AddNotesForm').innerHTML = req.responseText;
        }
    }
    catch (e) {
        alert('Error in Ajax respone:' + req.readyState);
    }
}
function addnote() {
    document.getElementById("AddNotesForm").style.display = '';
}

function GetAddNotes() {
    var OrderID = document.getElementById("OrderHistory_OrderID").value
    AjaxGetData("/userpages/addnotes.aspx?OID=" + OrderID + "", AjaxHandler_Notes)
}

function savenote() {
    var Note = document.getElementById("Notes_Notes").value.replace(/\r\n/g, "|-\r\n");
    var UserName = document.getElementById("Notes_UserName").value;
    var OrderID = document.getElementById("Notes_OrderID").value;
    var Action;
    var Message = "";

    AjaxGetData("/myaccount/savenote.aspx?OID=" + OrderID + "&User=" + UserName + "&Note=" + Note + "", AjaxHandler_Notes);
}

function AjaxHandler_NotesSend() {
    try {
        //readyState of 4 or 'complete' represents  
        //that data has been returned  
        if (req.readyState == 4 || req.readyState == 'complete') {
            savenote();
        }
    }
    catch (e) {
        alert('Error in Ajax respone:' + req.readyState);
    }
}

function setFilter(FilterID, FilterValue) {
    var qURL = "";
    if (FilterValue != '') {
        if (location.href.indexOf('?') != -1) {
            qURL = '&f' + FilterID + '=' + urlencode(FilterValue);
        }
        else {
            qURL = '?f' + FilterID + '=' + urlencode(FilterValue);
        }
        location.href = location.href + qURL;
    }
}
function urlencode(str) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: AJ
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: travc
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Lars Fischer
    // +      input by: Ratheous
    // +      reimplemented by: Brett Zamir (http://brett-zamir.me)
    // %          note 1: This reflects PHP 5.3/6.0+ behavior
    // *     example 1: urlencode('Kevin van Zonneveld!');
    // *     returns 1: 'Kevin+van+Zonneveld%21'
    // *     example 2: urlencode('http://kevin.vanzonneveld.net/');
    // *     returns 2: 'http%3A%2F%2Fkevin.vanzonneveld.net%2F'
    // *     example 3: urlencode('http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a');
    // *     returns 3: 'http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'

    var hexStr = function (dec) {
        return '%' + dec.toString(16).toUpperCase();
    };

    var ret = '',
            unreserved = /[\w.-]/; // A-Za-z0-9_.- // Tilde is not here for historical reasons; to preserve it, use rawurlencode instead
    str = (str + '').toString();

    for (var i = 0, dl = str.length; i < dl; i++) {
        var ch = str.charAt(i);
        if (unreserved.test(ch)) {
            ret += ch;
        }
        else {
            var code = str.charCodeAt(i);
            // Reserved assumed to be in UTF-8, as in PHP
            if (code === 32) {
                ret += '+'; // %20 in rawurlencode
            }
            else if (code < 128) { // 1 byte
                ret += hexStr(code);
            }
            else if (code >= 128 && code < 2048) { // 2 bytes
                ret += hexStr((code >> 6) | 0xC0);
                ret += hexStr((code & 0x3F) | 0x80);
            }
            else if (code >= 2048 && code < 65536) { // 3 bytes
                ret += hexStr((code >> 12) | 0xE0);
                ret += hexStr(((code >> 6) & 0x3F) | 0x80);
                ret += hexStr((code & 0x3F) | 0x80);
            }
            else if (code >= 65536) { // 4 bytes
                ret += hexStr((code >> 18) | 0xF0);
                ret += hexStr(((code >> 12) & 0x3F) | 0x80);
                ret += hexStr(((code >> 6) & 0x3F) | 0x80);
                ret += hexStr((code & 0x3F) | 0x80);
            }
        }
    }
    return ret;

}

var TestimonialArray = new Array(

'"This is just to confirm that the three Harveys maps (Lakeland West, East and Central) have arrived in the post this morning and to thank you for your courtesy and efficiency in rectifying the loss of the original despatch by Royal Mail. The whole issue was dealt with an understanding not often met in the world of e-sales. We shall certainly know where to come when next we order maps!, with appreciation and thanks" Yours sincerely University of Cumbria',

'"Thank you so much for your very speedy response to my query with regard to the Silva Compass. I have spoken to Paul and he was very helpful like you said and the anniversary compass is just what I want - in a leather pouch - so pleased - and he is sending it off tomorrow.  He knew who I was straight away!   I wish I could get such customer satisfaction with all the people I contact!!  You did really well.  Show this e-mail to your boss and ask for a promotion! Best wishes and thanks again" J Newman ',

'"Good morning, I would like to thank you for your very prompt replacement of the faulty Satmap unit which I returned to you last Friday. The replacement was safely received yesterday which is a wonderful service. When I so often find a need to complain it is very good to praise your attention". Many thanks N Totman',

'"Hello, I just wanted to thank you for your excellent service. I rang you yesterday afternoon wanting to buy a Huntsman knife.  I needed it for Saturday and you suggested I chose First Class post and thought it may get here in time.  Well, it actually arrived this morning!  Brilliant service as I only ordered it late afternoon yesterday.  It\'s just what we were after and I wanted you to know that I appreciate your helpfulness on the phone yesterday and fantastic customer service.  People are very quick to criticise companies and service and I only think it right to praise those that deserve credit and deliver a great service which you did. Thanks again". Best wishes M Laws',

'"Many thanks for your exceptional service in delivery of order no 15569. This was only ordered on Wednesday night and arrived on Saturday morning by 2nd class post. With this level of service I will definitely use your company for any further map requirements. Many thanks” Regards A Parkes',

'"Alan, “Many thanks for your help with this. The maps arrived at 8 this morning. If only everyone could be as efficient as you guys!!!!!!”regards Kevin',

'“Thanks Paul for your prompt reply. Your service is excellent and I will highly recommend you to anyone who needs maps.” Regards, Anne',

'“Hi Paul, Wow, that was very prompt, thanks for that - much appreciated! We\'ll be needing it this weekend for our trip to Cheddar so that\'s great news. I will endeavour to get to the Post Office tomorrow and let you know as soon as I\'ve posted them. Will obviously send first class. Thanks again,” Sarah',

'“Hi Paul, Thanks for your email and for keeping me informed, I have received the refund (thank you) and I just wanted to say how happy I am with your service. Thanks again” Kelly Payne',

'“Recieved goods,great service” Regards J Lawrence',

'“Hello Paul, Just to let you know i have received the map today. thanks for your reply and look forward to doing more business in the future. many thanks” N James',

'“Dear Mr Hopwood, Thanks for exchanging the map. You give  real service as it was a while ago I mistakenly ordered two of the same in succession. I will post it tomorrow so you should recieve by the end of the week. Thanks again" Anne',

'“Hi Paul, I\'m ever so grateful to you; it would be tragic to dissapoint the Scouts, many of whom are only 11 years old and very excited about taking part. We will use you again. It is a pleasure to do business with people so caring. Best wishes for your business to prosper.” Jim',

'Hi Paul, “Great news. The replacements have already arrived. Thanks for sorting it out so quickly. I\'ll be using you guys again - as we tour the whole country gradually in our motorhome!” Cheers, Julie',

'“Hi Paul, I arranged a re-delivery to a different address, and I now have them. Thank you very much for your care.” Tony',

'“Thank you SO much for your phone call this morning to reassure me - your customer service is great” J. Whitewright',

'"Paul, The bike mount has arrived today...thanks for your help and for keeping me in touch with progress.” With best wishes, Kevin',

'"Dear Paul, I ordered a Quincy globe to be delivered to my son\'s address on the 30-6-2010 it was delivered today 3-6-2010. thank you for your good service and prompt delivery". P Connors',

'"Hi Paul, Just like to say thanks for a brilliant service.  Got my replacements maps today.Many thanks". M John',

'"Thank you Paul that\'s perfect. I\'ve spoken to my grandma and she\'s happy to return it. You\'ve been a great help so thank you. Hope my boyfriend loves the globe after all the trouble you\'ve gone to!" Xxx',

'"Good afternoon Tracey,Thank you for your help and for the compass.I received the compass at my home in Edmonds, Washington, last Thursday.  You shipped on a Friday and I signed for it several days later.  It was very nice to get the compass so fast.  I sent a note to the Silva company in Livingston telling them about your great service and thanking them for recommending Above and Beyond. Thank you,"D Donchak USA',

'“Alan, Thank you for your request for comments on your service. I find the present system perfect for my needs and cannot imagine how it can be improved on. Obtaining the plans I require could not, for me, be more convenient or simpler. The online payment system and your monthly invoicing of plans downloaded is ideal as is your speedy response and help with any queries I may have regarding the use of the system.” N Pooley, N E England, Architect',

'"Alan, Please use our testimonial as below: ‘During our several years using you, we have always found the company and its representatives very helpful and entirely professional in the deliverance of their products. The service is first class, if there are ever any technical problems, you have a knack of forewarning you in advance and taking you through any remedial required. We have never considered using another supplier for the mapping service we receive and in all honesty we never will.’ regards, G Elvidge, N E England (specialists in Conservatory, Orangery Sales/Build)',

'“Alan, I have no suggestions for improvements and we are happy for you to use the following testimonial in promotional material:We have been buying Ordnance Survey map data from you since 2004: Excellent customer service and technical support!” L Bosveld, Graphics Production Manager, N E England (Universities)'

);


function SetTestimonial() {
    var r = Math.floor(Math.random() * (TestimonialArray.length - 1));
    document.getElementById('Testimonials').innerHTML = "<a href='/static.aspx?page=testimonials'>" + TestimonialArray[r] + "</a>";
}


function AddBespokeProducts() {
    var str = "";
    var strAlert = "";
    var HouseName = document.getElementById("BASKET_personalisation_textbox2").value;
    var StreetName = document.getElementById("BASKET_personalisation_textbox3").value;
    var Town = document.getElementById("BASKET_personalisation_textbox4").value;
    var County = document.getElementById("BASKET_personalisation_textbox5").value;
    var PostCode = document.getElementById("BASKET_personalisation_textbox").value;
    var GridReference = document.getElementById("BASKET_personalisation_textbox6").value;
    var LocationInfo = document.getElementById("LocationInfo").value;
    var StockID = document.getElementById("SelectedStockID").value;

    if (HouseName == "") { strAlert = strAlert + "Please enter the Property Name / Number\n" }
    if (StreetName == "" | Town == "" | County == "") { strAlert = strAlert + "Please enter all the address information\n" }
    if (PostCode == ""){ strAlert = strAlert + "Please enter the postcode\n" }

    if (strAlert == "") {
        location.href = "/userpages/bespoke/Order.aspx?StockID=" + StockID + "&HouseName=" + HouseName + "&StreetName=" + StreetName + "&Town=" + Town + "&County=" + County + "&PostCode=" + PostCode + "&Grid=" + GridReference + "&LocationInfo=" + LocationInfo + "";
    } else {
        alert(strAlert);
    }
    return false;
}

function ShowBespokeDescription(ProdCode){
    if (document.getElementById("BespokeLongDescription_" + ProdCode).style.display == ""){
        document.getElementById("BespokeLongDescription_" + ProdCode).style.display = "none";
        document.getElementById("BespokeProduct_" + ProdCode).scrollIntoView();
        
    }else{
        //showdeadcenterdiv(500, 700, "BespokeLongDescription_" + ProdCode);
        document.getElementById("BespokeLongDescription_" + ProdCode).style.display = "";
    }
}

function showdeadcenterdiv(Xwidth, Yheight, divid) {
    // First, determine how much the visitor has scrolled 

    var scrolledX, scrolledY;
    if (self.pageYoffset) {
        scrolledX = self.pageXoffset;
        scrolledY = self.pageYoffset;
    } else if (document.documentElement && document.documentElement.scrolltop) {
        scrolledX = document.documentElement.scrollLeft;
        scrolledY = document.documentElement.scrollTop;
    } else if (document.body) {
        scrolledX = document.body.scrollLeft;
        scrolledY = document.body.scrollTop;
    }

    // Next, determine the coordinates of the center of browser's window 

    var centerX, centerY;
    if (self.innerHeight) {
        centerX = self.innerWidth;
        centerY = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {
        centerX = document.documentElement.clientWidth;
        centerY = document.documentElement.clientHeight;
    } else if (document.body) {
        centerX = document.body.clientWidth;
        centerY = document.body.clientHeight;
    }

    // Xwidth is the width of the div, Yheight is the height of the 
    // div passed as arguments to the function: 
    var leftoffset = scrolledX + (centerX - Xwidth) / 2;
    var topoffset = scrolledY + (centerY - Yheight) / 2;
    // The initial width and height of the div can be set in the 
    // style sheet with display:none; divid is passed as an argument to // the function 
    var o = document.getElementById(divid);
    var r = o.style;
    r.position = 'absolute';
    r.top = topoffset + 'px';
    r.left = leftoffset + 'px';
    r.display = "block";
} 

function CheckMailing() {
    if (window.event.keyCode == 13) {
        MailingConfirm()
    }
}

function AjaxGetDataMail(url, responseHandler) {
    if (window.XMLHttpRequest) {
        // browser has native support for XMLHttpRequest object          
        reqMail = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        // try XMLHTTP ActiveX (Internet Explorer) version          
        reqMail = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (reqMail) {
        reqMail.onreadystatechange = responseHandler;
        reqMail.open('get', url, true);
        reqMail.setRequestHeader("If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT");
        reqMail.setRequestHeader("Cache-Control", "no-cache");
        reqMail.setRequestHeader("content-type", "application/x-www-form-urlencoded");
        reqMail.send('');
    }
    else { alert('Your browser does not seem to support XMLHttpRequest.'); }
}

function AjaxHandler_Mailing() {
    try {
        //readyState of 4 or 'complete' represents  
        //that data has been returned  
        if (reqMail.readyState == 4 ||
            reqMail.readyState == 'complete') {
            document.getElementById('MailingListResponse').innerHTML = reqMail.responseText;
        }
    }
    catch (e) {
        alert('Error in Ajax respone:' + reqMail.readyState);
    }

}

function MailingConfirm() {
    var Message = "";
    var Action = "";
    var Email = document.getElementById("MailingList").value;

    if (Email == "") { Message = Message + "Please enter your Email Address\n"; }
    if (Message == "") { Action = "True"; } else { Action = "False"; }
    if (Action == "True") { AjaxGetDataMail("/userpages/MailingSave.aspx?Email=" + Email, AjaxHandler_Mailing); } else { alert(Message); }
}

function ScrollBespoke(Product, TotalAmount, StockID) {
    document.getElementById("BespokeSelectedProductName").innerHTML = "<b>" + Product + '</b>';
    document.getElementById("BespokeSelectedProductPrice").innerHTML = '<b>&pound;' + TotalAmount + '</b>';

    document.getElementById("ctl00_ContentPlaceHolder1_SelectedStockID").value = StockID;

    document.getElementById("BespokeSelectedProductDefault").style.display = "none";
    document.getElementById("BespokeSelectedProduct").style.display = "";
    document.getElementById("BespokeInformation").scrollIntoView();
}


/* ************************************ PRODUCT REVIEW ************************************* */

function isValidEmail(str) {
    return (str.indexOf(".") > 0) && (str.indexOf("@") > 0);
}

function AddProductReview() {
    document.getElementById("ProductReviewAdd").style.display = "";
}

function ShowProductReview() {
    if (document.getElementById("ShowProductReviews").style.display != "") {
        document.getElementById("ShowProductReviews").style.display = "";
        document.getElementById("ShowHideReview").innerHTML = "<b>Hide Product Reviews</b>";
    } else {
        document.getElementById("ShowProductReviews").style.display = "none";
        document.getElementById("ShowHideReview").innerHTML = "<b>Show Product Reviews</b>";
    }

}

function AjaxGetDataProductReview(url, responseHandler) {
    if (window.XMLHttpRequest) {
        // browser has native support for XMLHttpRequest object          
        reqMail = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        // try XMLHTTP ActiveX (Internet Explorer) version          
        reqMail = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (reqMail) {
        reqMail.onreadystatechange = responseHandler;
        reqMail.open('get', url, true);
        reqMail.setRequestHeader("If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT");
        reqMail.setRequestHeader("Cache-Control", "no-cache");
        reqMail.setRequestHeader("content-type", "application/x-www-form-urlencoded");
        reqMail.send('');
    }
    else { alert('Your browser does not seem to support XMLHttpRequest.'); }
}

function AjaxHandler_ProductReview() {
    try {
        if (reqMail.readyState == 4 ||
            reqMail.readyState == 'complete') {
            document.getElementById('ProductReviewAdd').style.display = 'none';
            alert("Thank you for submitting a product review.")
        }
    }
    catch (e) {
        alert('Error in Ajax respone:' + reqMail.readyState);
    }

}

function SubmitProductReview() {
    var Message = "";
    var Action = "";
    var Code = document.getElementById("ProductCode").value;
    var Name = document.getElementById("ProductReviewName").value;
    var Email = document.getElementById("ProductReviewEmail").value;
    var Rating = document.getElementById("ProductReviewRating").value;
    var Review = document.getElementById("ProductReview").value;
    Review = Review.replace(/\r\n/g, "{CS_LineBreak}\r\n");

    if (isValidEmail(Email) == false) { Message = Message + "Invalid email address\n"; }
    if (Name == "") { Message = Message + "Please enter your Name\n"; }
    if (Rating == "" || Rating == "0") { Message = Message + "Please enter your Rating\n"; }
    if (Review == "") { Message = Message + "Please enter your Review\n"; }
    if (Message == "") { Action = "True"; } else { Action = "False"; }
    if (Action == "True") { AjaxGetDataProductReview("/productreviewsave.aspx?Code=" + Code + "&Name=" + Name + "&Rating=" + Rating + "&Email=" + Email + "&Review=" + Review, AjaxHandler_ProductReview); } else { alert(Message); }
}

function CheckBespokeLength() {
    if (document.getElementById("ctl00_ContentPlaceHolder1_LocationInfo").value.length > 255) {
        document.getElementById("ctl00_ContentPlaceHolder1_LocationInfo").value = document.getElementById("ctl00_ContentPlaceHolder1_LocationInfo").value.substr(0, 255);
    }
}
