﻿Type.registerNamespace("Telerik.Web.UI");
$telerik.findTimeView=$find;
$telerik.toTimeView=function(a){return a;
};
Telerik.Web.UI.RadTimeView=function(a){Telerik.Web.UI.RadTimeView.initializeBase(this,[a]);
this._itemsCount=null;
this._timeOverStyleCss=null;
this._ownerDatePickerID=null;
this._itemStyles=null;
this._culture=null;
this._timeFormat=null;
this._columns=3;
this._showFooter=true;
this._showHeader=true;
this._startTime=new Date(1990,1,0,0,0,0,0);
this._endTime=new Date(1990,1,0,23,59,59,0);
this._interval=new Date(1990,1,0,1,0,0,0);
this._onCellMouseOutDelegate=null;
this._onCellMouseOverDelegate=null;
this._onCellMouseOverDelegate=null;
this._dataSource=null;
this._renderDirection=="Horizontal";
};
Telerik.Web.UI.RadTimeView.prototype={initialize:function(){Telerik.Web.UI.RadTimeView.callBaseMethod(this,"initialize");
this.DivElement=$get(this.get_id());
this._timeMatrix=this._setTimeMatrix();
this._tempStyle=null;
this._attachEventHandlers();
},dispose:function(){if(this._onCellMouseOutDelegate){$removeHandler(this.DivElement,"mouseout",this._onCellMouseOutDelegate);
this._onCellMouseOutDelegate=null;
}if(this._onCellMouseOverDelegate){$removeHandler(this.DivElement,"mouseover",this._onCellMouseOverDelegate);
this._onCellMouseOverDelegate=null;
}if(this._onCellClickDelegate){$removeHandler(this.DivElement,"click",this._onCellClickDelegate);
this._onCellClickDelegate=null;
}Telerik.Web.UI.RadTimeView.callBaseMethod(this,"dispose");
},getTime:function(){var a=$find(this.get__OwnerDatePickerID());
return a.get_selectedDate();
},setTime:function(c,a,e,g){var f=$find(this.get__OwnerDatePickerID());
var d;
if(Object.getType(f).getName()=="Telerik.Web.UI.RadDateTimePicker"&&!f.get_calendar()){d=g;
}else{d=f.get_selectedDate();
}if(!d){d=new Date();
}d.setHours(c);
d.setMinutes(a);
d.setSeconds(e);
if(f.get_autoPostBackControl()!=Telerik.Web.UI.Calendar.AutoPostBackControl.Both&&f.get_autoPostBackControl()!=Telerik.Web.UI.Calendar.AutoPostBackControl.TimeView){var b=function(h,i){i.set_cancel(true);
};
f._dateInput.add_valueChanged(b);
f.set_selectedDate(d);
f._dateInput.remove_valueChanged(b);
}else{f.set_selectedDate(d);
}},get_dataSource:function(){return this._dataSource;
},set_dataSource:function(a){if(this._dataSource!==a){this._dataSource=a;
this.raisePropertyChanged("dataSource");
}},get_itemStyles:function(){return this._itemStyles;
},set_itemStyles:function(a){if(this._itemStyles!==a){this._itemStyles=a;
this.raisePropertyChanged("itemStyles");
}},get__renderDirection:function(){return this._renderDirection;
},set__renderDirection:function(a){this._renderDirection=a;
this.raisePropertyChanged("renderDirection");
},get_columns:function(){return this._columns;
},set_columns:function(a){if(this._columns!==a){this._columns=a;
this.raisePropertyChanged("columns");
}},get_showFooter:function(){return this._columns;
},set_showFooter:function(a){if(this._showFooter!==a){this._showFooter=a;
this.raisePropertyChanged("showFooter");
}},get_showHeader:function(){return this._showHeader;
},set_showHeader:function(a){if(this._showHeader!==a){this._showHeader=a;
this.raisePropertyChanged("showHeader");
}},get_startTime:function(){return this._startTime;
},set_startTime:function(b){var a=this._deserializerTime(b);
if(this._startTime!==a){this._startTime=a;
this.raisePropertyChanged("startTime");
}},get_endTime:function(){return this._endTime;
},set_endTime:function(b){var a=this._deserializerTime(b);
if(this._endTime!==a){this._endTime=a;
this.raisePropertyChanged("endTime");
}},get_interval:function(){return this._interval;
},set_interval:function(b){var a=this._deserializerTime(b);
if(this._interval!==a){this._interval=a;
this.raisePropertyChanged("interval");
}},get_culture:function(){return this._culture;
},get_timeFormat:function(){return this._timeFormat;
},_clearHovers:function(){var a=this.get_element().getElementsByTagName("td");
for(var b=0;
b<a.length;
b++){if(a[b].className&&a[b].className.indexOf("rcHover")!=-1){a[b].className=a[b].className.replace("rcHover","");
}}},_selectTimeCell:function(d,a){var f=null;
var g=null;
for(var b=0;
b<this._timeMatrix.length;
b++){for(var c=0;
c<this._timeMatrix[b].length;
c++){if(!this._timeMatrix[b][c]){continue;
}if(this._timeMatrix[b][c].getHours()==d&&this._timeMatrix[b][c].getMinutes()==a){f=b;
g=c;
}}}if($get(this.get_id()+"_selectedCell")){$get(this.get_id()+"_selectedCell").className=$get(this.get_id()+"_selectedCell").className.replace("rcSelected","");
$get(this.get_id()+"_selectedCell").removeAttribute("id");
}var e=this._findTableElement(this.DivElement);
if(f!=null&&g!=null&&e){e.rows[f].cells[g].className+=" rcSelected";
e.rows[f].cells[g].id=this.get_id()+"_selectedCell";
}},_attachEventHandlers:function(){this._onCellMouseOutDelegate=Function.createDelegate(this,this._onCellMouseOutHandler);
this._onCellMouseOverDelegate=Function.createDelegate(this,this._onCellMouseOverHandler);
this._onCellClickDelegate=Function.createDelegate(this,this._onCellClickHandler);
$addHandler(this.DivElement,"mouseout",this._onCellMouseOutDelegate);
$addHandler(this.DivElement,"mouseover",this._onCellMouseOverDelegate);
$addHandler(this.DivElement,"click",this._onCellClickDelegate);
},_onCellMouseOutHandler:function(b){if(this._tempStyle==null){return;
}var a=Telerik.Web.UI.Calendar.Utils.FindTarget(b,this.get_id());
if(a==null){return;
}if(a.className.indexOf("rcHeader")==-1&&a.className.indexOf("rcFooter")==-1){a.style.cssText=this._tempStyle[0];
a.className=this._tempStyle[1];
}},_onCellMouseOverHandler:function(c){var b=Telerik.Web.UI.Calendar.Utils.FindTarget(c,this.get_id());
if(b==null){return;
}if(b.className.indexOf("rcHeader")==-1&&b.className.indexOf("rcFooter")==-1){var a=new Array(2);
a[0]=b.style.cssText;
a[1]=b.className;
this._tempStyle=a;
b.style.cssText=this.get_itemStyles()["TimeOverStyle"][0];
b.className=this.get_itemStyles()["TimeOverStyle"][1];
}},_onCellClickHandler:function(k){var c=Telerik.Web.UI.Calendar.Utils.FindTarget(k,this.get_id());
if(c!=null){var g=c.cellIndex;
if(navigator.userAgent.match(/Safari/)){var h=c.parentNode;
var a;
for(a=0;
a<h.cells.length;
a++){if(h.cells[a]==c){g=a;
}}}var m=this._findTime(c.parentNode.rowIndex,g);
if(m!=null){this._onCellMouseOutHandler(k);
var j=this.getTime();
if(j!=null){m.setDate(j.getDate());
m.setMonth(j.getMonth());
m.setYear(j.getYear());
}var n=new Telerik.Web.UI.TimeViewSelectingEventArgs(m,j);
var d=this.raise_clientTimeSelecting(n);
if(!d){this.setTime(m.getHours(),m.getMinutes(),m.getSeconds(),m);
m=this.getTime();
if((j-m)!=0){var b=new Telerik.Web.UI.TimeViewSelectedEventArgs(m,j);
this.raise_clientTimeSelected(b);
}}}}var f=(k.srcElement)?k.srcElement:k.target;
if(f.tagName&&f.tagName.toLowerCase()=="a"){var l=f.getAttribute("href",2);
if(l=="#"||(location.href+"#"==l)){if(k.preventDefault){k.preventDefault();
}return false;
}}},_findTableElement:function(a){var b=a.getElementsByTagName("table");
if(b.length>0){return b[0];
}return null;
},_findTime:function(b,a){var c=this._timeMatrix[b][a];
if(c!=null){return c;
}return null;
},_setTimeMatrix:function(){var k=0;
var a=new Array(this.get__ItemsCount());
var s=this.get_startTime();
if(this.get_dataSource()==null){while(s<this.get_endTime()){var b=s.getHours();
var x=s.getMinutes();
var h=s.getSeconds();
var w=s.getMilliseconds();
var g=new Date(s.getYear(),s.getMonth(),s.getDate(),s.getHours(),s.getMinutes(),s.getSeconds(),s.getMilliseconds());
a[k]=g;
k++;
s.setHours(b+this.get_interval().getHours());
s.setMinutes(x+this.get_interval().getMinutes());
s.setSeconds(h+this.get_interval().getSeconds());
s.setMilliseconds(w+this.get_interval().getMilliseconds());
}}var c=this._findTableElement(this.DivElement);
var d=c.rows.length;
var v=new Array(d);
for(k=0;
k<d;
k++){v[k]=new Array(this.get_columns());
var l;
for(l=0;
l<this.get_columns();
l++){v[k][l]=null;
}}var q=0;
var p=0;
if(this.get_showHeader()){q=1;
}var f=false;
if(this.get_dataSource()!=null){f=true;
}var r=(f)?this.get_dataSource():a;
if(this._renderDirection=="Horizontal"){for(k=0;
k<r.length;
k++){if(!v[q]){break;
}v[q][p]=(f)?new Date(parseInt(r[k].replace("/Date(","").replace(")/",""))):r[k];
p++;
if(p==this.get_columns()){p=0;
q++;
}}}else{var e=0;
var u=0;
var o=this.get_showHeader()?1:0;
for(var l=0;
l<this.get_columns();
l++){for(k=q;
k<d;
k++){if(c.rows[k].cells[l].innerHTML.length>0){v[k][l]=(f)?new Date(parseInt(r[e+k-o-u].replace("/Date(","").replace(")/",""))):r[e+k-o-u];
}else{u++;
}}e=e+k-o;
}}return v;
},_deserializerTime:function(b){if(typeof(b)=="string"){b=b.split(/-/);
}var a=new Date(1990,1,b[0],b[1],b[2],b[3],b[4]);
return a;
},get__ItemsCount:function(){return this._itemsCount;
},set__ItemsCount:function(a){if(this._itemsCount!==a){this._itemsCount=a;
}},get__TimeOverStyleCss:function(){return this._timeOverStyleCss;
},set__TimeOverStyleCss:function(a){if(this._timeOverStyleCss!==a){this._timeOverStyleCss=a;
}},get__OwnerDatePickerID:function(){return this._ownerDatePickerID;
},set__OwnerDatePickerID:function(a){if(this._ownerDatePickerID!==a){this._ownerDatePickerID=a;
}},add_clientTimeSelecting:function(a){this.get_events().addHandler("clientTimeSelecting",a);
},add_clientTimeSelected:function(a){this.get_events().addHandler("clientTimeSelected",a);
},remove_clientTimeSelecting:function(a){this.get_events().removeHandler("clientTimeSelecting",a);
},remove_clientTimeSelected:function(a){this.get_events().removeHandler("clientTimeSelected",a);
},raise_clientTimeSelecting:function(a){this.raiseEvent("clientTimeSelecting",a);
return a.get_cancel();
},raise_clientTimeSelected:function(a){this.raiseEvent("clientTimeSelected",a);
}};
Telerik.Web.UI.RadTimeView.registerClass("Telerik.Web.UI.RadTimeView",Telerik.Web.UI.RadWebControl);

if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();