﻿function setAction( strActionName, strActionValue, strConfirm ) {
    var bConfirm;

    //  Request confirmation if necessary.
    if ( strConfirm != null ) {
        bConfirm = confirm( strConfirm );
    } else {
        bConfirm = true;
    }
    
    if ( bConfirm == true ) {

        //  Set the action.
        document.getElementById( "action_name" ).value = strActionName;
        document.getElementById( "action_value" ).value = strActionValue;

        //  Submit the form.
        document.getElementById( "aspnetForm" ).submit();
    }
}
function showHideOpeningHours() {
    var objHours = document.getElementById("ctl00_cntMain_hours");
    
    if ( objHours.style.display == "block" ) {
        objHours.style.display = "none";
    } else {
        objHours.style.display = "block";
    }
}
function showHideDiscount() {
    var objDiscount = document.getElementById("discount");
    
    if ( objDiscount.style.display == "block" ) {
        objDiscount.style.display = "none";
    } else {
        objDiscount.style.display = "block";
    }
}
function showHideVouchers() {
    var objVouchers = document.getElementById("vouchers");
    
    if ( objVouchers.style.display == "block" ) {
        objVouchers.style.display = "none";
    } else {
        objVouchers.style.display = "block";
    }
}
function showHideSelectedType( strPriceListID ) {
    var objPriceListItem = document.getElementById("ctl00_cntMain_" + strPriceListID);
    
    if ( objPriceListItem.style.display == "block" ) {
        objPriceListItem.style.display = "none";
    } else {
        objPriceListItem.style.display = "block";
    }
}

function checkLength(oObject) 
{

if (oObject.value.length<=60) 
return true;

else 
{ 

if ((event.keyCode>=37 && event.keyCode<=40) || (event.keyCode==8) || (event.keyCode==46)) 
event.returnValue = true;

else

event.returnValue = false; 
}

}

function numbersonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) || (key==32) )
   return true;

// numbers
else if ((("0123456789").indexOf(keychar) > -1))
   return true;
   
else
   return false;
}

function pricesonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if ((("0123456789.").indexOf(keychar) > -1))
   return true;

else
   return false;
}
var newwindow;
function macInstructions()
{
	newwindow=window.open('http://stationery.susanmolyneuxshop.co.uk/order/mac-instructions.htm','name','height=400,width=300');
	if (window.focus) {newwindow.focus()}
}