function clickButton(e, buttonid){ 
  var evt = e ? e : window.event;
  var bt = document.getElementById(buttonid);

  if (bt){ 
      if (evt.keyCode == 13){ 
         bt.click(); 
        return false; 
      } 
  } 
}


function ShowAlternativeImage(imageName, clientID)    {
    
    document.getElementById(clientID).src = '/images/ecommerce/standard/' + imageName;
    //document['mainImage'].src = '/images/ecommerce/mini/' + imageName;
}

function zoomProductImage(productImage) {
    
	if (productImage) {
		window.open('/Ecommerce/zoom.aspx?image=' + productImage,'ZOOM','width=700,height=700,scrollbars=no,resize=no');
    }
    
    //[RK] 21/12/06 - triggered from ImageButton so MUST return false
    return false;
}

function fitPic() {
	if (window.innerWidth){
		iWidth = window.innerWidth;
		iHeight = window.innerHeight;
	}else{
		iWidth = document.body.clientWidth;
		iHeight =document.body.clientHeight;
	}
	
	iWidth = document.images[0].width - iWidth;
	iHeight = document.images[0].height - iHeight;
	window.resizeBy(iWidth, iHeight);
}

function copyAddress()  {
    //[RK] 27/03/2007.
    //Uses hidden fields to allow us to access ASP.NET controls from Javascript.
    
    var prefix = document.forms['aspnetForm'].elements['jsPrefix'].value;
    var oForm = document.forms['aspnetForm']

    oForm.elements[prefix + '_DeliveryLine1TextBox'].value = oForm.elements[prefix + '_Line1TextBox'].value
    oForm.elements[prefix + '_DeliveryLine2TextBox'].value = oForm.elements[prefix + '_Line2TextBox'].value
    oForm.elements[prefix + '_DeliveryLine3TextBox'].value = oForm.elements[prefix + '_Line3TextBox'].value
    oForm.elements[prefix + '_DeliveryTownTextBox'].value = oForm.elements[prefix + '_TownTextBox'].value
    oForm.elements[prefix + '_DeliveryCountyTextBox'].value = oForm.elements[prefix + '_CountyTextBox'].value
    oForm.elements[prefix + '_DeliveryPostcodeTextBox'].value = oForm.elements[prefix + '_PostcodeTextBox'].value
    oForm.elements[prefix + '_DeliveryPhoneNumberTextBox'].value = oForm.elements[prefix + '_PhoneNumberTextBox'].value
    oForm.elements[prefix + '_DeliveryCountryDropDownList'].selectedIndex = oForm.elements[prefix + '_CountryDropDownList'].selectedIndex

}

function ConfirmOrder() {
    
    var prefix = document.forms['aspnetForm'].elements['jsPrefix'].value;
    var oForm = document.forms['aspnetForm']
    //alert('prefix=' + prefix)
    
    
    var confirmButton =  document.getElementById(prefix + '_OrderOptionsPanelNextButton');
    var cvnNumber = document.getElementById(prefix + '_CVNTextBox').value;
    
    
    //If the issue number is valid too, then disable the button so we dont get multiple submissions
    if (cvnNumber.length == 3)  {
        confirmButton.src = '/images/buttons/pleasewait.gif';
        confirmButton.style.cursor = 'wait';
        //confirmButton.onclick.value = '';
        return true;
        
        //oForm.submit();

        //confirmButton.disabled = true;
    }
}


function GlossaryTerm(term) {

	if (term) {
		window.open('/Glossary/Term.aspx?term=' + term, 'Glossary','width=450,height=350,scrollbars=yes,resize=no');
    }
}


function SubmitSecureIFrame() {
    document.forms['secureForm'].submit()
}

function showCustomImage(imageUrl)
{
    //alert('in');
    
	document.getElementById('customImage').src = imageUrl;
}