
// ALL WORKSHOP FORM SCRIPTS

//         places booked	    display when more than
var portland_places  = 17	;var portland_show  = 10
var solvang_places   = 14	;var solvang_show   = 10
var concord_places   = 9	;var concord_show   = 10
var loveland_places  = 6	;var loveland_show  = 10

var ottawa_places    = 21	;var ottawa_show    = 10
var calgary_places   = 7	;var calgary_show   = 6
var vancouver_places = 13	;var vancouver_show = 10

var macOS    = navigator.userAgent.indexOf("mac") != -1 || navigator.userAgent.indexOf("Mac") != -1

function onEnter() {
    var evt  = (evt) ? evt : ((event) ? event : null);
    var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
    if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
  }
  document.onkeypress = onEnter

function checkStart()  {
 if(opt =='0'){alert('Please select your workshop by\n\nclicking the box next to its name')
 fees= '0'
 this.checked = true}
}
function checkTot()  {
 if(tot ==0){alert('Please select your workshop by\n\nclicking the box next to its name')}
}

function update()  {
var opt1 = ie4 ? document.all.opt1 : document.getElementById('opt1');
var opt2 = ie4 ? document.all.opt2 : document.getElementById('opt2');
var opt3 = ie4 ? document.all.opt3 : document.getElementById('opt3');
var opt4 = ie4 ? document.all.opt4 : document.getElementById('opt4');
var opt5 = ie4 ? document.all.opt5 : document.getElementById('opt5');
var updt = ie4 ? document.all.updt : document.getElementById('updt');
var payby = ie4 ? document.all.payby : document.getElementById('payby');
var subs1 = ie4 ? document.all.subs1 : document.getElementById('subs1');
var subs2 = ie4 ? document.all.subs2 : document.getElementById('subs2');
var adrs_msg  = ie4 ? document.all.adrs_msg : document.getElementById('adrs_msg');
var submit_pp = ie4 ? document.all.submit_pp : document.getElementById('submit_pp')
var submit_pd = ie4 ? document.all.submit_pd : document.getElementById('submit_pd')

 if(balanceOnly == 1) {
	document.getElementById('p1').style.visibility = 'hidden'
	document.getElementById('p2').style.visibility = 'hidden'
}

    num   =  parseFloat(document.order.places.value)
    cst   =  parseFloat(fees)
    tot   =  parseFloat(num * cst).toFixed(2)

    ttl   =  tot + '&nbsp; <a class="conv" href="#"  onClick="return false" onFocus="this.blur()"onMouseOver="cost=tot; menuOn(event,\'link[1]\')" onMouseout="dlayhide()">&#149;convert currency</a>'
  duenow  =  parseFloat(deposit * num).toFixed(2)
  balance =  parseFloat(tot - duenow).toFixed(2)

   tens1  = ': &pound;'
   tens2  = ': &pound;'
   tens3  = ': &pound;'
 if (duenow < 100){tens1 = ': &pound;<img src="px.gif" width="8" height="1" border="0">'}
 if (balance< 100){tens2 = ': &pound;<img src="px.gif" width="8" height="1" border="0">'}
 if (tot    < 100){tens3 = ': &pound;<img src="px.gif" width="8" height="1" border="0">'}
   
   topay =''

 if (opt == 1){
opt1.innerHTML = 'Deposit ' + tens1 + duenow + '&nbsp; <a class="conv" href="#" onClick="return false" onFocus="this.blur()"onMouseOver="cost=duenow; menuOn(event,\'link[1]\')" onMouseout="dlayhide()">&#149;convert currency</a>'
opt2.innerHTML = 'Balance ' + tens2 + balance + '&nbsp; <a class="conv" href="#" onClick="return false" onFocus="this.blur()"onMouseOver="cost=balance; menuOn(event,\'link[1]\')" onMouseout="dlayhide()">&#149;convert currency</a>';
opt3.innerHTML = 'Total<img src="px.gif" width="22" height="1" border="0">' + tens3 + tot + '&nbsp; <a class="conv" href="#" onClick="return false" onFocus="this.blur()"onMouseOver="cost=tot; menuOn(event,\'link[1]\')" onMouseout="dlayhide()">&#149;convert currency</a>';
opt4.innerHTML = 'Balance to be invoiced - payable any'
opt5.innerHTML = 'time up to one month before workshop.'

         topay = duenow
document.forms['shopcart'].amount.value = deposit
}
 if (opt == 2){
opt1.innerHTML = '&nbsp;'
opt2.innerHTML = '&nbsp;'
opt3.innerHTML = 'Pay now : &pound;' + tot + '&nbsp; <a class="conv" href="#" onClick="return false" onFocus="this.blur()"onMouseOver="cost=tot; menuOn(event,\'link[1]\')" onMouseout="dlayhide()">&#149;convert currency</a>'
opt4.innerHTML = ''
opt5.innerHTML = ''
         topay = tot
document.forms['shopcart'].amount.value = cst
}
 if (opt == 3){
opt1.innerHTML = 'I paid my deposit of &pound;' + duenow + ' and'
opt2.innerHTML = ' wish to pay the balance due:'
opt4.innerHTML = 'Pay now : &pound;' + balance + '&nbsp; <a class="conv" href="#" onClick="return false" onFocus="this.blur()"onMouseOver="cost=balance; menuOn(event,\'link[1]\')" onMouseout="dlayhide()">&#149;convert currency</a>'
opt3.innerHTML = ''
opt5.innerHTML = ''
         topay = balance
document.forms['shopcart'].amount.value = (balance/num)
}

 if (subs == 1){
payby.innerHTML = 'Payment: now through PayPal'
subs1.innerHTML = ''
subs2.innerHTML = '<div style="text-align:center;font-weight:bold;color:red">For Information Pack please include your address at check-out.</div>'
adrs_msg.style.display  = 'none'
submit_pp.style.display = 'block'
submit_pd.style.display = 'none'
}
 if (subs == 3){
payby.innerHTML = 'Payment: later from option chosen'
subs1.innerHTML = 'from emailed list.'
subs2.innerHTML = '<div style="text-align:center;font-weight:bold;color:red">Is your email address correct?</div>'
adrs_msg.style.display  = 'block'
submit_pp.style.display = 'none'
submit_pd.style.display = 'block'
}
document.forms['shopcart'].quantity.value = num
updt.innerHTML = '[<a class="update" href="#" onClick="update();return false;">update</a>]'
}

//-- -----------------WORKSHOP TERMS Callout-------------
function ws_callout(pos) {

call  = '<div style="width:250px;background-color:#fffff0;color:#ff5900;border:1px solid #b00000;font-family:verdana;font-size:14pt;text-align:center;margin-top:10px;">Workshop Payments and<br>Cancellations</div>'
call += '<div style="width:98%;text-align:left;margin-top:6px;"><ul>'
call += '<li>A deposit is required to secure your place on each selected workshop.</li>'
call += '<li>Full payment (or balance of payment) must be made prior to 30 days before the commencement date of your selected workshop.</li>'
call += '<li>All payments made will be refunded if you cancel your booking prior to 30 days before the commencement of the workshop.</li>'
call += '<li>Your deposit only is non-refundable if a cancellation is received within 30 days of the published commencement date of the workshop.</li>'
call += '<li>No refunds will be made in the event of failure to attend on the day. All balances due must be paid, and invoices settled in full.</li></ul></div>'
call += '<a href="#" onClick="document.getElementById(\'ws_callout\').style.visibility=\'hidden\';return false" class="bigBtn" style="width:200px">Close</a><br><br>'
call += '</div></div>'

document.getElementById('ws_callout').innerHTML = call
document.getElementById('ws_callout').style.top = pos
document.getElementById('ws_callout').style.visibility='visible'
}

////--------------Show Dollar (CANADA + US + AUS fees)-------------------------
 function showDollars(id){
  var set = new Array()
   if(id=='can'){set[0]='cd';set[1]='CAD'}
   if(id=='usa'){set[0]='us';set[1]='USD'}
   if(id=='aud'){set[0]='ad';set[1]='AUD'}
   if(id=='gbp'){set[0]='eu';set[1]='EUR'}
     cst    = eval('(parseFloat(setFull) * parseFloat(' +set[0]+ ')).toFixed(0) + ""')
     cost   = document.getElementById('cost')
     write  = 'Cost:  &pound;' +parseFloat(setFull).toFixed(2)+ ' GBP &nbsp;(about $' +cst+' '+ set[1]+ ') &nbsp;'
   if(id=='gbp'){
     write  = 'Cost:  &pound;' +parseFloat(setFull).toFixed(2)+ ' GBP &nbsp;(about &#128;' +cst+' '+ set[1]+ ') &nbsp;'
	}

 cost.innerHTML = write
}
////--------------END Show Dollar ------------------------------------------
