this.OFramework = new function()
{

	var tag = document.getElementById("OFrameworkJS");
	var src = tag.src.toLowerCase();
	this.BaseURI	= src.indexOf("searchforms/oframework.js") > -1 ? src.replace("oframework.js","") : "../";
	this.ThemeID	= tag.getAttribute("ThemeID")!=null ? tag.getAttribute("ThemeID") : "default";
	this.SkinID		= tag.getAttribute("SkinID")!=null ? tag.getAttribute("SkinID") : "default";
	this.ThemeURI   = tag.getAttribute("ThemeURI")!=null ? tag.getAttribute("ThemeURI") : this.BaseURI + this.ThemeID +"/";
	document.write("<link id='OFrameworkCSS' rel='stylesheet' type='text/css' href='"+ this.ThemeURI + this.SkinID +".css'>");
	
	//IE operation aborted fix
	document.write("<span id='OFrameworkControls'></span>");
	this.Container = document.getElementById("OFrameworkControls");
	
    this.Culture = new function()
    {
        this.LanguageID = "1"//default language
        this.GetLanguageCode = function(id)
        {
			if(id==null)id=this.LanguageID
			switch(id)
			{
				case "3" : return "fr";break;
				case "4" : return "es";break;
				case "5" : return "lt";break;
				case "6" : return "ru";break;
				case "7" : return "gb";break;
				case "8" : return "bg";break;
				default : return "en";break;
			}	
        }
        this.Date = new Object();
        this.Date.Format = "mm/dd/yyyy";
        this.Date.Separator = "/";
        this.Date.MonthNames		= ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
        this.Date.WeekDays			= ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];
    }

    this.date = function(d, m, y)
    {
			
        this.ds = new Array(1,1,1);
        switch(arguments.length){
        case 3 : {
            y = parseInt(y,10);
            m = parseInt(m,10);
            d = parseInt(d,10);
            this.ds = new Array(d,m,y);				
            if(isNaN(d) || isNaN(m) || isNaN(y) || d < 0 || d > 31 || m < 1 || m > 12 || y < 0) throw("Invalid date format");
            break;
            }
        case 1 : {
            if(typeof(d)!="object") return null;
            y = d.getFullYear();
            m = d.getMonth()+1;
            d = d.getDate();
            this.ds = new Array(d,m,y);
            break;
            }
        //case 0 : {this.ds = new Array(1,1,1);break;}
        }
        
      
        
        this.get_Day = function(){return this.ds[0];};
        this.set_Day = function(n){this.ds[0] = n;};
        this.get_Month = function(){return this.ds[1];};
        this.set_Month = function(n){this.ds[1] = n;};
        this.get_Year = function(){return this.ds[2];};
        this.set_Year = function(n){this.ds[2] = n;};
        
        this.Parse = function(s, ci){
		    try{
		        var dFormat = ci!=null ? ci.Date.Format : OFramework.Culture.Date.Format;
		        var dSeparator = ci!=null ? ci.Date.Separator : OFramework.Culture.Date.Separator;
			    var objDateFormatParts = dFormat.split(dSeparator);
			    var objDateParts = s.split(dSeparator);
			    for(var i=0;i<objDateParts.length;i++)
			    {
				    if(objDateFormatParts[i].indexOf("d") > -1){
					    var objDay = objDateParts[i];
					    continue;
				    }
				    if(objDateFormatParts[i].indexOf("m") > -1){
					    var objMonth = objDateParts[i];
					    continue;
				    }
				    if(objDateFormatParts[i].indexOf("y") > -1){
					    var objYear = objDateParts[i];
					    continue;
				    }
			    }
			    return new OFramework.date(objDay, objMonth, objYear);
		    }
		    catch(e){alert(e);return null;}
        }
        this.ToString = function(f)
        {
            var dFormat = OFramework.Culture.Date.Format;
            var dSeparator = OFramework.Culture.Date.Separator;
            
            if(arguments.length==0) f = dFormat;
            
	        var objDateFormatParts = dFormat.split(dSeparator);
	        for(var i=0;i<objDateFormatParts.length;i++)
	        {
		        if(objDateFormatParts[i].indexOf("d") > -1)var dayPart = objDateFormatParts[i];
		        if(objDateFormatParts[i].indexOf("m") > -1)var monthPart = objDateFormatParts[i];
		        if(objDateFormatParts[i].indexOf("y") > -1)var yearPart = objDateFormatParts[i];
	        }
	        if (monthPart.length > 1 && this.Month < 10)m = "0" + this.Month;
	        if (dayPart.length > 1 && this.Day < 10) d = "0" + this.Day;
	        if (yearPart.length > 1 && this.Year < 10) y = "0" + this.Year;
	        return f.replace(dayPart,d).replace(monthPart,m).replace(yearPart,y);
        }
        this.toString = this.ToString;
        this.parse = this.Parse;
        
    }
    
    this.Date = new this.date();
    //d = new Date();
    //d.setFullYear(
    this.DateFromString = function(s)
    {
		//alert(s);
    	try
    	{
			var dFormat = OFramework.Culture.Date.Format;
			var dSeparator = OFramework.Culture.Date.Separator;
			var objDateFormatParts = dFormat.split(dSeparator);
			var objDateParts = s.split(dSeparator);
			for(var i=0;i<objDateParts.length;i++)
			{
				if(objDateFormatParts[i].indexOf("d") > -1){
					var objDay = objDateParts[i];
					continue;
				}
				if(objDateFormatParts[i].indexOf("m") > -1){
					var objMonth = objDateParts[i];
					continue;
				}
				if(objDateFormatParts[i].indexOf("y") > -1){
					var objYear = objDateParts[i];
					continue;
				}
			}
			//alert(objYear + " : " + objMonth + " : " + objDay);
			var retObj = new Date();
			retObj.setFullYear(parseInt(objYear,10), parseInt(objMonth,10)-1, parseInt(objDay,10));
			//alert(retObj);
			return retObj;
		}
		catch(e){return null;}
    }
    this.DateToString = function(s)
    {
        var dFormat = OFramework.Culture.Date.Format;
        var dSeparator = OFramework.Culture.Date.Separator;
        
        var objDateFormatParts = dFormat.split(dSeparator);
        var dayPart;var monthPart;var yearPart;
        for(var i=0;i<objDateFormatParts.length;i++)
        {
	        if(objDateFormatParts[i].indexOf("d") > -1)dayPart = objDateFormatParts[i];
	        if(objDateFormatParts[i].indexOf("m") > -1)monthPart = objDateFormatParts[i];
	        if(objDateFormatParts[i].indexOf("y") > -1)yearPart = objDateFormatParts[i];
        }
        var d = s.getDate();
        var m = s.getMonth()+1;
        var y = s.getFullYear();
        if (monthPart.length > 1 && m < 10)m = "0" + m;
        if (dayPart.length > 1 && d < 10) d = "0" + d;
        if (yearPart.length > 1 && y < 10) y = "0" + y;
        return dFormat.replace(dayPart,d).replace(monthPart,m).replace(yearPart,y); 
    }
    Date.prototype.Equals = function(d)
    {
        if(d==null) return false;
        var d1d = this.getDate();
        var d1m = this.getMonth();
        var d1y = this.getFullYear();

        var d2d = d.getDate();
        var d2m = d.getMonth();
        var d2y = d.getFullYear();
        
        return (d1d==d2d && d1m==d2m && d1y==d2y);
    }
    Date.prototype.CompareTo = function(d)
    {
        var d1d = this.getDate();
        var d1m = this.getMonth();
        var d1y = this.getFullYear();

        var d2d = d.getDate();
        var d2m = d.getMonth();
        var d2y = d.getFullYear();
        
        var date1 = new Date(d1y,d1m,d1d);
        var date2 = new Date(d2y,d2m,d2d);
        if(date1==date2) return 0;
        if(date1<date2) return -1;
        if(date1>date2) return 1;
    }
    Date.prototype.ToString = function()
    {
        if(this==null) return "";
        var d = this.getDate();
        var m = this.getMonth()+1;
        var y = this.getFullYear();
        if (m < 10)m = "0" + m;
        if (d < 10)d = "0" + d;
        if (y < 10)y = "0" + y;
        return m+"/"+d+"/"+y;
    }
    
    this.NumberFromString = function(s){}
    this.NumberToString = function(s){}
    
    this.Array = function()
    {
        var o = new Array()
	    o.Contains = function(val)
        {
	        for(var i=0;i<this.length;i++)if(this[i]==val)return true;
	        return false;
        }
        return o;
    }
    
    this.Controls = new function(){
        //this._list = new Array();
        
        this.Control = function()
        {
            this.ID = null;
            this.Type = "Control";
            this.Container = null;
            this.HTMLElement = null;
            this.Template = null;
            this.Controls = new Array();
            
            this.Width = 0;
            this.Height = 0;
            this.Top = 0;
            this.Left = 0;
            
            this.Render = function()
            {
                if(this.Container!=null){
                    this.Container.innerHTML = this.Template; 
                }
                else window.document.write(this.Template);
            }
            this.Register = function()
            {
                if(OFramework.Controls[this.ID]==null)OFramework.Controls[this.ID] = this;
                else return OFramework.Controls[this.ID];
                //for(var i=0; i<OFramework.Controls._list.length; i++){if(OFramework.Controls._list[i].ID==this.ID){return OFramework.Controls._list[i];}}
                //OFramework.Controls._list[OFramework.Controls._list.length]=this;
            }
        }
        
        this.IFrame = function()
        {
            this.Type = "IFrame";
            this.ID = "IFrame";
            this.Template = "<iframe id='OFrame_IFrame' style='display:block;position:absolute' onMouseOut='alert(this)'>";
            this.Register();
            
            this.Render();
        }
        this.IFrame.prototype = new this.Control();
        
        this.Overlay = function()
        {
			if(OFramework.Controls["OFrameworkOverlay"]!=null)return OFramework.Controls["OFrameworkOverlay"];
			var o = document.createElement("div");
			o.Type = "Overlay";
			o.className = "overlay";
			
			o.Show = function()
			{
				this.style.display = "block";
				this.style.width = document.body.scrollWidth;
				this.style.height = document.body.scrollHeight > document.body.clientHeight ? document.body.scrollHeight : document.body.clientHeight;
				this.style.zindex = "10000";
			}
			o.Hide = function()
			{
				this.style.display = "none";
			}
			
			OFramework.Controls["OFrameworkOverlay"] = this;
			OFramework.Container.appendChild(o);
			return o;
        }
        
        this.ModalPopUp = function(oContainer)
        {
			oContainer.Type = "ModalPopUp";
			oContainer.style.display = "none";
			//o.className = "overlay";
			
			oContainer.Overlay = new OFramework.Controls.Overlay();
			
			oContainer.Show = function()
			{
				this.Overlay.Show();
				this.style.display = "block";
				this.style.position = "absolute";
				this.style.left = document.body.scrollLeft + document.body.clientWidth/2 - this.scrollWidth/2;
				this.style.top = document.body.scrollTop + document.body.clientHeight/2 - this.scrollHeight/2;

				this.style.zIndex = this.Overlay.style.zIndex + 1;
			}
			oContainer.Close = function()
			{
				this.style.display = "none";
				this.Overlay.Hide();
			}
            return oContainer;
        }
        
        this.InputText = function(oContainer)
        {
            var o = document.createElement("input");
            o.Type = "InputText";
            o.type = "text";
            o.className="text";
            o.Value = "";
            o.value = "";
            o.HintText = "";

            o.Focus = function()
            {
                this.className="text focus";
                OFramework.ActiveElement = this;
                if(this.HintText!="" && this.value == this.HintText) this.value="";
            }
            o.Blur = function()
            {
               if(OFramework.ActivePopUp!=null)
               {
                    if(this.List!=null && this.List.CanHide)
                    {
                        o.List.Hide();
                        this.className="text";
                        OFramework.ActiveElement = null;
                    }
                }
                else
                {
                    this.className="text";
                    OFramework.ActiveElement = null;
                }
                
                if(this.HintText!="" && this.value=="") this.value=this.HintText;
            }
//            alert("b4 o.onfocus and o.onblur");
            o.onfocus = o.Focus
            o.onblur = o.Blur;
  //          alert("after o.onfocus and o.onblur");
            o.DataBind = function()
            {
                this.List = new OFramework.Controls.HtmlDropdownListBody();
                if(this.DataSource==null){return;}
                if(!this.DataSource.DataLoaded)
                {
                    this.value = "loading...";
                    this.disabled = true;
                    window.setTimeout("document.getElementById(\""+ this.id +"\").DataBind()", 100);return;
                }
                else
                {
					this.disabled = false;
                    if(this.Value!="")window.setTimeout("document.getElementById(\""+ this.id +"\").SetValue(\""+ this.Value +"\")", 50);
                    else this.value = this.HintText!=""?this.HintText:"";
                }
            }
            //alert("after data bind");
            o.onkeydown = function(e)
            {
                e=document.all?event:e;
                if(this.List==null)return;
                switch(e.keyCode)
                {
                    case 40 : {
                        this.List.MoveDown();
                        e.cancelBubble = true;
                        break;
                    }
                    case 38 : {
                        this.List.MoveUp();
                        e.cancelBubble = true;
                        break;
                    }
                    case 9 : {
                        this.List.Close();
                        e.cancelBubble = true;
                        break;
                    }
                    case 13 : 
                    {
                        this.List.Close();
                        e.cancelBubble = true;
                        break;
                    }
                }
            }            
			//alert("after keydown");
            o.onkeyup = function(e)
            {
                this.Value = this.value;
                if(this.List==null)return;
                
                e=document.all?event:e;
                if(e.keyCode==40 || e.keyCode==38 || e.keyCode==9 || e.keyCode==13){e.cancelBubble = true;return;}
                var filteredData = new Array();
                var idData = new Array();
                var codeData = new Array()
                if(this.value.length>0)
                {
					var userVal = this.value.toLowerCase();
                    for(var i=0;i<this.DataSource.length;i++)
                    {
                        if(this.DataSource[i].id.toLowerCase() == userVal) idData.push(this.DataSource[i]);
                        else if(this.DataSource[i].code && this.DataSource[i].code.toLowerCase()==userVal)codeData.push(this.DataSource[i]);
                        else if(this.DataSource[i].name.toLowerCase().indexOf(userVal)==0)filteredData.push(this.DataSource[i]);
                    }
                    
                    filteredData = idData.concat(codeData).concat(filteredData);
                }
                if(filteredData.length>0)
                {
                    this.List.Show(this, filteredData)
                    this.List.SetSelectedIndex(0);
                }
                else this.List.Hide();
            }
            			//alert("after keyup");
            o.SetValue = function(val)
            {
                this.Value = val==null?"":val;
                if(this.DataSource!=null && this.DataSource.DataLoaded)
                {
                    for(var i=0;i<this.DataSource.length;i++)
                    {
                        var found = false;
                        if(this.DataSource[i].id==this.Value)
                        {
                            found = true;
                            this.value = this.DataSource[i].name;
                            break;
                        }
                    }
                }
                if(!found)this.value = this.Value;
            }
    
            if(oContainer!=null)oContainer.appendChild(o);
            return o;
        }

        this.InputDate = function(oContainer)
        {
            var o = document.createElement("div");
            o.Type = "InputDate";
            o.className="date";
            o.hideFocus = true;
            o.innerHTML= OFramework.Culture.Date.Format;
            o.Value = null;
            o.MinDate = null;
            o.MaxDate = null;
            
            o.onselectstart=function(){return false;}
            
            o.Calendar = new OFramework.Controls.CalendarPopUp()
            o.Activate = function()
            {
                this.Focus();
                this.Calendar.focus();
            }
            o.Focus = function()
            {
                if(OFramework.ActiveElement!=null)OFramework.ActiveElement.Blur();
                OFramework.ActiveElement = this;
                this.className="date focus";
                this.Calendar.CanHide = true;
                this.Calendar.Show(this);
            }
			o.onclick = function (e){
                 if(OFramework.ActiveElement!=null)OFramework.ActiveElement.Blur();
                OFramework.ActiveElement = this;
                this.className="date focus";
                this.Calendar.CanHide = true;
                this.Calendar.Show(this);
			};
			
            o.Blur = function()
            {
                if(this.Calendar.CanHide)
                {
                    o.Calendar.Hide();
                    this.className="date";
                    OFramework.ActiveElement = null;
                }
            }
            o.SetValue = function(val, raiseEvent)
            {
				if(val==null)return;
                if(val.Equals(this.Value))raiseEvent = false;
                this.innerHTML = OFramework.DateToString(val);
                this.Value = val;
                if(raiseEvent && this.Parent!=null && this.Parent.FieldChanged!=null) this.Parent.FieldChanged(this, val);
            }
            o.onfocus = o.Focus
            o.onblur = o.Blur;

            if(oContainer!=null)oContainer.appendChild(o);
            return o;
        }
        this.CalendarPopUp = function()
        {
            if(document.getElementById("CalendarPopUp")!=null)return document.getElementById("CalendarPopUp");
            var o = document.createElement("div");
            o.id = "CalendarPopUp";
            o.type = "CalendarPopUp";
            o.className="popup calendar";
            
            o.MinDate = null;
            o.MaxDate = null;
            o.SelectedDate = null;
            o.CurrentDate = null;
            
            o.Show = function(attachTo)
            {
                if(OFramework.ActivePopUp!=null)OFramework.ActivePopUp.Hide();
                this.AttachedTo = attachTo;
                this.style.top = OFramework.getPosTop(attachTo) + attachTo.offsetHeight + 1 + 'px';
                this.style.left = OFramework.getPosLeft(attachTo) + 'px';
				this.style.display = "block";
                OFramework.ActivePopUp = this;
                
                this.MinDate = this.AttachedTo.MinDate;
                this.MaxDate = this.AttachedTo.MaxDate;
                this.SetDate(this.AttachedTo.Value);
                this.Render();
            }
            o.Hide = function()
            {
                this.style.display = "none";
                this.AttachedTo = null;
                OFramework.ActivePopUp = null;
            }
            o.Close = function()
            {
                this.CanHide=true;
                if(this.AttachedTo!=null)
                {
                    this.AttachedTo.SetValue(this.SelectedDate, true)
                    this.AttachedTo.Blur();
                }
            }
            o.SetDate = function(val)
            {
                this.SelectedDate = val!=null ? val : new Date();
            }
            o.Render = function(o)
            {
                var cDay, cMonth, cYear;
                var cDate = o!=null ? o : new Date(this.SelectedDate.getFullYear(), this.SelectedDate.getMonth(), this.SelectedDate.getDate());
                if(this.MinDate != null && cDate <= this.MinDate) {
                    cDate = new Date(this.MinDate.getFullYear(), this.MinDate.getMonth(), this.MinDate.getDate());
                }
                if(this.MaxDate != null && cDate >= this.MaxDate) {
                    cDate = new Date(this.MaxDate.getFullYear(), this.MaxDate.getMonth(), this.MaxDate.getDate());
                }
                //if(this.MaxDate != null && cDate > this.MaxDate) cDate = this.MaxDate;
                this.CurrentDate = cDate;
                cDay = cDate.getDate();
                //cMonth = cDate.getMonth();
                //cYear = cDate.getFullYear();
                //cDate = new Date(cYear, cMonth, 1);
                
                
                
                var container = document.createElement("table");
                container.cellPadding = 0;
                container.cellSpacing = 0;
                container.border = 0;
                container.Cells = new Array();
                var layout = this.AttachedTo.CalendarLayout;
                var cols=0; var rows=0;
                try
                {
					rows = parseInt(layout.substring(2),10);
					cols = parseInt(layout.substring(0,1),10);
					for(var r=0;r<rows;r++)
					{
						container.insertRow(r);
						container.rows[r].vAlign = "top";
						for(var c=0;c<cols;c++){
							container.rows[r].insertCell(c);
							container.Cells[container.Cells.length] = container.rows[r].cells[c];
							if(c<cols-1)container.rows[r].cells[c].className="divider";
						}
					}
					container.style.width = 160 * container.rows[0].cells.length;
					container.style.height = 140 * container.rows.length;
                }
                catch(e){}
                if(container.Cells.length<2)container = document.createElement("span");
				
				this.style.width = container.style.width;
				this.style.height = container.style.height;
                
                var displayCount = container.Cells?container.Cells.length:1;
                for(var mCount=0; mCount<displayCount; mCount++)
                {
					cMonth = cDate.getMonth();
					cYear = cDate.getFullYear();
					cDate = new Date(cYear, cMonth, 1);
                
					var dayOffset = cDate.getDay();
					var fDayAvailable = false;
					var lDayAvailable = false;
	                
					var calBody = document.createElement("table");
					calBody.border = "0";
					calBody.style.width = "100%";
					calBody.style.height = "100%";
					calBody.className = "calText";
					calBody.onselectstart = function(){return false;}
					var newRow, cCell;
	                
					newRow = calBody.insertRow(0);
					newRow.align="center";
					newRow.className = "cHead";
					var rwMonth = newRow.insertCell(0);
					if(mCount==0)
					{
						rwMonth.innerHTML = "&lt;"
						rwMonth.className = "navBtn";
						rwMonth.onclick = this.PrewMonth;
					}
					cCell = newRow.insertCell(1);
					cCell.colSpan=5;
					if(displayCount>1)
					{
						cCell.innerHTML = OFramework.Culture.Date.MonthNames[cMonth] + " " + cYear;
					}
					else
					{
						this.WriteDDown(cCell, cMonth, cYear);
					}
					var fwMonth = newRow.insertCell(2);
					if(mCount==(container.Cells?cols-1:0))
					{
						fwMonth.innerHTML = "&gt;"
						fwMonth.className = "navBtn";
						fwMonth.onclick = this.NextMonth;
					}
	                
					for(var r=1;r<8;r++)
					{
						newRow = calBody.insertRow(r);
						newRow.align="center";
						newRow.className = "wDay";
						for(var c=0;c<7;c++)
						{
							var cCell = newRow.insertCell(c);
							if(c==0||c==6){
								noSel = "wkNoSelDay";
								cCell.className="wkDay";
								}
							else{
								noSel = "wNoSelDay";
								cCell.className="wDay";
								}
							if(r==1)
							{//day names
								cCell.innerHTML = OFramework.Culture.Date.WeekDays[c].substring(0,2);
								//cCell.className = ""
							}
							else if(r==2 & c < dayOffset || cDate.getMonth()>cMonth || cDate.getFullYear()>cYear){
								cCell.innerHTML = "";
								cCell.onmouseover = null;
								cCell.onmouseout = null;	
							}
							else{
								cCell.innerHTML = cDate.getDate();
								if((this.MinDate != null && cDate >= this.MinDate) || (this.MaxDate != null && cDate <= this.MaxDate) || (this.MinDate != null && this.MaxDate != null && cDate >= this.MinDate && cDate <= this.MaxDate) || (this.MinDate == null && this.MaxDate == null)){
									cCell.onmouseover = this.CellOver;
									cCell.onmouseout = this.CellOut;
									cCell.onclick = this.CellClick;
									cCell.Year = cYear;
									cCell.Month = cMonth;
									cCell.Day = cDate.getDate();
								}
								else{
									cCell.onmouseover = null;
									cCell.onmouseout = null;
									cCell.className = noSel;
								}
                                if(!rwMonth.isDisbl && this.MinDate != null && cDate <= this.MinDate){rwMonth.isDisbl=true;rwMonth.className="navBtn_off"}
								if(!fwMonth.isDisbl && this.MaxDate != null && cDate >= this.MaxDate){fwMonth.isDisbl=true;fwMonth.className="navBtn_off"}
								if(cDate.Equals(this.SelectedDate))cCell.className="cDay";
								cDate.setDate(cDate.getDate()+1)
							}
						}
					}
					if(container.Cells)container.Cells[mCount].appendChild(calBody);
					else container.appendChild(calBody);
					
                }
                this.innerHTML="";
                this.appendChild(container);
            }
            o.CellOver = function(e){
	            cElement = document.all? event.srcElement : e.currentTarget
	            cStyle = cElement.className;
	            cElement.className = "cDay";
            }
            o.CellOut = function(e){
	            cElement = document.all? event.srcElement : e.currentTarget
	            cElement.className = cStyle;
            }
            o.CellClick = function(e)
            {
                cElement = document.all? event.srcElement : e.currentTarget
	            document.getElementById("CalendarPopUp").SelectedDate = new Date(cElement.Year, cElement.Month, cElement.Day);
	            document.getElementById("CalendarPopUp").Close();
            }
            
            o.NextMonth = function(e){
                cElement = document.all? event.srcElement : e.currentTarget
                if(cElement.isDisbl)return;
	            var cDate = document.getElementById("CalendarPopUp").CurrentDate;
	            cDate.setMonth(cDate.getMonth()+1)
	            document.getElementById("CalendarPopUp").Render(cDate);
            }
            o.PrewMonth = function(e){
                cElement = document.all? event.srcElement : e.currentTarget
                if(cElement.isDisbl)return;
	            var cDate = document.getElementById("CalendarPopUp").CurrentDate;
	            cDate.setMonth(cDate.getMonth()-1)
	            document.getElementById("CalendarPopUp").Render(cDate);
            }
            o.GoTo = function(m,y)
            {
	            var cDate = document.getElementById("CalendarPopUp").CurrentDate;
	            cDate.setFullYear(y, m);
	            document.getElementById("CalendarPopUp").Render(cDate);
            }
            
            o.WriteDDown = function(oContainer, cMonth, cYear)
            {
				var dDown = document.createElement("select");
		    	dDown.className="calText";
				dDown.onchange = function()
				{
					var params = this.value.split("-");
					document.getElementById("CalendarPopUp").GoTo(params[0],params[1]);
				}
				var minIndexDate = new Date(cYear, cMonth, 1);
				var maxIndexDate = new Date(cYear, cMonth, 1);
				minIndexDate.setMonth(minIndexDate.getMonth()-6);
				maxIndexDate.setMonth(maxIndexDate.getMonth()+5);
			    
				if(minIndexDate < this.MinDate){
					minIndexDate = new Date(this.MinDate.getFullYear(), this.MinDate.getMonth(), 1);
					maxIndexDate.setMonth(minIndexDate.getMonth()+12)
				}
				if(this.MaxDate!=null && this.axIndexDate > this.MaxDate){
					maxIndexDate = new Date(this.MaxDate.getFullYear(), this.MaxDate.getMonth(), 1);;
				}
			    
				for(i=1;i<13;i++)
				{
					o = new Option(OFramework.Culture.Date.MonthNames[minIndexDate.getMonth()].substring(0,3) + " " + minIndexDate.getFullYear(),minIndexDate.getMonth() + "-" + minIndexDate.getFullYear());
					dDown.options.add(o);
					minIndexDate.setMonth(minIndexDate.getMonth()+1);
				}
				dDown.value = cMonth + "-" + cYear;
				oContainer.appendChild(dDown);
            }
            
            o.onblur = function()
            {
                if(OFramework.ActiveElement!=null)OFramework.ActiveElement.Blur();
            }
            o.onmouseleave = function()
            {
                if(!this.CanHide)this.CanHide = true;
            }
            o.onmouseenter = function()
            {
                if(this.CanHide)
                {
                    this.CanHide = false;
                    this.hideFocus=true;
                    this.focus();
                }
            }
            o.onmouseout = o.onmouseleave;
            o.onmousemove = o.onmouseenter;

            OFramework.Container.appendChild(o);
	        return o;
        }

        this.DropdownList = function(oContainer)
        {
			
            var o = document.createElement("select");
            o.className="select";
            o.DataSource = null;

            o.Focus = function()
            {
                this.className="select focus";
                OFramework.ActiveElement = this;
            }
            o.Blur = function()
            {
                this.className="select";
                OFramework.ActiveElement = null;
            }
            o.onfocus = o.Focus
            o.onblur = o.Blur;
            
            o.DataBind = function()
            {
                if(this.DataSource==null)return;
                if(!this.DataSource.DataLoaded)
                {
                    this.disabled = true;
                    if(this.options.length>0)this.options[0].text="loading...";
                    else o.options.add(new Option("loading...", ""));
                    window.setTimeout("document.getElementById(\""+ this.id +"\").DataBind()", 50);return;
                }
                this.innerHTML = "";
                this.options.add(new Option("--select--", 0));
                for(var i=0;i<this.DataSource.length;i++)
                {
                    this.options.add(new Option(this.DataSource[i].name, this.DataSource[i].id));
                }
                this.disabled = false;
            }

            if(oContainer!=null)oContainer.appendChild(o);
            return o;
        }
        
        this.HtmlDropdownList = function(oContainer)
        {

            var o = document.createElement("div");
            o.Type = "HtmlDropdownList";
            o.className="dropdown";
            o.hideFocus = true;
            o.innerHTML="<br />";
            o.Value = "";
            o.SelectedItem  = null;
            o.Filter        = null;
            o.DataSource    = null;
            o.List          = new OFramework.Controls.HtmlDropdownListBody();
		
            o.Focus = function()
            {
                this.className="dropdown focus";
                OFramework.ActiveElement = this;
                this.List.CanHide = true;
                this.List.Show(this);
				Value="";
            }
			o.onclick = function (e){
                this.className="dropdown focus";
                OFramework.ActiveElement = this;
                this.List.CanHide = true;
                this.List.Show(this);
				Value="";
			};
            o.Blur = function()
            {
                if(OFramework.ActivePopUp!=null){
                    if(this.List.CanHide)
                    {
                        o.List.Hide();
                        this.className="dropdown";
                        OFramework.ActiveElement = null;
                    }
                }
                else
                {
                    this.className="dropdown";
                    OFramework.ActiveElement = null;
                }
            }
            o.onfocus = o.Focus
            o.onblur = o.Blur;
			o.onselectstart=function(){return false;}
			
			
			
            o.onkeydown = function(e)
            {
                e=document.all?event:e;				
				var seltext=filterList(e.keyCode,o);
                switch(e.keyCode)
                {
                    case 40 : {
                        this.List.MoveDown();
                        e.cancelBubble = true;
                        break;
                    }
                    case 38 : {
                        this.List.MoveUp();
                        e.cancelBubble = true;
                        break;
                    }
                    case 9 : {
                        this.List.Close();
                        e.cancelBubble = true;
                        break;
                    }
                    case 13 : 
                    {
                        this.List.Close();						
                        e.cancelBubble = true;				
                        break;
                    }
                }
            }
            
            o.SetValue = function(val, raiseEvent)
            {
                if(this.DataSource==null)return;
                if(!this.DataSource.DataLoaded)
                {
                    this.Value = val;
                    return;
                }
                var found = false;
                var dSource = this.DataSource;
                if(this.DefaultItem) dSource = new Array(this.DefaultItem).concat(dSource);
                for(var i=0;i<dSource.length;i++)
                {
                    if(((this.DefaultItem && i>0) || (!this.DefaultItem)) && this.Filter!=null && !this.Filter.Value.Contains(dSource[i][this.Filter.Property])) continue;
                    if(dSource[i].id==val)
                    {
                        this.Value = val;
                        this.SelectedItem = dSource[i];
                        this.SetText(dSource[i].name);
                        found = true;
                        break;
                    }
                }
                if(!found) 
                {
                    this.SelectedItem = dSource[0];
                    this.Value = dSource[0].id;
                    this.SetText(dSource[0].name);
                }
                
                if(raiseEvent && this.Parent!=null && this.Parent.FieldChanged!=null) this.Parent.FieldChanged(this, this.SelectedItem.id);
            }
            o.SetText = function(val)
            {
                var newLen = val.length-1;
                var width = this.clientWidth > 0 ? this.clientWidth : 50;
                if(val.length * 7 > width)
                {
                    this.innerHTML = val.substring(0, width/7);
                }
                else this.innerHTML = val; 
                if(this.innerHTML.length==0 && val.length > 4)this.innerHTML = val.substring(0, 4);
            }
            o.SetFilter = function(prop, val)
            {
                if(val==null){this.Filter = null;}
                else{
                this.Filter = new Object();
                this.Filter.Property = prop;
                this.Filter.Value = val;
                }
                this.SetValue(this.Value, false);
            }
            o.GetItem = function(val)
            {
                if(this.DataSource==null) return null;
                for(var i=0;i<this.DataSource.length;i++)
                {
                    if(this.DataSource[i].id==val)return this.DataSource[i];
                }
                return null;
            }
            o.DataBind = function()
            {
                if(this.DataSource==null){this.innerHTML = "&nbsp;<br/>";return;}
                if(!this.DataSource.DataLoaded)
                {
                    this.innerHTML = "loading...";
                    window.setTimeout("document.getElementById(\""+ this.id +"\").DataBind()", 100);return;
                }
                else
                {
                    var val = null;
                    if(this.DefaultItem) val=this.Value==""?this.DefaultItem.id:this.Value;
                    else if(this.DataSource.length>0)
                    {
						val = this.Value==""?this.DataSource[0].id:this.Value;
                    }
                    if(val!=null)window.setTimeout("document.getElementById(\""+ this.id +"\").SetValue(\""+ val +"\")", 50);
                }
            }

            if(oContainer!=null)
				{
					oContainer.appendChild(o);
				}
            return o;
        }
        
        this.HtmlDropdownListBody = function()
        {

            if(document.getElementById("DDListPopUp")!=null)return document.getElementById("DDListPopUp");
            var o = document.createElement("div");
            
            o.id = "DDListPopUp";
            o.type = "DDListPopUp";
            o.className="popup list";
            
            o.Show = function(attachTo, dSource)
            {			
                if(attachTo==null)return;
                if(OFramework.ActivePopUp!=null)OFramework.ActivePopUp.Hide();
                this.AttachedTo = attachTo;
                this.style.top = OFramework.getPosTop(attachTo) + attachTo.offsetHeight + 1 + 'px';
                this.style.left = OFramework.getPosLeft(attachTo) + 'px';
                this.style.display = "block";
                var lw = this.AttachedTo.getAttribute("listWidth");
                this.style.width = lw!=null?lw:"100px";
                var lh = this.AttachedTo.getAttribute("listHeight");
                if(lh==null)lh=5;

                OFramework.ActivePopUp = this;
                this.CanHide=true;
                var setSelIndex = 0;
                dSource = dSource!=null ? dSource : ((this.AttachedTo.DataSource!=null && this.AttachedTo.DataSource.DataLoaded)? this.AttachedTo.DataSource : null);
                var itemTemplate = this.AttachedTo.ItemTemplate!="" ? this.AttachedTo.ItemTemplate : null;
                if(dSource!=null)
                {
                    if(this.AttachedTo.DefaultItem) dSource = new Array(this.AttachedTo.DefaultItem).concat(dSource);
                    if(lh > dSource.length)lh=dSource.length;
                    this.innerHTML = "";
                    for(var i=0;i<dSource.length;i++)
                    {
                        if(((this.AttachedTo.DefaultItem && i>0) || (!this.AttachedTo.DefaultItem)) && this.AttachedTo.Filter!=null && !this.AttachedTo.Filter.Value.Contains(dSource[i][this.AttachedTo.Filter.Property])) continue;
                        var o = document.createElement("div");
                        o.className = "list_item";
                        o.innerHTML =  itemTemplate != null ? OFramework.ProcessItemTemplate(itemTemplate, dSource[i]):dSource[i].name;
                        o.Value = dSource[i].id
                        o.ItemIndex = this.childNodes.length;
                        o.onmouseover = function(){OFramework.ActivePopUp.SetSelectedIndex(this.ItemIndex);}
                        o.onclick = function(){OFramework.ActivePopUp.Close();}
                        this.appendChild(o);
                        
                        if(this.AttachedTo.Value==o.Value)setSelIndex=o.ItemIndex;
                    }
                    this.SetSelectedIndex(setSelIndex, true);
                }
                
                var mul = this.childNodes.length>0 ? this.childNodes[0].scrollHeight : this.scrollHeight;
                this.style.height = lh*mul + 2;
            }
            o.Hide = function()
            {
                if(OFramework.ActivePopUp==null)return;
                OFramework.ActivePopUp.style.display = "none";
                OFramework.ActivePopUp.CanHide = false;
                OFramework.ActivePopUp.AttachedTo = null;
                OFramework.ActivePopUp = null;
                
                window.onmousedown = null;
            }
            o.Close = function()
            {
                this.CanHide=true;
                if(this.SelectedIndex>-1)
                {
                    var selItem = this.childNodes[this.SelectedIndex];
                    if(this.AttachedTo!=null)this.AttachedTo.SetValue(selItem.Value, true);
                }
                if(this.AttachedTo!=null)this.AttachedTo.Blur();
            }
            
            o.onblur = function(e, src)
            {
                if(src==null)src=this;
                this.CanHide = true;
                this.Hide();
            }
            o.onmouseover = function(e)
            {
                if(!this.mouseCanEnter)return;
                else {this.mouseCanEnter = false;this.mouseCanLeave=true;}
                if(!this.CanHide)this.CanHide = false;
                e=document.all?event:e;e.cancelBubble = true;
                
                window.onmousedown = OFramework.ActivePopUp.Hide;
            }
            o.onmouseout = function(e)
            {
                if(!this.mouseCanLeave)return;
                else {this.mouseCanLeave = false;this.mouseCanEnter=true;}
                if(this.CanHide)this.CanHide = true;
                e=document.all?event:e;e.cancelBubble = true;
            }
            o.onmousedown = function(e)
            {
                this.CanHide = false;
                e=document.all?event:e;e.cancelBubble = true;
            }
            o.mouseCanEnter = true;
            o.mouseCanLeave = false;
            
            
            o.onkeydown = function(e)
            {
                e=document.all?event:e;
				
                switch(e.keyCode)
                {
                    case 40 : {
                        this.MoveDown();
                        e.cancelBubble = true;
                        break;
                    }
                    case 38 : {
                        this.MoveUp();
                        e.cancelBubble = true;
                        break;
                    }
                    case 9 : {
                        this.Close();
                        e.cancelBubble = true;
                        break;
                    }
                    case 13 : 
                    {
                        this.Close();
                        e.cancelBubble = true;
                        break;
                    }
                }
            }
            o.SelectedIndex = -1;
            o.SetSelectedIndex = function(val, scroll)
            {
                if(this.SelectedIndex>-1 && this.SelectedIndex<this.childNodes.length)this.childNodes[this.SelectedIndex].className='list_item';
                this.SelectedIndex = val;
                this.childNodes[this.SelectedIndex].className='list_item_hover';
                if(scroll)
                {
                    this.scrollTop = this.childNodes[this.SelectedIndex].offsetTop;
                }
            }
            o.MoveUp = function()
            {
                if(this.SelectedIndex>0)this.SetSelectedIndex(this.SelectedIndex-1);
                this.childNodes[this.SelectedIndex].scrollIntoView();
            }
            o.MoveDown = function()
            {
                if(this.SelectedIndex<this.childNodes.length-1)this.SetSelectedIndex(this.SelectedIndex+1);
                this.childNodes[this.SelectedIndex].scrollIntoView();
            }
            OFramework.Container.appendChild(o);
	        return o;
        }
        
        this.Clone = function(srcObj)
        {
			//alert("deep: in this.clone"+ srcObj);
            var retObj = null;
            switch(srcObj.Type)
            {
                case "InputText" : {retObj = new OFramework.Controls.InputText();break;}
                case "InputDate" : {retObj = new OFramework.Controls.InputDate();break;}
            }
            
            if(retObj==null) return null;
            
            //if(srcObj.style!=null && srcObj.style.cssText!=""){retObj.style.cssText=srcObj.style.cssText;}
            //if(srcObj.Parent!=null){retObj.Parent=srcObj.Parent;}
            //if(srcObj.DataSource!=null){retObj.DataSource=srcObj.DataSource;retObj.DataBind();}
            //if(srcObj.ItemTemplate!=null){retObj.ItemTemplate=srcObj.ItemTemplate;}
            //if(srcObj.MinDate!=null){retObj.MinDate=srcObj.MinDate;}
            //if(srcObj.MaxDate!=null){retObj.MaxDate=srcObj.MaxDate;}
            
            //if(srcObj.listWidth!=null){retObj.listWidth=srcObj.listWidth;}
            //if(srcObj.listHeight!=null){retObj.listHeight=srcObj.listHeight;}
            return retObj;
        }
     }
     this.Controls.prototype = new Array();
     
     this.Console = new function()
     {
        this.container = null;

        this.Write = function(s)
        {
            if(this.container == null)this.container = this.createContainer();
            this.container.innerHTML += "<br>" + s;
        }

        this.createContainer = function()
        {
            var o = document.createElement("div");
            o.id = "OFrameworkConsole";
            o.innerHTML = "Console";
            document.body.appendChild(o);
            return o;
        }
     }
     
     this.TemplateControl = function(oContainer, oTemplate)
     {
        var o = document.createElement("div");
        o.Type = "TemplateControl";
        
	    this.LoadComplete = function(data)
	    {
	        o.innerHTML = data;
	        OFramework.ProcessTemplate(o, o.firstChild);
	    }
        var tLoader = new OFramework.HtmlLoader(this.LoadComplete);
	    tLoader.open("GET", oTemplate + ".html", true);
	    tLoader.send(null);
	    
	    
	    if(oContainer!=null)oContainer.appendChild(o);
	    return o;
	    
     }

     this.AirSearchForm = function(oContainer)
     {
        oContainer.Type = "AirSearchForm";
        oContainer.innerHTML = "loading...";
        oContainer.Target = "_top";
        oContainer.StateBag = new Array();
        oContainer.SearchType = "RoundTrip";
        
        oContainer.UseLangID = (OFramework.Culture.LanguageID!="1");
	    oContainer.LoadComplete = function(data, success)
	    {
	        if(success)
	        {
	            oContainer.innerHTML = data.replace(/Container./g,"document.getElementById('" + oContainer.id + "').");
                OFramework.ProcessTemplate(oContainer, oContainer.firstChild);
                window.setTimeout("document.getElementById('" + oContainer.id + "').Init()",50);
            }
            else
            {	
                if(oContainer.UseLangID)
                {
                    oContainer.UseLangID = false;
                    tFileName = "air_search_form.html";
                    tLoader.open("GET", OFramework.ThemeURI!=null ? OFramework.ThemeURI + tFileName : tFileName, true);
	                tLoader.send(null);
	            }
	            else
	            {
	                oContainer.innerHTML="Error loading template source";
	            }
            }
	    }

	    var tLoader = new OFramework.HtmlLoader(oContainer.LoadComplete);
	    var tFileName = oContainer.UseLangID ? "air_search_form_"+ OFramework.Culture.GetLanguageCode() +".html" : "air_search_form.html";
		tLoader.open("GET", OFramework.ThemeURI!=null ? OFramework.ThemeURI + tFileName : tFileName, true);
	    tLoader.send(null);
	    
	    oContainer.Set = function(f,v)
	    {
			var oElem = OFramework.Eval(this, f);
			if(oElem)
			{
				switch(f)
				{
					case "SearchType" : this.SearchType = v;break;
					case "NonStopOption" : this[f].checked = (v=="true");break;
					case "RefOption" : this[f].checked = (v=="true");break;
					case "FromDate" : this.FromDate.SetValue(OFramework.DateFromString(v), true);break;
					case "ReturnDate" : this.ReturnDate.SetValue(OFramework.DateFromString(v), true);break;
					
					case "MultiCityTBL.FlyDate.0": oElem.SetValue(OFramework.DateFromString(v), true);break;
					case "MultiCityTBL.FlyDate.1": oElem.SetValue(OFramework.DateFromString(v), true);break;
					case "MultiCityTBL.FlyDate.2": oElem.SetValue(OFramework.DateFromString(v), true);break;
					case "MultiCityTBL.FlyDate.3": oElem.SetValue(OFramework.DateFromString(v), true);break;
					case "MultiCityTBL.FlyDate.4": oElem.SetValue(OFramework.DateFromString(v), true);break;
					case "MultiCityTBL.FlyDate.5": oElem.SetValue(OFramework.DateFromString(v), true);break;
					
					default : oElem.SetValue(v);
				}
			}
			else this.StateBag[f] = v;
	    }
	    oContainer.Init = function()
	    {
	        this.From           = document.getElementById(this.id +'_From');
	        this.FromDate       = document.getElementById(this.id +'_FromDate');
	        this.FromTime       = document.getElementById(this.id +'_FromTime');
	        this.FromInterval   = document.getElementById(this.id +'_FromInterval');
	        this.FromRadius     = document.getElementById(this.id +'_FromRadius');
	        
	        this.To             = document.getElementById(this.id +'_To');
	        this.ReturnDate     = document.getElementById(this.id +'_ReturnDate');
	        this.ReturnTime     = document.getElementById(this.id +'_ReturnTime');
	        this.ToInterval     = document.getElementById(this.id +'_ToInterval');
	        this.ToRadius       = document.getElementById(this.id +'_ToRadius');

	        this.Adults         = document.getElementById(this.id +'_Adults');
	        this.Seniors        = document.getElementById(this.id +'_Seniors');
	        this.Youths         = document.getElementById(this.id +'_Youths');
	        this.Children       = document.getElementById(this.id +'_Children');
	        this.InfantsInLap   = document.getElementById(this.id +'_InfantsInLap');
	        this.InfantsInSeat  = document.getElementById(this.id +'_InfantsInSeat');

	        
	        this.PrefAirline    = document.getElementById(this.id +'_Airlines');
	        this.PrefAirlineTwo = document.getElementById(this.id +'_AirlinesTwo');
	        this.PrefAirlineThree = document.getElementById(this.id +'_AirlinesThree');
	        this.Class          = document.getElementById(this.id +'_Class');
	        this.NonStopOption  = document.getElementById(this.id +'_NonStopOption');
	        this.RefOption      = document.getElementById(this.id +'_RefundableOption');
	        
	        
	        this.Panels             = new Object();
	        this.Panels.FromTo      = document.getElementById(this.id +'_FromToPanel');
	        this.Panels.Dates       = document.getElementById(this.id +'_DatesPanel');
	        this.Panels.Return      = document.getElementById(this.id +'_ReturnPanel');
	        this.Panels.MultiCity   = document.getElementById(this.id +'_MultiCityPanel');
			this.Panels.RowOne      = document.getElementById(this.id +'_RowOnePanel');
	        this.Panels.RowTwo      = document.getElementById(this.id +'_RowTwoPanel');
	        this.Panels.RowThree    = document.getElementById(this.id +'_RowThreePanel');
	        this.Panels.RowFour     = document.getElementById(this.id +'_RowFourPanel');
	        this.Panels.ReturnDate  = document.getElementById(this.id +'_ReturnDatePanel');
	        this.Panels.ReturnDateLBL  = document.getElementById(this.id +'_ReturnDateLBL');
	        this.Panels.ReturnTime  = document.getElementById(this.id +'_ReturnTimePanel');
	        this.Panels.ReturnTimeLBL  = document.getElementById(this.id +'_ReturnTimeLBL');
	        
			this.SType					= new Object()
			this.SType.DDList			= document.getElementById(this.id +'_SearchTypeDD');
			this.SType.RoundTrip		= document.getElementById(this.id +'_SearchTypeRoundTrip');
			this.SType.OneWay			= document.getElementById(this.id +'_SearchTypeOneWay');
			this.SType.MultiDestination	= document.getElementById(this.id +'_SearchTypeMultiDestination');

	        
	        if(document.getElementById(this.id +'_FromIntervalCHK')!=null)
	        {
	            this.FromInterval = document.getElementById(this.id +'_FromIntervalCHK');
	            this.FromInterval.Value = "";
	            this.FromInterval.SetValue = function(v){if(this.value==v){this.checked=true;this.Value=v}else{this.Value="";}}
	            this.FromInterval.onchange = function(){this.Value=this.checked?this.value:""};
	        }
	        if(document.getElementById(this.id +'_ToIntervalCHK')!=null)
	        {
	            this.ToInterval = document.getElementById(this.id +'_ToIntervalCHK');
	            this.ToInterval.Value = "";
	            this.ToInterval.SetValue = function(v){if(this.value==v){this.checked=true;this.Value=v}else{this.Value="";}}
	            this.ToInterval.onchange = function(){this.Value=this.checked?this.value:""};
	        }
	        if(document.getElementById(this.id +'_IntervalCHK')!=null)
	        {
	            this.FromInterval = document.getElementById(this.id +'_IntervalCHK');
	            this.FromInterval.Value = "";
	            this.FromInterval.SetValue = function(v){if(this.value==v){this.checked=true;this.Value=v}else{this.Value="";}}
	            this.FromInterval.onchange = function(){this.Value=this.checked?this.value:""};
	            this.ToInterval = this.FromInterval;
	        }
	        if(document.getElementById(this.id +'_FromRadiusCHK')!=null)
	        {
	            this.FromRadius = document.getElementById(this.id +'_FromRadiusCHK');
	            this.FromRadius.Value = "";
	            this.FromRadius.SetValue = function(v){if(this.value==v){this.checked=true;this.Value=v}else{this.Value="";}}
	            this.FromRadius.onchange = function(){this.Value=this.checked?this.value:""};
	        }
	        if(document.getElementById(this.id +'_ToRadiusCHK')!=null)
	        {
	            this.ToRadius = document.getElementById(this.id +'_ToRadiusCHK');
	            this.ToRadius.Value = "";
	            this.ToRadius.SetValue = function(v){if(this.value==v){this.checked=true;this.Value=v}else{this.Value="";}}
	            this.ToRadius.onchange = function(){this.Value=this.checked?this.value:""};
	        }
	        if(document.getElementById(this.id +'_RadiusCHK')!=null)
	        {
	            this.FromRadius = document.getElementById(this.id +'_RadiusCHK');
	            this.FromRadius.Value = "";
	            this.FromRadius.SetValue = function(v){if(this.value==v){this.checked=true;this.Value=v}else{this.Value="";}}
	            this.FromRadius.onchange = function(){this.Value=this.checked?this.value:""};
	            this.ToRadius = this.FromRadius;
	        }

	        //set default values
	        var today = new Date();
	        var dDate = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 7);
	        var rDate = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 14);
	        
			
	        this.FromDate.MinDate = today;
	        this.FromDate.SetValue(dDate);
			
	        this.ReturnDate.MinDate = dDate;
	       	this.ReturnDate.SetValue(rDate);
     		

	       this.Adults.SetValue(1);
	        
	        this.MultiCityTBL           = document.getElementById(this.id +'_MultiCityTBL');
	        this.MultiCityTBL.Items     = 1;
            this.MultiCityTBL.From      = new Array();
            this.MultiCityTBL.To        = new Array();
            this.MultiCityTBL.FlyDate   = new Array();
            for(var i=0; i<6; i++)
            {
	            this.MultiCityTBL.From[i]   = document.getElementById(this.id +'_FromCity_' + i);
	            this.MultiCityTBL.To[i]     = document.getElementById(this.id +'_ToCity_' + i);
	            this.MultiCityTBL.FlyDate[i]= document.getElementById(this.id +'_FlyDate_' + i);
	            this.MultiCityTBL.FlyDate[i].MinDate = today;
	        }
	        for(var f in this.StateBag)
	        {
				var oElem = OFramework.Eval(this, f);
				if(!oElem) continue;
				switch(f)
				{
					case "SearchType" : this.SearchType = this.StateBag[f];break;
					case "NonStopOption" : this[f].checked = (this.StateBag[f]=="true");break;
					case "RefOption" : this[f].checked = (this.StateBag[f]=="true");break;
					case "FromDate" : this.FromDate.SetValue(OFramework.DateFromString(this.StateBag[f]), true);break;
					case "ReturnDate" : this.ReturnDate.SetValue(OFramework.DateFromString(this.StateBag[f]), true);break;
					
					case "MultiCityTBL.Items" : 
						{
							while(this.MultiCityTBL.Items < this.StateBag[f])this.AddSegment();
							break;
						}
					case "MultiCityTBL.FlyDate.0": oElem.SetValue(OFramework.DateFromString(this.StateBag[f]), true);break;
					case "MultiCityTBL.FlyDate.1": oElem.SetValue(OFramework.DateFromString(this.StateBag[f]), true);break;
					case "MultiCityTBL.FlyDate.2": oElem.SetValue(OFramework.DateFromString(this.StateBag[f]), true);break;
					case "MultiCityTBL.FlyDate.3": oElem.SetValue(OFramework.DateFromString(this.StateBag[f]), true);break;
					case "MultiCityTBL.FlyDate.4": oElem.SetValue(OFramework.DateFromString(this.StateBag[f]), true);break;
					case "MultiCityTBL.FlyDate.5": oElem.SetValue(OFramework.DateFromString(this.StateBag[f]), true);break;
					
					default : oElem.SetValue(this.StateBag[f]);
				}
	        }
	        
	        this.ChangeSearchType(this.SearchType);
	    }
	    oContainer.FieldChanged = function(obj, val)
	    {
	        switch(obj.id)
	        {
				case this.id + "_SearchTypeDD" :
				{
					this.ChangeSearchType(this.SType.DDList.Value);
					break;
				}
	            case this.id + "_FromDate" : 
	            {
	                this.ReturnDate.MinDate = this.FromDate.Value;
	                if(this.ReturnDate.Value.CompareTo(val)<0)this.ReturnDate.SetValue(val, true);
	                break;
	            }
                case this.id + "_FlyDate_0" : 
	            {
	                var dObj = this.MultiCityTBL.FlyDate[1];
	                if(dObj==null)return;
	                dObj.MinDate = this.MultiCityTBL.FlyDate[0].Value;
	                //this.ReturnDate.MinDate = this.FromDate.Value;
	                if(dObj.Value!=null && dObj.Value.CompareTo(val)<0)dObj.SetValue(val, true);
	                break;
	            }
                case this.id + "_FlyDate_1" : 
	            {
	                var dObj = this.MultiCityTBL.FlyDate[2];
	                dObj.MinDate = this.MultiCityTBL.FlyDate[1].Value;
	                if(dObj==null)return;
	                //this.ReturnDate.MinDate = this.FromDate.Value;
	                if(dObj.Value!=null && dObj.Value.CompareTo(val)<0)dObj.SetValue(val, true);
	                break;
	            }
	            case this.id + "_FlyDate_2" : 
	            {
	                var dObj = this.MultiCityTBL.FlyDate[3];
	                dObj.MinDate = this.MultiCityTBL.FlyDate[2].Value;
	                if(dObj==null)return;
	                //this.ReturnDate.MinDate = this.FromDate.Value;
	                if(dObj.Value!=null && dObj.Value.CompareTo(val)<0)dObj.SetValue(val, true);
	                break;
	            }
	            case this.id + "_FlyDate_3" : 
	            {
	                var dObj = this.MultiCityTBL.FlyDate[4];
	                dObj.MinDate = this.MultiCityTBL.FlyDate[3].Value;
	                if(dObj==null)return;
	                //this.ReturnDate.MinDate = this.FromDate.Value;
	                if(dObj.Value!=null && dObj.Value.CompareTo(val)<0)dObj.SetValue(val, true);
	                break;
	            }
	            case this.id + "_FlyDate_4" : 
	            {
	                var dObj = this.MultiCityTBL.FlyDate[5];
	                dObj.MinDate = this.MultiCityTBL.FlyDate[4].Value;
	                if(dObj==null)return;
	                //this.ReturnDate.MinDate = this.FromDate.Value;
	                if(dObj.Value!=null && dObj.Value.CompareTo(val)<0)dObj.SetValue(val, true);
	                break;
	            }
	            case this.id + "_FlyDate_5" : 
	            {
	                var dObj = this.MultiCityTBL.FlyDate[6];
	                if(dObj==null)return;
	                dObj.MinDate = this.MultiCityTBL.FlyDate[5].Value;
	                //this.ReturnDate.MinDate = this.FromDate.Value;
	                if(dObj.Value!=null && dObj.Value.CompareTo(val)<0)dObj.SetValue(val, true);
	                break;
	            }
	        }
	    }
	    oContainer.ChangeSearchType = function(val)
	    {
	        switch(val)
	        {
	            case "OneWay" : 
	            {
                    if(this.Panels.FromTo)this.Panels.FromTo.style.display = document.all ? "block":"table-row";
	                if(this.Panels.Dates)this.Panels.Dates.style.display = document.all ? "block":"table-row";
	                if(this.Panels.Return)this.Panels.Return.style.display = "none";
	                if(this.Panels.MultiCity)this.Panels.MultiCity.style.display = "none";
	                
					if(this.Panels.RowOne)this.Panels.RowOne.style.display = document.all ? "block":"table-row";
	                if(this.Panels.RowTwo)this.Panels.RowTwo.style.display = document.all ? "block":"table-row";
	                if(this.Panels.RowThree)this.Panels.RowThree.style.display = document.all ? "block":"table-row";
	                if(this.Panels.RowFour)this.Panels.RowFour.style.display = document.all ? "block":"table-row";

	                if(this.Panels.ReturnDateLBL)this.Panels.ReturnDateLBL.style.visibility = "hidden";
	                if(this.Panels.ReturnDate)this.Panels.ReturnDate.style.visibility = "hidden";
					if(this.Panels.ReturnTimeLBL)this.Panels.ReturnTimeLBL.style.visibility = "hidden";
	                if(this.Panels.ReturnTime)this.Panels.ReturnTime.style.visibility = "hidden";
	                
	                if(this.SType.OneWay!=null && !this.SType.OneWay.checked)this.SType.OneWay.checked = true;
	                break;
	            }
                case "RoundTrip" : 
	            {
                    if(this.Panels.FromTo)this.Panels.FromTo.style.display = document.all ? "block":"table-row";
	                if(this.Panels.Dates)this.Panels.Dates.style.display = document.all ? "block":"table-row";
	                if(this.Panels.Return)this.Panels.Return.style.display = document.all ? "block":"table-row";
	                if(this.Panels.MultiCity)this.Panels.MultiCity.style.display = "none";
	                
					if(this.Panels.RowOne)this.Panels.RowOne.style.display = document.all ? "block":"table-row";
	                if(this.Panels.RowTwo)this.Panels.RowTwo.style.display = document.all ? "block":"table-row";
	                if(this.Panels.RowThree)this.Panels.RowThree.style.display = document.all ? "block":"table-row";
	                if(this.Panels.RowFour)this.Panels.RowFour.style.display = document.all ? "block":"table-row";

	                if(this.Panels.ReturnDateLBL)this.Panels.ReturnDateLBL.style.visibility = "visible";
	                if(this.Panels.ReturnDate)this.Panels.ReturnDate.style.visibility = "visible";
					if(this.Panels.ReturnTimeLBL)this.Panels.ReturnTimeLBL.style.visibility = "visible";
	                if(this.Panels.ReturnTime)this.Panels.ReturnTime.style.visibility = "visible";
	                
	                if(this.SType.RoundTrip!=null && !this.SType.RoundTrip.checked)this.SType.RoundTrip.checked = true;
	                break;
	            }
	            case "MultiDestination" : 
	            {
	                if(this.Panels.FromTo)this.Panels.FromTo.style.display = "none";
	                if(this.Panels.Dates)this.Panels.Dates.style.display = "none";
	                if(this.Panels.MultiCity)this.Panels.MultiCity.style.display = document.all ? "block":"table-row";
	                
					if(this.Panels.RowOne)this.Panels.RowOne.style.display = "none";
	                if(this.Panels.RowTwo)this.Panels.RowTwo.style.display = "none";
	                if(this.Panels.RowThree)this.Panels.RowThree.style.display = "none";
	                if(this.Panels.RowFour)this.Panels.RowFour.style.display = "none";

	                
	                if(this.SType.MultiDestination!=null && !this.SType.MultiDestination.checked)this.SType.MultiDestination.checked = true;
	                break;
	            }
	        }
	        
	        this.SearchType = val;
	    }
	    oContainer.AddSegment = function()
	    {
	        if(this.MultiCityTBL.Items==6)return;
	        this.MultiCityTBL.rows[this.MultiCityTBL.Items].style.display = document.all?"block":"table-row";
	        this.MultiCityTBL.Items ++;
	    }
        oContainer.RemoveSegment = function()
	    {
	        if(this.MultiCityTBL.Items==1)return;
            this.MultiCityTBL.Items --;
            this.MultiCityTBL.rows[this.MultiCityTBL.Items].style.display = "none";
	    }
		oContainer.AdvancedSearch = function()
	    {
			var baseStr = OFramework.BaseURI + "air/";
			var sStr = baseStr;
            if(OFramework.QSParams["siid"]!=null)sStr+= (sStr==baseStr?"?":"&") + "siid="+OFramework.QSParams["siid"];
            if(OFramework.QSParams["sid1"]!=null)sStr+= (sStr==baseStr?"?":"&") + "sid1="+OFramework.QSParams["sid1"];
            if(OFramework.QSParams["sid2"]!=null)sStr+= (sStr==baseStr?"?":"&") + "sid2="+OFramework.QSParams["sid2"];
            if(OFramework.QSParams["referrer"]!=null)sStr+= (sStr==baseStr?"?":"&") + "referrer="+OFramework.QSParams["referrer"];
            if(OFramework.Culture.LanguageID!="en")sStr+= (sStr==baseStr?"?":"&") + "lang="+OFramework.Culture.LanguageID;
            
            window.open(sStr,this.Target);
	    }
	    oContainer.SubmitSearch = function()
	    {
            if(!this.ValidateInput())return;
            var mainStr = OFramework.BaseURI + "pass/";
			var sStr = mainStr;
            if(OFramework.QSParams["siid"]!=null)sStr+= (sStr==mainStr?"?":"&") + "siid="+OFramework.QSParams["siid"];
            if(OFramework.QSParams["sid1"]!=null)sStr+= (sStr==mainStr?"?":"&") + "sid1="+OFramework.QSParams["sid1"];
            if(OFramework.QSParams["sid2"]!=null)sStr+= (sStr==mainStr?"?":"&") + "sid2="+OFramework.QSParams["sid2"];
            if(OFramework.QSParams["referrer"]!=null)sStr+= (sStr==mainStr?"?":"&") + "referrer="+OFramework.QSParams["referrer"];
            if(OFramework.Culture.LanguageID!="en")sStr+= (sStr==mainStr?"?":"&") + "lang="+OFramework.Culture.LanguageID;
            
            var airSegCount = 2;
            var segmentData = "";
            
            var fromInterval = this.FromInterval!=null ? this.FromInterval.Value : "";
            var toInterval = this.ToInterval!=null ? this.ToInterval.Value : "";
            
            if(this.SearchType == "RoundTrip")
            {
	            airSegCount = 2;
	            segmentData += "AirSeg_1=" 
		            + this.From.Value 
		            + "|"+ this.To.Value 
		            + "|"+ this.FromDate.Value.ToString()
		            + "|"+ (this.FromTime!=null ? this.FromTime.Value : "")
		            + "|"+ (this.FromRadius!=null ? this.FromRadius.Value : "")
		            + "|"+ (this.ToRadius!=null ? this.ToRadius.Value : "")
		            + "|"+ fromInterval
		            + "|"+ toInterval
		            + "";
	            segmentData += "&AirSeg_2=" 
		            + this.To.Value 
		            + "|"+ this.From.Value
		            + "|"+ this.ReturnDate.Value.ToString()
		            + "|"+ (this.ReturnTime!= null ? this.ReturnTime.Value : "")
		            + "|"+ (this.ToRadius!=null ? this.ToRadius.Value : "")
		            + "|"+ (this.FromRadius!=null ? this.FromRadius.Value : "")
		            + "|"+ toInterval
		            + "|"+ fromInterval
		            + "";
            }

            if(this.SearchType == "OneWay")
            {
	            airSegCount = 1;
	            segmentData += "AirSeg_1=" 
		            + this.From.Value 
		            + "|"+ this.To.Value 
		            + "|"+ this.FromDate.Value.ToString()
		            + "|"+ (this.FromTime!=null ? this.FromTime.Value : "")
		            + "|"+ (this.FromRadius!=null ? this.FromRadius.Value : "")
		            + "|"+ (this.ToRadius!=null ? this.ToRadius.Value : "")
		            + "|"+ fromInterval
		            + "|"+ toInterval
		            + "";
            }
            if(this.SearchType == "MultiDestination")
            {
                airSegCount=this.MultiCityTBL.Items;
                for(var i=0; i<airSegCount; i++)
                {
                  	segmentData += (i>0?"&":"") + "AirSeg_"+ (i+1) +"=" 
		            + this.MultiCityTBL.From[i].Value
		            + "|"+ this.MultiCityTBL.To[i].Value 
		            + "|"+ this.MultiCityTBL.FlyDate[i].Value.ToString()
		            + "|"
		            + "|"
		            + "|"
		            + "|"
		            + "|"
		            + "";  
                }
	            
	        }
            sStr += (sStr==mainStr?"?":"&") + "AirSegCount=" + airSegCount + "&aCount=" + this.Adults.Value;
            
            if(this.Seniors!=null && this.Seniors.Value!=0)sStr += "&sCount=" + this.Seniors.Value;
            if(this.Youths!=null && this.Youths.Value!=0)sStr += "&yCount=" + this.Youths.Value;
            if(this.Children!=null && this.Children.Value!=0)sStr += "&cCount=" + this.Children.Value;
            if(this.InfantsInLap!=null && this.InfantsInLap.Value!=0)sStr += "&iLCount=" + this.InfantsInLap.Value;
            if(this.InfantsInSeat!=null && this.InfantsInSeat.Value!=0)sStr += "&iSCount=" + this.InfantsInSeat.Value;

            var airlines="";
            if(this.PrefAirline!=null && this.PrefAirline.Value!="") airlines = this.PrefAirline.Value;
            if(this.PrefAirlineTwo!=null && this.PrefAirlineTwo.Value!="") airlines += (airlines!=""?",":"") + this.PrefAirlineTwo.Value;
            if(this.PrefAirlineThree!=null && this.PrefAirlineThree.Value!="") airlines += (airlines!=""?",":"") + this.PrefAirlineThree.Value;
            if(airlines!="")sStr+="&Airline=" + airlines;
            
            if(this.Class!=null && this.Class.Value!="")sStr += "&Class=" + this.Class.Value;
            if(this.NonStopOption!=null && this.NonStopOption.checked)sStr += "&DirectFlight=1";
            if(this.RefOption!=null && this.RefOption.checked)sStr += "&Refundable=1";
            
            sStr += "&" + segmentData;
            window.open(sStr,this.Target);
	    }
	    oContainer.ValidateInput = function()
	    {
	        var alert_message="";
	        if(this.SearchType=="OneWay" || this.SearchType=="RoundTrip")
	        {
                if(this.From.Value=="")alert_message += " - departure city\n";
                if(this.To.Value=="")alert_message += " - arrival city\n";
	        }
	        else
	        {
	            for(var i=0;i<this.MultiCityTBL.Items;i++)
	            {
	                if(this.MultiCityTBL.From[i].Value == "")alert_message += " - segment #"+ (i+1) +" departure city\n";
	                if(this.MultiCityTBL.To[i].Value == "")alert_message += " - segment #"+ (i+1) +" arrival city\n";
	                if(this.MultiCityTBL.FlyDate[i].Value == null)alert_message += " - segment #"+ (i+1) +" departure date\n";
	            }
	        }
	        if(this.Adults.Value + (this.Seniors!=null?this.Seniors.Value:0) < (this.InfantsInLap!=null?this.InfantsInLap.Value:0))
	        {
	            alert_message += " - infants in lap must be less than the number of adults and/or seniors travelling\n";
	        }
	        if(this.Adults.Value + (this.Seniors!=null?this.Seniors.Value:0)==0 && (this.Youths!=null?this.Youths.Value:0) + (this.Children!=null?this.Children.Value:0) > 0)
	        {
	            alert_message += " - youths/children must be accompanied by an adult/senior\n";
	        }
            var passNum = this.Adults.Value + (this.Seniors!=null?this.Seniors.Value:0) + (this.Youths!=null?this.Youths.Value:0) + (this.Children!=null?this.Children.Value:0) + (this.InfantsInLap!=null?this.InfantsInLap.Value:0) + (this.InfantsInSeat!=null?this.InfantsInSeat.Value:0);
            if(passNum == 0)alert_message += " - the number of passengers travelling \n";

            if(alert_message!=""){
                alert("The following information was not provided : \n" + alert_message);
                return false;
            }
            return true;
	    }
	    return oContainer;
     }

     this.CruiseSearchForm = function(oContainer)
     {
        oContainer.Type = "CruiseSearchForm";
        oContainer.innerHTML = "loading...";
        //oContainer.BaseURI = window.location.protocol + "//" + window.location.host + "/odyssey/website/";
        oContainer.Target = "_top";
        
	    oContainer.UseLangID = (OFramework.Culture.LanguageID!="1");
	    oContainer.LoadComplete = function(data, success)
	    {
	        if(success)
	        {
	            oContainer.innerHTML = data.replace(/Container./g,"document.getElementById('" + oContainer.id + "').");
                OFramework.ProcessTemplate(oContainer, oContainer.firstChild);
                window.setTimeout("document.getElementById('" + oContainer.id + "').Init()", 100);
            }
            else
            {
                if(oContainer.UseLangID)
                {
                    oContainer.UseLangID = false;
                    tLoader.open("GET", OFramework.ThemeURI!=null ? OFramework.ThemeURI + "cruise_search_form.html" : "cruise_search_form.html", true);
	                tLoader.send(null);
	            }
	            else
	            {
	                oContainer.innerHTML="Error loading template source";
	            }
            	}
	    }

	    var tLoader = new OFramework.HtmlLoader(oContainer.LoadComplete);
        var tFileName = oContainer.UseLangID ? "cruise_search_form_"+ OFramework.Culture.GetLanguageCode() +".html" : "cruise_search_form.html";
	    tLoader.open("GET", OFramework.ThemeURI!=null ? OFramework.ThemeURI + tFileName : tFileName, true);
	    tLoader.send(null);
	    
	    oContainer.DataSource = new OFramework.DataSources.JSDataSource("Sailings", oContainer);
	    oContainer.DataBind = function()
	    {
	        if(this.DataSource.DataLoaded)
	        {
	            if(this.SailingsLBL && this.SailingsLBL.innerHTML == "loading...")this.SailingsLBL.innerHTML = "Sailings : " + this.DataSource.length;
	        }
	        else
	        {
	            if(this.SailingsLBL)this.SailingsLBL.innerHTML = "loading...";
	            window.setTimeout("document.getElementById(\""+ this.id +"\").DataBind()", 200);return;
	        }
	    }
        
	    oContainer.Init = function()
	    {
            this.SailingsLBL    = document.getElementById(this.id +'_SailingsLBL');
            this.Destination    = document.getElementById(this.id +'_Destination');
            this.Departure      = document.getElementById(this.id +'_Departure');
	        this.CruiseLine     = document.getElementById(this.id +'_CruiseLine');
	        this.Ship           = document.getElementById(this.id +'_Ship');
	        this.Length         = document.getElementById(this.id +'_Length');
	        this.Month          = document.getElementById(this.id +'_Month');
	        
	        this.DataBind();
	        
	        var dt = new Date();
	        dt.setDate(1);
	        for(var i=0;i<30;i++)
	        {
	            var txt = OFramework.Culture.Date.MonthNames[dt.getMonth()] + " " + dt.getFullYear();
	            var val = dt.getMonth() + "-" + dt.getFullYear();
	            this.Month.DataSource.push({id:val,name:txt});
	            dt.setMonth(dt.getMonth()+1);
	        }
	        
	        this.OnLoad();
	    }
	    oContainer.OnLoad = function()
	    {
	        if(!this.DataSource.DataLoaded || !this.Destination.DataSource.DataLoaded || !this.Departure.DataSource.DataLoaded || !this.CruiseLine.DataSource.DataLoaded || !this.Ship.DataSource.DataLoaded)
	        {
	            window.setTimeout("document.getElementById('" + this.id + "').OnLoad()", 100);
	        }
	        else
	        {
	            this.FilterData();
	        }	        
	    }
	    
	    oContainer.FieldChanged = function(obj, val)
	    {
	        if(this.DataSource.DataLoaded){this.FilterData();return;}
	        switch(obj)
	        {
	            case this.CruiseLine : 
	            {
	                var flt = new OFramework.Array();
	                flt.push(val);
	                this.Ship.SetFilter("cid", val!=""?flt:null);
	                break;
	            }
	        }
	    }
	    oContainer.FilterData = function()
	    {
	        if(!this.DataSource.DataLoaded)return;
	        if(this.SailingsLBL)this.SailingsLBL.innerHTML = "Filtering...";
	        dstData = new OFramework.Array();
	        depData = new OFramework.Array();
	        crlData = new OFramework.Array();
	        shpData = new OFramework.Array();
	        //lngData = new OFramework.Array();
	        
	        var sCount = 0;
	        //var selDst = this.Destination.Value;
		    var selDst = "";
	        var selDep = this.Departure.Value;
	        var selCrl = this.CruiseLine.Value;
	        var selShp = this.Ship.Value;
	        var dstPar = null;
	        var dstItm = null;
	        for(var i=0;i<this.DataSource.length;i++)
	        {
	            var ds = this.DataSource[i];
	            if(this.MatchData(ds, "",selDep,selCrl,selShp) && !dstData.Contains(ds.d))
	            {
	                dstItm = this.Destination.GetItem(ds.d);
	                if(dstItm!=null && dstItm.p!=null)
	                {
	                    if(!dstData.Contains(dstItm.p) && (dstPar==null || dstPar!=dstItm.p))
	                    {
	                        dstPar=dstItm.p;
	                        dstData.push(dstPar);
	                    }
	                }
	                dstData.push(ds.d);
	            }
	            if(this.MatchData(ds, selDst,"",selCrl,selShp) && !depData.Contains(ds.p))depData.push(ds.p);
	            if(this.MatchData(ds, selDst,selDep,"",selShp) && !crlData.Contains(ds.c))crlData.push(ds.c);
	            if(this.MatchData(ds, selDst,selDep,selCrl,"") && !shpData.Contains(ds.s))shpData.push(ds.s);

	            if(this.MatchData(ds,selDst,selDep,selCrl,selShp))sCount++;
	        }
	        
	        this.Destination.SetFilter("id", dstData);
            	this.Departure.SetFilter("id", depData);
	        this.CruiseLine.SetFilter("id", crlData);
	        this.Ship.SetFilter("id", shpData);
	        //this.Length.SetFilter("id", lngData);
	        
	        if(this.SailingsLBL)this.SailingsLBL.innerHTML = "Sailings : " + sCount;
	    }
	    oContainer.MatchData = function(ds,dst,dep,crl,shp)
	    {
	        if(dst!="" && ds.d!=dst)return false;
	        if(dep!="" && ds.p!=dep)return false;
	        if(crl!="" && ds.c!=crl)return false;
	        if(shp!="" && ds.s!=shp)return false;
	        return true;
	    }
	    oContainer.SubmitSearch = function()
	    {
            if(!this.ValidateInput())return;
            var sStr = OFramework.BaseURI;
            if(OFramework.QSParams["siid"]!=null)sStr+= (sStr==OFramework.BaseURI?"?":"&") + "siid="+OFramework.QSParams["siid"];
            if(OFramework.QSParams["sid1"]!=null)sStr+= (sStr==OFramework.BaseURI?"?":"&") + "sid1="+OFramework.QSParams["sid1"];
            if(OFramework.QSParams["sid2"]!=null)sStr+= (sStr==OFramework.BaseURI?"?":"&") + "sid2="+OFramework.QSParams["sid2"];
            if(OFramework.QSParams["referrer"]!=null)sStr+= (sStr==OFramework.BaseURI?"?":"&") + "referrer="+OFramework.QSParams["referrer"];
	        if(OFramework.Culture.LanguageID!="en")sStr+= (sStr==OFramework.BaseURI?"?":"&") + "lang="+OFramework.Culture.LanguageID;
	        
	        sStr += (sStr==OFramework.BaseURI?"?":"&") + "SearchCruise=1";
            
            if(this.CruiseLine!=null && this.CruiseLine.Value!="")sStr +="&CruiseLine=" + this.CruiseLine.Value;
            if(this.Ship!=null && this.Ship.Value!="")sStr +="&Ship=" + this.Ship.Value;
            if(this.Destination!=null && this.Destination.Value!="")sStr +="&Destinations=" + this.Destination.Value;
            if(this.Departure!=null && this.Departure.Value!="")sStr +="&DeparturePorts=" + this.Departure.Value;
            if(this.Length!=null && this.Length.Value!="")
            {
                sStr +="&MinDuration=" + this.Length.SelectedItem["min"] + "&MaxDuration=" + this.Length.SelectedItem["max"];
            }
            if(this.Month!=null && this.Month.Value!="")
            {
                var sel_date = this.Month.Value.split("-");
                var startDate = new Date();
                startDate.setFullYear(parseInt(sel_date[1],10), parseInt(sel_date[0],10), 1);
                var endDate = new Date();
                endDate.setFullYear(parseInt(sel_date[1],10), parseInt(sel_date[0],10)+1, 1);
                endDate.setDate(0);
                sStr += "&StartDate=" + (startDate.getMonth() + 1) + "/" + startDate.getDate() + "/" + startDate.getFullYear();
                sStr += "&EndDate=" + (endDate.getMonth() + 1) + "/" + endDate.getDate() + "/" + endDate.getFullYear();
            }
	        //alert(sStr);
	        window.open(sStr,this.Target);
	    }
	    oContainer.ValidateInput = function()
	    {
	        return true;
	    }
	    return oContainer;
     }
     
     this.HotelSearchForm = function(oContainer)
     {
        oContainer.Type = "HotelSearchForm";
        oContainer.innerHTML = "loading...";
        oContainer.Target = "_top";
        
        oContainer.UseLangID = (OFramework.Culture.LanguageID!="1");
	    oContainer.LoadComplete = function(data, success)
	    {
	        if(success)
	        {
	            oContainer.innerHTML = data.replace(/Container./g,"document.getElementById('" + oContainer.id + "').");
                OFramework.ProcessTemplate(oContainer, oContainer.firstChild);
                window.setTimeout("document.getElementById('" + oContainer.id + "').Init()",50);
            }
            else
            {
                if(oContainer.UseLangID)
                {
                    oContainer.UseLangID = false;
                    tLoader.open("GET", OFramework.ThemeURI!=null ? OFramework.ThemeURI + "hotel_search_form.html" : "hotel_search_form.html", true);
	                tLoader.send(null);
	            }
	            else
	            {
	                oContainer.innerHTML="Error loading template source";
	            }
            }
	    }
        
	    var tLoader = new OFramework.HtmlLoader(oContainer.LoadComplete);
        var tFileName = oContainer.UseLangID ? "hotel_search_form_"+ OFramework.Culture.GetLanguageCode() +".html" : "hotel_search_form.html";
	    tLoader.open("GET", OFramework.ThemeURI!=null ? OFramework.ThemeURI + tFileName : tFileName, true);
	    tLoader.send(null);
	    
	    oContainer.Init = function()
	    {
	        this.Destination    = document.getElementById(this.id +'_Destination');
	        this.CheckInDate    = document.getElementById(this.id +'_CheckInDate');
	        this.CheckInDay     = document.getElementById(this.id +'_CheckInDay');
	        this.CheckOutDate   = document.getElementById(this.id +'_CheckOutDate');
	        this.CheckOutDay    = document.getElementById(this.id +'_CheckOutDay');
	        this.RoomCount      = document.getElementById(this.id +'_RoomCount');
	        this.HotelName      = document.getElementById(this.id +'_HotelName');
	        this.HotelClass     = document.getElementById(this.id +'_Class');
	        
	        
	        this.RoomOne		        = document.getElementById(this.id +'_RoomOneTR');
	        this.RoomOne.Adults         = document.getElementById(this.id +'_RoomOneAdults');
	        this.RoomOne.Children       = document.getElementById(this.id +'_RoomOneChildren');
	        this.RoomOne.Children.TR	= document.getElementById(this.id +'_RoomOneChildTR');
	        this.RoomOne.ChildOneAge    = document.getElementById(this.id +'_RoomOneChildOneAge');
	        this.RoomOne.ChildTwoAge    = document.getElementById(this.id +'_RoomOneChildTwoAge');
	        this.RoomOne.ChildThreeAge  = document.getElementById(this.id +'_RoomOneChildThreeAge');
	        this.RoomOne.ChildFourAge   = document.getElementById(this.id +'_RoomOneChildFourAge');
	        
	        this.RoomTwo		        = document.getElementById(this.id +'_RoomTwoTR');
	        this.RoomTwo.Adults         = document.getElementById(this.id +'_RoomTwoAdults');
	        this.RoomTwo.Children       = document.getElementById(this.id +'_RoomTwoChildren');
	        this.RoomTwo.Children.TR	= document.getElementById(this.id +'_RoomTwoChildTR');
	        this.RoomTwo.ChildOneAge    = document.getElementById(this.id +'_RoomTwoChildOneAge');
	        this.RoomTwo.ChildTwoAge    = document.getElementById(this.id +'_RoomTwoChildTwoAge');
	        this.RoomTwo.ChildThreeAge  = document.getElementById(this.id +'_RoomTwoChildThreeAge');
	        this.RoomTwo.ChildFourAge   = document.getElementById(this.id +'_RoomTwoChildFourAge');
	        
	        this.RoomThree		        = document.getElementById(this.id +'_RoomThreeTR');
	        this.RoomThree.Adults       = document.getElementById(this.id +'_RoomThreeAdults');
	        this.RoomThree.Children     = document.getElementById(this.id +'_RoomThreeChildren');
	        this.RoomThree.Children.TR	= document.getElementById(this.id +'_RoomThreeChildTR');
            this.RoomThree.ChildOneAge  = document.getElementById(this.id +'_RoomThreeChildOneAge');
	        this.RoomThree.ChildTwoAge  = document.getElementById(this.id +'_RoomThreeChildTwoAge');
	        this.RoomThree.ChildThreeAge= document.getElementById(this.id +'_RoomThreeChildThreeAge');
	        this.RoomThree.ChildFourAge = document.getElementById(this.id +'_RoomThreeChildFourAge');
	        
	        
	        //set default values
	        var today = new Date();
	        var dDate = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 7);
	        var rDate = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 8);
	        
	        this.CheckInDate.MinDate = today;
	        this.CheckInDate.SetValue(dDate);
	        this.CheckInDay.innerHTML = OFramework.Culture.Date.WeekDays[dDate.getDay()].substring(0,3);
	        
	        this.CheckOutDate.MinDate = dDate;
	        this.CheckOutDate.SetValue(rDate);
	        this.CheckOutDay.innerHTML = OFramework.Culture.Date.WeekDays[rDate.getDay()].substring(0,3);
	        
	        
	        var ds = new OFramework.DataSources.HtmlDataSource();
	        for(i=0;i<18;i++)
		    {
			    var lbl = i==0 ? "<1" : i;
			    ds.push({id:i,name:lbl});
		    }
		    with(this.RoomOne.ChildOneAge){DataSource = ds;DataBind();}
		    with(this.RoomOne.ChildTwoAge){DataSource = ds;DataBind();}
		    with(this.RoomOne.ChildThreeAge){DataSource = ds;DataBind();}
		    with(this.RoomOne.ChildFourAge){DataSource = ds;DataBind();}
		    with(this.RoomTwo.ChildOneAge){DataSource = ds;DataBind();}
		    with(this.RoomTwo.ChildTwoAge){DataSource = ds;DataBind();}
		    with(this.RoomTwo.ChildThreeAge){DataSource = ds;DataBind();}
		    with(this.RoomTwo.ChildFourAge){DataSource = ds;DataBind();}
		    with(this.RoomThree.ChildOneAge){DataSource = ds;DataBind();}
		    with(this.RoomThree.ChildTwoAge){DataSource = ds;DataBind();}
		    with(this.RoomThree.ChildThreeAge){DataSource = ds;DataBind();}
		    with(this.RoomThree.ChildFourAge){DataSource = ds;DataBind();}

	    }
	    oContainer.FieldChanged = function(obj, val)
	    {
	        switch(obj)
	        {
	            case this.CheckInDate : 
	            {
	                var nDate = new Date(val.getFullYear(), val.getMonth(), val.getDate()+1);
	                this.CheckOutDate.MinDate = nDate;
	                if(this.CheckOutDate.Value.CompareTo(nDate)<0)this.CheckOutDate.SetValue(nDate, true);
	                
	                this.CheckInDay.innerHTML = OFramework.Culture.Date.WeekDays[val.getDay()].substring(0,3);
	                break;
	            }
	            case this.CheckOutDate : 
	            {
	                this.CheckOutDay.innerHTML = OFramework.Culture.Date.WeekDays[val.getDay()].substring(0,3);
	                break;
	            }
	            case this.RoomCount :{this.Display();break;}
	            case this.RoomOne.Children : {this.Display();break;}
	            case this.RoomTwo.Children : {this.Display();break;}
	            case this.RoomThree.Children : {this.Display();break;}
	        }
	    }
	    oContainer.Display = function()
	    {
    	    this.RoomTwo.style.display = "none";
            this.RoomThree.style.display = "none";
            var bStr = document.all ? "block" : "table-row";
    		
		    switch(this.RoomCount.Value){
			    case "1" : {this.RoomTwo.Children.SetValue(0,false);this.RoomThree.Children.SetValue(0,false);break}
			    case "2" : {this.RoomTwo.style.display=bStr;this.RoomThree.Children.SetValue(0,false);break;}
			    case "3" : {this.RoomTwo.style.display=bStr;this.RoomThree.style.display=bStr;break;}
		    }
            
	        if(this.RoomOne.Children.TR!=null)this.RoomOne.Children.TR.style.display = this.RoomOne.Children.Value==0 ? "none" : bStr;
		    this.RoomOne.ChildOneAge.style.visibility = this.RoomOne.Children.Value>0 ? "visible":"hidden";
		    this.RoomOne.ChildTwoAge.style.visibility = this.RoomOne.Children.Value>1 ? "visible":"hidden";
		    this.RoomOne.ChildThreeAge.style.visibility = this.RoomOne.Children.Value>2 ? "visible":"hidden";
		    this.RoomOne.ChildFourAge.style.visibility = this.RoomOne.Children.Value>3 ? "visible":"hidden";
    		
		    if(this.RoomTwo.Children.TR!=null)this.RoomTwo.Children.TR.style.display = this.RoomTwo.Children.Value==0 ? "none" : bStr;
		    this.RoomTwo.ChildOneAge.style.visibility = this.RoomTwo.Children.Value>0 ? "visible":"hidden";
		    this.RoomTwo.ChildTwoAge.style.visibility = this.RoomTwo.Children.Value>1 ? "visible":"hidden";
		    this.RoomTwo.ChildThreeAge.style.visibility = this.RoomTwo.Children.Value>2 ? "visible":"hidden";
		    this.RoomTwo.ChildFourAge.style.visibility = this.RoomTwo.Children.Value>3 ? "visible":"hidden";
    		
		    if(this.RoomThree.Children.TR!=null)this.RoomThree.Children.TR.style.display = this.RoomThree.Children.Value==0 ? "none" : bStr;
		    this.RoomThree.ChildOneAge.style.visibility = this.RoomThree.Children.Value>0 ? "visible":"hidden";
		    this.RoomThree.ChildTwoAge.style.visibility = this.RoomThree.Children.Value>1 ? "visible":"hidden";
		    this.RoomThree.ChildThreeAge.style.visibility = this.RoomThree.Children.Value>2 ? "visible":"hidden";
		    this.RoomThree.ChildFourAge.style.visibility = this.RoomThree.Children.Value>3 ? "visible":"hidden";
	    }
	    oContainer.SubmitSearch = function()
	    {
            if(!this.ValidateInput())return;
            var sStr = OFramework.BaseURI;
            if(OFramework.QSParams["siid"]!=null)sStr+= (sStr==OFramework.BaseURI?"?":"&") + "siid="+OFramework.QSParams["siid"];
            if(OFramework.QSParams["sid1"]!=null)sStr+= (sStr==OFramework.BaseURI?"?":"&") + "sid1="+OFramework.QSParams["sid1"];
            if(OFramework.QSParams["sid2"]!=null)sStr+= (sStr==OFramework.BaseURI?"?":"&") + "sid2="+OFramework.QSParams["sid2"];
            if(OFramework.QSParams["referrer"]!=null)sStr+= (sStr==OFramework.BaseURI?"?":"&") + "referrer="+OFramework.QSParams["referrer"];
	        if(OFramework.Culture.LanguageID!="en")sStr+= (sStr==OFramework.BaseURI?"?":"&") + "lang="+OFramework.Culture.LanguageID;
    		
		    var SegmentData = "&RoomCount="+ this.RoomCount.Value;
		    switch(this.RoomCount.Value)
		    {
			    case "1" : {
				    SegmentData += "&R1="+ this.RoomOne.Adults.Value +"|"+ this.RoomOne.Children.Value + "|" + this.RoomOne.ChildOneAge.Value + "," + this.RoomOne.ChildTwoAge.Value + "," + this.RoomOne.ChildThreeAge.Value + "," + this.RoomOne.ChildFourAge.Value
				    break;
			    }
			    case "2" : {
				    SegmentData += "&R1="+ this.RoomOne.Adults.Value +"|"+ this.RoomOne.Children.Value + "|" + this.RoomOne.ChildOneAge.Value + "," + this.RoomOne.ChildTwoAge.Value + "," + this.RoomOne.ChildThreeAge.Value + "," + this.RoomOne.ChildFourAge.Value;
				    SegmentData += "&R2="+ this.RoomTwo.Adults.Value +"|"+ this.RoomTwo.Children.Value + "|" + this.RoomTwo.ChildOneAge.Value + "," + this.RoomTwo.ChildTwoAge.Value + "," + this.RoomTwo.ChildThreeAge.Value + "," + this.RoomTwo.ChildFourAge.Value;
				    break;
			    }
			    case "3" : {
				    SegmentData += "&R1="+ this.RoomOne.Adults.Value +"|"+ this.RoomOne.Children.Value + "|" + this.RoomOne.ChildOneAge.Value + "," + this.RoomOne.ChildTwoAge.Value + "," + this.RoomOne.ChildThreeAge.Value + "," + this.RoomOne.ChildFourAge.Value;
				    SegmentData += "&R2="+ this.RoomTwo.Adults.Value +"|"+ this.RoomTwo.Children.Value + "|" + this.RoomTwo.ChildOneAge.Value + "," + this.RoomTwo.ChildTwoAge.Value + "," + this.RoomTwo.ChildThreeAge.Value + "," + this.RoomTwo.ChildFourAge.Value;
				    SegmentData += "&R3="+ this.RoomThree.Adults.Value +"|"+ this.RoomThree.Children.Value + "|" + this.RoomThree.ChildOneAge.Value + "," + this.RoomThree.ChildTwoAge.Value + "," + this.RoomThree.ChildThreeAge.Value + "," + this.RoomThree.ChildFourAge.Value;
				    break;
			    }
		    }
		    //add rest of the stuff
		    sStr += (sStr==OFramework.BaseURI?"?":"&") + "loc=" + encodeURI(this.Destination.Value);
		    sStr += "&fDate=" + encodeURI(this.CheckInDate.Value.ToString());
		    sStr += "&tDate=" + encodeURI(this.CheckOutDate.Value.ToString());
		    if(this.HotelName!=null && this.HotelName.Value!="")sStr += "&hName=" + this.HotelName.Value;
		    if(this.HotelClass!=null && this.HotelClass.Value!="")sStr += "&hClass=" + this.HotelClass.Value;
            //final concat
            sStr += SegmentData;
		    
		    //alert(sStr);
		    window.open(sStr,this.Target);
	    }
	    oContainer.ValidateInput = function()
	    {
		    alert_message = "";

		    if(!this.Destination.Value || this.Destination.Value == "")alert_message += " - destination\n";
		    if(this.CheckInDate.Value == "")alert_message += " - check in date\n";
		    if(this.CheckOutDate.Value == "")alert_message += " - check out date\n";

		    if(alert_message!=""){
			    alert("The following information was not provided : \n" + alert_message);
			    return false;
		    }
		    return true;
	    }
	    return oContainer;
     }
    
     this.DataSources = new function()
     {
        this.DataSource = function(oID, source)
        {
            if(OFramework.DataSources[oID]!=null) return OFramework.DataSources[oID];
            var o = new Array();
            o.DataLoaded = false;
            o.LoadComplete = function(data)
            {
                if(data!=null && data.firstChild!=null)
                {
                    for(var n=0; n<data.firstChild.childNodes.length; n++)
                    {
                        var node = data.firstChild.childNodes[n];
                        if(node.nodeType==1)
                        {
                            var newDataItem = new Object();
                            for(a=0;a<node.attributes.length;a++){
                                newDataItem[node.attributes[a].name] = node.attributes[a].value;
                            }
                            o.push(newDataItem);
                        }
                    }
                }
                o.DataLoaded = true;
            }

            var tLoader = new OFramework.XmlLoader(o.LoadComplete);
            tLoader.open("GET", OFramework.BaseURI + "searchforms/data/" + source, true);
            tLoader.send(null);

            OFramework.DataSources[oID] = o;
            return o;
        }
        this.HtmlDataSource = function(source)
        {
            var o = new Array();
            if(source!=null && source.childNodes!=null){
                for(var n=0; n<source.childNodes.length; n++)
                {
                    var node = source.childNodes[n];
                    if(node.nodeType==1 && node.nodeName.toLowerCase()=="item")
                    {
                        var newDataItem = new Object();
                        for(a=0;a<node.attributes.length;a++){
                            newDataItem[node.attributes[a].name] = node.attributes[a].value;
                        }
                        o.push(newDataItem);
                    }
                }
            }
            o.DataLoaded = true;
            return o;
        }
        this.JSDataSource = function(oID, oBind)
        {
            if(OFramework.DataSources.Bindings[oID]==null)OFramework.DataSources.Bindings[oID] = new Array();
            
            if(OFramework.DataSources[oID]!=null)
            {
                if(!OFramework.DataSources[oID].DataLoaded)OFramework.DataSources.Bindings[oID].push(oBind);
                return OFramework.DataSources[oID];
            }
            else
            {
                var retObj=new Object();
                retObj.DataLoaded = false;
            
                OFramework.DataSources.Bindings[oID].push(oBind);
                OFramework.DataSources[oID] = retObj;
				var params = "data/?type=" + oID;
				if(OFramework.QSParams["siid"]!=null)params += "&siid=" + OFramework.QSParams["siid"];
				else if(OFramework.QSParams["data_siid"]!=null)params += "&siid=" + OFramework.QSParams["data_siid"];
				if(OFramework.Culture.LanguageID!="en")params += "&lang=" + OFramework.Culture.LanguageID;
                window.setTimeout(function(){var sObj = document.createElement("script");sObj.src = OFramework.BaseURI + params;sObj.defer = true;OFramework.Container.appendChild(sObj);}, 50);return;
                return retObj;
            }
        }
        this.DataLoaded = function(oID)
        {
            if(!OFramework.DataSources.Bindings[oID])return;
            for(var i=0;i<OFramework.DataSources.Bindings[oID].length;i++)
            {
                OFramework.DataSources.Bindings[oID][i].DataSource = OFramework.DataSources[oID];
            }
        }
        this.Bindings = new Array();
     }
     this.DataSources.prototype = new Array();
    
    this.Templates = new function()
    {

    }
    this.Templates.prototype = new Array();
     
     this.ProcessTemplate = function(oContainer, oElement)
     {

        for(var c=0;c<oElement.childNodes.length;c++)
        {
            var oNode = oElement.childNodes[c];
            var oNodeType = null;
            var newNode = null;

            if(oNode.scopeName=="OFramework")
            {
                oNodeType = oNode.nodeName.toLowerCase();

            }
            else if(oNode.nodeName.indexOf("OFRAMEWORK")==0 || oNode.nodeName.indexOf("OFramework")==0 )
            {

                oNodeType = oNode.nodeName.substring(11, oNode.nodeName.length).toLowerCase();
            }		
            if(oNodeType!=null)
            {				
				
                switch(oNodeType){							 
                    case "input" : {newNode = new OFramework.Controls.InputText();break;}
                    case "dateinput" : {newNode = new OFramework.Controls.InputDate();break;}
                    case "calendarbutton" : {newNode = new OFramework.Controls.CalendarButton();break;}
                    case "dropdownlist": {newNode = new OFramework.Controls.HtmlDropdownList();break;}
                }
                
                if(newNode==null) continue;
                //parent
                newNode.Parent = oContainer;
                //attributes
                for(var a=0;a<oNode.attributes.length;a++)
                {
                    if(!oNode.attributes[a].specified)continue;
                    var att = oNode.attributes[a].name;
                    var att_val = oNode.attributes[a].value;
                    switch(att.toLowerCase())
                    {
                        case "id" : {newNode.id = oContainer.id + "_" + att_val;continue;}
                        case "style" : {newNode.style.cssText = oNode.style.cssText;continue;}
                        case "datasource" : 
                        {
                            //newNode.DataSource = new OFramework.DataSources.DataSource(att_val, att_val + ".xml");
                            newNode.DataSource = new OFramework.DataSources.JSDataSource(att_val, newNode);
                            continue;
                        }
                        case "itemtemplate" : {newNode.ItemTemplate=att_val;continue;}
                        case "emptyitem":{newNode.DefaultItem = new Object();newNode.DefaultItem.id="";newNode.DefaultItem.name="&nbsp;";continue;}
                        case "calendarlayout" : {newNode.CalendarLayout=att_val;continue;}
                        case "hinttext" : {newNode.HintText=att_val;continue;}
                    }
                    newNode.setAttribute(att, att_val);
                }
                if(oNodeType=="dropdownlist" && oNode.childNodes.length>0)
                {
                    var ds = new OFramework.DataSources.HtmlDataSource(oNode);
                    if(newNode.DataSource==null)newNode.DataSource = ds;
                    else newNode.DefaultItem = ds[0];
                    oNode.innerHTML="";
                }
                if(newNode.DataSource!=null)newNode.DataBind();
                oNode = oElement.replaceChild(newNode, oNode);
            }
            else
            {				
                if(oNode.id && oNode.id!="")oNode.id = oContainer.id + "_" + oNode.id;
                if(oNode.htmlFor && oNode.htmlFor!="")oNode.htmlFor = oContainer.id + "_" + oNode.htmlFor;
            }
            if(oNode.childNodes.length>0)OFramework.ProcessTemplate(oContainer, oNode);
        }
     }
     this.ProcessItemTemplate = function(sTemplate, sData)
     {
        var retStr = sTemplate;
        for(s in sData)
        {
            retStr = retStr.replace(s, sData[s]);
        }
        return retStr;
     }
     
     this.XmlLoader = function(iCallback)
     {
        var xmlLoader = null;
		try {xmlLoader = new XMLHttpRequest();}
		catch (e)
		{
			try {xmlLoader = new ActiveXObject('Microsoft.XMLHTTP');}
			catch (e2) 
			{
				try {xmlLoader = new ActiveXObject('Msxml2.XMLHTTP');}
				catch (e3) {xmlLoader = null;}
			}
		}
		xmlLoader.onreadystatechange = function()
		{
            if (xmlLoader.readyState == 4)
	        {
		        if(xmlLoader.status==200)iCallback(xmlLoader.responseXML);
	        }
		}
		
		return xmlLoader;
     }
     
     this.HtmlLoader = function(iCallback)
     {
        var htmlLoader = null;
		try {htmlLoader = new XMLHttpRequest();}
		catch (e)
		{
			try {htmlLoader = new ActiveXObject('Microsoft.XMLHTTP');}
			catch (e2) 
			{
				try {htmlLoader = new ActiveXObject('Msxml2.XMLHTTP');}
				catch (e3) {htmlLoader = null;}
			}
		}
		htmlLoader.onreadystatechange = function()
		{
            if (htmlLoader.readyState == 4)
	        {
		        if(htmlLoader.status==200)iCallback(htmlLoader.responseText, true);
		        if(htmlLoader.status==404)iCallback(null, false);//file not found error, try switch language ?
	        }
		}
		
		return htmlLoader;
     }
	
	this.getPosTop = function(obj)
	{
		//var retVal = obj.offsetTop;
		//if(obj.offsetParent!=null)retVal += OFramework.getPosTop(obj.offsetParent);
		//return retVal;
		var cTop = 0;
	    if (obj.offsetParent)
	    {
		    while (obj.offsetParent){
			    cTop += obj.offsetTop
			    obj = obj.offsetParent;
		    }
	    }
	    else if (obj.y)cTop += obj.y;
	    return cTop;
		
	}
	this.getPosLeft = function(obj)
	{
		//var retVal = obj.offsetLeft;
		//if(obj.offsetParent!=null)retVal += OFramework.getPosLeft(obj.offsetParent);
		//return retVal;
        var cLeft = 0;
	    if (obj.offsetParent)
	    {
		    while (obj.offsetParent){
			    cLeft += obj.offsetLeft
			    obj = obj.offsetParent;
		    }
	    }
	    else if (obj.x)cLeft += obj.x;
	    return cLeft;
	}
    this.addEvent = function(elm, strEvent, fnHandler)
    {
	    return (elm.addEventListener
	    ? elm.addEventListener(strEvent, fnHandler, false)
	    : elm.attachEvent('on'+strEvent, fnHandler)
	    );
    }
    this.Eval = function(oObj, sStr)
    {
		var sParts = sStr.split(".");
		for(i=0;i<sParts.length;i++)
		{
			if(oObj[sParts[i]]!=null)oObj = oObj[sParts[i]];
			else return null;
		}
		return oObj;
    }
    this.Dictionary = function (str, d1, d2)
    {
	    this.Add = function(key, value){this[key] = value;}
	    this.Remove = function(key){this[key]=null;}
	    this.GetValue = function(key){return this[key];}
    	
	    if(str.length>1)
	    {
		    str=str.substring(1,str.length);
		    var keyValuePairs = str.split(d1);
		    for(var k=0;k<keyValuePairs.length;k++)
		    {
			    keyValuePair = keyValuePairs[k].split(d2);
			    this.Add(unescape(keyValuePair[0]), unescape(keyValuePair[1]))
		    }
	    }
    }
    this.Dictionary.prototype =  new Array();
    this.QSParams = new this.Dictionary(window.location.search, "&", "=");
    this.Culture.LanguageID = this.QSParams["lang"]!=null ? this.QSParams["lang"].toLowerCase() : "1";
}

var Value;
function filterList(key,oContainer)
{
		if(Value==null || Value=="")
			Value=String.fromCharCode(key);		
		else
			Value+=String.fromCharCode(key);
		
		var DivEle=document.getElementById("DDListPopUp");
		var List=oContainer.List;
		var divArr = List.getElementsByTagName("div");	
		for(var i=0;i<divArr.length;i++)
		{
				var ele=divArr[i];
				ele.className='list_item';
		}
		for(var i=0;i<divArr.length;i++)
		{
				var ele=divArr[i];
				var eleVal=ele.innerHTML;
				var str=eleVal;
				eleVal=eleVal.toUpperCase();
				Value=Value.toUpperCase();
				ele.className='list_item';
				if(eleVal.startsWith(Value))
				{
						ele.className='list_item_hover';
					    DivEle.scrollTop = ele.offsetTop;	
						oContainer.innerHTML=str;
						break;
				}
		}
		window.setTimeout("resetVal()", 1500);
		return str;
}

/*function setDropDownValue(oContainer)
{
		var List=oContainer.List;
		var divArr = List.getElementsByTagName("div");		
		for(var i=0;i<divArr.length;i++)
		{
				var ele=divArr[i];
				if(ele.className=='list_item_hover')
				{
					oContainer.innerHTML=str;
					break;
				}
		}
		return;
}*/
function resetVal()
{
		Value="";
}

String.prototype.startsWith = function(str)
{
	return (this.match("^"+str)==str);
}

