/**
* PFZCHAT CAMS
*
*/

this.watching = {};
this.cam_AppUrl = "/club/cam/pfzchat.swf";
this.cam_RoomUrl = "./index.html?room=";

this.cam_chatvideo = 0;
this.cam_loadCams = function(params) {
	/*
	id:'chatvideocam',
	width:'".$flawidth."',
	height:'".$flaheight."',
	container:'divcamcontainer',
	params:myParam_cam,
	vars:myFlashvars_cam}
	*/
	var attributes = {id:params.id, name:params.id};
	//var obj = swfobject.embedSWF(cam_AppUrl, params.id, params.width, params.height, '9.0.28', 'expressInstall.swf', params.vars, params.params);
	var obj = new Swiff(cam_AppUrl,params);
	//alert(Swiff.remote(obj, 'version'));
	return true;
}
/** Affiche les controls cam si dispo **/
this.cam_showControls = function(state) {
	cam_SwfObj('chatvideo').showControls(state);
}
/** Déclenché quand un user regarde notre flux **/
this.cam_onWatcher = function(hash,watching) {
	var thishash = hash.split('|'); watching[thishash[2]] = watching;
}
/** Déclenché quand on regarde un user **/
this.cam_onWatching = function(hash,watching) {
	var thishash = hash.split('|');
}
this.cam_onChatOpenRequest = function(room) {
	if (cam_RoomUrl=='') return false;
	if (room==0) return false;
	openNewWin(cam_RoomUrl+room, 'room'+room)
}
this.cam_onProfilRequest = function(hash) {
	var thishash = hash.split('|');
	profil('',thishash[2]);
}
this.cam_onNewMessage = function(messObj) {
	setTitle('Nouveau message de '+messObj.uida_name);
}
this.cam_onChatReady = function(version) {
	//var obj = Swiff.remote(chatvideo_forum.toElement(),'version',null);alert(obj);
}
this.cam_onTabUpdate = function(tab) {
	tab.idx;tab.label;tab.restricted;tab.nb_users;
}
this.cam_onStreamPublish = function(txt) {
}
this.cam_onPassThrough = function(url) {
	document.location.href=url;
}
this.lastupdate_notif = false;
this.cam_onUpdate = function(version) {
	return false;
	var currentVersion = Swiff.remote(chatvideo_forum.toElement(),'version',null);
	if (currentVersion!=version) {
		if (!this.lastupdate_notif) {
			this.lastupdate_notif = true;
			if (confirm('Une nouvelle version de chat est en ligne.\nTu dois le relancer au plus vite afin d\'éviter tout dysfonctionnement.\n\nRelancer maintenant?\n\nVersion:'+version)) {
				document.location.reload();
			} else {
				this.lastupdate_notif = false;
				setTimeout(function(){this.cam_onUpdate(version)},30000);
			}
		}
	}
}
this.cam_onExit = function(motif) {
	//if (motif!='fin')  document.location.href='".$_SERVER["PHP_SELF"]."?".$arg."&erreur=1&content='+motif;else window.close();
}

this.setTitleTimer = false;
this.setTitle = function(thistitle) {
	clearInterval(setTitleTimer);
	if (!thistitle || thistitle=='') document.title='Club LiveCam';
	else {
		document.title = thistitle;
		setTitleTimer = setTimeout('setTitle()',3000);
		//window.focus();
	}
}
this.showUserVideo = function(md, uid) {
	alert(cam_SwfObj('chatvideo').viewUser(md, uid));
}
this.cam_SwfObj = function(movieName) {
	if (navigator.appName.indexOf('Microsoft') != -1) { return window[movieName]; }
	else { return document[movieName]; }
}

this.cam_test = function() {
	alert(cam_SwfObj('chatvideo').version());
}

