V_Base="www.Alnmouth.co.uk"
V_Name="Quality Self Catering, Alnmouth"

function V_AddFave() {J_AddFave('http://'+V_Base,V_Name)}

function V_Butt(V_0,V_1,V_2,V_3,V_4) {if (!V_4) {V_4=""}
if (V_4!="") {V_4=' onMouseOver="'+V_4+'"'} 
V_5=""; if (V_3!=";") {V_5=' style="cursor:hand"'}
J_Inse('<input'+V_5+' class="'+V_0+'" name="'+V_1+'" type="button" value="'+V_2+'"')
J_Inse(' onClick="'+V_3+'"'+V_4+'><br>')}

function V_Butts() {J_Inse('<td width=125><form name="Butts">');V_0=0

if (V_Base) {V_Butt("j","Base",V_Base,"J_Link(V_Base)"); V_0=2;
//V_Butt("j","AddFave","Add to Favourites","V_AddFave()")
} 


if (window.print) {V_Butt("j","Print","Print this Page","V_Prnt("+V_0+")")}

V_Butt("j","GoBack","Go Back","J_Back()",""); J_Inse('<!/form></td>')}

function V_Cell(V_1,V_2,V_3) {if(!V_3) {V_3=''}; if (V_3!='') {V_3='colspan='+V_3}
J_Inse('<td class="'+V_1+'"'+V_3+'>'+V_2+'</td>')}

function V_Prnt(V_1) {document.forms[0].elements[V_1].value=J_Date(); J_Prnt()}

function V_Send(V_1) {J_Inse(J_Wrap(V_1,'Email: <a href="mailto:'+V_1+'?Subject=A%20Message%20via%20Alnmouth.co.uk">','</a><br>'))}

Q_MsDay=86400000                                   // Milliseconds in one day
var Q_Mon, Q_Day, Q_Start, Q_End, Q_Today, Q_Late, Q_Past, Q_Days, Q_Cutoff
var Q_td, Q_Rate, Q_3day, Q_Disct, Q_Booked, Q_Season, Q_Prop
var Q_Admin='a'                                   // Admin TD Class
var Q_Week=7                                      // Days in Week
var Q_BkStart=''
var Q_BkEnd=''
var G_pppw=0
var Q_Closed=false
var Q_XClosed=false

function Q_BkBuild(Q_Start,Q_End) {if (Q_BkStart=='') {Q_BkStart=Q_Start}; Q_BkEnd=Q_End}

function Q_BkShow() {if (Q_BkStart!='')                   // If booking exists, show and clear
{J_Inse('<tr>'); V_Cell(Q_Admin,J_Date1(Q_BkStart)); V_Cell(Q_Admin,J_Date1(Q_BkEnd))
Q_BkText='Booked'; if (Q_XClosed) {Q_BkText='Closed for refurbishment'}
V_Cell(Q_Admin,Q_BkText,Q_MaxPer-Q_MinPer+2); J_Inse('</tr>'); Q_BkStart=''}}

function Q_GetPeriod(Q_1,Q_2,Q_3) {                        // Start Day, Start Month, Days
Q_Start=new Date(Q_Yr,Q_2-1,Q_1)                           // Period start date
var K_End=new Date(Q_Start.setHours(12)+Q_3*Q_MsDay); Q_End=new Date(K_End) // Period end date
Q_Yr=Q_End.getFullYear(); Q_Mon=Q_End.getMonth()+1; Q_Day=Q_End.getDate() // Remember Date
Q_Today=new Date(); var K_Cur=Q_Today.setHours(12)         // Current Date
K_Cut=Q_Start-Q_DiscD*Q_MsDay                              // Late Discount cut-off date
Q_Late=((K_Cut<=K_Cur) && (Q_3=Q_Week))                    // Late Discount Applies
Q_Past=K_End<K_Cur }                                       // Period is past

function Q_GetTarf(Q_Prop,Q_Season) {//Property,Season,TD class,Week,Late avail disct,3nights,pppw,Min
var T_=-1; do {T_=T_+1} while (Q_Prop+Q_Season!=Q_Tarfs[T_][0]+Q_Tarfs[T_][1])
Q_td      =Q_Tarfs[T_][2]                                  // <td> Class
Q_Rate    =Q_Tarfs[T_][3]                                  // Weekly Base Rate 
Q_Disct   =Q_Tarfs[T_][4]; if (!Q_Disct)    {Q_Disct=0}    // late Availability Discount
Q_3day    =Q_Tarfs[T_][5]; if (!Q_3day)     {Q_3day='Short Breaks Not Available'} // 3 night Price
Q_pppw    =Q_Tarfs[T_][6]; if (!Q_pppw)     {Q_pppw=0}     // price per person per week
Q_MinchPer=Q_Tarfs[T_][7]; if (!Q_MinchPer) {Q_MinchPer=Q_MinPer} } // Minimum number of people

function Q_Show(Q_0) {
Q_Prop=Q_0; var J_=0; K_=G_Wks; Q_MinPer=G_MinPer; Q_MaxPer=G_MaxPer; Q_pppw=G_pppw, Q_MinchPer=G_MinchPer, Q_Minch=G_Minch
    if (Q_Prop=='L') {K_=L_Wks; Q_MinPer=L_MinPer; Q_MaxPer=L_MaxPer; Q_pppw=L_pppw, Q_MinchPer=L_MinchPer, Q_Minch=L_Minch} 
do {Q_Status=K_[J_][0]; Q_Booked=(Q_Status<1); Q_XClosed=Q_Closed; Q_Closed=(Q_Status==0)
    Q_Season=K_[J_][1]
    Q_Day1  =K_[J_][2]; if (!Q_Day1) {Q_Day1=Q_Day}
    Q_Mon1  =K_[J_][3]; if (!Q_Mon1) {Q_Mon1=Q_Mon}
    Q_Days  =K_[J_][4]; if (!Q_Days) {Q_Days=Q_Week}
    Q_GetPeriod(Q_Day1,Q_Mon1,Q_Days)                      // Get Period

 if (!Q_Past) {Q_GetTarf(Q_Prop,Q_Season)                  // If period valid, Get Tariff
 Q_Price =K_[J_][5]; if (!Q_Price) {Q_Price=Q_Rate}        // Default Price
 if (!Q_Booked) {Q_BkShow(); Q_Show1()}                    // If not Booked
 if ( Q_Booked && Q_Closed!=Q_XClosed) {Q_BkShow(); Q_BkBuild(Q_Start,Q_End)} // If Booked
 if ( Q_Booked) {Q_BkBuild(Q_Start,Q_End)}                 // If Booked
 }
 
 J_=J_+1} while (J_<K_.length); Q_BkShow()}

function Q_Show1() {Q_pppp=Q_pppw*Q_Days/7                // Process Booking
if (Q_Late) {Q_Price=Q_Price-Q_Disct; if(Q_Disct!=0) {Q_MinchPer=Q_MinPer; Q_3day='Late Availability'}} // Apply late disct
J_Inse('<tr>'); V_Cell(Q_td,J_Date1(Q_Start)); V_Cell(Q_td,J_Date1(Q_End)) // Show Period Dates
Q_Span=Q_MinchPer-Q_MinPer+1; for (var J_=0; J_<=Q_MaxPer-Q_MinPer; J_=J_+1)
{var K_=Q_Price+J_*Q_pppp; if (K_<Q_Minch) {K_=Q_Minch}
if (Q_MinPer+J_>=Q_MinchPer) {V_Cell(Q_td,'£'+K_.toFixed(0),Q_Span); Q_Span=1} }
V_Cell(Q_Admin,Q_3day); J_Inse('</tr>')}

P_Base=295; P_pppw=40; P_pn=20; P_pppn=10; P_Minper=2; P_Minch=180; P_Maxper=6; P_Maxnights=7;
function P_Breaks() {var P_Guests,P_Nights=3,P_Price;
do {J_Inse('<tr><td class="x">'+P_Nights+'</td>'); P_Guests=P_Minper;
 do { J_Inse('<td class="s">£'+L_SB(P_Nights,P_Guests)+'</td>'); P_Guests=P_Guests+1}
 while (P_Guests<=P_Maxper); J_Inse('</tr>'); P_Nights=P_Nights+1 }
while (P_Nights<=P_Maxnights) }

function L_SB(L_1,L_2) {return L_SBv[L_1][L_2]} // Nights, People


