function LoadGallery(pictureName, imageFile) { var preload = document.getElementById('preload_'+current_preload); if(document.all) { document.getElementById('preloaded_img_'+current_preload).style.filter="blendTrans(duration=1)"; document.getElementById('preloaded_img_'+current_preload).filters.blendTrans.Apply(); document.getElementById('preloaded_img_'+current_preload).filters.blendTrans.Play(); } sty = preload.style; sty.display = 'none'; var new_preload = document.getElementById('preload_'+imageFile); if (document.all) { document.getElementById('preloaded_img_'+imageFile).style.filter="blendTrans(duration=1)"; document.getElementById('preloaded_img_'+imageFile).filters.blendTrans.Apply(); document.getElementById('preloaded_img_'+imageFile).filters.blendTrans.Play(); } sty = new_preload.style; sty.display = 'block'; current_preload = imageFile; } function popup2(topic) { aPopUp= window.open(topic,'PopupViewer','scrollbars=yes,location=no,status=no,menubar=0,directories=no,top=0,left=0,width=390,height=360,titlebar=no'); self.aNoteWin = aPopUp; return false; } function popup(topic, width, height) { aPopUp= window.open(topic,'PopupViewer','scrollbars=yes,location=no,status=no,menubar=0,directories=no,top=0,left=0,width='+width+',height='+height+',titlebar=no'); self.aNoteWin = aPopUp; return false; } function popupWindow(image_id, product_id) { LeftPosition = (screen.width) ? (screen.width-500)/2 : 0; TopPosition = (screen.height) ? (screen.height-500)/2 : 0; settings = 'height=737,width=485,top='+TopPosition+',left='+LeftPosition+',toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1'; win = window.open("/view_image.html?image_id=" + image_id+ "&product_id="+product_id,null,settings); } function confirmAction(strMsg) { var bAnswer = confirm (strMsg); if (bAnswer) { return true; } else { return false; } } /* Generic Form Validation */ window.onload = attachFormHandlers; function attachFormHandlers() { if (document.getElementsByTagName) { var objForm = document.getElementsByTagName('form'); for (var iCounter=0; iCounter<objForm.length; iCounter++) { objForm[iCounter].onsubmit = function(){return checkForm(this);} } } } function checkForm(objForm) { var arClass, bValid; var objField = objForm.getElementsByTagName('*'); for (var iFieldCounter=0; iFieldCounter<objField.length; iFieldCounter++) { arClass = objField[iFieldCounter].className.split(' '); for (var iClassCounter=0; iClassCounter<arClass.length; iClassCounter++) { switch (arClass[iClassCounter]) { case 'fullname': bValid = isName(objField[iFieldCounter].value.replace(/^\s*|\s*$/g, '')); break; case 'notempty' : bln = f[i].value != ''; break; case 'string': bValid = isString(objField[iFieldCounter].value.replace(/^\s*|\s*$/g, '')); break; case 'number' : bValid = isNumber(objField[iFieldCounter].value); break; case 'email' : bValid = isEmail(objField[iFieldCounter].value); break; case 'telephone' : bValid = isTelephone(objField[iFieldCounter].value); break; case 'postcode' : bValid = isPostcode(objField[iFieldCounter].value); break; case 'password' : bValid = isPassword(objField[iFieldCounter].value); break; case 'check' : bValid = isChecked(objField[iFieldCounter].checked); break; default: bValid = true; } if (bValid == false) { s = new String(objField[iFieldCounter].name); s = s.replace(/_/g," "); alert('Please review the value you entered for ' + s); objField[iFieldCounter].select(); objField[iFieldCounter].focus(); return false; } } } return true; } function strpos( haystack, needle, offset) { var i = haystack.indexOf( needle, offset); return i >= 0 ? i : false; } function isName(strValue) { return (typeof strValue == 'string' && strpos(strValue,' ',0) !== false && strValue != '' && isNaN(strValue)); } function isString(strValue) { return (typeof strValue == 'string' && strValue != '' && isNaN(strValue)); } function isNumber(strValue) { return (!isNaN(strValue) && strValue != ''); } function isChecked(blnChecked) { return blnChecked; } function isTelephone(strValue) { return (strValue != ''); } function isPostcode(strValue) { if(document.getElementById('postcode_mandatory')) { if(document.getElementById('postcode_mandatory').style.visibility == 'hidden') { return true; } else { return (strValue.length >= 3); } } else { return (strValue.length >= 3); } } function isPassword(strValue) { return (strValue != ''); } function isEmail(strValue) { var objRE = /^[\w-\.\']{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,}$/; return (strValue != '' && objRE.test(strValue)); } function centralisedpopup(mypage, myname, w, h, scroll, status) { var winl = (screen.width - w) / 2; var wint = (screen.height - h) / 2; winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',menubar=no,location=no,resize=yes,status='+status+''; win = window.open(mypage, myname, winprops); if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); } }

    var account_code = 'BANGL11112';
		var license_code = 'EH89-TJ24-AX74-CD43';

    function pcaFastAddressBegin()
    {
      var postcode = document.getElementById('postcode').value;
      var building = document.getElementById('house').value;
      if(postcode != '' && building != '')
      {
        var scriptTag = document.getElementById("pcaScriptTag");
        var headTag = document.getElementsByTagName("head").item(0);
        var strUrl = "";

        //Build the url
        strUrl = "http://services.postcodeanywhere.co.uk/inline.aspx?";
        strUrl += "&action=fetch";
        strUrl += "&postcode=" + escape(postcode);
        strUrl += "&building=" + escape(building);
        strUrl += "&account_code=" + escape(account_code);
        strUrl += "&license_code=" + escape(license_code);
        strUrl += "&callback=pcaFastAddressEnd";

        //Make the request
        if (scriptTag)
        {
          //The following 2 lines perform the same function and should be interchangeable
          headTag.removeChild(scriptTag);
          //scriptTag.parentNode.removeChild(scriptTag);
        }
        scriptTag = document.createElement("script");
        scriptTag.src = strUrl
        scriptTag.type = "text/javascript";
        scriptTag.id = "pcaScriptTag";
        headTag.appendChild(scriptTag);

      }
      else
      {
        alert("Please enter your house number or name and a valid postcode and try again.");
        return false;
      }
    }

		function pcaFastAddressEnd()
    {
      //Test for an error
      if (pcaIsError)
      {
        //Show the error message
        alert(pcaErrorMessage);
        return false;
      }
      else
      {
        //Check if there were any items found
        if (pcaRecordCount==0)
        {
          alert("Sorry, no matching items found");
          return false;
        }
        else
        {
          document.getElementById('address1').value = '' + pca_line1[0];
          document.getElementById('address2').value = '' + pca_line2[0];
          document.getElementById('town').value = '' + pca_post_town[0];
          document.getElementById('county').value = '' + pca_county[0];
          document.getElementById('postcode').value = '' + pca_postcode[0];
          return false;
        }
      }
    }


function doChangeImage(img) {
  document.getElementById('image_left').innerHTML = '<img src="'+img+'" border="0" align="middle" height="'+MAIN_IMAGE_HEIGHT+'" width="'+MAIN_IMAGE_WIDTH+'" />';
}

function changeBestSellerImg(src,href)
{
  //alert(src);
  document.getElementById("top_product_img").src=src;
  document.getElementById("top_product_link").href=href;
  //document['sim2'].src=src;
  return;
}

function scrollUp(elem)
{
  var scroller = document.getElementById(elem);
  if (scroller.scrollTop > 0)
  {
    scroller.scrollTop = scroller.scrollTop - 97;
  }
}
function scrollDown(elem)
{
  var scroller = document.getElementById(elem);
  if (scroller.scrollTop < scroller.scrollHeight)
  {
    scroller.scrollTop = scroller.scrollTop + 97;
  }
}

function getDocHeight(IFrameDoc) {
     return (typeof IFrameDoc.height != 'undefined') ?
                IFrameDoc.height :
            (IFrameDoc.body && typeof IFrameDoc.body.scrollHeight != 'undefined') ?
                IFrameDoc.body.scrollHeight :
                null;
}

function sizeToContent(iframe_ref) {

     var IFrameDoc, oIframe = document.getElementById(iframe_ref);

     if (typeof oIframe != null) {
         if (oIframe.contentDocument) IFrameDoc = oIframe.contentDocument;
         else if (oIframe.contentWindow) IFrameDoc = oIframe.contentWindow.document;
         else if (oIframe.document) IFrameDoc = oIframe.document;

     var hgt = getDocHeight(IFrameDoc);

     if (hgt) oIframe.style.height = String(hgt + 'px');
   }
}

