var Player = function(div){
	var _this = this;
	
	this.START_CAMERA_URL_BASE = "/kapi/startCamera/%s/?key_type=%s";
	
	this.div = div;
	this.el = {
		streamInfo : this.div.find(".streamInfo"),
		address : this.div.find(".address"),
		name : this.div.find(".name"),
		description : this.div.find(".description"),
		activeViewers: this.div.find(".activeViewers"),
		pushButton : this.div.find(".push-button"),
		videoDiv : this.div.find(".player"),
		thumbDiv : this.div.find(".thumbDiv"),
		overlay : this.div.find(".overlay"),
		clearOverlay : this.div.find(".clear-overlay"),
		serialNo : this.div.find(".serialNo")
	};

	this.camera = null;
	this.streamKey = null;
	this.el.address.click(this.goToPlayingAddress);
	this.cameraCallback = null;


	this.show = function (){
		if(!checkFlashVer()){
			return false;
		}
	};


	this.openCallback = function(response){};

	this.showStream = function(cameraToStream, callback){};

	this.showNoCamera = function(){};

	this.openLoader = function(){};


	this.streamInfoUpdate = function(widthLimits){
		var text,
			limits = {"name":null, "activeViewers" : null, "description":null, "address": null};

		if (widthLimits){
			$.extend(limits, widthLimits);
		}

		text = this.camera.shortName ? this.camera.shortName : this.camera.serialNo;
		if (limits.name){
			this.el.name.html(fitStringToWidth(text, limits.name))
		}
		else {
			this.el.name.text(text);
		}


		this.el.activeViewers.text(this.camera.activeViewers+1).show();

		this.el.description.text(this.camera.description);

		if (limits.address){
			this.el.address.html(fitStringToWidth(this.camera.address, 350));
		}
		else  {
			this.el.address.text(this.camera.address);
		}

		this.el.serialNo.text(this.camera.serialNo);
	};

	this.clearStreamInfo = function(){
		this.el.name.text("");
		this.el.description.text("");
		this.el.address.text("");
		this.el.activeViewers.hide();
	};
	this.goToPlayingAddress = function(map){
		this.camera.goToUpperCorner(map);
	};


};
