//Javascript name: My Date Time Picker
//Date created: 16-Nov-2003 23:19
//Scripter: TengYong Ng
//Website: http://www.rainforestnet.com
//Copyright (c) 2003 TengYong Ng
//FileName: DateTimePicker.js
//Version: 0.8
//Contact: contact@rainforestnet.com
// Note: Permission given to use this script in ANY kind of applications if
//       header lines are left unchanged.

//Global variables
var winCal;
var dtToday=new Date();
var Cal;
var docCal;
var MonthName=["January", "February", "March", "April", "May", "June","July", 
	"August", "September", "October", "November", "December"];
var WeekDayName=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];	
var exDateTime;//Existing Date and Time

//Configurable parameters
var cnTop="200";//top coordinate of calendar window.
var cnLeft="500";//left coordinate of calendar window
var WindowTitle ="DateTime Picker";//Date Time Picker title.
var WeekChar=2;//number of character for week day. if 2 then Mo,Tu,We. if 3 then Mon,Tue,Wed.
var CellWidth=20;//Width of day cell.
var DateSeparator="-";//Date Separator, you can change it to "/" if you want.
var TimeMode=24;//default TimeMode value. 12 or 24

var ShowLongMonth=true;//Show long month name in Calendar header. example: "January".
var ShowMonthYear=true;//Show Month and Year in Calendar header.
var MonthYearColor="#cc0033";//Font Color of Month and Year in Calendar header.
var WeekHeadColor="#0099CC";//Background Color in Week header.
var SundayColor="#6699FF";//Background color of Sunday.
var SaturdayColor="#CCCCFF";//Background color of Saturday.
var WeekDayColor="white";//Background color of weekdays.
var FontColor="blue";//color of font in Calendar day cell.
var TodayColor="#FFFF33";//Background color of today.
var SelDateColor="#FFFF99";//Backgrond color of selected date in textbox.
var YrSelColor="#cc0033";//color of font of Year selector.
var ThemeBg="";//Background image of Calendar window.
//end Configurable parameters
//end Global variable

function NewCal(pCtrl,pFormat,pShowTime,pTimeMode)
{
	Cal=new Calendar(dtToday);
	if ((pShowTime!=null) && (pShowTime))
	{
		Cal.ShowTime=true;
		if ((pTimeMode!=null) &&((pTimeMode=='12')||(pTimeMode=='24')))
		{
			TimeMode=pTimeMode;
		}		
	}	
	if (pCtrl!=null)
		Cal.Ctrl=pCtrl;
	if (pFormat!=null)
		Cal.Format=pFormat.toUpperCase();
	
	exDateTime=document.getElementById(pCtrl).value;
	if (exDateTime!="")//Parse Date String
	{
		var Sp1;//Index of Date Separator 1
		var Sp2;//Index of Date Separator 2 
		var tSp1;//Index of Time Separator 1
		var tSp1;//Index of Time Separator 2
		var strMonth;
		var strDate;
		var strYear;
		var intMonth;
		var YearPattern;
		var strHour;
		var strMinute;
		var strSecond;
		//parse month
		Sp1=exDateTime.indexOf(DateSeparator,0)
		Sp2=exDateTime.indexOf(DateSeparator,(parseInt(Sp1)+1));
		
		if ((Cal.Format.toUpperCase()=="DDMMYYYY") || (Cal.Format.toUpperCase()=="DDMMMYYYY"))
		{
			strMonth=exDateTime.substring(Sp1+1,Sp2);
			strDate=exDateTime.substring(0,Sp1);
		}
		else if ((Cal.Format.toUpperCase()=="MMDDYYYY") || (Cal.Format.toUpperCase()=="MMMDDYYYY"))
		{
			strMonth=exDateTime.substring(0,Sp1);
			strDate=exDateTime.substring(Sp1+1,Sp2);
		}
		if (isNaN(strMonth))
			intMonth=Cal.GetMonthIndex(strMonth);
		else
			intMonth=parseInt(strMonth,10)-1;	
		if ((parseInt(intMonth,10)>=0) && (parseInt(intMonth,10)<12))
			Cal.Month=intMonth;
		//end parse month
		//parse Date
		if ((parseInt(strDate,10)<=Cal.GetMonDays()) && (parseInt(strDate,10)>=1))
			Cal.Date=strDate;
		//end parse Date
		//parse year
		strYear=exDateTime.substring(Sp2+1,Sp2+5);
		YearPattern=/^\d{4}$/;
		if (YearPattern.test(strYear))
			Cal.Year=parseInt(strYear,10);
		//end parse year
		//parse time
		if (Cal.ShowTime==true)
		{
			tSp1=exDateTime.indexOf(":",0)
			tSp2=exDateTime.indexOf(":",(parseInt(tSp1)+1));
			strHour=exDateTime.substring(tSp1,(tSp1)-2);
			Cal.SetHour(strHour);
			strMinute=exDateTime.substring(tSp1+1,tSp2);
			Cal.SetMinute(strMinute);
			strSecond=exDateTime.substring(tSp2+1,tSp2+3);
			Cal.SetSecond(strSecond);
		}	
	}
	winCal=window.open("","DateTimePicker","toolbar=0,status=0,menubar=0,fullscreen=no,width=195,height=245,resizable=0,top="+cnTop+",left="+cnLeft);
	docCal=winCal.document;
	RenderCal();
}

function RenderCal()
{
	var vCalHeader;
	var vCalData;
	var vCalTime;
	var i;
	var j;
	var SelectStr;
	var vDayCount=0;
	var vFirstDay;

	docCal.open();
	docCal.writeln("<html><head><title>"+WindowTitle+"</title>");
	docCal.writeln("<script>var winMain=window.opener;</script>");
	docCal.writeln("</head><body background='"+ThemeBg+"' link="+FontColor+" vlink="+FontColor+"><form name='Calendar'>");

	vCalHeader="<table border=1 cellpadding=1 cellspacing=1 width='100%' align=\"center\" valign=\"top\">\n";
	//Month Selector
	vCalHeader+="<tr>\n<td colspan='7'><table border=0 width='100%' cellpadding=0 cellspacing=0><tr><td align='left'>\n";
	vCalHeader+="<select name=\"MonthSelector\" onChange=\"javascript:winMain.Cal.SwitchMth(this.selectedIndex);winMain.RenderCal();\">\n";
	for (i=0;i<12;i++)
	{
		if (i==Cal.Month)
			SelectStr="Selected";
		else
			SelectStr="";	
		vCalHeader+="<option "+SelectStr+" value >"+MonthName[i]+"\n";
	}
	vCalHeader+="</select></td>";
	//Year selector
	vCalHeader+="\n<td align='right'><a href=\"javascript:winMain.Cal.DecYear();winMain.RenderCal()\"><b><font color=\""+YrSelColor+"\"><</font></b></a><font face=\"Verdana\" color=\""+YrSelColor+"\" size=2><b> "+Cal.Year+" </b></font><a href=\"javascript:winMain.Cal.IncYear();winMain.RenderCal()\"><b><font color=\""+YrSelColor+"\">></font></b></a></td></tr></table></td>\n";	
	vCalHeader+="</tr>";
	//Calendar header shows Month and Year
	if (ShowMonthYear)
		vCalHeader+="<tr><td colspan='7'><font face='Verdana' size='2' align='center' color='"+MonthYearColor+"'><b>"+Cal.GetMonthName(ShowLongMonth)+" "+Cal.Year+"</b></font></td></tr>\n";
	//Week day header
	vCalHeader+="<tr bgcolor="+WeekHeadColor+">";
	for (i=0;i<7;i++)
	{
		vCalHeader+="<td align='center'><font face='Verdana' size='2'>"+WeekDayName[i].substr(0,WeekChar)+"</font></td>";
	}
	vCalHeader+="</tr>";	
	docCal.write(vCalHeader);
	
	//Calendar detail
	CalDate=new Date(Cal.Year,Cal.Month);
	CalDate.setDate(1);
	vFirstDay=CalDate.getDay();
	vCalData="<tr>";
	for (i=0;i<vFirstDay;i++)
	{
		vCalData=vCalData+GenCell();
		vDayCount=vDayCount+1;
	}
	for (j=1;j<=Cal.GetMonDays();j++)
	{
		var strCell;
		vDayCount=vDayCount+1;
		if ((j==dtToday.getDate())&&(Cal.Month==dtToday.getMonth())&&(Cal.Year==dtToday.getFullYear()))
			strCell=GenCell(j,true,TodayColor);//Highlight today's date
		else
		{
			if (j==Cal.Date)
			{
				strCell=GenCell(j,true,SelDateColor);
			}
			else
			{	 
				if (vDayCount%7==0)
					strCell=GenCell(j,false,SaturdayColor);
				else if ((vDayCount+6)%7==0)
					strCell=GenCell(j,false,SundayColor);
				else
					strCell=GenCell(j,null,WeekDayColor);
			}		
		}						
		vCalData=vCalData+strCell;

		if((vDayCount%7==0)&&(j<Cal.GetMonDays()))
		{
			vCalData=vCalData+"</tr>\n<tr>";
		}
	}
	docCal.writeln(vCalData);	
	//Time picker
	if (Cal.ShowTime)
	{
		var showHour;
		showHour=Cal.getShowHour();		
		vCalTime="<tr>\n<td colspan='7' align='center'>";
		vCalTime+="<input type='text' name='hour' maxlength=2 size=1 style=\"WIDTH: 22px\" value="+showHour+" onchange=\"javascript:winMain.Cal.SetHour(this.value)\">";
		vCalTime+=" : ";
		vCalTime+="<input type='text' name='minute' maxlength=2 size=1 style=\"WIDTH: 22px\" value="+Cal.Minutes+" onchange=\"javascript:winMain.Cal.SetMinute(this.value)\">";
		vCalTime+=" : ";
		vCalTime+="<input type='text' name='second' maxlength=2 size=1 style=\"WIDTH: 22px\" value="+Cal.Seconds+" onchange=\"javascript:winMain.Cal.SetSecond(this.value)\">";
		if (TimeMode==12)
		{
			var SelectAm =(parseInt(Cal.Hours,10)<12)? "Selected":"";
			var SelectPm =(parseInt(Cal.Hours,10)>=12)? "Selected":"";

			vCalTime+="<select name=\"ampm\" onchange=\"javascript:winMain.Cal.SetAmPm(this.options[this.selectedIndex].value);\">";
			vCalTime+="<option "+SelectAm+" value=\"AM\">AM</option>";
			vCalTime+="<option "+SelectPm+" value=\"PM\">PM<option>";
			vCalTime+="</select>";
		}	
		vCalTime+="\n</td>\n</tr>";
		docCal.write(vCalTime);
	}	
	//end time picker
	docCal.writeln("\n</table>");
	docCal.writeln("</form></body></html>");
	docCal.close();
}

function GenCell(pValue,pHighLight,pColor)//Generate table cell with value
{
	var PValue;
	var PCellStr;
	var vColor;
	var vHLstr1;//HighLight string
	var vHlstr2;
	var vTimeStr;
	
	if (pValue==null)
		PValue="";
	else
		PValue=pValue;
	
	if (pColor!=null)
		vColor="bgcolor=\""+pColor+"\"";
	else
		vColor="";	
	if ((pHighLight!=null)&&(pHighLight))
		{vHLstr1="color='red'><b>";vHLstr2="</b>";}
	else
		{vHLstr1=">";vHLstr2="";}	
	
	if (Cal.ShowTime)
	{
		vTimeStr="winMain.document.getElementById('"+Cal.Ctrl+"').value+=' '+"+"winMain.Cal.getShowHour()"+"+':'+"+"winMain.Cal.Minutes"+"+':'+"+"winMain.Cal.Seconds";
		if (TimeMode==12)
			vTimeStr+="+' '+winMain.Cal.AMorPM";
	}	
	else
		vTimeStr="";		
	PCellStr="<td "+vColor+" width="+CellWidth+" align='center'><font face='verdana' size='2'"+vHLstr1+"<a href=\"javascript:winMain.document.getElementById('"+Cal.Ctrl+"').value='"+Cal.FormatDate(PValue)+"';"+vTimeStr+";window.close();\">"+PValue+"</a>"+vHLstr2+"</font></td>";
	return PCellStr;
}

function Calendar(pDate,pCtrl)
{
	//Properties
	this.Date=pDate.getDate();//selected date
	this.Month=pDate.getMonth();//selected month number
	this.Year=pDate.getFullYear();//selected year in 4 digits
	this.Hours=pDate.getHours();	
	
	if (pDate.getMinutes()<10)
		this.Minutes="0"+pDate.getMinutes();
	else
		this.Minutes=pDate.getMinutes();
	
	if (pDate.getSeconds()<10)
		this.Seconds="0"+pDate.getSeconds();
	else		
		this.Seconds=pDate.getSeconds();
		
	this.MyWindow=winCal;
	this.Ctrl=pCtrl;
	this.Format="ddMMyyyy";
	this.Separator=DateSeparator;
	this.ShowTime=false;
	if (pDate.getHours()<12)
		this.AMorPM="AM";
	else
		this.AMorPM="PM";	
}

function GetMonthIndex(shortMonthName)
{
	for (i=0;i<12;i++)
	{
		if (MonthName[i].substring(0,3).toUpperCase()==shortMonthName.toUpperCase())
		{	return i;}
	}
}
Calendar.prototype.GetMonthIndex=GetMonthIndex;

function IncYear()
{	Cal.Year++;}
Calendar.prototype.IncYear=IncYear;

function DecYear()
{	Cal.Year--;}
Calendar.prototype.DecYear=DecYear;
	
function SwitchMth(intMth)
{	Cal.Month=intMth;}
Calendar.prototype.SwitchMth=SwitchMth;

function SetHour(intHour)
{	
	var MaxHour;
	var MinHour;
	if (TimeMode==24)
	{	MaxHour=23;MinHour=0}
	else if (TimeMode==12)
	{	MaxHour=12;MinHour=1}
	else
		alert("TimeMode can only be 12 or 24");		
	var HourExp=new RegExp("^\\d\\d$");
	if (HourExp.test(intHour) && (parseInt(intHour,10)<=MaxHour) && (parseInt(intHour,10)>=MinHour))
	{	
		if ((TimeMode==12) && (Cal.AMorPM=="PM"))
		{
			if (parseInt(intHour,10)==12)
				Cal.Hours=12;
			else	
				Cal.Hours=parseInt(intHour,10)+12;
		}	
		else if ((TimeMode==12) && (Cal.AMorPM=="AM"))
		{
			if (intHour==12)
				intHour-=12;
			Cal.Hours=parseInt(intHour,10);
		}
		else if (TimeMode==24)
			Cal.Hours=parseInt(intHour,10);	
	}
}
Calendar.prototype.SetHour=SetHour;

function SetMinute(intMin)
{
	var MinExp=new RegExp("^\\d\\d$");
	if (MinExp.test(intMin) && (intMin<60))
		Cal.Minutes=intMin;
}
Calendar.prototype.SetMinute=SetMinute;

function SetSecond(intSec)
{	
	var SecExp=new RegExp("^\\d\\d$");
	if (SecExp.test(intSec) && (intSec<60))
		Cal.Seconds=intSec;
}
Calendar.prototype.SetSecond=SetSecond;

function SetAmPm(pvalue)
{
	this.AMorPM=pvalue;
	if (pvalue=="PM")
	{
		this.Hours=(parseInt(this.Hours,10))+12;
		if (this.Hours==24)
			this.Hours=12;
	}	
	else if (pvalue=="AM")
		this.Hours-=12;	
}
Calendar.prototype.SetAmPm=SetAmPm;

function getShowHour()
{
	var finalHour;
    if (TimeMode==12)
    {
    	if (parseInt(this.Hours,10)==0)
		{
			this.AMorPM="AM";
			finalHour=parseInt(this.Hours,10)+12;	
		}
		else if (parseInt(this.Hours,10)==12)
		{
			this.AMorPM="PM";
			finalHour=12;
		}		
		else if (this.Hours>12)
		{
			this.AMorPM="PM";
			if ((this.Hours-12)<10)
				finalHour="0"+((parseInt(this.Hours,10))-12);
			else
				finalHour=parseInt(this.Hours,10)-12;	
		}
		else
		{
			this.AMorPM="AM";
			if (this.Hours<10)
				finalHour="0"+parseInt(this.Hours,10);
			else
				finalHour=this.Hours;	
		}
	}
	else if (TimeMode==24)
	{
		if (this.Hours<10)
			finalHour="0"+parseInt(this.Hours,10);
		else	
			finalHour=this.Hours;
	}	
	return finalHour;	
}				
Calendar.prototype.getShowHour=getShowHour;		

function GetMonthName(IsLong)
{
	var Month=MonthName[this.Month];
	if (IsLong)
		return Month;
	else
		return Month.substr(0,3);
}
Calendar.prototype.GetMonthName=GetMonthName;

function GetMonDays()//Get number of days in a month
{
	var DaysInMonth=[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	if (this.IsLeapYear())
	{
		DaysInMonth[1]=29;
	}	
	return DaysInMonth[this.Month];	
}
Calendar.prototype.GetMonDays=GetMonDays;

function IsLeapYear()
{
	if ((this.Year%4)==0)
	{
		if ((this.Year%100==0) && (this.Year%400)!=0)
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
		return false;
	}
}
Calendar.prototype.IsLeapYear=IsLeapYear;

function FormatDate(pDate)
{
	if (this.Format.toUpperCase()=="DDMMYYYY")
		return (pDate+DateSeparator+(this.Month+1)+DateSeparator+this.Year);
	else if (this.Format.toUpperCase()=="DDMMMYYYY")
		return (pDate+DateSeparator+this.GetMonthName(false)+DateSeparator+this.Year);
	else if (this.Format.toUpperCase()=="MMDDYYYY")
		return ((this.Month+1)+DateSeparator+pDate+DateSeparator+this.Year);
	else if (this.Format.toUpperCase()=="MMMDDYYYY")
		return (this.GetMonthName(false)+DateSeparator+pDate+DateSeparator+this.Year);			
}
Calendar.prototype.FormatDate=FormatDate;	

function showByLink(object,link,x,y) {
    if (document.layers && document.layers[object]) {
        document.layers[object].left = link.x + x;
        document.layers[object].top = link.y + y;
        document.layers[object].visibility = 'visible';
    }
    else if (document.all) {
        document.all[object].style.visibility = 'visible';

        if (document.all[object].myFlag == null) {
            document.all[object].style.posLeft = document.all[object].offsetLeft + x;
            document.all[object].style.posTop = document.all[object].offsetTop + y;
        }

        document.all[object].myFlag = true;
    }
}

function hide(object) {
    if (document.layers && document.layers[object])
        document.layers[object].visibility = 'hidden';
    else if (document.all)
        document.all[object].style.visibility = 'hidden';
}

 var regular_Post_Code1= /^[A-Z_0-9]{2,4} [A-Z_0-9]{3,3}$/i;

     function logoutAlert(){
	    alert("Please indicate what the assignment is for this booking");
	 }
	 function formCheck(){
	 if(document.bookingform.assignment.value==""){alert("Please indicate what the assignment is for this booking");
        document.bookingform.assignment.focus();
        return false}
     if(document.bookingform.time.value==""){alert("Please indicate what time this assignment is for");
	    document.bookingform.time.focus();
	    return false}
	 if(document.bookingform.location.value==""){alert("Please indicate the location of the keys");
	    document.bookingform.location.focus();
	    return false}
	 if(document.bookingform.post_code.value==""){alert("Please indicate the Post Code of this address");
	    document.bookingform.post_code.focus();
	    return false}
     if (!regular_Post_Code1.exec(document.bookingform.post_code.value)){
        alert("Please specify a Post Code in the correct format.");
        return false;
     }
	  }
	  
	   function logoutAlert(){
	    alert("Please indicate what the assignment is for this booking");
	 }

	 function formCheck2(){
     var regular_flat = /^\d{1,4}\D?$/i;
     var regular_house = /^\d{0,4}[A-Z]{0,1}-{0,1}\d{1,4}[A-Z]{0,1}$/i;
     var regular_street= /^[A-Z ]{1,}$/i;
     var regular_Post_Code= /^[A-Z_0-9]{2,4} [A-Z_0-9]{3,3}$/i;

   
     if (document.getElementById('propertyform').house_no.value){
        if (!regular_house.exec(document.getElementById('propertyform').house_no.value)){
           alert("The House Number field must be a number on its own, a number\n followed by a single letter, or numbers separated by a hypen.\n I.e 15 or 15A or 14-16");
           return false;
        }
     }
	 if(document.getElementById('propertyform').street.value==""){alert("Please indicate the street name.");
	    document.getElementById('propertyform').street.focus();
	    return false}

     if (!regular_street.exec(document.getElementById('propertyform').street.value)){
        alert("The street field must not contain numbers or commas. If you\n have a flat number, house number or property name to add, please\n add them in the appropriate fields.");
        return false;
     }
	 if(document.getElementById('propertyform').town.value==""){alert("Please indicate the Town of this address");
	    document.getElementById('propertyform').town.focus();
	    return false}
	 if(document.getElementById('propertyform').post_code.value==""){alert("Please indicate the Post Code of this address");
	    document.getElementById('propertyform').post_code.focus();
	    return false}
     if (!regular_Post_Code.exec(document.getElementById('propertyform').post_code.value)){
        alert("Please specify a Post Code in the correct format.");
        return false;
     }
	 if(document.getElementById('propertyform').type.value==""){alert("Please indicate whether this property is furnished or not");
 	    document.getElementById('propertyform').type.focus();
 	    return false}
 	 if(document.getElementById('propertyform').size.value==""){alert("Please indicate the # Bedrooms of this property");
 	    document.getElementById('propertyform').size.focus();
 	    return false}
 	 if(document.getElementById('propertyform').garden.value==""){alert("Please indicate whether there is a garden or not");
 	    document.getElementById('propertyform').garden.focus();
 	    return false}
 	 if(document.getElementById('propertyform').outhouse.value==""){alert("Please indicate whether there is a shed or outhouse or not");
 	    document.getElementById('propertyform').outhouse.focus();
	    return false}
	 if(document.getElementById('propertyform').garage.value==""){alert("Please indicate whether there is a garage or not");
	    document.getElementById('propertyform').garage.focus();
	    return false}
	 }
	 
	 /*Contractable Headers script- !*/

function firefox(obj) {
document.getElementById(obj).style.display='block';
} 
//-->
/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

//************************************************************************************
// Copyright (C) 2006, Massimo Beatini
//
// This software is provided "as-is", without any express or implied warranty. In 
// no event will the authors be held liable for any damages arising from the use 
// of this software.
//
// Permission is granted to anyone to use this software for any purpose, including 
// commercial applications, and to alter it and redistribute it freely, subject to 
// the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not claim 
//    that you wrote the original software. If you use this software in a product, 
//    an acknowledgment in the product documentation would be appreciated but is 
//    not required.
//
// 2. Altered source versions must be plainly marked as such, and must not be 
//    misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
//************************************************************************************

//
// global variables
//
var isMozilla;
var objDiv = null;
var originalDivHTML = "";
var DivID = "";
var over = false;

//
// dinamically add a div to 
// dim all the page
//
function buildDimmerDiv()
{
    document.write('<div id="dimmer" class="dimmer" style="width:'+ window.screen.width + 'px; height:' + window.screen.height +'px"></div>');
}


//
//
//
function displayFloatingDiv(divId, title, width, height, left, top) 
{
	DivID = divId;

	document.getElementById('dimmer').style.visibility = "visible";

    document.getElementById(divId).style.width = width + 'px';
    document.getElementById(divId).style.height = height + 'px';
    document.getElementById(divId).style.left = left + 'px';
    document.getElementById(divId).style.top = top + 'px';
	
	var addHeader;
	
	if (originalDivHTML == "")
	    originalDivHTML = document.getElementById(divId).innerHTML;
	
	addHeader = '<table style="width:' + width + 'px" class="floatingHeader">' +
	            '<tr><td ondblclick="void(0);" onmouseover="over=true;" onmouseout="over=false;" style="cursor:move;height:18px">' + title + '</td>' + 
	            '<td style="width:18px" align="right"><a href="javascript:hiddenFloatingDiv(\'' + divId + '\');void(0);">' + 
	            '<img alt="Close..." title="Close..." src="close.jpg" border="0"></a></td></tr></table>';
	

    // add to your div an header	
	document.getElementById(divId).innerHTML = addHeader + originalDivHTML;
	
	
	document.getElementById(divId).className = 'dimming';
	document.getElementById(divId).style.visibility = "visible";


}


//
//
//
function hiddenFloatingDiv(divId) 
{
	document.getElementById(divId).innerHTML = originalDivHTML;
	document.getElementById(divId).style.visibility='hidden';
	document.getElementById('dimmer').style.visibility = 'hidden';
	
	DivID = "";
}

//
//
//
function MouseDown(e) 
{
    if (over)
    {
        if (isMozilla) {
            objDiv = document.getElementById(DivID);
            X = e.layerX;
            Y = e.layerY;
            return false;
        }
        else {
            objDiv = document.getElementById(DivID);
            objDiv = objDiv.style;
            X = event.offsetX;
            Y = event.offsetY;
        }
    }
}


//
//
//
function MouseMove(e) 
{
    if (objDiv) {
        if (isMozilla) {
            objDiv.style.top = (e.pageY-Y) + 'px';
            objDiv.style.left = (e.pageX-X) + 'px';
            return false;
        }
        else 
        {
            objDiv.pixelLeft = event.clientX-X + document.body.scrollLeft;
            objDiv.pixelTop = event.clientY-Y + document.body.scrollTop;
            return false;
        }
    }
}

//
//
//
function MouseUp() 
{
    objDiv = null;
}


//
//
//


	function showStatement() {
		
		//document.getElementById('windowcontent').style.display='block';
		//new Effect.Highlight(document.getElementById('windowcontent'), { startcolor: '#fffffff',endcolor: '#FD862C' });
		
		scrollingelement='todaysbookings';
		
		Effect.toggle('windowcontent', 'appear', { queue: 'end' });
		
		
		return false;
		
	}

  
		    
function showByLink(object,link,x,y) {
    if (document.layers && document.layers[object]) {
        document.layers[object].left = link.x + x;
        document.layers[object].top = link.y + y;
        document.layers[object].visibility = 'visible';
    }
    else if (document.all) {
        document.all[object].style.visibility = 'visible';

        if (document.all[object].myFlag == null) {
            document.all[object].style.posLeft = document.all[object].offsetLeft + x;
            document.all[object].style.posTop = document.all[object].offsetTop + y;
        }

        document.all[object].myFlag = true;
    }
}

function hide(object) {
    if (document.layers && document.layers[object])
        document.layers[object].visibility = 'hidden';
    else if (document.all)
        document.all[object].style.visibility = 'hidden';
}


function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=830,height=800,left = 0,top = 0');");
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

function changeTotal(startPrice, formObj) {

startPrice = formObj.BASEPRICECHARGED.value;

if (IsNumeric(startPrice)) {
	
} else {

	alert("Non-numeric price entered..that won't work. Changing to zero.");
	startPrice = 0;
	formObj.BASEPRICECHARGED.value=0;
}


addition1 = formObj.amount1.options[formObj.amount1.selectedIndex].value;
addition2 = formObj.amount2.options[formObj.amount2.selectedIndex].value;
addition3 = formObj.amount3.options[formObj.amount3.selectedIndex].value;
addition4 = formObj.amount4.options[formObj.amount4.selectedIndex].value;

newPrice = parseFloat(startPrice) + parseFloat(addition1) + parseFloat(addition2) + parseFloat(addition3) + parseFloat(addition4);




/*alert(' startPrice: ' + parseFloat(startPrice) + '\n amount1: ' + parseFloat(addition1) + '\n amount2: ' + parseFloat(addition2) + '\n amount3: ' + parseFloat(addition3) + '\n amount4: ' + parseFloat(addition4) + '\n');*/

	if (formObj.vat[1].checked) {

	vat1 = parseFloat(newPrice) / 100;
	vatamount = parseFloat(vat1) * 17.5;

	gross = parseFloat(newPrice) + parseFloat(vatamount);
	
	


	document.getElementById('bittotal').innerHTML='NET £' + newPrice.toFixed(2) + '<br />VAT £' + vatamount.toFixed(2);

	document.getElementById('total').innerHTML='TOTAL £' + gross.toFixed(2);

	document.getElementById('bittotal').style.display='block';

	} else {

document.getElementById('total').innerHTML='TOTAL £' + newPrice.toFixed(2);
document.getElementById('bittotal').style.display='none';

	}
}
function imposeMaxLength(Object, MaxLen)
{
  return (Object.value.length <= MaxLen);
}

var xmlhttp=false;
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)
		// JScript gives us Conditional compilation, we can cope with old IE versions.
		// and security blocked creation of the objects.
		 try {
		  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		 } catch (e) {
		  try {
		   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (E) {
		   xmlhttp = false;
		  }
		 }
		@end @*/
		if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		  xmlhttp = new XMLHttpRequest();
		}

		function searching(input, returned) {

		 xmlhttp.open("GET", "search_ajax.php" + input,true);
		 xmlhttp.onreadystatechange=function() {
		  if (xmlhttp.readyState==4) {
		   document.getElementById(returned).innerHTML=xmlhttp.responseText;
		   new Effect.Highlight(document.getElementById(returned), { startcolor: '#E68200',endcolor: '#E1E3ED' });
		
		  }
		 }
		 xmlhttp.send(null)
}

function ajaxSlots(id) {
	randomvalue = Math.floor(Math.random()*50000);
	
	
	day = document.getElementById(id + 'Day');
	month = document.getElementById(id + 'Month');
	year = document.getElementById(id + 'Year');
	
	dayvalue = day.options[day.selectedIndex].value;
	monthvalue = month.options[month.selectedIndex].value;
	yearvalue = year.options[year.selectedIndex].value;
	
	xmlhttp.open("GET", "user.php?mode=ajaxslotoptions&day=" + dayvalue + "&month=" + monthvalue + "&year=" + yearvalue + "&random=" + randomvalue,true);
	//alert("user_booking.beta.php?mode=ajaxslotoptions&day=" + dayvalue + "&month=" + monthvalue + "&year=" + yearvalue + "&random=" + randomvalue);
	xmlhttp.onreadystatechange=function() {
		
		document.getElementById('assignmentselect').innerHTML=xmlhttp.responseText;
		
	}
	xmlhttp.send(null)
}

function checkHolidays(id, feedback) {
	randomvalue = Math.floor(Math.random()*50000);
	feedback = document.getElementById(feedback);
	friendlytext = document.getElementById('friendlytext');
	day = document.getElementById(id + 'Day');
	month = document.getElementById(id + 'Month');
	year = document.getElementById(id + 'Year');
	
	dayvalue = day.options[day.selectedIndex].value;
	monthvalue = month.options[month.selectedIndex].value;
	yearvalue = year.options[year.selectedIndex].value;
	
	xmlhttp.open("GET", "user.php?mode=checkholiday&day=" + dayvalue + "&month=" + monthvalue + "&year=" + yearvalue + "&random=" + randomvalue,true);
	xmlhttp.onreadystatechange=function() {
	 if (xmlhttp.readyState==4) {
		   feedback.innerHTML=xmlhttp.responseText;
		   if (xmlhttp.responseText == 'FULL') {
		   	friendlytext.innerHTML='This day is FULL! You cannot move the booking here, sorry <img src="/forum/images/smilies/icon_redface.gif" align="absmiddle" />'
		   	if (friendlytext.style.display!='none') {
		   		$('friendlytext').shake();
		   	} else {
		   	Effect.Appear('friendlytext');
		   	}
		   } else if (xmlhttp.responseText == 'BLOCKED') {

		   	friendlytext.innerHTML='This day is BLOCKED! You cannot move the booking here, sorry <img src="/forum/images/smilies/icon_redface.gif" align="absmiddle" />'
		   	
		   	if (friendlytext.style.display!='none') {
		   		$('friendlytext').shake();
		   	} else {
		   	
		   	Effect.Appear('friendlytext');
			
		   	}
		   	} else if (xmlhttp.responseText == 'EARLY') {

		   	friendlytext.innerHTML='You cannot move bookings into the past or today, sorry <img src="/forum/images/smilies/icon_redface.gif" align="absmiddle" />'
		   	
		   	if (friendlytext.style.display!='none') {
		   		$('friendlytext').shake();
		   	} else {
		   	
		   	Effect.Appear('friendlytext');

		   	}
		   } else if (xmlhttp.responseText == 'HOLIDAY') {

		   	friendlytext.innerHTML='That day is blocked by the clerk! <img src="/dcal/images/holiday.gif" align="absmiddle" />'
		   	
		   	if (friendlytext.style.display!='none') {
		   		$('friendlytext').shake();
		   	} else {
		   	
		   	Effect.Appear('friendlytext');

		   	}
		   }

		   
		   else {
		   	if (friendlytext.style.display!='none') {
		   		Effect.Fade('friendlytext');
		   	/*
		   new Effect.Highlight(feedback, { startcolor: '#E68200',endcolor: '#E1E3ED' });
		   */
		   }
		   }
		
		  }
		 }
		 xmlhttp.send(null)
}

function checkFormStatus(obj) {
	
	tocheck = document.getElementById('feedbackspan');
	
	if (tocheck.innerHTML == 'FULL') {
		alert('You cannot move bookings to a FULL day! Please choose another day.');
		return false;
	}
	
	if (tocheck.innerHTML == 'EARLY') {
		alert('You cannot move bookings to the PAST or TODAY! Please choose another day.');
		return false;
	}
	
		if (tocheck.innerHTML == 'HOLIDAY') {
		alert('You cannot move bookings to a day that is BLOCKED! Please choose another day.');
		return false;
	}
	
	return true;
	
}

function create_interim(taskid) {
	
	formdiv = jQuery('#create_interim_' + taskid);
	
	
	
	formdiv.load('user.php?mode=auto_interim_data&taskid=' + taskid, function() {
  
});
	
	
}
