	function check_language_form()

		{

		if (!document.form_lang.lang_name.value)

			{

			alert('Please enter the language name.');

			document.form_lang.lang_name.focus();

			return false;

			}

	if (!document.form_lang.body.value)

			{

			alert('Please enter the Translation File.');

			document.form_lang.body.focus();

			return false;

			}

		}

	function check_unit_types_form()

		{

	if (!document.form_hotel.room_name.value)

			{

			alert('Please enter the Unit Type/Name or Ref.');

			document.form_hotel.room_name.focus();

			return false;

			}

	if (!document.form_hotel.max_adults.value)

			{

			alert('Please Enter the maximum number of persons that can occupy this Unit type.');

			document.form_hotel.max_adults.focus();

			return false;

			}

	if (!document.form_hotel.main_rake_rate.value)

			{

			alert('Please Enter the Rack Rate For this Unit type.');

			document.form_hotel.main_rake_rate.focus();

			return false;

			}
if (document.form_hotel.min_occupancy.selectedIndex == 1)
{
	if (!document.form_hotel.adult_rack_rate.value)

			{

			alert('Please Enter the Adult Rack Rate For this Unit types.');

			document.form_hotel.adult_rack_rate.focus();

			return false;

			}
}
if (document.form_hotel.max_additional.selectedIndex == 1)
{
	if ((!document.form_hotel.additional_rate.value) && (!document.form_hotel.additional_child_rate.value))

			{

			alert('Please Enter the Additional Adults or Children Rates For this Unit types.');

			return false;

			}
}

	if (!document.form_hotel.room_quantity.value)

			{

			alert('Please Enter the total number of Units For this Unit types.');

			document.form_hotel.room_quantity.focus();

			return false;

			}

		}

	function check_extraservices_form()

		{

	if (!document.form_rates.service_name.value)

			{

			alert('Please Enter the Service Name.');

			document.form_rates.service_name.focus();

			return false;

			}

	if (!document.form_rates.price.value)

			{

			alert('Please Enter the price For this service.');

			document.form_rates.price.focus();

			return false;

			}

		}
	function check_vouchers_form()

		{
	if (!document.form_rates.voucher_code.value)

			{

			alert('Please Enter the Voucher Code.');

			document.form_rates.voucher_code.focus();

			return false;

			}

	if (!document.form_rates.voucher_saving.value)

			{

			alert('Please Enter the saving For this voucher.');

			document.form_rates.voucher_saving.focus();

			return false;

			}

		}


function delete_room_types_confirm(url)

			{

			var check_delete = window.confirm('Are you sure want to delete this Unit? All Availability Dates, Rates and unit translation will be permanently deleted too.');



			if (check_delete)

				{

				location.href = url;

				}

			}
function delete_room_images_confirm(url)

			{

			var check_delete = window.confirm('Are you sure want to delete this Image?');



			if (check_delete)

				{

				location.href = url;

				}

			}
function delete_reservation_payment_confirm(url)
{
var check_delete = window.confirm('Are you sure want to delete this Payment?');
if (check_delete)
{
location.href = url;
}
}
function delete_languages_confirm(url)

			{

			var check_delete = window.confirm('Are you sure want to delete this language? All related translation file and unit type will be permanently deleted too.');



			if (check_delete)

				{

				location.href = url;

				}

			}
function delete_extraservices_confirm(url)

			{

			var check_delete = window.confirm('Are you sure want to delete this service?');



			if (check_delete)

				{

				location.href = url;

				}

			}
function delete_voucher_confirm(url)

			{

			var check_delete = window.confirm('Are you sure want to delete this voucher?');



			if (check_delete)

				{

				location.href = url;

				}

			}
function delete_mailshot_confirm(url)

			{

			var check_delete = window.confirm('Are you sure want to delete this message?');



			if (check_delete)

				{

				location.href = url;

				}

			}

	function check_settings_form()

		{

		if (!document.form_settings.username.value)

			{

			alert('Please enter the user name.');

			document.form_settings.username.focus();

			return false;

			}

	if (!document.form_settings.password.value)

			{

			alert('Please enter the password.');

			document.form_settings.password.focus();

			return false;

			}

		}
function check_form_pay()
{
if (!document.form_pay.payment_ammount.value)
{
alert('Please enter the payment ammount.');
document.form_pay.payment_ammount.focus();
return false;
}
}

	function check_payements_form()

		{

		if (!document.form_payments.currency.value)

			{

			alert('Please enter the main default currency.');

			document.form_payments.currency.focus();

			return false;

			}

		}
	function check_form_members()
		{
		if (!document.form_members.discount.value)
			{
			alert('Please enter the discount in percentage for this member.');
			document.form_members.discount.focus();
			return false;
			}
	if (!document.form_members.password.value)
			{
			alert('Please enter the password for this member.');
			document.form_members.password.focus();
			return false;
			}
		}
	function check_seasonal_rates_form()

			{

			if ((document.form_rates.from_mday.selectedIndex == 0) || (document.form_rates.from_mon.selectedIndex == 0))

				{

				alert('Please specify a valid start date');

				document.form_rates.from_mday.focus();

				return false;

				}

			if ((document.form_rates.to_mday.selectedIndex == 0) || (document.form_rates.to_mon.selectedIndex == 0))

				{

				alert('Please specify a valid to date');

				document.form_rates.to_mday.focus();

				return false;

				}

			if (!document.form_rates.weekday_rate.value)

				{

				alert('Please specify the daily rate.');

				document.form_rates.weekday_rate.focus();

				return false;				

				}

			if (!document.form_rates.weekend_rate.value)

				{

				alert('Please specify the weekend rate.');

				document.form_rates.weekend_rate.focus();

				return false;				

				}

				}

	function delete_seasonal_rates_confirm(url)

			{

			var check_delete = window.confirm('Are you sure want to delete this unit rate?');



			if (check_delete)

				{

				location.href = url;

				}

			}



function check_form_hot_deals()

			{

	if (!document.form_rates.special_title.value)

				{

				alert('Please specify the Special Offer Name.');

				document.form_rates.special_title.focus();

				return false;				

				}

			if ((document.form_rates.from_mday.selectedIndex == 0) || (document.form_rates.from_mon.selectedIndex == 0))

				{

				alert('Please specify a valid start date');

				document.form_rates.from_mday.focus();

				return false;

				}

			if ((document.form_rates.to_mday.selectedIndex == 0) || (document.form_rates.to_mon.selectedIndex == 0))

				{

				alert('Please specify a valid to date');

				document.form_rates.to_mday.focus();

				return false;

				}

	if (!document.form_rates.nights.value)

				{

				alert('Please specify the number of nights required.');

				document.form_rates.nights.focus();

				return false;				

				}

	     		}


	function delete_hot_deals_confirm(url)

			{

			var check_delete = window.confirm('Are you sure want to delete this Special Offer?');



			if (check_delete)

				{

				location.href = url;

				}

			}
	function delete_member_confirm(url)

			{

			var check_delete = window.confirm('Are you sure want to delete this Member?');



			if (check_delete)

				{

				location.href = url;

				}

			}
function delete_reservatin_confirm(url)

			{

			var check_delete = window.confirm('Are you sure want to delete this reservation? All details of this reservation will be permanently deleted.');



			if (check_delete)

				{

				location.href = url;

				}

			}
function delete_currency_confirm(url)

			{

			var check_delete = window.confirm('Are you sure want to delete this currency?');



			if (check_delete)

				{

				location.href = url;

				}

			}
function pass_values(thisform)
	{
	opener.document.form_rates.member_id.value = document.guest_form.member_id.value;
	opener.document.form_rates.title.value = document.guest_form.title.value;
	opener.document.form_rates.first_name.value = document.guest_form.first_name.value;
	opener.document.form_rates.last_name.value = document.guest_form.last_name.value;
	opener.document.form_rates.address.value = document.guest_form.address.value;
	opener.document.form_rates.town_city.value = document.guest_form.town_city.value;
	opener.document.form_rates.postcode.value = document.guest_form.postcode.value;
	opener.document.form_rates.country.value = document.guest_form.country.value;
	opener.document.form_rates.telephone.value = document.guest_form.telephone.value;
	opener.document.form_rates.email.value = document.guest_form.email.value;
	window.close();
	}
function Show_Room_break_down(IDS) { 
  document.getElementById(IDS).style.display = "block";
} 
function Hide_Room_break_down(IDS) { 
  document.getElementById(IDS).style.display = "none"; 
} 
function check_room_types_form()
						{
						var count = 0;
						for (i=0,n=document.form_reservation.elements.length;i<n;i++)
							{
	   						if ((document.form_reservation.elements[i].name.indexOf('quantity_') !=-1) && (document.form_reservation.elements[i].value))
								{
								count++;
								}
							}

						if (count == 0)
							{
							alert('You Have Not Selected Any Rooms.\n\nPlease Select The Number Of Rooms.');
							return false;
							}
						}
function new_reservation_add_form()
{
var count = 0;
for (i=0,n=document.form_rates.elements.length;i<n;i++)
{
if ((document.form_rates.elements[i].name.indexOf('quantity_') !=-1) && (document.form_rates.elements[i].value))
{
count++;
}
}
if (count == 0)
{
alert('You Have Not Selected Any Accommodation.\n\nPlease Select The Number Of Units you wish to reserve.');
return false;
}
if (!document.form_rates.accommodation_costs.value)
{
alert('Please enter the Total Accommodation Cost.');
document.form_rates.accommodation_costs.focus();
return false;
}
if (!document.form_rates.last_name.value)
{
alert('Please enter the Last Name.');
document.form_rates.last_name.focus();
return false;
}
}
function reservation_edit_form()
{
if (!document.form_contact.last_name.value)
{
alert('Please enter the Last Name.');
document.form_contact.last_name.focus();
return false;
}
}
var win=null;

function NewWindow(mypage,myname,w,h,scroll,pos){

if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}

if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}

else if((pos!="center" && pos!="random") || pos==null){LeftPosition=20;TopPosition=20}

settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';

win=window.open(mypage,myname,settings);}


//Contents for menu 0

var menu0=new Array()

menu0[0]='<table width=200 cellpadding="3" cellspacing="3" border="1" bgcolor="lightyellow" bordercolor="#006699" id="nine"><TR bordercolor="#006699"><td id="nine" nowrap><b><a href="admin_config.cgi?task=edit_paths" style="color: #0000FF; text-decoration: none">Server Settings</a></b></td></tr>'

menu0[1]='<TR bordercolor="#006699"><td id="nine"><b><a href="admin_config.cgi" style="color: #0000FF; text-decoration: none">System Settings</a></b></td></tr>'

menu0[2]='<TR bordercolor="#006699"><td id="nine"><b><a href="admin_payments.cgi" style="color: #0000FF; text-decoration: none">Payments Settings</a></b></td></tr>'

menu0[3]='<TR bordercolor="#006699"><td id="nine"><b><a href="admin_payments.cgi?task=currencies" style="color: #0000FF; text-decoration: none">Additional Currencies</a></b></td></tr></table>'


//Contents for menu 1

var menu1=new Array()

menu1[0]='<table width=200 cellpadding="3" cellspacing="3" border="1" bgcolor="lightyellow" bordercolor="#006699" id="nine"><TR bordercolor="#006699"><td id="nine" nowrap><b><a href="admin_rates.cgi" style="color: #0000FF; text-decoration: none">Seasonal, Monthly Variations</a></b></td></tr>'

menu1[1]='<TR bordercolor="#006699"><td id="nine"><b><a href="admin_rates.cgi?task=edit_hot_deals" style="color: #0000FF; text-decoration: none">Discounts, Special Offers</a></b></td></tr>'

menu1[2]='<TR bordercolor="#006699"><td id="nine"><b><a href="admin_corp_members.cgi" style="color: #0000FF; text-decoration: none">Members, Corp Discounts</a></b></td></tr>'
menu1[3]='<TR bordercolor="#006699"><td id="nine"><b><a href="admin_rates.cgi?task=vouchers" style="color: #0000FF; text-decoration: none">Vouchers And Coupons</a></b></td></tr>'

menu1[4]='<TR bordercolor="#006699"><td id="nine"><b><a href="admin_rates.cgi?task=edit_services" style="color: #0000FF; text-decoration: none">Extra Services</a></b></td></tr></table>'



//Contents for menu 2

var menu2=new Array()

menu2[0]='<table width=200 cellpadding="3" cellspacing="3" border="1" bgcolor="lightyellow" bordercolor="#006699" id="nine"><TR bordercolor="#006699"><td id="nine" nowrap><b><a href="admin_settings.cgi?task=reservations_search&current=yes" style="color: #0000FF; text-decoration: none">Current Reservations</a></b>&nbsp;</td></tr>'

menu2[1]='<TR bordercolor="#006699"><td id="nine" nowrap><b><a href="admin_settings.cgi?task=reservations_search" style="color: #0000FF; text-decoration: none">All Reservations</a></b></td></tr>'

menu2[2]='<TR bordercolor="#006699"><td id="nine" nowrap><b><a href="admin_modules.cgi?module=advanced_reports" style="color: #0000FF; text-decoration: none">Reservations Reports</a></b></td></tr>'

menu2[3]='<TR bordercolor="#006699"><td id="nine" nowrap><b><a href="admin_modules.cgi?module=failed_report" style="color: #0000FF; text-decoration: none">Denied Reservations</a></b></td></tr>'

menu2[4]='<TR bordercolor="#006699"><td id="nine" nowrap><b><a href="admin_settings.cgi?task=new_reservation" style="color: #0000FF; text-decoration: none">Add New Reservation</a></b></td></tr></table>'

//Contents for menu 3

var menu3=new Array()

menu3[0]='<table width=200 cellpadding="3" cellspacing="3" border="1" bgcolor="lightyellow" bordercolor="#006699" id="nine"><TR bordercolor="#006699"><td id="nine" nowrap><b><a href="admin_inventory.cgi" style="color: #0000FF; text-decoration: none">Update Availability</a></b>&nbsp;</td></tr>'
menu3[1]='<TR bordercolor="#006699"><td id="nine" nowrap><b><a href="admin_inventory.cgi?task=global_update" style="color: #0000FF; text-decoration: none">Close, Open Availability</a></b>&nbsp;</td></tr>'
menu3[2]='<TR bordercolor="#006699"><td id="nine" nowrap><b><a href="admin_inventory.cgi?task=availability" style="color: #0000FF; text-decoration: none">Availability Calendar</a></b></td></tr>'
menu3[3]='<TR bordercolor="#006699"><td id="nine" nowrap><b><a href="admin_inventory.cgi?task=availability_report" style="color: #0000FF; text-decoration: none">Availability Report</a></b></td></tr></table>'

var menuwidth='180px' //default menu width

var menubgcolor='lightyellow'  //menu bgcolor

var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)

var hidemenu_onclick="yes" //hide menu when user clicks within menu?



/////No further editting needed



var ie4=document.all

var ns6=document.getElementById&&!document.all



if (ie4||ns6)

document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')



function getposOffset(what, offsettype){

var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;

var parentEl=what.offsetParent;

while (parentEl!=null){

totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;

parentEl=parentEl.offsetParent;

}

return totaloffset;

}





function showhide(obj, e, visible, hidden, menuwidth){

if (ie4||ns6)

dropmenuobj.style.left=dropmenuobj.style.top=-500

if (menuwidth!=""){

dropmenuobj.widthobj=dropmenuobj.style

dropmenuobj.widthobj.width=menuwidth

}

if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")

obj.visibility=visible

else if (e.type=="click")

obj.visibility=hidden

}



function iecompattest(){

return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body

}



function clearbrowseredge(obj, whichedge){

var edgeoffset=0

if (whichedge=="rightedge"){

var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15

dropmenuobj.contentmeasure=dropmenuobj.offsetWidth

if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)

edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth

}

else{

var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18

dropmenuobj.contentmeasure=dropmenuobj.offsetHeight

if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)

edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight

}

return edgeoffset

}



function populatemenu(what){

if (ie4||ns6)

dropmenuobj.innerHTML=what.join("")

}





function dropdownmenu(obj, e, menucontents, menuwidth){

if (window.event) event.cancelBubble=true

else if (e.stopPropagation) e.stopPropagation()

clearhidemenu()

dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv

populatemenu(menucontents)



if (ie4||ns6){

showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)

dropmenuobj.x=getposOffset(obj, "left")

dropmenuobj.y=getposOffset(obj, "top")

dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"

dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"

}



return clickreturnvalue()

}



function clickreturnvalue(){

if (ie4||ns6) return false

else return true

}



function contains_ns6(a, b) {

while (b.parentNode)

if ((b = b.parentNode) == a)

return true;

return false;

}



function dynamichide(e){

if (ie4&&!dropmenuobj.contains(e.toElement))

delayhidemenu()

else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))

delayhidemenu()

}



function hidemenu(e){

if (typeof dropmenuobj!="undefined"){

if (ie4||ns6)

dropmenuobj.style.visibility="hidden"

}

}



function delayhidemenu(){

if (ie4||ns6)

delayhide=setTimeout("hidemenu()",disappeardelay)

}



function clearhidemenu(){

if (typeof delayhide!="undefined")

clearTimeout(delayhide)

}



if (hidemenu_onclick=="yes")

document.onclick=hidemenu

// 727417091948
// stbec1975
	var font='<font face="arial, helvetica" size=1 color=white>';
	var headerColor="#BBBBBB";
	var lightHeaderColor="#CCCCCC";
	var monthDaysColor="#EEEEEE";
	var url = "http://www.systemforhotels.com/";
	var dayName=new Array(	"Sunday",
				"Monday",
				"Tuesday",
				"Wednesday",
				"Thursday",
				"Friday",
				"Saturday")
				
	var monthName=new Array("January",
				"February",
				"March",
				"April",
				"May",
				"June",
				"July",
				"August",
				"September",
				"October",
				"November",
				"December")
	
	
// 727417091948
				
	var monthDays=new Array(31,28,31,30,31,30,31,31,30,31,30,31)
	var now=new Date
	var nowd=now.getDate()
	var nowm=now.getMonth()
	var nowy=now.getYear()
	var NN4 = document.layers? true : false;
	var IE4 = document.all? true : false;
	
	
	function prevCalendar(day,month,year)
	{
	nowm--; if (nowm<0) { nowy--; nowm=11; } showCalendar(nowd,nowm,nowy)
	}
	
	function nextCalendar(day,month,year)
	{
	nowm++; if (nowm>11) { nowy++; nowm=0; } showCalendar(nowd,nowm,nowy)
	}
	
	function startDate(day,month,year)
	{
	var yearIndex=year - now.getYear()
	
	
	document.form_rates.from_mon.selectedIndex=month
	document.form_rates.from_mday.selectedIndex=day
	document.form_rates.from_year.selectedIndex=yearIndex
	document.all['calendar'].style.visibility = "hidden";
	
	}
	
	function showCalendar(day,month,year)
	{
	var monthNumber = month + 1;
	var monthIndex= now.getMonth()
	var yearIndex = now.getYear()
	
	if ((year%4 == 0)&&(year%100 != 0) || (year%400 == 0)) monthDays[1]=29; else monthDays[1]=28 // test for leap years
	var firstDay=new Date(year,month,1).getDay()
	var startCalCode="<table cellpadding=1 bgcolor=" +headerColor+ "><tr><td><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2 width=150 height=175 bgcolor=white>"
	startCalCode+="<TR>"
	startCalCode+="<TD height=20 bgcolor="+headerColor+" ALIGN=center><a href=\"javascript:prevCalendar(nowd,nowm,nowy)\">"+font+"<font size=2><b><<</b></a></TD>"
	startCalCode+="<TD height=20 bgcolor="+headerColor+" COLSPAN=5 ALIGN=center>"+font+"<font size=2><b>"+monthName[month]+" "+year
	startCalCode+="</TD><TD height=20 bgcolor="+headerColor+" ALIGN=center><a href=\"javascript:nextCalendar(nowd,nowm,nowy)\">"+font+"<font size=2><b>>></b></a></TD>"
	startCalCode+="</TR>"
	startCalCode+="<TR>"
	for (var i=0;i<dayName.length;i++) startCalCode+="<TD bgcolor="+lightHeaderColor+" ALIGN=center>"+font+dayName[i].substring(0,1)+"</TD>"
	var dayCount=1
	startCalCode+="</TR>"
	startCalCode+="<TR>"
	for (var i=0;i<firstDay;i++) startCalCode+="<TD>&nbsp;</TD>"
	for (var i=0;i<monthDays[month];i++)
	{
		
		if ((nowd == (i+1))&&(nowm == monthIndex)&&(nowy == yearIndex)) startCalCode+='<TD bgcolor='+lightHeaderColor+' ALIGN=center>'+font+'<a href="Javascript:startDate('+dayCount+','+monthNumber+','+year+')">'+dayCount++;
		else startCalCode+='<TD bgcolor='+monthDaysColor+' ALIGN=center>'+font+'<a href="Javascript:startDate('+dayCount+','+monthNumber+','+year+')">'+dayCount++;
		
		startCalCode+="</a></TD>"
		if ((i+firstDay+1)%7==0&&(dayCount<monthDays[month]+1)) startCalCode+="</TR><TR>"
	}
	var totCells=firstDay+monthDays[month]
	for (var i=0;i<(totCells>28?(totCells>35?42:35):28)-totCells;i++) startCalCode+="<TD>&nbsp;</TD>"
	startCalCode+='</TR><TR><TD COLSPAN=7 BGCOLOR='+lightHeaderColor+'><center>'+font+'( <a href="javascript:void()" onMouseDown="javascript:hide_start()">close</a> )</center></TD></TR></TABLE></td></tr></table><BR>'
	calendar.innerHTML=startCalCode
	document.all['calendar'].style.visibility = "visible";
	
	
	}

	function display() {
	    document.all['calendar'].style.visibility = "visible";
	}
	
	function hide_start() {
	    document.all['calendar'].style.visibility = "hidden";
	}	
	
	
// ENDING DATE CALENDAR ROUTINES


	function prevCalendar_end(day,month,year)
	{
	nowm--; if (nowm<0) { nowy--; nowm=11; } showCalendarEnd(nowd,nowm,nowy)
	}
	
	function nextCalendar_end(day,month,year)
	{
	nowm++; if (nowm>11) { nowy++; nowm=0; } showCalendarEnd(nowd,nowm,nowy)
	}
	
	function endDate(day,month,year)
	{
	var yearIndex=year - now.getYear()
	
	document.form_rates.to_mon.selectedIndex=month
	document.form_rates.to_mday.selectedIndex=day
	document.form_rates.to_year.selectedIndex=yearIndex
	document.all['calendar_end'].style.visibility = "hidden";
	
	}
	    
	function showCalendarEnd(day,month,year)
	{
	var monthNumber = month + 1;
	var monthIndex = now.getMonth()
	var yearIndex = now.getYear()
	
	if ((year%4 == 0)&&(year%100 != 0) || (year%400 == 0)) monthDays[1]=29; else monthDays[1]=28 // test for leap years
	var firstDay=new Date(year,month,1).getDay()
	var endCalCode="<table cellpadding=1 bgcolor=" +headerColor+ "><tr><td><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2 width=150 height=175 bgcolor=white>"
	endCalCode+="<TR>"
	endCalCode+="<TD height=20 bgcolor="+headerColor+" ALIGN=center><a href=\"javascript:prevCalendar_end(nowd,nowm,nowy)\">"+font+"<font size=2><b><<</b></a></TD>"
	endCalCode+="<TD height=20 bgcolor="+headerColor+" COLSPAN=5 ALIGN=center>"+font+"<font size=2><b>"+monthName[month]+" "+year
	endCalCode+="</TD><TD height=20 bgcolor="+headerColor+" ALIGN=center><a href=\"javascript:nextCalendar_end(nowd,nowm,nowy)\">"+font+"<font size=2><b>>></b></a></TD>"
	endCalCode+="</TR>"
	endCalCode+="<TR>"
	for (var i=0;i<dayName.length;i++) endCalCode+="<TD bgcolor="+lightHeaderColor+" ALIGN=center>"+font+dayName[i].substring(0,1)+"</TD>"
	var dayCount=1
	endCalCode+="</TR>"
	endCalCode+="<TR>"
	for (var i=0;i<firstDay;i++) endCalCode+="<TD>&nbsp;</TD>"
	for (var i=0;i<monthDays[month];i++)
	{
		if ((nowd == (i+1))&&(nowm == monthIndex)&&(nowy == yearIndex)) endCalCode+='<TD bgcolor='+lightHeaderColor+' ALIGN=center>'+font+'<a href="Javascript:endDate('+dayCount+','+monthNumber+','+year+')">'+dayCount++;		
		else endCalCode+='<TD bgcolor='+monthDaysColor+' ALIGN=center>'+font+'<a href="Javascript:endDate('+dayCount+','+monthNumber+','+year+')">'+dayCount++;
		endCalCode+="</a></TD>"
		if ((i+firstDay+1)%7==0&&(dayCount<monthDays[month]+1)) endCalCode+="</TR><TR>"
	}
	var totCells=firstDay+monthDays[month]
	for (var i=0;i<(totCells>28?(totCells>35?42:35):28)-totCells;i++) endCalCode+="<TD>&nbsp;</TD>"
	endCalCode+='</TR><TR><TD COLSPAN=7 BGCOLOR='+lightHeaderColor+'><center>'+font+'( <a href="javascript:void()" onMouseDown="javascript:hide_end()">close</a> )</center></TD></TR></TABLE></td></tr></table><BR>'
	calendar_end.innerHTML=endCalCode
	document.all['calendar_end'].style.visibility = "visible";
	
	}



	function display_end() {
	    document.all['calendar_end'].style.visibility = "visible";
	}
	

	
	function hide_end() {
	    document.all['calendar_end'].style.visibility = "hidden";
	}


// MAIN CALENDAR DATE DISPLAY

	function showMainCalendar(day,month,year)
	{
		
	var monthNumber = month + 1;
	var monthIndex= now.getMonth()
	var yearIndex = now.getYear()
	var session = GetCookie('session')
	
	if ((year%4 == 0)&&(year%100 != 0) || (year%400 == 0)) monthDays[1]=29; else monthDays[1]=28 // test for leap years
	var firstDay=new Date(year,month,1).getDay()
	var mainCalCode="<table cellpadding=1 bgcolor=" +headerColor+ "><tr><td><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2 width=150 height=175 bgcolor=white>"
	mainCalCode+="<TR>"
	mainCalCode+="<TD height=20 bgcolor="+headerColor+" ALIGN=center><a href=\"javascript:prevCalendar_main(nowd,nowm,nowy)\">"+font+"<font size=2><b><<</b></a></TD>"
	mainCalCode+="<TD height=20 bgcolor="+headerColor+" COLSPAN=5 ALIGN=center>"+font+"<font size=2><b>"+monthName[month]+" "+year
	mainCalCode+="</TD><TD height=20 bgcolor="+headerColor+" ALIGN=center><a href=\"javascript:nextCalendar_main(nowd,nowm,nowy)\">"+font+"<font size=2><b>>></b></a></TD>"
	mainCalCode+="</TR>"
	mainCalCode+="<TR>"
	for (var i=0;i<dayName.length;i++) mainCalCode+="<TD bgcolor="+lightHeaderColor+" ALIGN=center>"+font+dayName[i].substring(0,1)+"</TD>"
	var dayCount=1
	mainCalCode+="</TR>"
	mainCalCode+="<TR>"
	for (var i=0;i<firstDay;i++) mainCalCode+="<TD>&nbsp;</TD>"
	for (var i=0;i<monthDays[month];i++)
	{
		
		if ((nowd == (i+1))&&(nowm == monthIndex)&&(nowy == yearIndex)) mainCalCode+='<TD bgcolor='+lightHeaderColor+' ALIGN=center>'+font+'<a href="'+url+'?request=display_specific_date_events&website=default&month='+monthNumber+'&day='+dayCount+'&year='+year+'&category_id=&set=1&session='+session+'">'+dayCount++;
		else mainCalCode+='<TD bgcolor='+monthDaysColor+' ALIGN=center>'+font+'<a href="'+url+'?request=display_specific_date_events&website=default&month='+monthNumber+'&day='+dayCount+'&year='+year+'&category_id=&set=1&session='+session+'">'+dayCount++;
		
		mainCalCode+="</a></TD>"
		if ((i+firstDay+1)%7==0&&(dayCount<monthDays[month]+1)) mainCalCode+="</TR><TR>"
	}
	var totCells=firstDay+monthDays[month]
	for (var i=0;i<(totCells>28?(totCells>35?42:35):28)-totCells;i++) mainCalCode+="<TD>&nbsp;</TD>"
	mainCalCode+='</TR><TR><TD COLSPAN=7 BGCOLOR='+lightHeaderColor+'><center>'+font+'( <a href="javascript:void()" onMouseDown="javascript:hide()">close</a> )</center></TD></TR></TABLE></td></tr></table><BR>'
	calendar_main.innerHTML=mainCalCode
	document.all['calendar_main'].style.visibility = "visible";
	}

	function display() {
	    document.all['calendar_main'].style.visibility = "visible";
	}
	
	function hide() {
	    document.all['calendar_main'].style.visibility = "hidden";
	}	
	
	function prevCalendar_main(day,month,year)
	{
	nowm--; if (nowm<0) { nowy--; nowm=11; } showMainCalendar(nowd,nowm,nowy)
	}
	
	function nextCalendar_main(day,month,year)
	{
	nowm++; if (nowm>11) { nowy++; nowm=0; } showMainCalendar(nowd,nowm,nowy)
}	

function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
	var j = i + alen;
	if (document.cookie.substring(i, j) == arg)
	return getCookieVal (j);
	i = document.cookie.indexOf(" ", i) + 1;
	if (i == 0) break;
	}
	return null;
}
var TCP = new TColorPicker();
function TCPopup(field, palette) {
	this.field = field;
	this.initPalette = !palette || palette > 3 ? 0 : palette;
	var w = 184, h = 240,
	move = screen ? 
		',left=' + ((screen.width - w) >> 1) + ',top=' + ((screen.height - h) >> 1) : '', 
	o_colWindow = window.open('admin_modules.cgi\?module\=picker', null, "help=no,status=no,scrollbars=no,resizable=no" + move + ",width=" + w + ",height=" + h + ",dependent=yes", true);
	o_colWindow.opener = window;
	o_colWindow.focus();
}
function TCBuildCell (R, G, B, w, h) {
	return '<td bgcolor="#' + this.dec2hex((R << 16) + (G << 8) + B) + '"><a href="javascript:P.S(\'' + this.dec2hex((R << 16) + (G << 8) + B) + '\')" onmouseover="P.P(\'' + this.dec2hex((R << 16) + (G << 8) + B) + '\')"><img src="pixel.gif" width="' + w + '" height="' + h + '" border="0"></a></td>';
}
function TCSelect(c) {
	this.field.value = '#' + c.toUpperCase();
	this.win.close();
}

function TCPaint(c, b_noPref) {
	c = (b_noPref ? '' : '#') + c.toUpperCase();
	if (this.o_samp) 
		this.o_samp.innerHTML = '<font face=Tahoma size=2>' + c +' <font color=white>' + c + '</font></font>'
	if(this.doc.layers)
		this.sample.bgColor = c;
	else { 
		if (this.sample.backgroundColor != null) this.sample.backgroundColor = c;
		else if (this.sample.background != null) this.sample.background = c;
	}
}

function TCGenerateSafe() {
	var s = '';
	for (j = 0; j < 12; j ++) {
		s += "<tr>";
		for (k = 0; k < 3; k ++)
			for (i = 0; i <= 5; i ++)
				s += this.bldCell(k * 51 + (j % 2) * 51 * 3, Math.floor(j / 2) * 51, i * 51, 8, 10);
		s += "</tr>";
	}
	return s;
}

function TCGenerateWind() {
	var s = '';
	for (j = 0; j < 12; j ++) {
		s += "<tr>";
		for (k = 0; k < 3; k ++)
			for (i = 0; i <= 5; i++)
				s += this.bldCell(i * 51, k * 51 + (j % 2) * 51 * 3, Math.floor(j / 2) * 51, 8, 10);
		s += "</tr>";
	}
	return s	
}
function TCGenerateMac() {
	var s = '';
	var c = 0,n = 1;
	var r,g,b;
	for (j = 0; j < 15; j ++) {
		s += "<tr>";
		for (k = 0; k < 3; k ++)
			for (i = 0; i <= 5; i++){
				if(j<12){
				s += this.bldCell( 255-(Math.floor(j / 2) * 51), 255-(k * 51 + (j % 2) * 51 * 3),255-(i * 51), 8, 10);
				}else{
					if(n<=14){
						r = 255-(n * 17);
						g=b=0;
					}else if(n>14 && n<=28){
						g = 255-((n-14) * 17);
						r=b=0;
					}else if(n>28 && n<=42){
						b = 255-((n-28) * 17);
						r=g=0;
					}else{
						r=g=b=255-((n-42) * 17);
					}
					s += this.bldCell( r, g,b, 8, 10);
					n++;
				}
			}
		s += "</tr>";
	}
	return s;
}

function TCGenerateGray() {
	var s = '';
	for (j = 0; j <= 15; j ++) {
		s += "<tr>";
		for (k = 0; k <= 15; k ++) {
			g = Math.floor((k + j * 16) % 256);
			s += this.bldCell(g, g, g, 9, 7);
		}
		s += '</tr>';
	}
	return s
}

function TCDec2Hex(v) {
	v = v.toString(16);
	for(; v.length < 6; v = '0' + v);
	return v;
}

function TCChgMode(v) {
	for (var k in this.divs) this.hide(k);
	this.show(v);
}

function TColorPicker(field) {
	this.build0 = TCGenerateSafe;
	this.build1 = TCGenerateWind;
	this.build2 = TCGenerateGray;
	this.build3 = TCGenerateMac;
	this.show = document.layers ? 
		function (div) { this.divs[div].visibility = 'show' } :
		function (div) { this.divs[div].visibility = 'visible' };
	this.hide = document.layers ? 
		function (div) { this.divs[div].visibility = 'hide' } :
		function (div) { this.divs[div].visibility = 'hidden' };
	// event handlers
	this.C       = TCChgMode;
	this.S       = TCSelect;
	this.P       = TCPaint;
	this.popup   = TCPopup;
	this.draw    = TCDraw;
	this.dec2hex = TCDec2Hex;
	this.bldCell = TCBuildCell;
	this.divs = [];
}

function TCDraw(o_win, o_doc) {
	this.win = o_win;
	this.doc = o_doc;
	var 
	s_tag_openT  = o_doc.layers ? 
		'layer visibility=hidden top=54 left=5 width=182' : 
		'div style=visibility:hidden;position:absolute;left:6px;top:54px;width:182px;height:0',
	s_tag_openS  = o_doc.layers ? 'layer top=32 left=6' : 'div',
	s_tag_close  = o_doc.layers ? 'layer' : 'div'
		
	this.doc.write('<' + s_tag_openS + ' id=sam name=sam><table cellpadding=0 cellspacing=0 border=1 width=181 align=center class=bd><tr><td align=center height=18><div id="samp"><font face=Tahoma size=2>sample <font color=white>sample</font></font></div></td></tr></table></' + s_tag_close + '>');
	this.sample = o_doc.layers ? o_doc.layers['sam'] : 
		o_doc.getElementById ? o_doc.getElementById('sam').style : o_doc.all['sam'].style

	for (var k = 0; k < 4; k ++) {
		this.doc.write('<' + s_tag_openT + ' id="p' + k + '" name="p' + k + '"><table cellpadding=0 cellspacing=0 border=1 align=center>' + this['build' + k]() + '</table></' + s_tag_close + '>');
		this.divs[k] = o_doc.layers 
			? o_doc.layers['p' + k] : o_doc.all 
				? o_doc.all['p' + k].style : o_doc.getElementById('p' + k).style
	}
	if (!o_doc.layers && o_doc.body.innerHTML) 
		this.o_samp = o_doc.all 
			? o_doc.all.samp : o_doc.getElementById('samp');
	this.C(this.initPalette);
	if (this.field.value) this.P(this.field.value, true)
}


