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());
if(this.get_showFooter()&&this.DivElement.innerHTML.indexOf('"rcFooter"')==-1){this.set_showFooter(false);
}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,g,f){var b=$find(this.get__OwnerDatePickerID());
var e;
if(Object.getType(b).getName()=="Telerik.Web.UI.RadDateTimePicker"&&!b.get_calendar()){e=f;
}else{e=b.get_selectedDate();
}if(!e){e=new Date();
}e.setHours(c);
e.setMinutes(a);
e.setSeconds(g);
if(b.get_autoPostBackControl()!=Telerik.Web.UI.Calendar.AutoPostBackControl.Both&&b.get_autoPostBackControl()!=Telerik.Web.UI.Calendar.AutoPostBackControl.TimeView){var d=function(h,i){i.set_cancel(true);
};
b._dateInput.add_valueChanged(d);
b.set_selectedDate(e);
b._dateInput.remove_valueChanged(d);
}else{b.set_selectedDate(e);
}},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._showFooter;
},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 b=this.get_element().getElementsByTagName("td");
for(var a=0;
a<b.length;
a++){if(b[a].className&&b[a].className.indexOf("rcHover")!=-1){b[a].className=b[a].className.replace("rcHover","");
}}},_selectTimeCell:function(a,b){var f=null;
var g=null;
for(var c=0;
c<this._timeMatrix.length;
c++){for(var d=0;
d<this._timeMatrix[c].length;
d++){if(!this._timeMatrix[c][d]){continue;
}if(this._timeMatrix[c][d].getHours()==a&&this._timeMatrix[c][d].getMinutes()==b){f=c;
g=d;
}}}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(a){if(this._tempStyle==null){return;
}var b=Telerik.Web.UI.Calendar.Utils.FindTarget(a,this.get_id());
if(b==null){return;
}if(b.className.indexOf("rcHeader")==-1&&b.className.indexOf("rcFooter")==-1){b.style.cssText=this._tempStyle[0];
b.className=this._tempStyle[1];
}},_onCellMouseOverHandler:function(a){var b=Telerik.Web.UI.Calendar.Utils.FindTarget(a,this.get_id());
if(b==null){return;
}if(b.className.indexOf("rcHeader")==-1&&b.className.indexOf("rcFooter")==-1){var c=new Array(2);
c[0]=b.style.cssText;
c[1]=b.className;
this._tempStyle=c;
b.style.cssText=this.get_itemStyles()["TimeOverStyle"][0];
b.className=this.get_itemStyles()["TimeOverStyle"][1];
}},_onCellClickHandler:function(g){var n=Telerik.Web.UI.Calendar.Utils.FindTarget(g,this.get_id());
if(n!=null){var a=n.cellIndex;
if(navigator.userAgent.match(/Safari/)){var f=n.parentNode;
var k;
for(k=0;
k<f.cells.length;
k++){if(f.cells[k]==n){a=k;
}}}var m=this._findTime(n.parentNode.rowIndex,a);
if(m!=null){this._onCellMouseOutHandler(g);
var d=this.getTime();
if(d!=null){m.setDate(d.getDate());
m.setMonth(d.getMonth());
m.setYear(d.getFullYear());
}var j=new Telerik.Web.UI.TimeViewSelectingEventArgs(m,d);
var l=this.raise_clientTimeSelecting(j);
if(!l){this.setTime(m.getHours(),m.getMinutes(),m.getSeconds(),m);
m=this.getTime();
if((d-m)!=0){var c=new Telerik.Web.UI.TimeViewSelectedEventArgs(m,d);
this.raise_clientTimeSelected(c);
}}}}var h=(g.srcElement)?g.srcElement:g.target;
if(h.tagName&&h.tagName.toLowerCase()=="a"){var b=h.getAttribute("href",2);
if(b=="#"||(location.href+"#"==b)){if(g.preventDefault){g.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 v=0;
var o=new Array(this.get__ItemsCount());
var b=new Date(this.get_startTime().getFullYear(),this.get_startTime().getMonth(),this.get_startTime().getDate(),this.get_startTime().getHours(),this.get_startTime().getMinutes(),this.get_startTime().getSeconds(),this.get_startTime().getMilliseconds());
if(this.get_dataSource()==null){while(b<this.get_endTime()){var c=b.getHours();
var p=b.getMinutes();
var e=b.getSeconds();
var a=b.getMilliseconds();
var r=new Date(b.getFullYear(),b.getMonth(),b.getDate(),b.getHours(),b.getMinutes(),b.getSeconds(),b.getMilliseconds());
o[v]=r;
v++;
b.setHours(c+this.get_interval().getHours());
b.setMinutes(p+this.get_interval().getMinutes());
b.setSeconds(e+this.get_interval().getSeconds());
b.setMilliseconds(a+this.get_interval().getMilliseconds());
}}var d=this._findTableElement(this.DivElement);
var y=d.rows.length;
var w=new Array(y);
for(v=0;
v<y;
v++){w[v]=new Array(this.get_columns());
var s;
for(s=0;
s<this.get_columns();
s++){w[v][s]=null;
}}var q=0;
var x=0;
if(this.get_showHeader()){q=1;
}var u=false;
if(this.get_dataSource()!=null){u=true;
}var h=(u)?this.get_dataSource():o;
if(this._renderDirection=="Horizontal"){for(v=0;
v<h.length;
v++){if(!w[q]){break;
}w[q][x]=(u)?new Date(parseInt(h[v].replace("/Date(","").replace(")/",""))):h[v];
x++;
if(x==this.get_columns()){x=0;
q++;
}}}else{var g=0;
var k=0;
var l=this.get_showHeader()?1:0;
var f=this.get_showFooter()?1:0;
for(var s=0;
s<this.get_columns();
s++){for(v=q;
v<y-f;
v++){if(d.rows[v].cells[s]&&d.rows[v].cells[s].innerHTML.length>0){w[v][s]=(u)?new Date(parseInt(h[g+v-l-k].replace("/Date(","").replace(")/",""))):h[g+v-l-k];
}else{k++;
}}g=g+v-l;
}}return w;
},_deserializerTime:function(a){if(typeof(a)=="string"){a=a.split(/-/);
}var b=new Date(1990,1,a[0],a[1],a[2],a[3],a[4]);
return b;
},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();
