var CMSEditor=function(){
this.html=new Html()
this.textarea=new Textarea()
this.url=new Url()
this.init=function(){
}
this.position=function(elem, editor){
var SF=this
var left=$(elem).parent().position().left + 10,
top=$(elem).parent().position().top + 10
$('#' + editor).css('top', top + 'px')
$('#' + editor).css('left', left + 'px')
$('#' + editor).fadeIn()
}
this.inserters=function(data, target, table){
var SF=this
SF.inserterTarget=target
SF.inserterTable=table
$('#insertTd').html(data.Inserts)
$('#inserters').html(data.Inserters)
		$('#leftButton').click(function(){SF.textarea.left($('#' + target))})
		$('#indentButton').click(function(){SF.textarea.indent($('#' + target))})
		$('#centreButton').click(function(){SF.textarea.centre($('#' + target))})
		$('#rightButton').click(function(){SF.textarea.right($('#' + target))})
		$('#boldButton').click(function(){SF.textarea.bold($('#' + target))})
$('#italicButton').click(function(){SF.textarea.italic($('#textText'))})
$('#underlineButton').click(function(){SF.textarea.underline($('#textText'))})
$('#superscriptButton').click(function(){SF.textarea.superscript($('#textText'))})
$('#insertInsert').click(function(){SF.insertLink()})
$('#insertLinkSubmit').click(function(){SF.insertTheLink('Link')})
$('#insertLinkCancel').click(function(){SF.cancelInsertLink('Link')})
$('#insertNewsItemSubmit').click(function(){SF.insertTheLink('NewsItem')})
$('#insertNewsItemCancel').click(function(){SF.cancelInsertLink('NewsItem')})
$('#insertEventSubmit').click(function(){SF.insertTheLink('Event')})
$('#insertEventCancel').click(function(){SF.cancelInsertLink('Event')})
$('#insertFormLinkSubmit').click(function(){SF.insertTheFormLink()})
$('#insertFormLinkCancel').click(function(){SF.cancelInsertFormLink()})
$('#insertDocumentSubmit').click(function(){SF.insertTheDocumentLink()})
$('#insertDocumentCancel').click(function(){SF.cancelInsertDocumentLink()})
$('#insertCommitteeRoleSubmit').click(function(){SF.insertTheCommitteeRole()})
$('#insertCommitteeRoleCancel').click(function(){SF.cancelInsertCommitteeRole()})
$('#insertContactSubmit').click(function(){SF.insertTheContact()})
$('#insertContactCancel').click(function(){SF.cancelInsertContact()})
$('#insertContactUsSubmit').click(function(){SF.insertTheContactUs()})
$('#insertContactUsCancel').click(function(){SF.cancelInsertContactUs()})
}
this.hideBackgroundEditor=function(){
var SF=this
$('#' + SF.inserterTable).addClass('editorHidden')
$('#' + SF.inserterTable + ' *').addClass('editorHidden')
}
this.showBackgroundEditor=function(){
var SF=this
$('#' + SF.inserterTable).removeClass('editorHidden')
$('#' + SF.inserterTable + ' *').removeClass('editorHidden')
}
this.insertLink=function(){
var SF=this
var val=$('#insertType').val()
if(val==0){
jAlert('Please select an element to insert', 'Alert')
return
}
switch(val){
case 'Link':
SF.hideBackgroundEditor()
$('#insertLinkDiv').fadeIn()
break
			case 'News Item Link':
SF.hideBackgroundEditor()
$('#insertNewsItemDiv').fadeIn()
break
			case 'Event Link':
SF.hideBackgroundEditor()
$('#insertEventDiv').fadeIn()
break
case 'Form Link':
SF.hideBackgroundEditor()
$('#insertFormLinkDiv').fadeIn()
break
case 'Document':
SF.hideBackgroundEditor()
$('#insertDocumentDiv').fadeIn()
break
case 'Contact':
SF.hideBackgroundEditor()
$('#insertContactDiv').fadeIn()
break
case 'Contact Us':
SF.hideBackgroundEditor()
$('#insertContactUsDiv').fadeIn()
break
case 'Committee Role':
SF.hideBackgroundEditor()
$('#insertCommitteeRoleDiv').fadeIn()
break
case 'Table From CSV File':
SF.hideBackgroundEditor()
$('#insertCSVTableDiv').fadeIn()
break
case 'Price List':
SF.hideBackgroundEditor()
$('#insertPriceListDiv').fadeIn()
break
case 'Opening Times':
SF.hideBackgroundEditor()
$('#insertOpeningTimesDiv').fadeIn()
break
case 'Plain List':
SF.textarea.insertList('#' + SF.inserterTarget, 'Plain')
break
case 'Numbered List':
SF.textarea.insertList('#' + SF.inserterTarget, 'Numbered')
break
case 'Add Feedback Link':
SF.textarea.insertAtCaret('#' + SF.inserterTarget, '[FeedbackLink]')
}
}
this.cancelInsertCommitteeRole=function(){
var SF=this
$('#committeeRoleSelect').val('')
$('#insertCommitteeRoleSubject').val('')
$('#insertCommitteeRoleText').val('')
$('#insertCommitteeRoleDiv').fadeOut()
SF.showBackgroundEditor()
}
this.insertTheCommitteeRole=function(){
var SF=this
var contact=$('#committeeRoleSelect').val(),
name=$('#committeeRoleSelect option:selected').html(),
text=$('#insertCommitteeRoleText').val(),
subject=$('#insertCommitteeRoleSubject').val()
var url=SF.url.encode("html/contact.html?height=480&width=480&RoleId=" + contact + "&Role=" + name + "&Subject=" + subject + "' class='thickbox'")
if(! text){ text=name }
SF.textarea.insertAtCaret('#' + SF.inserterTarget, " <a href='" + url + "'>" + text + "</a> ")
SF.cancelInsertCommitteeRole()
}
this.cancelInsertContact=function(){
var SF=this
$('#contactSelect').val('')
$('#insertContactSubject').val('')
$('#insertContactText').val('')
$('#insertContactDiv').fadeOut()
SF.showBackgroundEditor()
}
this.insertTheContact=function(){
var SF=this
var contact=$('#contactSelect').val(),
name=$('#contactSelect option:selected').html(),
text=$('#contactText').val(),
subject=$('#contactSubject').val()
if(! text){ text=name }
var url=SF.url.encode("html/contact.html?height=480&width=480&Contact=" + contact + "&Subject=" + subject + "' class='thickbox'")
SF.textarea.insertAtCaret('#' + SF.inserterTarget, " <a href='" + url + "'>" + text + "</a> ")
SF.cancelInsertContact()
}
this.cancelInsertContactUs=function(){
var SF=this
$('#contactUsSelect').val('')
$('#insertContactUsText').val('')
$('#insertContactUsSubject').val('')
$('#insertContactUsDiv').fadeOut()
SF.showBackgroundEditor()
}
this.insertTheContactUs=function(){
var SF=this
var contact=$('#contactUsSelect').val(),
name=$('#contactUsSelect option:selected').html(),
text=$('#contactUsText').val(),
subject=$('#contactUsSubject').val()
if(! text){ text=name }
var url=SF.url.encode("html/contact.html?height=480&width=480&Contact=" + contact + "&Subject=" + subject + "' class='thickbox'")
SF.textarea.insertAtCaret('#' + SF.inserterTarget, " <a href='" + url + "'>" + text + "</a> ")
SF.cancelInsertContactUs()
}
this.cancelInsertLink=function(type){
var SF=this
$('#insert' + type + 'Link').val('')
$('#insert' + type + 'Text').val('')
$('#insert' + type + 'Div').fadeOut()
SF.showBackgroundEditor()
}
this.insertTheLink=function(type){
var SF=this
var linkLink=$('#insert' + type + 'Link').val(),
linkText=$('#insert' + type + 'Text').val(),
siteLink=$('#page' + type + 'Select').val()
			console.log(linkLink, linkText, siteLink)
if(siteLink!=0){
linkLink=siteLink
if(! linkText){
linkText=$('#page' + type + 'Select option:selected').html()
}
}else{
if(! linkLink.match(/^http:\/\//)){
linkLink='http://' + linkLink
}
}
if(! linkText){ linkText=linkLink }
linkLink=SF.url.encode(linkLink)
SF.textarea.insertAtCaret('#' + SF.inserterTarget, " <a href='" + linkLink + "'>" + linkText + "</a> ")
SF.cancelInsertLink(type)
}
this.cancelInsertFormLink=function(){
var SF=this
$('#insertFormLink').val('')
$('#insertFormText').val('')
$('#insertFormLinkDiv').fadeOut()
SF.showBackgroundEditor()
}
this.insertTheFormLink=function(){
var SF=this
var linkId=$('#insertFormLink').val(),
linkText=$('#insertFormLinkText').val(),
linkLink=$('#insertFormUrl_' + linkId).val()
if(! linkText){ linkText=$('#insertFormText_' + linkId).val()}
linkLink=SF.url.encode(linkLink)
SF.textarea.insertAtCaret('#' + SF.inserterTarget, " <a class='thickbox formLink' href='" + linkLink + "&Id={Id}'>" + linkText + "</a> ")
SF.cancelInsertFormLink()
}
this.cancelInsertDocumentLink=function(){
var SF=this
$('#insertDocumentLink').val('')
$('#insertDocumentText').val('')
$('#insertDocumentDiv').fadeOut()
SF.showBackgroundEditor()
}
this.insertTheDocumentLink=function(){
var SF=this
var documentId=$('#insertDocument').val(),
documentText=$('#insertDocumentText').val()
if(! documentText){ documentText=$('#insertDocument option:selected').html()}
SF.textarea.insertAtCaret('#' + SF.inserterTarget, " <a href='text/docs/" + documentId + "'>" + documentText + "</a> ")
SF.cancelInsertDocumentLink()
}
this.cancelInsertCSVTable=function(){
var SF=this
SF.html.setCheckBoxValue($('#insertCSVTableHeader'), 1)
$('#insertCSVTableDiv').fadeOut()
SF.showBackgroundEditor()
}
this.insertTheCSVTable=function(){
var SF=this
var file=$('#insertCSVTableFile').val()
if(file==0){
jAlert('Please select a file', 'Alert')
return
}
var fileName=$('#insertCSVTableFile option:selected').html(),
header=SF.html.getCheckBoxValue($('#insertCSVTableHeader')),
delimiter=$('#insertCSVTableDelimiter').val(),
align=$('#insertCSVTableAlignment').val()
SF.textarea.insertAtCaret('#' + SF.inserterTarget, "[CSVTable file='" + fileName +
"' header='" + header +
"' delimiter='" + delimiter +
"' align='" + align +
"']\n")
SF.cancelInsertCSVTable()
$('#uploadCSVFileForm').submit()
}
this.getPriceListSections=function(){
var SF=this
if(! SF.priceListsHaveSections){
return
}
var list=$('#insertPriceList').val()
if(! list){
return
}
$.ajax({type:'POST',url:CMSURL,data:'Action=getPriceListSectionsDropDown&Id=' + list,
dataType:'json',timeout:40000,error:
function(){
return false
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
$('#insertPriceListSectionTd').html(data.Sections)
}
}
})
}
this.cancelInsertPriceList=function(){
var SF=this
$('#insertPriceList').val('')
$('#insertPriceListSectionTd').html('')
$('#insertPriceListDiv').fadeOut()
SF.showBackgroundEditor()
}
this.insertThePriceList=function(){
var SF=this
var list=$('#insertPriceList').val()
if(list==0){
jAlert('Please select a price list', 'Alert')
return
}
var section=0
if(SF.priceListsHaveSections){
section=$('#insertPriceListSections').val()
}
if(section!=0){
SF.textarea.insertAtCaret('#' + SF.inserterTarget, "[PriceList list='" + list + "' section='" + section + "']")
}else{
SF.textarea.insertAtCaret('#' + SF.inserterTarget, "[PriceList list='" + list + "']")
}
SF.cancelInsertPriceList()
}
this.cancelInsertOpeningTimes=function(){
var SF=this
$('#insertOpeningTimesDiv').fadeOut()
SF.showBackgroundEditor()
}
this.insertTheOpeningTimes=function(){
var SF=this
SF.textarea.insertAtCaret('#' + SF.inserterTarget, "[OpeningTimes]")
SF.cancelInsertPriceList()
}
}
;var Booking=function(){
this.json=new Json()
this.site=new SiteGeneric()
this.contactId=''
	this.description=''
this.subject=''
this.mobile=''
this.name=''
this.email=''
this.phone=''
this.message=''
this.people=''
this.children=''
this.babies=''
	this.setDates=function(){
var SF=this
$.ajax({type:'POST',url:CMSURL,data:'Action=getCalendar',
dataType:'json',timeout:40000,error:
function(){
return false
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
$('#dateSpan').html(SF.json.jsonDecode(data.Dates))
$('#timeSpan').html(SF.json.jsonDecode(data.Times))
						$('#timeSpan').hide()
}
					SF.site.setDatePicker($('#DateSelect_Calendar'), '', '', '', SF.getOpeningTimesForDay)
$('#bookingTable').fadeIn()
}
})
}
	this.getOpeningTimesForDay=function(){
	 var SF=this
		var day=$('#DateSelect_Day').val(),
		 month=$('#DateSelect_Month').val(),
		 year=$('#DateSelect_Year').val()
		$.ajax({type:'POST',url:CMSURL,data:'Action=getOpeningTimesForDay&Day=' + day +
				 '&Month=' + month +
													 '&Year=' + year,
dataType:'json',timeout:40000,error:
function(){
return false
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
					 if(! (data.OpeningTimes.length)){
						 jAlert('We are closed on that day. Please select another date', 'ERROR')
						 $('#timeSpan').hide()
						}else{
					 $('#TimeSelect_Hour option').each(
						 function(){
var val=parseInt($(this).val()) * 100,
								 len=data.OpeningTimes.length,
									 start, end
							 $(this).hide()
for(var i=0; i < len; i++){
								 start='' + data.OpeningTimes[i].startHour + data.OpeningTimes[i].startMinute
								 end='' + data.OpeningTimes[i].endHour + data.OpeningTimes[i].endMinute
									 console.log(val + ' >= ' + start + '&&' + val + ' <= ' + end)
							 if(val >= start&&val <= end){
								 $(this).show()
									 }
								 }
						 })
					 $('#timeSpan').show()
						}
					}
				}
		})
	}
this.submitBooking=function(subject, contactId, mobile){
var SF=this
		if(subject){SF.subject=subject }
		if(contactId){SF.contactId=contactId }
		if(mobile){SF.mobile=mobile }
if($('#bookingDescription').length>0){SF.description=$('#bookingDescription').html()}
if($('#bookingName').length>0){SF.name=$('#bookingName').val()}
if($('#bookingPhone').length>0){SF.phone=$('#bookingPhone').val()}
if($('#bookingEmail').length>0){SF.email=$('#bookingEmail').val()}
if($('#bookingPeople').length>0){SF.people=$('#bookingPeople').val()}
if($('#bookingChildren').length>0){SF.children=$('#bookingChildren').val()}
if($('#bookingBabies').length>0){SF.babies=$('#bookingBabies').val()}
if($('#bookingMessage').length>0){SF.message=$('#bookingMessage').val()}
if(SF.phone==''){
jAlert('Please enter a phone number so we can confirm your booking.', 'Alert')
return
}
var day=$('#DateSelect_Day').val(),
month=$('#DateSelect_Month').val(),
year=$('#DateSelect_Year').val(),
hour=$('#TimeSelect_Hour').val(),
minute=$('#TimeSelect_Minute').val()
$.ajax({type:'POST',url:AJAXURL,data:'Action=submitBooking&ContactId=' + SF.contactId +
'&Description=' + SF.description +
'&Name=' + SF.name +
'&Email=' + SF.email +
'&Subject=' + SF.subject +
'&Phone=' + SF.phone +
'&People=' + SF.people +
'&Children=' + SF.children +
'&Babies=' + SF.babies +
'&Message=' + SF.message +
'&Day=' + day +
'&Month=' + month +
'&Year=' + year +
'&Hour=' + hour +
'&Minute=' + minute,
dataType:'json',timeout:40000,error:
function(){
return false
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
if(mobile){
$('#bookedMessage').html(data.Message)
$('.book').hide()
$('.booked').fadeIn()
}else{
jAlert(data.Message, 'AJAX Error')
}
}
if(! mobile){
tb_remove()
}
}
})
}
};var Calendar=function(obj){
this.json=new Json()
this.thickbox=new ThickBoxGeneric()
this.obj=obj
this.type=''
this.init=function(id, type){
var SF=this
		if(type){
SF.type=type
}
$('#calendarGoToThisMonth_'+id).click(function(){SF.thisMonth(id)})
$('#calendarPrevMonth_'+id).click(function(){SF.prevMonth(id)})
$('#calendarNextMonth_'+id).click(function(){SF.nextMonth(id)})
$('#calendarGoToMonth_'+id).click(function(){SF.goToMonth(id)})
SF.storeCurrentMonth(id)
SF.storeCurrentYear(id)
}
this.storeCurrentMonth=function(id){
var month=$('#calendarMonthSelect_'+id).val()
$('#currentCalendarMonth_'+id).val(month)
}
this.storeCurrentYear=function(id){
var year=$('#calendarYearSelect_'+id).val()
$('#currentCalendarYear_'+id).val(year)
}
this.thisMonth=function(id){
var SF=this
var d=new Date()
var month=+d.getMonth() + 1
var year=+d.getYear() + 1900
$('#currentCalendarMonth_'+id).val(month)
$('#currentCalendarYear_'+id).val(year)
$('#calendarMonthSelect_'+id).val(month)
$('#calendarYearSelect_'+id).val(year)
SF.getDates(id, month, year)
return false
}
this.prevMonth=function(id){
var SF=this
var month=$('#currentCalendarMonth_'+id).val()
var year=$('#currentCalendarYear_'+id).val()
if(month==1){
month=12
year=year - 1
}else{
month=month - 1
}
$('#currentCalendarMonth_'+id).val(month)
$('#currentCalendarYear_'+id).val(year)
$('#calendarMonthSelect_'+id).val(month)
$('#calendarYearSelect_'+id).val(year)
SF.getDates(id, month, year)
return false
}
this.nextMonth=function(id){
var SF=this
var month=$('#currentCalendarMonth_'+id).val()
var year=$('#currentCalendarYear_'+id).val()
if(month==12){
month=1
year=+year + 1
}else{
month=+month + 1
}
$('#currentCalendarMonth_'+id).val(month)
$('#currentCalendarYear_'+id).val(year)
$('#calendarMonthSelect_'+id).val(month)
$('#calendarYearSelect_'+id).val(year)
SF.getDates(id, month, year)
return false
}
this.goToMonth=function(id){
var SF=this
var month=$('#calendarMonthSelect_'+id).val()
var year=$('#calendarYearSelect_'+id).val()
$('#currentCalendarMonth_'+id).val(month)
$('#currentCalendarYear_'+id).val(year)
SF.getDates(id, month, year)
return false
}
this.getDates=function(id, month, year){
var SF=this
$('#calendarTableDiv_' + id + ' tr.calendarTableDataTr').hide()
$('#calendarTableDivLoading_'+id).show()
if(!month){
month=currentMonth()
}
if(!year){
year=currentYear()
}
		if(SF.obg&&SF.obj.getDates){
		 SF.obj.getDates(month, SF.type, year, id)
return
		}
$.ajax({type:'POST',url:AJAXURL,data:'Action=getMonthDates&Month=' + month +
'&Type=' + SF.type +
'&Year=' + year +
'&Id=' + id,
dataType:'json',timeout:40000,error:
function(){
return false
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
$('#calendarTableDiv_'+id).html(SF.json.jsonDecode(data.Calendar))
SF.thickbox.applyThickBox('#calendarTable_' + id + ' .thickbox')
$('#calendarTableDivLoading_'+id).hide()
$('#calendarTableDiv_' + id + ' tr.calendarTableDataTr').show()
if(SF.obj){
SF.obj.initThisCalendar(id)
}
}
}
})
}
this.getDayCellValue=function(elem){
var html=$(elem).html()
if(! html.match(/>/)){
return ''
}
html=html.split('>')
html=html[1]
html=html.split('<')
html=html[0]
return html
}
this.getDateCellString=function(elem){
var SF=this
var val=SF.getDayCellValue(elem)
if(!val){
return ''
}
return val + '-' + SF.currentMonth() + '-' + SF.currentYear()
}
this.getDateMarker=function(date){
if(date.Type=='Next Meeting'){
return "<img src='images/m.gif' class='clubCalendarImg'>";
} else if(date.Type=='Unavailable'){
return "<img src='images/u.gif' class='clubCalendarImg'>";
}
}
}
;var CheckOut=function(){
this.loader=new Loader()
this.checkOut=function(mock){
	 var SF=this
		if(mock){
		 SF.goToMock()
		}else{
	 switch(CHECKOUT){
		 case 'PayPal':
			 SF.goToPayPal(mock)
				 break
			 case 'Google':
			 SF.goToGoogle(mock)
					break
		 }
		}
	}
	this.goToMock=function(){
	 url='MOCKPAYPAL.html'
	 location.replace(url)
	}
	this.goToGoogle=function(){
var SF=this
		var total=parseFloat($('#basketTotal').text())
		SF.loader.loaderOn($('#basket table').eq(2))
	 $.ajax({type:'POST',url: AJAXSITEURL,
data:'Action=getGoogleBasket&Amount=' + total,
dataType:'json',timeout:40000,error:
function(){
return false
},success:
function(data){
				 if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
				 $('#basketForm').html(data.Basket)
		 $('#basketForm form').submit()
					}
}
})
	}
this.goToPayPal=function(mock){
	 url='checkout.php?Total=' + parseFloat($('#basketTotal').text())
	 location.replace(url)
	}
};var Contacts=function(){
this.doContacts=function(){
var SF=this
$.ajax({type:'POST',url:AJAXURL,data:'Action=getContacts',
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
alert(data.Error)
}else{
SF.doSiteContacts(data)
}
}
})
SF.doHogsmillContacts("{ 'HogsmillPhone' : '020 8399 2110' , " +
" 'HogsmillMobile' : '07881 631015' , " +
" 'HogsmillEmail' : 'info@hogsmill.com' }")
}
this.doSiteContacts=function(data){
var SF=this
$('span.contactName').html(data.Name)
$('span.contactPhone').html(data.Phone)
$('span.contactMobile').html(data.Mobile)
$('span.contactEmail').html(data.Email)
$('span.contactAdminName').html(data.AdminName)
$('span.contactAdminPhone').html(data.AdminPhone)
$('span.contactAdminMobile').html(data.AdminMobile)
$('span.contactAdminEmail').html(data.AdminEmail)
$('span.contactName').html(data.Name)
$('span.contactName').html(data.Name)
$('a.contactEmail').attr('href', 'mailto:' + data.Email)
$('a.contactAdminEmail').attr('href', 'mailto:' + data.AdminEmail)
}
this.doHogsmillContacts=function(data){
var SF=this
$('span.hogsmillPhone').html(data.HogsmillPhone)
$('span.hogsmillMobile').html(data.HogsmillMobile)
$('span.hogsmillEmail').html(data.HogsmillEmail)
$('a.hogsmillEmail').attr('href', 'mailto:' + data.HogsmillEmail)
}
}
;var ContactUs=function(){
this.id=''
this.type=''
this.name=''
this.contact=''
this.subject=''
this.email=''
this.phone=''
this.message=''
this.emailOnly=0
this.webmaster=1
this.url=new Url()
this.validate=new Validate()
this.submitContactUs=function(type, id, contactId){
var SF=this
if($('#contactName').length>0){SF.name=$('#contactName').val()}
if($('#contactContact').length>0){SF.contact=$('#contactContact').val()}
if($('#contactSubject').length>0){SF.subject=$('#contactSubject').val()}
if($('#contactPhone').length>0){SF.phone=$('#contactPhone').val()}
if($('#contactEmail').length>0){SF.email=$('#contactEmail').val()}
if($('#contactMessage').length>0){SF.message=$('#contactMessage').val()}
if(type){SF.type=type }
if(id){SF.id=id }
if(contactId){SF.contact=contactId }
var page=SF.url.urlPage(location.href)
if(! SF.emailOnly){
if(SF.email==''&&SF.phone==''){
jAlert('Please enter an email or phone number.', 'Alert')
return
}
}
		if(SF.email){
		 if(! SF.validate.checkEmailFormat(SF.email)){
jAlert('Please enter a valid email address.', 'Alert')
return
			}
		}
		if(SF.url.clickedUrlArg('webmaster')){
		 SF.webmaster=1
		}
$.ajax({type:'POST',url:AJAXURL,data:'Action=submitContactUs&Name=' + SF.name +
'&Webmaster=' + SF.webmaster +
'&Email=' + SF.email +
'&Contact=' + SF.contact +
'&Subject=' + SF.subject +
'&Phone=' + SF.phone +
'&Message=' + SF.message +
'&Page=' + page +
'&Type=' + SF.type +
'&Id=' + SF.id,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
jAlert(data.Message, 'Alert')
}
tb_remove()
}
})
}
};var Cookie=function(){
this.cookieName=''
this.createCookie=function(name, value, days){
if( days ){
var date=new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000))
var expires="; expires=" + date.toGMTString()
}else{
var expires=""
}
document.cookie=name + "=" + value + expires +"; path=/"
}
this.eraseCookie=function(name){
this.createCookie(name,"",-1);
}
this.readCookie=function(name){
var nameEQ=name + "="
var ca=document.cookie.split(';')
for(var i=0; i < ca.length; i++){
var c=ca[i];
while(c.charAt(0)==' ') c=c.substring(1, c.length)
if(c.indexOf(nameEQ)==0){
return c.substring(nameEQ.length, c.length)
}
}
return null;
}
}
;var DateTime=function(){
this.dateFromSQLString=function(dateStr){
dateStr=dateStr.split(' ')
return dateStr[0]
}
	this.dateIsAfterToday=function(day, month, year){
	 var SF=this
	 var tomorrow=new Date(SF.currentYear(), SF.currentMonth(), SF.currentDay(), 23, 59).getTime()
		var date=new Date(year, month, day).getTime()
		if(date>tomorrow){
		 return 1
		}else{
		 return 0
		}
	}
this.currentDate=function(){
var SF=this
return SF.currentDay() + '-' + SF.currentMonth() + '-' + SF.currentYear()
}
this.currentDay=function(){
var date=new Date()
return date.getDate()
}
this.currentMonth=function(){
var date=new Date()
var month=date.getMonth()
return month + 1
}
this.currentYear=function(){
var date=new Date()
var year=date.getFullYear()
return year
}
	this.currentHour=function(){
var date=new Date()
return date.getHours()
}
}
;var Emails=function(){
this.height=480
this.width=480
this.init=function(height, width){
var SF=this
if(height){SF.height=height }
if(width){SF.width=width }
$('a.emailLink').each(function(){SF.getEmail($(this), 1)})
$('.emailNonLink').each(function(){SF.getEmail($(this), 0)})
}
this.getEmail=function(elem, link){
var SF=this
var emailId=$(elem).html(),
action
if(emailId=='WEBMASTER'){
$(elem).attr('href', 'html/contact.html?webmaster=1&height=' + SF.height + '&width=' + SF.width)
			$(elem).html('Contact Webmaster')
			$(elem).show()
			return
} else if(emailId.match(/PERSONEMAIL_/)){
action='getPersonEmail'
emailId=emailId.replace('PERSONEMAIL_', '')
} else if(emailId.match(/CONTACTUSEMAIL_/)){
action='getContactUsEmail'
emailId=emailId.replace('CONTACTUSEMAIL_', '')
		}else{
action='getContactUsEmail'
emailId=emailId.replace('CONTACTEMAIL_', '')
}
$.ajax({type:'POST',url:AJAXURL,data:'Action=' + action + '&Id=' + emailId,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(link){
$(elem).attr('href', 'html/contact.html?height=' + SF.height + '&width=' + SF.width)
}
$(elem).html(data.Email)
$(elem).removeClass('hide')
}
})
}
}
;var Expander=function(){
this.toggle=function(elem, target, state){
var SF=this
var src=$(elem).attr('src'),
alt=$(elem).attr('alt')
if(src.match('expand')||state=='expand'){
$(elem).attr('src', src.replace(/expand/, 'collapse'))
$(elem).attr('alt', alt.replace(/Expand/, 'Collapse'))
$(elem).attr('title', alt.replace(/Expand/, 'Collapse'))
$(target).slideDown()
}else{
$(elem).attr('src', src.replace(/collapse/, 'expand'))
$(elem).attr('alt', alt.replace(/Collapse/, 'Expand'))
$(elem).attr('title', alt.replace(/Collapse/, 'Expand'))
$(target).slideUp()
}
}
this.expanded=function(elem){
if($(elem).attr('src').match('expand')){
return 0
}else{
return 1
}
}
}
;var Faqs=function(){
this.html=new Html()
this.thickbox=new ThickBoxGeneric()
this.url=new Url()
this.initCMS=function(){
var SF=this
$('#cmsFaqsTable .deleteFaq').click(function(){SF.deleteFaq($(this))})
$('#cmsFaqsTable .enableFaq').click(function(){SF.enable($(this))})
$('#updateFaqSendMailTo').click(function(){SF.updateEmail()})
}
this.updateEmail=function(){
var SF=this
var email=$('#faqSendMailTo').val()
$('#sendFaqMailToSpan').html(email)
$.ajax({type:'POST',url:CMSURL,data:'Action=updateFaqMail&Email=' + email,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
jAlert('email updated', 'Alert')
}
}
})
}
this.enable=function(elem){
var SF=this
var elemId=$(elem).attr('id'),
enable=SF.html.getCheckBoxValue('#' + elemId)
id=elemId.split('_')
id=id[1]
$('#faqTr_'+id).addClass('selectedRow')
if(enable==0){
action='disableFaq'
if(! confirm('Disable this Faq?')){
SF.html.setCheckBoxValue($(elem), 1)
$('#faqTr_'+id).removeClass('selectedRow')
return
}
}else{
action='enableFaq'
if(! confirm('Enable this Faq?')){
SF.html.setCheckBoxValue($(elem), 0)
$('#faqTr_'+id).removeClass('selectedRow')
return
}
}
$('#faqTr_'+id).removeClass('selectedRow')
$.ajax({type:'POST',url:CMSURL,data:'Action=' + action + '&Id=' + id,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
if(enable==0){
$('#faqTr_'+id).addClass('disabledTr')
}else{
$('#faqTr_'+id).removeClass('disabledTr')
}
}
}
})
}
this.deleteFaq=function(elem){
var SF=this
var elemId=$(elem).attr('id').split('_')
id=id[1]
$('#faqTr_'+id).addClass('selectedRow')
if(! confirm('Delete this FAQ?')){
$('#faqTr_'+id).removeClass('selectedRow')
return
}
$('#faqTr_'+id).removeClass('selectedRow')
$.ajax({type:'POST',url:CMSURL,data:'Action=deleteFaq&Id=' + id,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
$('#faqTr_'+id).remove()
}
}
})
}
this.initFaq=function(){
var SF=this
this.thickbox.init()
SF.cms=SF.url.clickedUrlArg('cms')
SF.id=SF.url.clickedUrlArg('Id')
if(SF.cms){
$('#faqTable .cmsTr').show()
			if(typeof(FAQSHAVETYPES)!='undefined'){
			 $('#faqTypeTr').show()
				SF.getTypes()
}
		}
if(SF.id){
SF.loadFaq()
}
$('#submitFaq').click(function(){SF.submitFaq()})
}
	this.getTypes=function(){
var SF=this
$.ajax({type:'POST',url: CMSSITEURL,
data:'Action=getFaqTypes',
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
					 $('#faqTypeTypeSpan').html(data.FaqTypes)
					 $('#faqTypeIdSpan').html(data.FaqTypesIds)
		 SF.loadFaq()
}
}
})
	}
this.loadFaq=function(){
var SF=this
$.ajax({type:'POST',url:CMSURL,data:'Action=loadFaq&Id=' + SF.id,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'Alert')
}else{
$('#faqName').val(data.FAQ.raisedby)
$('#faqPhone').val(data.FAQ.raisedbyphone)
$('#faqEmail').val(data.FAQ.raisedbyemail)
SF.html.setCheckBoxValue($('#faqEnabled'), data.FAQ.enabled)
$('#faqQuestion').val(unescape(data.FAQ.question))
$('#faqAnswer').val(unescape(data.FAQ.answer))
						if($('#faqTypeType').length){
						 $('#faqTypeType').val(data.FAQ.objecttype)
						 $('#faqTypeId').val(data.FAQ.objectid)
						}
}
}
})
}
this.submitFaq=function(){
var SF=this
var name=escape($('#faqName').val()),
phone=escape($('#faqPhone').val()),
email=escape($('#faqEmail').val()),
question=escape($('#faqQuestion').val()),
answer=escape($('#faqAnswer').val()),
enabled=SF.html.getCheckBoxValue($('#faqEnabled')),
			faqType='',
			faqTypeId=''
		if($('#faqTypeType').length){
		 faqType=$('#faqTypeType').val()
		 faqTypeId=$('#faqTypeId').val()
		}
if(SF.email==''&&! SF.cms){
jAlert('Please enter an email.', 'Alert')
return
}
if(SF.question==''){
jAlert('Please enter a question.', 'Alert')
return
}
$.ajax({type:'POST',url:CMSURL,data:'Action=saveFaq&Id=' + SF.id +
'&CMS=' + SF.cms +
'&Name=' + name +
'&Phone=' + phone +
'&Email=' + email +
'&Enabled=' + enabled +
'&Question=' + question +
'&Answer=' + answer +
										 '&FaqType=' + faqType +
										 '&FaqTypeId=' + faqTypeId,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
if(! SF.cms){
jAlert('Thank you for question, we will get back once we have reviewed it', 'Alert')
}else{
$('#cmsContent').replaceWith(unescape(data.Faqs))
SF.thickbox.applyThickBox('#content .thickbox')
if(SF.id){
jAlert('FAQ updated', 'Alert')
}else{
jAlert('FAQ created', 'Alert')
}
SF.initCMS()
}
}
tb_remove()
}
})
}
}
;var Feedback=function(){
this.editor=new CMSEditor()
this.html=new Html()
this.json=new Json()
this.site=new SiteGeneric()
this.textarea=new Textarea()
this.thickbox=new ThickBoxGeneric()
this.url=new Url()
this.initCMS=function(){
var SF=this
$('#showFeedbackDates').click(function(){SF.showFeedbackDates($(this))})
$('#cmsFeedbackTable .deleteFeedback').click(function(){SF.deleteFeedback($(this))})
$('#cmsFeedbackTable .enableFeedback').click(function(){SF.enable($(this))})
$('#updateFeedbackSendMailTo').click(function(){SF.updateMailTo()})
}
this.updateMailTo=function(){
var SF=this
		var email=$('#sendFeedbackMailTo').val()
$.ajax({type:'POST',url:CMSURL,data:'Action=feedbackSendMailTo&Email=' + email,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
					 $('#sendFeedbackMailToSpan').text(email)
jAlert('Feedback mail will now be sent to "' + email + '"', 'Alert')
}
}
})
}
this.showFeedbackDates=function(elem){
var SF=this
var show=SF.html.getCheckBoxValue($(elem))
$.ajax({type:'POST',url:CMSURL,data:'Action=showFeedbackDates&Show=' + show,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
if(show==1){
jAlert('Dates will now be shown on feedback', 'Alert')
}else{
jAlert('Dates will not now be shown on feedback', 'Alert')
}
}
}
})
}
this.enable=function(elem){
var SF=this
var elemId=$(elem).attr('id'),
enable=SF.html.getCheckBoxValue('#' + elemId)
id=elemId.split('_')
id=id[1]
$('#feedbackTr_'+id).addClass('selectedRow')
if(enable==0){
action='disableFeedback'
if(! confirm('Disable this Feedback?')){
SF.html.setCheckBoxValue($(elem), 1)
$('#feedbackTr_'+id).removeClass('selectedRow')
return
}
}else{
action='enableFeedback'
if(! confirm('Enable this Feedback?')){
SF.html.setCheckBoxValue($(elem), 0)
$('#feedbackTr_'+id).removeClass('selectedRow')
return
}
}
$('#feedbackTr_'+id).removeClass('selectedRow')
$.ajax({type:'POST',url:CMSURL,data:'Action=' + action + '&Id=' + id,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
if(enable==0){
$('#feedbackTr_'+id).addClass('disabledTr')
}else{
$('#feedbackTr_'+id).removeClass('disabledTr')
}
}
}
})
}
this.deleteFeedback=function(elem){
var SF=this
var id=$(elem).attr('id').split('_')
id=id[1]
$('#feedbackTr_'+id).addClass('selectedRow')
if(! confirm('Delete this Feedback?')){
$('#feedbackTr_'+id).removeClass('selectedRow')
return
}
$('#feedbackTr_'+id).removeClass('selectedRow')
$.ajax({type:'POST',url:CMSURL,data:'Action=deleteFeedback&Id=' + id,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
$('#feedbackTr_'+id).remove()
}
}
})
}
this.initFeedback=function(){
var SF=this
SF.textarea.initSpellChecker('checkSpellingButton', 'feedbackText')
this.thickbox.init()
SF.id=SF.url.clickedUrlArg('Id')
SF.cms=SF.url.clickedUrlArg('Cms')
		if(typeof(FEEDBACKCOMPANIES)!='undefined'&&FEEDBACKCOMPANIES==1){
$('#feedbackTable .feedbackCompany').show()
}
if(SF.cms==0){
$('#thickBoxTitle').html('Leave Feedback')
}else{
$('#feedbackTable .cmstr').show()
if(SF.id){
$('#thickBoxTitle').html('Edit Feedback')
}else{
$('#thickBoxTitle').html('New Feedback')
}
SF.loadFeedbackParameters()
}
$('#submitFeedback').click(function(){SF.submitFeedback()})
}
this.loadFeedbackParameters=function(){
	 var SF=this
	 $.ajax({type:'POST',url:CMSURL,data:'Action=loadFeedbackParameters&CalendarId=feedbackDate',
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
						$('#feedbackDatesTd').html(SF.json.jsonDecode(data.Dates))
						SF.site.setDatePicker($('#feedbackDateDateSelect_Calendar'))
SF.editor.inserters(data, 'feedbackText', 'feedbackTable')
						if(SF.id){
						 SF.loadFeedback()
						}
}
}
})
	}
this.loadFeedback=function(){
var SF=this
$.ajax({type:'POST',url:CMSURL,data:'Action=loadFeedback&Id=' + SF.id,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
					 $('.cmsTr').show()
$('#feedbackName').val(data.Feedback.name)
$('#feedbackTitle').val(data.Feedback.title)
$('#feedbackEmail').val(data.Feedback.email)
$('#feedbackPosition').val(data.Feedback.position)
$('#feedbackCompany').val(data.Feedback.company)
$('#feedbackWebsite').val(data.Feedback.companywebsite)
SF.html.setCheckBoxValue($('#feedbackEnabled'), data.Feedback.enabled)
$('#feedbackText').val(unescape(data.Feedback.text))
						SF.html.setDateSelector('feedbackDate', data.Feedback.day, data.Feedback.month, data.Feedback.year)
}
}
})
}
this.submitFeedback=function(){
var SF=this
var name=escape($('#feedbackName').val())
title=escape($('#feedbackTitle').val())
email=escape($('#feedbackEmail').val())
position=escape($('#feedbackPosition').val())
company=escape($('#feedbackCompany').val())
webSite=escape($('#feedbackWebsite').val())
text=encodeURI($('#feedbackText').val())
enabled=SF.html.getCheckBoxValue($('#feedbackEnabled'))
			day='',
			month='',
			year=''
		if($('#feedbackDateDateSelect_Day').length){
day=$('#feedbackDateDateSelect_Day').val()
month=$('#feedbackDateDateSelect_Month').val()
		 year=$('#feedbackDateDateSelect_Year').val()
		}
$.ajax({type:'POST',url:CMSURL,data:'Action=saveFeedback&Id=' + SF.id +
'&Cms=' + SF.cms +
'&Title=' + title +
'&Name=' + name +
'&Email=' + email +
'&Position=' + position +
'&Company=' + company +
'&WebSite=' + webSite +
'&Enabled=' + enabled +
											 '&Day=' + day +
											 '&Month=' + month +
											 '&Year=' + year +
'&Text=' + text,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
if(SF.cms==0){
jAlert('Thanks for you feedback, we really appreciate your comments', 'Alert')
}else{
$('#cmsContent').replaceWith(data.Feedback)
SF.thickbox.applyThickBox('#content .thickbox')
if(SF.id){
jAlert('Feedback updated', 'Alert')
}else{
jAlert('Feedback created', 'Alert')
}
SF.initCMS()
}
}
tb_remove()
}
})
}
}
;var File=function(){
this.basename=function(file){
file=file.split('\\')
return file[file.length - 1]
}
};var Forum=function(){
this.login=new Login(COOKIENAME)
this.thickbox=new ThickBoxGeneric()
this.url=new Url()
this.init=function(){
var SF=this
if(! SF.login.loggedIn()){
$('a.newPost').click(function(){ alert('You must be logged in to create a new post'); tb_remove(); return false })
$('a.replyToPost').click(function(){ alert('You must be logged in to reply to a post'); tb_remove(); return false })
}
}
this.initPost=function(){
var SF=this
SF.thickbox.init()
SF.id=SF.url.clickedUrlArg('Id')
SF.title=SF.url.clickedUrlArg('Title')
if(SF.id){
$('#postTitle').html(SF.title)
$('#postTitleEdit').hide()
$('#postTitleSpan').html(SF.title)
$('#postTitleSpan').show()
}else{
$('#postTitle').html('New Post')
$('#postTitleEdit').show()
$('#postTitleSpan').hide()
}
$('#savePostButton').click(function(){SF.savePost()})
SF.loadPostParameters()
}
this.loadPostParameters=function(){
var SF=this
$.ajax({type:'POST',url:CMSURL,data:'Action=getEmoticons',
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
alert(data.Message)
}else{
$('#postTypesTd').html(data.Emoticons)
}
}
})
}
this.savePost=function(){
var SF=this
var title=escape($('#postTitleEdit').val()),
emoticon=$('#emoticonsSelect').val(),
text=escape($('#post').val())
$.ajax({type:'POST',url:AJAXURL,data:'Action=savePost&Id=' + SF.id +
'&Title=' + title +
'&Emoticon=' + emoticon +
'&Text=' + text,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
alert(data.Message)
}else{
SF.thickbox.applyThickBox($('#content_other a.thickbox'))
alert('Post submitted')
}
tb_remove()
location.reload()
}
})
}
};var GoogleMap=function(){
this.showFromPoint=function(elem, latPos, longPos, markerText){
	 if(GBrowserIsCompatible()){
var map=new GMap2(document.getElementById(elem))
var marker=null
			map.addControl(new GSmallMapControl());
			map.addControl(new GMapTypeControl());
			map.setCenter(new GLatLng(latPos, longPos), 15);
			function createMarker(point,html){
			 var marker=new GMarker(point);
			 GEvent.addListener(marker, "click",
function(){
			 marker.openInfoWindowHtml(html);
			 });
			 return marker;
			 }
			var point=new GLatLng(latPos, longPos);
			marker=createMarker(point,'<div id="mapNote">' + markerText + '</div>')
			map.addOverlay(marker);
	 }
}
this.showFromAddress=function(elem, address){
var SF=this
map=new GMap2(document.getElementById(elem))
geocoder=new GClientGeocoder()
if(geocoder){
geocoder.getLatLng(
address,
function(point){
alert(point)
if(!point){
alert(address + " not found")
}else{
map.setCenter(point, 13)
marker=new GMarker(point)
map.addOverlay(SF.marker)
marker.openInfoWindowHtml(address)
}
})
}
}
}
;var Html=function(){
this.getCheckBoxValue=function(elem){
	 if($(elem).is(':checked')){
return 1
}else{
return 0
}
}
this.setCheckBoxValue=function(elem, value){
if(value==1){
$(elem).prop('checked', true)
}else{
$(elem).prop('checked', false)
}
}
this.setSelect=function(elem, value){
if(value){
$(elem).val(value)
}
}
this.unbindClick=function(elem){
$(elem).unbind('click')
}
this.formatHtml=function(str){
str=str.replace(/£/g, '&pound;') ;
str=str.replace(/é/g, '&eacute;') ;
str=str.replace(/&/g, '_AMP_;') ;
return str
}
this.unformatHtml=function(str){
str=str.replace(/_AMP_;/g, '&') ;
str=str.replace(/&eacute;/g, 'é') ;
str=str.replace(/&pound;/g, '£') ;
str=str.replace(/&apos;/g, "'") ;
str=str.replace(/&quot;/g, '"') ;
str=str.replace(/%u2013/g, '-') ;
return str
}
	this.setDateSelector=function(id, day, month, year){
	 $('#' + id + 'DateSelect_Calendar').val(day + '/' + month + '/' + year)
	 $('#' + id + 'DateSelect_Day').val(day)
$('#' + id + 'DateSelect_Month').val(month)
$('#' + id + 'DateSelect_Year').val(year)
	}
}
;var InputGeneric=function(){
this.tweetLength=140
this.countSummaryChars=function(id){
var SF=this
var len=$('#'+id).val().length
lenStr=len
if(!lenStr){
lenStr='0'
}
$('#' + id + 'Characters').html(lenStr)
if(len>SF.tweetLength){
$('#'+id).addClass('invalid')
}else{
$('#'+id).removeClass('invalid')
}
}
this.inTagsArray=function(val, arr){
for(var i=0; i < arr.length; i++){
if(val==arr[i].tag){
return 1
}
}
return 0 ;
}
}
;var Json=function(){
this.jsonEncode=function(data){
data=data.replace(/£/g, '&pound;')
return encodeURI(data)
}
this.jsonDecode=function(data){
data=decodeURI(data)
data=data.replace(/%26/g, '&')
data=data.replace(/%2C/g, ',')
data=data.replace(/%2F/g, '/')
data=data.replace(/%3A/g, ':')
data=data.replace(/%3B/g, ';')
data=data.replace(/%3D/g, '=')
data=data.replace(/%3F/g, '?')
data=data.replace(/%3F/g, '?')
data=data.replace(/%40/g, '@')
data=data.replace(/%2B/g, '+')
data=data.replace(/&apos;/g, "'")
data=data.replace(/&pound;/g, '£')
return data
}
}
;// See here for more options: http://leandrovieira.com/projects/jquery/lightbox/
var LightBoxGeneric=function(){
this.applyLightBox=function(nodes){
$(nodes).lightBox({
	 imageBlank: COMMONROOT + '/images/lightbox-blank.gif',
	 imageLoading: COMMONROOT + '/images/lightBoxLoading.gif',
	 imageBtnClose: COMMONROOT + '/images/lightBoxClose.gif',
	 imageBtnPrev: COMMONROOT + '/images/lightBoxPrev.gif',
	 imageBtnNext: COMMONROOT + '/images/lightBoxNext.gif'
})
}
}
;var Loader=function(){
this.imageWidth=128
	this.imageHeight=128
this.loaderOn=function(elem, noBackground){
	 var SF=this
if(! $(elem).length){
return
}
	 if($('#loaderOverlay').length==0){
		 $('body').append('<div class="hide" id="loaderOverlay">'
			 + '<img src="images/loading.gif" />'
			 + '</div>')
			if(noBackground){
			 $('#loaderOverlay').css('background-color', 'transparent')
			}
		}
		var left=parseInt($(elem).offset().left)
		var top=parseInt($(elem).offset().top)
		var width=parseInt($(elem).width())
		var height=parseInt($(elem).height())
		$('#loaderOverlay').css('width', width + 'px')
		$('#loaderOverlay').css('height', height + 'px')
		$('#loaderOverlay').css('left', left + 'px')
		$('#loaderOverlay').css('top', top + 'px')
		var imgLeft=parseInt((width - SF.imageWidth) / 2)
		var imgTop=parseInt((height - SF.imageHeight) / 2)
		$('#loaderOverlay img').css('margin-left', imgLeft + 'px')
		$('#loaderOverlay img').css('margin-top', imgTop + 'px')
	 $('#loaderOverlay').show()
	}
	this.loaderOff=function(){
	 $('#loaderOverlay').hide()
	}
};var Login=function(cookieName, noRedirect){
this.username=''
this.password=''
this.loginCookie=cookieName||COOKIENAME
	this.editCookie=this.loginCookie + '_doEdit'
this.noRedirect=noRedirect||false
this.cookie=new Cookie()
this.loader=new Loader()
this.url=new Url()
this.validate=new Validate()
this.email=''
this.username=''
	this.loginLoader=''
	if(typeof(this.loginCookie)=='undefined'){
	 alert('ERROR: No login cookie defined')
	}
this.init=function(redirectUrl){
var SF=this
		SF.redirectUrl=redirectUrl
$('#username').focus(function(){SF.clear($(this), 'Login')})
$('#email').focus(function(){SF.clear($(this), 'Email')})
$('#password').focus(function(){SF.clear($(this), '***')})
$('#submitLogin').click(function(){SF.login()})
$('#logout').click(function(){SF.logout()})
$('#loginTable .mandatory').keyup(function(){SF.validate.checkValid('#loginTable .mandatory')})
}
this.clear=function(elem, val){
if($(elem).val()==val){
$(elem).val('')
}
}
this.loggedIn=function(){
var SF=this
return SF.cookie.readCookie(this.loginCookie) ? 1 : 0
}
this.logout=function(redirect){
var SF=this
var session=SF.cookie.readCookie(this.loginCookie)
$.ajax({type:'POST',url:AJAXURL,data:'Action=logout&Session=' + session,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}
}
})
SF.cookie.eraseCookie(this.loginCookie)
SF.cookie.eraseCookie(this.editCookie)
if(location.href.match(/cms/)||(typeof(GOHOMEONLOGOUT)!='undefined'&&GOHOMEONLOGOUT==1)){
location.replace('index.php')
}else{
location.reload()
}
return false ;
}
this.login=function(){
var SF=this
if(! SF.redirectUrl){
		 SF.redirectUrl='index.php'
		}
if($('#username').length==1){
SF.username=$('#username').val()
}
if($('#email').length==1){
SF.email=$('#email').val()
}
SF.password=$('#password').val()
if(! SF.validate.checkValue('#loginTable .mandatory')){
jAlert('Please complete all mandatory fields', 'Alert')
return
}
		if(SF.loginLoader){
		 $('#' + SF.loginLoader).children().hide()
SF.loader.loaderOn($('#' + SF.loginLoader), 1)
}
$.ajax({type:'POST',url:AJAXURL,data:'Action=login&Username=' + SF.username
+ '&Email=' + SF.email
+ '&Password=' + SF.password,
dataType:'json',timeout:40000,error:
function(){
return false
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'Error')
						if(SF.loginLoader){
						 SF.loader.loaderOff()
						 $('#' + SF.loginLoader).children().show()
						}
}else{
SF.cookie.createCookie(SF.loginCookie, data.Session, 3)
						if(typeof(LOGINNOEDIT)!='undefined'&&LOGINNOEDIT==1&&data.CanEdit==1){
						 SF.doEdit()
						}else{
						 SF.redirect()
						}
}
}
})
}
	this.redirect=function(){
	 var SF=this
		if(SF.noRedirect){
		 location.reload()
		}else{
location.replace(SF.redirectUrl)
		}
	}
this.initForgottenPassword=function(){
var SF=this
var thickbox=new ThickBoxGeneric()
		if(typeof(LOGINWITHUSERNAMES)=='undefined'){
		 $('forgottenPasswordDiv .username').show()
		 $('forgottenPasswordDiv .noUsername').hide()
		}
thickbox.init()
$('#forgottenPasswordSaveButton').click(function(){SF.forgottenPassword()})
}
this.forgottenPassword=function(email, username){
var SF=this
var site=SF.url.clickedUrlArg('Site')
		if(! email&&$('#forgottenPasswordEmail').length){
email=$('#forgottenPasswordEmail').val()
		}
		if(! username&&$('#forgottenPasswordUsername').length){
username=$('#forgottenPasswordUsername').val()
}
$.ajax({type:'POST',url:AJAXURL,data:'Action=forgottenPassword&Site=' + site
+ '&Email=' + email
+ '&Username=' + username,
dataType:'json',timeout:40000,error:
function(){
return false
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
tb_remove()
jAlert('Please check you email for your new password')
}
}
})
}
	this.doEdit=function(val){
	 var SF=this
		var doEdit=SF.cookie.readCookie(SF.editCookie)
		if(! doEdit){
			jConfirm('Edit during this session?', 'Confirm',
			 function(r){
			 if(r){
			 SF.cookie.createCookie(SF.editCookie, 1, 3)
				 }else{
			 SF.cookie.createCookie(SF.editCookie, 0, 3)
					}
					SF.redirect()
			 })
		}
	}
	this.getDoEdit=function(){
	 var SF=this
		return SF.cookie.readCookie(SF.editCookie)
	}
}
;var Page=function(){
this.goToHomePage=function(){
replacePage('index.php')
}
this.replacePage=function(page, args){
url=SITEROOT + '/' + page
if(args){
url=url + '&' + args
}
location.replace(url)
}
this.submitPage=function(url){
$('#replacePage').attr('action', url)
$('#replacePage').submit() ;
}
this.reLoadPage=function(){
submitPage(location.href)
}
}
function toggleExpand(elem, expandText, collapseText){
var id=$(elem).attr('id'),
textId=id + 'Text',
divId=id.replace(/_Expander$/, '')
var src=$(elem).attr('src')
if(src.match(/expand/)){
src=src.replace(/expand/, 'collapse')
if(collapseText){
$('span#' + textId).html(collapseText)
}
$('div#' + divId).show()
}else{
src=src.replace(/collapse/, 'expand')
if(expandText){
$('span#' + textId).html(expandText)
}
$('div#' + divId).hide()
}
$(elem).attr('src', src)
}
;var videoPlayer
var Popup=function(){
this.url=new Url()
	this.init=function(){
	 var SF=this
		var hasVideo=0,
		 player,
		 id=SF.url.clickedUrlArg('Id')
		if($('#sliderImage_'+id).length){
		 if($('#sliderImage_'+id).data('alt')){
		 $('#popupDescriptionTitle').html($('#sliderImage_'+id).data('alt'))
		 }
		 if($('#sliderImage_'+id).data('description')){
		 $('#popupDescriptionText').html($('#sliderImage_'+id).data('description'))
		 }
		 if($('#sliderImage_'+id).data('video')){
			 var str=SF.videoStr($('#contentPod_'+id).data('video'))
		 $('#popupVideo').html(SF.videoStr($('#sliderImage_'+id).data('video')))
				hasVideo=1;
			}
		}
		if($('#podTitle_'+id).length){
		 $('#popupDescriptionTitle').html($('#podTitle_'+id).text())
		 if($('#contentPod_'+id).data('description')){
		 $('#popupDescriptionText').text($('#contentPod_'+id).data('description'))
		 }
		 if($('#contentPod_'+id).data('video')){
			 var str=SF.videoStr($('#contentPod_'+id).data('video'))
		 $('#popupVideo').html(SF.videoStr($('#contentPod_'+id).data('video')))
				hasVideo=1;
			}
		}
		if(hasVideo){
			videoPlayer=_V_('#video-player')
			videoPlayer.ready(function(){ videoPlayer.play()})
			$('#TB_overlay').click(function(){ videoPlayer.destroy()})
		}
	}
	this.videoStr=function(video){
	 return "<video id='video-player' class='video-js vjs-default-skin' controls "
+ "	 preload='auto' width='640' height='360' poster='' "
+ " data-setup='{}'>"
+ " <source src='" + SITEROOT + "/videos/one.mp4' type='video/mp4'> "
+ "</video>"
	}
}
;var Pricelist=function(){
this.booking=new Booking()
this.json=new Json()
this.site=new SiteGeneric()
this.thickbox=new ThickBoxGeneric()
this.url=new Url()
	this.initPricelistBook=function(){
	 var SF=this
		var id=SF.url.clickedUrlArg('Id'),
		 description=$('#itemDescription_'+id).html(),
			sectionId=$('#itemDescription_'+id).data('section')
		if(sectionId){
		 description=$('#sectionDescription_'+id).html() + ' - ' + description
		}
		$('#bookingDescription').html(description)
		SF.thickbox.init()
SF.setDates()
$('#submitBooking').click(function(){SF.booking.submitBooking()})
	}
	this.setDates=function(){
var SF=this
$.ajax({type:'POST',url:CMSURL,data:'Action=getCalendar',
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
alert(data.Message)
}else{
$('#dateSpan').html(SF.json.jsonDecode(data.Dates))
$('#timeSpan').html(SF.json.jsonDecode(data.Times))
}
					SF.site.setDatePicker($('#DateSelect_Calendar'))
}
})
}
this.updateContent=function(data){
var SF=this
$('#cmsContent').replaceWith(data.PriceLists)
SF.initCMS()
SF.thickbox.applyThickBox('#cmsContent .thickbox')
}
}
;var Profile=function(){
this.person=new Person()
this.validate=new Validate()
this.init=function(){
var SF=this
$('#profileTable .changePassword').click(function(){SF.changePassword($(this))})
$('#profileTable .passwordField').keyup(function(){SF.validate.checkValid($(this))})
$('#subscriptionsSaveButton').click(function(){SF.person.saveNewsletterSubscriptions($('#currentUserId').val())})
$('#subscriptionBlogSaveButton').click(function(){SF.person.saveBlogSubscription($('#currentUserId').val())})
}
this.changePassword=function(elem){
var SF=this
var id=$(elem).attr('id').split('_')
id=id[1]
var password=$('#password_'+id),
confirm=$('#confirm_'+id)
if(! SF.validate.checkValue($('#profileTable .passwordField')) ){ return }
if(! SF.validate.checkLength($(password), 6) ){ return }
if(! SF.validate.checkMatch($(password), $(confirm)) ){ return }
var password=$(password).val(),
confirm=$(confirm).val()
$.ajax({type:'POST',url:AJAXURL,data:'Action=changePassword&Id=' + id + '&Password=' + password,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
alert(data.Message)
}else{
alert('Password changed')
}
}
})
}
};var ResetPassword=function(){
this.url=new Url()
this.validate=new Validate()
this.init=function(){
	 var SF=this
		$('#resetPasswordSubmit').click(function(){SF.checkTemporaryPassword()})
	}
	this.checkTemporaryPassword=function(){
	 var SF=this
		var loginId=SF.url.currentUrlArg('LoginId'),
		 password=$('#resetPasswordPassword').val()
		if(! loginId){
		 jAlert('The URL is not valid, or has timed out. Please submit another reset request', 'Alert')
			location.replace('index.php')
		}
		if(! password||password.length < 6){
		 jAlert('Invalid password', 'Alert')
		 return
		}
		$.ajax({type:'POST',url:AJAXURL,data:'Action=submitTemporaryPassword&LoginId=' + loginId +
				 '&Password=' + password,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
					 $('#resetPassword').replaceWith(data.ResetPassword)
						SF.userId=data.UserId
					 $('#changePasswordSubmit').click(function(){SF.changePassword()})
					}
}
})
	}
	this.changePassword=function(){
	 var SF=this
		var password=$('#newPassword').val(),
		 confirm=$('#newPasswordConfirm').val()
		if(! SF.validate.checkLength($('#newPassword'), 6, '', 'Password')){
		 return
		}
		if(! SF.validate.checkMatch($('#newPassword'), $('#newPasswordConfirm'), 'Password')){
		 return
		}
		$.ajax({type:'POST',url:AJAXURL,data:'Action=changePassword&Id=' + SF.userId +
				 '&Password=' + password,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
					 $('#resetPasswordText').text(data.ResetPasswordText)
					 $('#resetPasswordTable').text(data.ResetPasswordTable)
						SF.userId=data.UserId
					 $('#changePasswordSubmit').click(function(){SF.changePassword()})
					}
					jAlert('Password changed', 'ALERT')
}
})
	}
};var Roundabout=function(){
this.thickbox=new ThickBoxGeneric()
this.init=function(elem){
	 var SF=this
var id=$(elem).attr('id').split('-')
SF.id=id[1]
		SF.hasLinks=$('#contentSlider_' + SF.id).data('links')
		SF.autoplay=$('#contentSlider_' + SF.id).data('autoplay')==1 ? true : false
		SF.thickbox.applyThickBoxNoLogin($(elem).find('a').eq(0))
		$(elem).roundabout({
		 autoplay: SF.autoplay,
		 autoplayDuration: 5000,
			triggerFocusEvents: true,
		 clickToFocusCallback: function(){SF.showInfo($(elem))}
		}).bind('childrenUpdated', function(){SF.showInfo($(elem))})
		.fadeIn()
	}
	this.showInfo=function(elem){
	 var SF=this
	 var selected=$(elem).find('.roundabout-in-focus img')
		if(SF.hasLinks){
		 $(elem).find('a').unbind('click')
			SF.thickbox.applyThickBoxNoLogin($(selected).parent())
		}
		if($('#sliderSlideTitle_' + SF.id).length){
		 $('#sliderSlideTitle_' + SF.id).text($(selected).data('alt'))
		}
		if($('#sliderSlideDescription_' + SF.id).length){
		 $('#sliderSlideDescription_' + SF.id).text($(selected).data('description'))
		}
	}
};var StringFuns=function(){
this.getNResultsString=function(n){
var str=''
switch(n){
case 0:
str ='No results'
case 1:
str='1 result'
default:
str=n + ' results'
}
return str
}
this.trim=function(str){
	 str=str.replace(/^\s*/, '')
	 str=str.replace(/\s*$/, '')
		return str
	}
this.ucFirst=function(str){
return str.substr(0, 1).toUpperCase() + str.substr(1)
}
this.lcFirst=function(str){
return str.substr(0, 1).toLowerCase() + str.substr(1)
}
	this.formatTime=function(n){
	 if(n < 10){
		 return '0' + n
		}else{
		 return n
		}
	}
	this.formatMoney=function(n){
	 n=n.toString()
	 if(n.match(/^[0-9]+$/)){
		 return n + '.00'
		} else if(n.match(/^[0-9]+\.[0-9]$/)){
		 return n + '0'
		}else{
		 return n
		}
	}
};var Suggestions=function(){
this.searchId=1
this.init=function(elem, type){
var SF=this
		if(! elem){
		 return
		}
if($('#suggestions').length==0){
$('body').append('<div id="suggestions" >'
			 + '</div>')
}
var left=$(elem).offset().left
var height=$(elem).height()
var top=$(elem).offset().top
$('#suggestions').css('top', +top + height + 5 + 'px')
$('#suggestions').css('left', +left + 'px')
$(elem).keyup(function(){SF.getSuggestions($(this), type)})
}
	this.adjustForThickBox=function(elem){
		if($($(elem).attr('id'), '#TB_window')){
		 var left=$(elem).offset().left,
		 top=$(elem).offset().top,
height=$(elem).height()
$('#suggestions').css('top', +top + height + 5 + 'px')
$('#suggestions').css('left', +left + 'px')
		}
	}
this.getSuggestions=function(elem, type){
var SF=this
var term=$(elem).val()
if(! term){
$('#suggestions').fadeOut()
return
}
		SF.adjustForThickBox(elem)
		SF.searchId++
$.ajax({type:'POST',url:CMSURL,data:'Action=getSuggestions&SearchId=' + SF.searchId + '&Type=' + type + '&Term=' + term,
dataType:'json',timeout:40000,error:
function(){
return false
},success:
function(data){
if(data.Error){
alert(data.Message)
}else{
if(data.SearchId!=SF.searchId){
return
}
$('#suggestions').html(data.Results)
if($('#suggestions').html()){
$('#suggestions div').click(
function(){
$(elem).val($(this).text())
									if($('#' + $(elem).attr('id') + '_Id').length){
									 var id=$(this).attr('id').split('_')
										id=id[1]
										$('#' + $(elem).attr('id') + '_Id').val(id)
									}
$('#suggestions').hide()
})
$('#suggestions').fadeIn()
}else{
$('#suggestions').fadeOut()
}
}
}
})
}
}
;var Textarea=function(){
this.initSpellChecker=function(checker, elem){
		$("#" + checker).click(function(e){
			e.preventDefault();
			$(".loading").show();
			$("#" + elem)
			.spellchecker({
				lang: "en",
				engine: "google",
				suggestBoxPosition: "above",
				url: COMMONROOT + "/checkSpelling.php"
			})
			.spellchecker("check", function(result){
				$(".loading").hide();
				if(result){
					alert('There are no incorrectly spelt words.');
				}
			});
		});
	}
this.bold=function(elem){
var SF=this
SF.insertAtCaret(elem, '', 'bold')
}
this.italic=function(elem){
var SF=this
SF.insertAtCaret(elem, '', 'italic')
}
this.underline=function(elem){
var SF=this
SF.insertAtCaret(elem, '', 'underline')
}
this.superscript=function(elem){
var SF=this
SF.insertAtCaret(elem, '', 'superscript')
}
this.left=function(elem){
var SF=this
SF.insertAtCaret(elem, '', 'left')
}
this.centre=function(elem){
var SF=this
SF.insertAtCaret(elem, '', 'centre')
}
	this.right=function(elem){
var SF=this
SF.insertAtCaret(elem, '', 'right')
}
	this.indent=function(elem){
var SF=this
SF.insertAtCaret(elem, '', 'indent')
}
this.insertAtCaret=function(elem, myValue, type){
var SF=this
return $(elem).each(
function(){
if(document.selection){
this.focus()
sel=document.selection.createRange()
if(! myValue){
myValue=sel.text
}
myValue=SF.getTypedString(myValue, type)
sel.text=myValue
this.focus()
} else if(this.selectionStart||this.selectionStart=='0'){
var startPos=this.selectionStart
var endPos=this.selectionEnd
var scrollTop=this.scrollTop
if(! myValue){
myValue=this.value.substring(startPos, endPos)
}
myValue=SF.getTypedString(myValue, type)
this.value=this.value.substring(0, startPos)
+ myValue
+ this.value.substring(endPos, this.value.length)
this.focus()
this.selectionStart=startPos + myValue.length
this.selectionEnd=startPos + myValue.length
this.scrollTop=scrollTop
}else{
this.value += myValue
this.focus()
}
})
}
this.getTypedString=function(str, type){
switch(type){
case 'bold':
return '<b>' + str + '</b>'
break
case 'italic':
return '<i>' + str + '</i>'
break
case 'underline':
return '<u>' + str + '</u>'
break
case 'superscript':
return '<sup>' + str + '</sup>'
break
			case 'right':
			 return "<p class='right'>" + str + '</p>'
				break
			case 'centre':
			 return "<p class='center'>" + str + '</p>'
				break
			case 'indent':
			 return "<p class='indent'>" + str + '</p>'
				break
default:
return str
break
}
}
this.insertList=function(elem, type){
var SF=this
if(type=='Plain'){
listString='List'
}else{
listString='OList'
}
SF.insertAtCaret(elem, "\n[" + listString + "]\n\n[End" + listString + "]")
}
};var TextNoEdit=function(){
this.thickbox=new ThickBoxGeneric()
this.url=new Url()
this.init=function(){
var SF=this
SF.thickbox.init()
var title=SF.url.clickedUrlArg('Title'),
		 text=SF.url.clickedUrlArg('Text')
		if($('#textNoEditText').length){
		 text=$('#textNoEditText').text()
		}
		$('#textTitle').text(title)
		$('#text').text(text)
	}
};var Textarea=function(){
this.initSpellChecker=function(checker, elem){
		$("#" + checker).click(function(e){
			e.preventDefault();
			$(".loading").show();
			$("#" + elem)
			.spellchecker({
				lang: "en",
				engine: "google",
				suggestBoxPosition: "above",
				url: COMMONROOT + "/checkSpelling.php"
			})
			.spellchecker("check", function(result){
				$(".loading").hide();
				if(result){
					alert('There are no incorrectly spelt words.');
				}
			});
		});
	}
this.bold=function(elem){
var SF=this
SF.insertAtCaret(elem, '', 'bold')
}
this.italic=function(elem){
var SF=this
SF.insertAtCaret(elem, '', 'italic')
}
this.underline=function(elem){
var SF=this
SF.insertAtCaret(elem, '', 'underline')
}
this.superscript=function(elem){
var SF=this
SF.insertAtCaret(elem, '', 'superscript')
}
this.left=function(elem){
var SF=this
SF.insertAtCaret(elem, '', 'left')
}
this.centre=function(elem){
var SF=this
SF.insertAtCaret(elem, '', 'centre')
}
	this.right=function(elem){
var SF=this
SF.insertAtCaret(elem, '', 'right')
}
	this.indent=function(elem){
var SF=this
SF.insertAtCaret(elem, '', 'indent')
}
this.insertAtCaret=function(elem, myValue, type){
var SF=this
return $(elem).each(
function(){
if(document.selection){
this.focus()
sel=document.selection.createRange()
if(! myValue){
myValue=sel.text
}
myValue=SF.getTypedString(myValue, type)
sel.text=myValue
this.focus()
} else if(this.selectionStart||this.selectionStart=='0'){
var startPos=this.selectionStart
var endPos=this.selectionEnd
var scrollTop=this.scrollTop
if(! myValue){
myValue=this.value.substring(startPos, endPos)
}
myValue=SF.getTypedString(myValue, type)
this.value=this.value.substring(0, startPos)
+ myValue
+ this.value.substring(endPos, this.value.length)
this.focus()
this.selectionStart=startPos + myValue.length
this.selectionEnd=startPos + myValue.length
this.scrollTop=scrollTop
}else{
this.value += myValue
this.focus()
}
})
}
this.getTypedString=function(str, type){
switch(type){
case 'bold':
return '<b>' + str + '</b>'
break
case 'italic':
return '<i>' + str + '</i>'
break
case 'underline':
return '<u>' + str + '</u>'
break
case 'superscript':
return '<sup>' + str + '</sup>'
break
			case 'right':
			 return "<p class='right'>" + str + '</p>'
				break
			case 'centre':
			 return "<p class='center'>" + str + '</p>'
				break
			case 'indent':
			 return "<p class='indent'>" + str + '</p>'
				break
default:
return str
break
}
}
this.insertList=function(elem, type){
var SF=this
if(type=='Plain'){
listString='List'
}else{
listString='OList'
}
SF.insertAtCaret(elem, "\n[" + listString + "]\n\n[End" + listString + "]")
}
};var ThickBoxGeneric=function(){
this.images={
'Add':'add.png',
'Left':'text_left.png',
'Indent':'text_indent.png',
'Centre':'text_centre.png',
'Right':'text_right.png',
'Bold':'bold.png',
'Delete':'delete.png',
'Italic':'italic.png',
'Superscript':'superscript.png',
'Underline':'underline.png',
'Sent':'tick.png',
'Is A User':'tick.png',
					'Spelling':'tick.png',
					'Edit':'edit.png',
					'Save':'save.png',
					'Cancel':'close.gif'
}
this.url=new Url()
this.init=function(reload){
var SF=this
SF.setCommonImages($('img.commonFurniture'))
$('.thickBoxCancel').click(function(){ tb_remove()})
$('.mandatory').keyup(function(){SF.checkValid($(this))})
		if(reload){
			$('#TB_overlay').click(function(){ location.reload()})
		}
}
this.setCommonImages=function(elems){
var SF=this
$(elems).each(
function(){
var alt=$(this).attr('alt')
$(this).attr('src', COMMONROOT + '/images/furniture/' + SF.images[alt])
})
}
this.applyThickBox=function(nodes){
var SF=this
$(nodes).unbind('click')
$(nodes).click(
function(){
var login=new Login()
var href=$(this).attr('href')
if($(this).hasClass('needLogin')&&! login.isLoggedIn()){
href=href + '&NotLoggedIn=1'
}
if($(this).hasClass('formLink')){
var id=SF.url.urlArg(location.href, 'Id')
href=SF.url.addIdToHref(href, id)
$(this).attr('href', href)
}
$('#clickedURL').val(href)
})
tb_init(nodes)
}
this.applyThickBoxNoLogin=function(nodes){
$(nodes).unbind('click')
$(nodes).click(
function(){
var href=$(this).attr('href')
$('#clickedURL').val(href)
})
tb_init(nodes)
}
this.checkValid=function(elem){
if($(elem).val()){
$(elem).removeClass('invalid')
}
}
}
;var Url=function(){
this.encode=function(url){
var SF=this
url=encodeURI(url)
url=url.replace(/&amp;/g, '&')
url=url.replace(/&/g, '&amp;')
return url
}
this.currentUrl=function(){
var href=location.href.split('?')
return href[0]
}
this.urlPage=function(url){
url=url.split('?')
url=url[0]
url=url.split('/')
return url[url.length - 1]
}
this.currentUrlArg=function(val){
var SF=this
return SF.urlArg(location.href, val)
}
this.urlArg=function(url, val){
var args=url.split('?')
args=args[1]
if(!args){
return ''
}
args=args.split('&')
var argHash=new Array()
for(var i=0; i < args.length; i++){
params=args[i].split('=')
if(params[0]==val){
return params[1]
}
}
return ''
}
this.clickedUrlArg=function(val){
var SF=this
var clickedURL=$('#clickedURL').val()
return SF.urlArg(clickedURL, val)
}
this.addIdToHref=function(href, id){
var SF=this
if(href.match(/Id=/)){
href=href.replace(/\&Id=[0-9]+\&/, '')
href=href.replace(/\&Id=[0-9]+$/, '')
href=href.replace(/\?Id=[0-9]+\&/, '')
href=href.replace(/\?Id=[0-9]+$/, '')
href=href.replace(/\&Id=\&/, '')
href=href.replace(/\&Id=$/, '')
href=href.replace(/\?Id=\&/, '')
href=href.replace(/\?Id=$/, '')
if(href.match(/\?/)){
href=href + '&Id=' + id
}else{
href=href + '?Id=' + id
}
}
return href
}
}
;var Validate=function(){
this.checkValid=function(elem){
if($(elem).val()){
$(elem).removeClass('invalid')
}
}
this.checkValue=function(elems){
var valid=1
$(elems).each(
function(){
if(! $(this).val()){
$(this).addClass('invalid')
valid=0
}
})
if(! valid){
jAlert('Please complete all mandatory fields', 'Validate Error')
}
return valid
}
	this.checkValueOneOf=function(elems, message){
var valid=0
$(elems).each(
function(){
if($(this).val()){
valid=1
}
})
if(! valid){
		 $(elems).each(
function(){
if(! $(this).val()){
$(this).addClass('invalid')
}
})
jAlert(message, 'Validate Error')
}
return valid
}
this.checkValueNot=function(elem, val){
if($(elem).val()==val){
$(elem).addClass('invalid')
return 0
}else{
return 1
}
}
this.checkMatch=function(elem1, elem2, field){
if($(elem1).val()!=$(elem2).val() ){
$(elem1).addClass('invalid')
$(elem2).addClass('invalid')
jAlert(field + ' fields do not match', 'Validate Error')
return 0
}
return 1
}
this.checkLength=function(elem, min, max, field){
len=$(elem).val().length
if(max){
if(len < min||len>max){
$(elem).addClass('invalid')
jAlert(field + ' field must be between ' + min + ' and ' + max + ' characters (currently ' + len + ')', 'Validate Error')
return 0
}
}else{
if(len < min){
$(elem).addClass('invalid')
jAlert(field + ' field must be at least ' + min + ' characters (currently ' + len + ')', 'Validate Error')
return 0
}
}
return 1
}
this.checkFloat=function(elem){
if($(elem).val().match(/^[0-9]+$/)||$(elem).val().match(/^[0-9]+\.[0-9]+$/)){
return 1
}else{
return 0
}
}
this.checkHourMinute=function(elem){
if($(elem).val().match(/^[0-9]*$/)||$(elem).val().match(/^[0-9]*:[0-9]*$/)){
return 1
}else{
return 0
}
}
	this.checkEmailFormat=function(email){
	 var re=/^[^@]+@[^@]+\.[^@]+$/
return email.match(re)
	}
}
;var Video=function(){
this.init=function(){
	 var SF=this
	 $('.contentGallery .textThumb').click(function(){SF.changeVideo($(this))})
	}
	this.changeVideo=function(elem){
	 var SF=this
		var videoName='',
		 videoId='',
			galleryId=''
		if($(elem).hasClass('selected')){
		 return ;
		}
		if($(elem).hasClass('textThumb')){
		 videoName=$(elem).text()
		 videoOrder=$(elem).attr('id').split('_')
			videoOrder=videoOrder[1]
			galleryId=$(elem).data('galleryid')
			$('#galleryVideoThumbs_' + galleryId + ' .textThumb').removeClass('selected')
			$(elem).addClass('selected')
		}
		$.ajax({type:'POST',url:AJAXURL,data:'Action=loadGalleryVideo&GalleryId=' + galleryId +
				 '&VideoOrder=' + videoOrder,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
						$('#galleryVideo_' + galleryId).html(data.Video)
					}
}
})
	}
};var WebMaster=function(){
this.initContactWebMaster=function(){
	 $('#contactUsTitle').html('Contact Webmaster')
		$('#contactDiv p').eq(0).text("Please enter your name and email address "
+ "(and an optional message), and we'll get back to you")
		$('#contactDiv p').eq(0).after("<p><b>Note: </b>This form is only for enmquiries about the"
+ " site - link exchange requests, web site build enquiries,"
+ " etc., not enquiries about the business who's web site this"
+ " is. Use the email link for these enquiries.")
$('#contactDiv textarea').height(200)
		$('.contactTr').hide()
	}
};var Search=function(){
this.html=new Html()
this.init=function(){
var SF=this
$('#searchOptions .searchOption').click(function(){SF.setSearchOption($(this))})
}
this.setSearchOption=function(elem){
var SF=this
var id=$(elem).attr('id').split('_')
id=id[1]
var checked=SF.html.getCheckBoxValue($(elem))
if(checked){
$('li.searchResult_'+id).show()
}else{
$('li.searchResult_'+id).hide()
}
}
	this.goSearch=function(){
var SF=this
var val=$('#txtSearch').val()
if(! val){
alert('Please enter a search term')
return
}
location.replace('search.php?Term=' + val)
}
}
;var Person=function(){
this.html=new Html()
this.json=new Json()
this.login=new Login()
this.thickbox=new ThickBoxGeneric()
this.suggestions=new Suggestions()
this.url=new Url()
this.initCMS=function(){
var SF=this
		if($('#term').length){
SF.suggestions.init($('#term'), 'People')
$('#searchSubmit').click(function(){SF.getByTerm()})
}
$('#letters .letter a').click(function(){SF.getByLetter($(this))})
$('#pages a').click(function(){SF.getByPage($(this))})
$('#userScopeSelector .userSelector').click(function(){SF.setSelection($(this))})
$('#cmsPeopleTable .deletePerson').click(function(){SF.deletePerson($(this))})
}
this.setSelection=function(elem){
var SF=this
var id=$(elem).attr('id'),
val=SF.html.getCheckBoxValue($(elem))
SF.html.setCheckBoxValue($('#userScopeSelector .userSelector'), 0)
if(id=='selectAll'&&val==0){
SF.html.setCheckBoxValue($(elem), 1)
}else{
if(! val){
SF.html.setCheckBoxValue($('#selectAll'), 1)
}else{
SF.html.setCheckBoxValue($('#selectAll'), 0)
SF.html.setCheckBoxValue($(elem), 1)
}
}
}
this.getByLetter=function(elem, currentPage){
var SF=this
var url=SF.url.currentUrl()
url=url + '?Letter=' + $(elem).text()
$('#userScopeSelector .userSelector').each(
function(){
if(SF.html.getCheckBoxValue($(this))){
var id=$(this).attr('id').replace('select', '')
url=url + '&' + id + '=1'
}
})
$(elem).attr('href', url)
}
this.getByPage=function(elem){
var SF=this
var url=SF.url.currentUrl()
if($('#letters a.selected').length){
url=url + '?Letter=' + $('#letters a.selected').text()
}else{
url=url + '?Term=' + $('#term').val()
}
$('#userScopeSelector .userSelector').each(
function(){
if(SF.html.getCheckBoxValue($(this))){
var id=$(this).attr('id').replace('select', '')
url=url + '&' + id + '=1'
}
})
url=url + '&Page=' + $(elem).html()
$(elem).attr('href', url)
}
this.getByTerm=function(){
var SF=this
var url=SF.url.currentUrl(),
term=$('#term').val()
if(! term){
jAlert('Please enter a search term', 'Alert')
return
}
url=url + '?Term=' + term
$('#userScopeSelector .userSelector').each(
function(){
if(SF.html.getCheckBoxValue($(this))){
var id=$(this).attr('id').replace('select', '')
url=url + '&' + id + '=1'
}
})
location.replace(url)
}
this.deletePerson=function(elem){
var SF=this
var id=$(elem).attr('id').split('_')
id=id[1]
var personName=$('#personName_'+id).html(),
personIsUser=SF.html.getCheckBoxValue($('#isUser_'+id))
$('#personTr_'+id).addClass('invalid')
if(personIsUser){
if(! confirm("Remove person and user '" + personName + "'")){
$('#personTr_'+id).removeClass('invalid')
return
}
}else{
if(! confirm("Remove person '" + personName + "'")){
$('#personTr_'+id).removeClass('invalid')
return
}
}
$('#personTr_'+id).removeClass('invalid')
$.ajax({type:'POST',url:CMSURL,data:'Action=deletePersonAndUser&Id=' + id,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
$('#personTr_'+id).remove()
jAlert('Person deleted', 'Alert')
}
}
})
}
this.initPerson=function(){
var SF=this
SF.thickbox.init()
SF.id=SF.url.clickedUrlArg('Id')
SF.player=SF.url.clickedUrlArg('Player')
SF.loadPersonParameters()
if(! SF.id){
$('#personTitle').html('New Person')
}
$('#isUser').click(function(){SF.toggleUserTable($(this))})
if(SF.player){
$('#isPlayerTr').show()
}
$('#personSaveButton').click(function(){SF.saveDetails()})
$('#userPassword').click(function(){SF.sendNewPassword()})
}
	this.sendNewPassword=function(){
	 var SF=this
		var email=$('#email').val()
		SF.login.forgottenPassword(email)
	}
this.toggleUserTable=function(elem){
var SF=this
var val=SF.html.getCheckBoxValue($(elem))
if(val){
$('#userDetails').slideDown()
}else{
$('#userDetails').slideUp()
}
}
this.loadPersonParameters=function(){
var SF=this
$.ajax({type:'POST',url:CMSURL,data:'Action=loadPersonParameters',
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
$('#userTypesTd').html(data.UserTypes)
$('#birthDateTd').html(SF.json.jsonDecode(data.Dates))
$('#DateSelect_Day').val(0)
$('#DateSelect_Month').val(0)
$('#DateSelect_Year').val(0)
if(SF.id){
SF.loadPerson()
}else{
SF.showTable()
}
}
}
})
}
this.loadPerson=function(){
var SF=this
$.ajax({type:'POST',url:CMSURL,data:'Action=loadPerson&Id=' + SF.id,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
$('#personTitle').html("Edit '" + data.Person.name + "'")
$('#firstName').val(data.Person.firstname)
$('#middleName').val(data.Person.middlename)
$('#surname').val(data.Person.surname)
$('#wholeName').val(data.Person.displayname)
$('#otherName').val(data.Person.othername)
SF.html.setCheckBoxValue($('#personEnabled'), data.Person.personenabled)
$('#userUsername').val(data.Person.username)
SF.html.setSelect($('#userType'), data.Person.usertypeid)
$('#email').val(data.Person.email)
$('#phone').val(data.Person.phoneno)
$('#mobile').val(data.Person.mobileno)
$('#fax').val(data.Person.faxno)
SF.html.setSelect($('#DateSelect_Day'), data.Person.birthday)
SF.html.setSelect($('#DateSelect_Month'), data.Person.birthmonth)
SF.html.setSelect($('#DateSelect_Year'), data.Person.birthyear)
if(data.IsPlayer){
SF.html.setCheckBoxValue($('#personIsPlayer'), 1)
}
if(data.Person.username){
$('#isUser').hide()
$('#isAUser').show()
SF.html.setCheckBoxValue($('#isUser'), 1)
SF.html.setCheckBoxValue($('#userEnabled'), data.Person.userenabled)
$('#username').val(data.Person.username)
SF.toggleUserTable($('#isUser'))
}
}
SF.showTable()
}
})
}
this.showTable=function(){
$('#personTable').fadeIn()
}
this.saveDetails=function(){
var SF=this
var firstName=$('#firstName').val(),
middleName=$('#middleName').val(),
surname=$('#surname').val(),
wholeName=$('#wholeName').val(),
otherName=$('#otherName').val(),
personEnabled=SF.html.getCheckBoxValue($('#personEnabled')),
birthDay=$('#DateSelect_Day').val(),
birthMonth=$('#DateSelect_Month').val(),
birthYear=$('#DateSelect_Year').val(),
isUser=SF.html.getCheckBoxValue($('#isUser')),
username=$('#userUsername').val(),
userType=$('#userType').val(),
userEnabled=SF.html.getCheckBoxValue($('#userEnabled')),
email=$('#email').val(),
phone=$('#phone').val(),
mobile=$('#mobile').val(),
fax=$('#fax').val(),
player=SF.html.getCheckBoxValue($('#personIsPlayer'))
if(! wholeName&&! firstName&&! middleName&&! wholeName){
jAlert('Please enter <i>either</i> First/Name/Middle Name/Surname (preferred) <i>or</i> Whole Name', 'Alert')
return
}
if(wholeName&&(firstName||middleName||wholeName)){
jAlert('Please only enter <i>either</i> First/Name/Middle Name/Surname (preferred) <i>or</i> Whole Name', 'Alert')
return
}
if(isUser&&! email){
jAlert('Please enter an email when creating/updating a user', 'Alert')
return
}
if(isUser){
if(userType==0){
jAlert('Please select a user type', 'Alert')
return
}
if(! username&&firstName){
if(! confirm("No user name; use '" + firstName + "'?")){
return
}else{
username=firstName
}
}
if(! username&&! firstName){
jAlert('Please supply a user name', 'Alert')
return
}
}
$.ajax({type:'POST',url:CMSURL,data:'Action=savePersonAndUser&Id=' + SF.id +
'&FirstName=' + firstName +
'&MiddleName=' + middleName +
'&Surname=' + surname +
'&WholeName=' + wholeName +
'&OtherName=' + otherName +
'&Birthday=' + birthDay +
'&Birthmonth=' + birthMonth +
'&Birthyear=' + birthYear +
'&PersonEnabled=' + personEnabled +
'&IsUser=' + isUser +
'&Username=' + username +
'&UserType=' + userType +
'&UserEnabled=' + userEnabled +
'&Email=' + email +
'&Phone=' + phone +
'&Mobile=' + mobile +
'&Fax=' + fax +
'&Player=' + SF.player +
'&IsPlayer=' + player +
'&Reload=1',
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
var str
if(SF.id){
str='updated'
}else{
str='created'
}
if(isUser){
jAlert('Person and User ' + str, 'Alert')
}else{
jAlert('Person ' + str, 'Alert')
}
}
tb_remove()
if(! SF.id){
location.reload()
}
}
})
}
this.initNewsletters=function( ){
var SF=this
SF.id=SF.url.clickedUrlArg('Id')
SF.thickbox.init()
$('#subscriptionsSaveButton').click(function(){SF.saveNewsletterSubscriptions()})
SF.loadPersonNewslettersParameters()
}
this.loadPersonNewslettersParameters=function(){
var SF=this
$.ajax({type:'POST',url:CMSURL,data:'Action=loadPersonNewslettersParameters',
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
$('#newslettersTable tbody').append(data.Newsletters)
SF.loadPersonNewsletters()
}
}
})
}
this.loadPersonNewsletters=function(){
var SF=this
$.ajax({type:'POST',url:CMSURL,data:'Action=loadPersonNewsletters&Id=' + SF.id,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
var len=data.Newsletters.length
for(var i=0; i < len; i++){
SF.html.setCheckBoxValue($('#newsletter_' + data.Newsletters[i].typeid), 1)
}
}
}
})
}
this.saveNewsletterSubscriptions=function(id){
var SF=this
if(id){
SF.id=id
}
var subscriptionAdds=new Array()
var subscriptionDeletes=new Array()
$('#newslettersTable .newsletterSubscribe').each(
function(){
var id=$(this).attr('id').split('_')
id=id[1]
if(SF.html.getCheckBoxValue($(this))){
subscriptionAdds.push(id)
}else{
subscriptionDeletes.push(id)
}
})
$.ajax({type:'POST',url:CMSURL,data:'Action=savePersonNewsletters&Id=' + SF.id +
'&Additions=' + subscriptionAdds.join(',') +
'&Deletions=' + subscriptionDeletes.join(','),
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
jAlert('Subscriptions saved', 'Alert')
}
tb_remove()
}
})
}
	this.saveBlogSubscription=function(id){
var SF=this
if(id){
SF.id=id
}
		var subscribe=SF.html.getCheckBoxValue($('.blogSubscribe'))
$.ajax({type:'POST',url:CMSURL,data:'Action=savePersonBlog&Id=' + SF.id +
'&Subscribe=' + subscribe,
dataType:'json',timeout:40000,error:
function(){
return false;
},success:
function(data){
if(data.Error){
jAlert(data.Message, 'AJAX Error')
}else{
jAlert('Subscription saved', 'Alert')
}
tb_remove()
}
})
}
};var SiteGeneric=function(){
this.init=function(emailX, emailY, url){
		$('#pageLoader').remove()
		if($('body.supersized').length){
			var urlObj=new Url(),
			 script=urlObj.urlPage(location.href).replace(/\.php.*/, '')
		 $.supersized({
				slides : [ {image : SITEROOT + '/images/supersized/' + script + '.jpg'} ]
			})
		}
		if($('body.supersized-all').length){
		 $.supersized({
				slides : [ {image : SITEROOT + '/images/supersized/supersized.jpg'} ]
			})
		}
		var search=new Search()
		if($('#searchOptions').length){
search.init()
}
		if($('#search.button').length){
$('#txtSearch').focus(function(){ $(this).val('')})
$('#search.button').click(function(){ search.goSearch()})
		}
if($('#loggedInDiv').length){
var cms=new CMS()
cms.init()
}
		if($('#resetPasswordText').length){
		 var reset=new ResetPassword()
			reset.init()
		}
		if($('#profile')){
		 var profile=new Profile()
			profile.init()
		}
var email=new Emails()
		if(emailX&&emailY){
email.init(emailX, emailY)
		}else{
email.init()
		}
var login=new Login(COOKIENAME)
login.init(url)
var thickBox=new ThickBoxGeneric()
thickBox.applyThickBox($('a.thickbox'))
var lBox=new LightBoxGeneric()
		if($('div.popupGallery').length){
lBox.applyLightBox($('div.popupGallery a'))
}
		if($('div.popupImage').length){
lBox.applyLightBox($('div.popupImage a'))
}
		if($('div.contentPopupImage').length){
lBox.applyLightBox($('#contentGallery_1 a'))
}
		if($('.contentWordpress').length){
		 $('.blogText a[rel=nofollow]').hide()
		}
if($('img.captify').length){
$('img.captify').each(function(){
			 if($(this).attr('alt')!=''){
			 $(this).captify({})
				}
			})
}
		if($('div.crossFader').length){
		 $('div.crossFader').sudoSlider({
continuous: true,
fade: true,
fadeSpeed: '1200',
auto: true,
prevNext:false
})
		}
		if($('.coda-slider').length){
$('.coda-slider').codaSlider({
				dynamicArrowLeftText: "&#171;",
		 dynamicArrowRightText: "&#187;"
})
}
		if($('div.nivoSlider').length){
	 $('div.nivoSlider img').eq(0).show()
	 $('div.nivoSlider').nivoSlider({
	 effect:'slideInLeft',
				animSpeed: 1000,
pauseTime: 5000
			})
		}
if($('ul.roundabout').length){
		 var roundabout=new Roundabout()
			$('ul.roundabout').each(function(){
			 roundabout.init($(this))
			})
		}
if($('div.spacegallery').length){
		 $('div.spacegallery').spacegallery({loadingClass: 'loading'}).fadeIn();
		}
if($('div.contentGallery .galleryVideoThumb').length){
var video=new Video()
video.init()
		}
	}
	this.setDatePicker=function(elem, startDay, startMonth, startYear, callback){
	 var SF=this
	 var id=$(elem).attr('id').replace('_Calendar', '_CalendarPicker'),
		 top=parseInt($(elem).position().top + 6),
		 left=parseInt($(elem).position().left + 6),
			fromDate
		$('#'+id).css('top', top + 'px')
		$('#'+id).css('left', left + 'px')
		if(startDay){
		 if(startDay=='today'){
			 fromDate=SF.todayString()
			} else if(startDay=='tomorrow'){
			 fromDate=SF.tomorrowString()
			}else{
		 if(startDay < 10){ startDay='0' + startDay }
		 if(startMonth < 10){ startMonth='0' + startMonth }
fromDate=startDay + '/' + startMonth + '/' + startYear
			}
}else{
fromDate='01/01/1996'
}
		$(elem).datePicker({ createButton:false, startDate: fromDate })
		 .unbind('click')
		 .bind('click', function(){
		 $(this).dpDisplay();
			 this.blur();
			 return false;
			 }
		 )
			 .unbind('dateSelected')
		 .bind('dateSelected', function(e, selectedDate, $td){
			 SF.setDateSelect($(elem), selectedDate)
			 }
		 ).bind('dateSelected', callback)
	}
	this.setDateSelect=function(elem, selectedDate){
	 var day=$(elem).attr('id').replace('_Calendar', '_Day'),
	 month=$(elem).attr('id').replace('_Calendar', '_Month'),
	 year=$(elem).attr('id').replace('_Calendar', '_Year'),
		 dateDay=selectedDate.getDate(),
		 dateMonth=parseInt(selectedDate.getMonth() + 1),
		 dateYear=selectedDate.getFullYear()
		$('#' + day).val(dateDay).focus()
		$('#' + month).val(dateMonth)
		$('#' + year).val(dateYear)
		if(dateDay < 10){ dateDay='0' + dateDay }
		if(dateMonth < 10){ dateMonth='0' + dateMonth }
		$(elem).val(dateDay + '/' + dateMonth + '/' + dateYear)
	}
	this.todayString=function(){
	 var SF=this
		var day=new Date();
		return SF.dateString(day)
	}
	this.tomorrowString=function(){
	 var SF=this
		var day=new Date();
day.setDate(day.getDate()+1);
day=new Date(day)
		return SF.dateString(day)
	}
	this.dateString=function(day){
		var d=day.getDate(day),
		 m=day.getMonth(day) + 1,
		 y=day.getFullYear(day)
		if(d < 10){ d='0' + d }
		if(m < 10){ m='0' + m }
return d + '/' + m + '/' + y
	}
};
