function ProgressBar(obj){
	//开始时间
	ProgressBar.startTime=obj.startTime;
	//结束时间
	ProgressBar.endTime=obj.endTime;
	//录像总时间
	ProgressBar.totalSecond=obj.totalSecond;
	//录像当前播放时间
	ProgressBar.currentSecond=0;
}
ProgressBar.init=function(obj){
	ProgressBar(obj);
};
ProgressBar.secondToTime=function(second){
	var timeStamp=ProgressBar.startTime.getTime()+(second*1000);
	return new Date(timeStamp);
};
ProgressBar.TimeToSecond=function(time){
	var s = '';
	
	var hour = time.split(':')[0];
	var min = time.split(':')[1];
	var sec = time.split(':')[2];
	
	s = Number(hour*3600) + Number(min*60) + Number(sec);
	
	return s;
};
ProgressBar.percentToSecond=function(percent){
	var currentSecond=percent*ProgressBar.totalSecond;
	return currentSecond;
};
var begin=0;
ProgressBar.showTimeTip=function(event,str){
	if(str=='over'){
		var currentSecond,currentDate;
		currentSecond=ProgressBar.percentToSecond(event.offsetX/$("#videoControls").width());
		currentDate=ProgressBar.secondToTime(currentSecond);
      	var year = currentDate.getFullYear();
        var month = currentDate.getMonth() + 1;
        var date = currentDate.getDate();
        var hour = currentDate.getHours();//得到小时
  	    var minu = currentDate.getMinutes();//得到分钟
  	    var sec = currentDate.getSeconds();//得到
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (date >= 0 && date <= 9) {
            date = "0" + date;
        }
          if (hour < 10) hour = "0" + hour;
	  	  if (minu < 10) minu = "0" + minu;
	  	  if (sec < 10) sec = "0" + sec;
	  	  
         var currentdate  = year + "-" + month + "-" + date+ " " + hour + ":" + minu + ":" + sec;
		if((event.offsetX+$("#timeTip").width())<$("#videoControls").width()){
			$("#timeTip").css({left:event.offsetX+"px"}).html(currentdate).show();
		}else{
			$("#timeTip").css({left:(event.offsetX-$("#timeTip").width())+"px"}).html(currentdate).show();
		}
		
	}else{
		$("#timeTip").hide();
		$("#videoControls").hide();
	}
	event.stopPropagation();
};

ProgressBar.sendMsg=function(event){
	//closeRecordvideo();
	var percent = event.offsetX/$("#videoControls").width();
	var currentSecond=ProgressBar.percentToSecond(percent);
	var currentDate=ProgressBar.secondToTime(currentSecond)
	if((new Date().getTime()<currentDate.getTime())){
		$.showMsg("播放时间不能大于当前时间");
	}else{
		
  	var year = currentDate.getFullYear();
    var month = currentDate.getMonth() + 1;
    var date = currentDate.getDate();
    var hour = currentDate.getHours();//得到小时
    var minu = currentDate.getMinutes();//得到分钟
    var sec = currentDate.getSeconds();//得到
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (date >= 0 && date <= 9) {
        date = "0" + date;
    }
      if (hour < 10) hour = "0" + hour;
  	  if (minu < 10) minu = "0" + minu;
  	  if (sec < 10) sec = "0" + sec;
  	  
     var currentdate  = year + "-" + month + "-" + date+ " " + hour + ":" + minu + ":" + sec;
     
     ProgressBar.currentSecond=currentSecond;
     var searchDate = $('#searchDate').val();
     var start = "";
     var end = "";
     if(searchDate){
    	 start = searchDate + " " + hour + ":" + minu + ":" + sec;
         end = searchDate + " 23:59:59";
     }else{
    	 start = currentdate;
         end = year + "-" + month + "-" + date + " 23:59:59";
     }
    
     unloadWindow();
	webrtc_startRecord(videodata.videonum, videodata.channelnum, videodata.channelname, start, end);
	}
	event.stopPropagation();
};


ProgressBar.progress=function(obj){
	  var playProgress=$("#playProgress")[0];
	  var progressWrap=$("#progressWrap")[0];
	  var showProgress=$("#showProgress")[0];
	  currentTime=ProgressBar.currentSecond+obj.currentTime;
	/*  var currentTime=ProgressBar.currentSecond;
	  currentTime=currentTime.getTime()+(Number(obj.currentTime)*1000);*/
     var percent = currentTime/ ProgressBar.totalSecond;
    playProgress.style.width = percent * (progressWrap.offsetWidth)  + "px";
    showProgress.innerHTML = (percent * 100).toFixed(3) + "%";
}	;

ProgressBar.showVideoControls=function(event,str){
	if(str=='over'){
		$("#videoControls").show();
	}else{
		$("#videoControls").hide();
	}
	event.stopPropagation();
};