var curPosPic = 0;
var DEFAULTSPEED = 500;
var listX = new Array();
var allowGoPic = true;
var timerAllowGoPic = null;
var totalPic = 0;
var _timerSlider = null;
var _typePlayer = null;
var zoomWI = 0;
var zoomHEI = 0;
var curPicId = 0;
var ID_SHOW = 0;

var _TIMER_MARQUEE = null;
var _maxMARQUEE;


function INIT_MARQUEE(_num){
	if($('.marquee').size()<1){ return false;}
	$('.marquee').eq(_num).stop();
	$('.marquee').eq(_num).css({left:$(window).width()+'px'});
	$('.marquee').eq(_num).animate({left:Math.round($('.marquee').eq(_num).width()*-1)+'px'},16000,'linear');
	
	if(_num<_maxMARQUEE){
	setTimeout(function(){INIT_MARQUEE(_num+1)},10000);
	}
	else
	{
	setTimeout(function(){INIT_MARQUEE(0)},10000);		
	}

	
}

var MAIN_UL_WI = 0;
var curLikes = 0;
var curUnlikes = 0;
var _delayCHECK = 8000;

var ID_SHOW = 0;

var viewTH = false;

var playing = true;
var DELAY_TIMER= 4000;
var _TIMERING = null;
var DELAY_LOADER_BG = 2500;
var DELAY_LOADER = 2500;
var remoteWi = 0;

var _allowSwichCam = true;
var timer_bg = null;

var _TIMER_MAIN_COUNT = null;


//future variables d'éléments
var NF_TIMER = null;
var NF_MAIN_UL = null;
var NF_MAIN_UL_CONTENT = null;
var _document = $(document);
var _WINDOW = $(window);
var _totWI = _WINDOW.width();
var _totHEI = _WINDOW.height();
var NF_TH_UL = $('#NF_TH_UL');
var NF_TH_UL_CONTENT = $('#NF_TH_UL_CONTENT');
var NF_MAIN_UL_CONTENT_JS = null;

var NF_PANNEL = null;
var NF_PANNEL_JS = null;
var NF_MAIN_UL_JS = null;
var NF_TH_UL_JS = null;
//


function associateElements(){
	
	
	NF_TIMER = $('#NF_TIMER');	
	NF_MAIN_UL = $('#NF_MAIN_UL');
	NF_MAIN_UL_JS = document.getElementById('NF_MAIN_UL');
	
	NF_MAIN_UL_CONTENT = $('#NF_MAIN_UL_CONTENT');
	NF_MAIN_UL_CONTENT_JS = document.getElementById('NF_MAIN_UL_CONTENT');
	
	NF_TH_UL = $('#NF_TH_UL');
	NF_TH_UL_JS =  document.getElementById('NF_TH_UL');
	
	NF_PANNEL =  $('#NF_PANNEL');
	NF_PANNEL_JS =  document.getElementById('NF_PANNEL');
	
	NF_TH_UL_CONTENT = $('#NF_TH_UL_CONTENT');
	
	
	
	_document = $(document);
	 _WINDOW = $(window);
	 _totWI = _WINDOW.width();
	 _totHEI = _WINDOW.height();
}




function PREVIOUS_PIC(){
	if(curPosPic>0){GO_PICTURE(curPosPic-1,DEFAULTSPEED);}
	STOP_TIMER();
}

function NEXT_PIC(){
	if(curPosPic<totalPic-1){GO_PICTURE(curPosPic+1,DEFAULTSPEED);}
	STOP_TIMER();
}

function PREVIOUS_PIC_ZOOM(){
	if(curPosPic>0){ZOOM_PICTURE(curPosPic-1,true);}
	STOP_TIMER();
}

function NEXT_PIC_ZOOM(){
	if(curPosPic<totalPic-1){ZOOM_PICTURE(curPosPic+1,true);}
	STOP_TIMER();
}


function UNBIND_KEYS(){
	_document.unbind('keyup');
}

function BIND_KEYS(){
_document.unbind('keyup');
_document.bind('keyup',function (e) {

if(e.which==106){ // +
AUTO_ZOOM();
}

if(e.which==107){ // +
LIKE_PHOTO(1)
}

if(e.which==109){ // -
LIKE_PHOTO(2)
}

if(e.which==37){
PREVIOUS_PIC();	
}
if(e.which==39){
NEXT_PIC()
}
});
}

function BIND_KEYS_ZOOM(){
_document.unbind('keyup');
_document.bind('keyup',function (e) {

if(e.which==106){ // +
CLOSE_ZOOM();
}
	
if(e.which==107){ // +
LIKE_PHOTO(1)
}

if(e.which==109){ // -
LIKE_PHOTO(2)
}	
	
if(e.which==37){
PREVIOUS_PIC_ZOOM();	
}
if(e.which==39){
NEXT_PIC_ZOOM()
}
if(e.which==27){
CLOSE_ZOOM();
}
});
}



function INIT_CAMS(id) {
		window.scroll(0,0);
		if($('#NF_LIST_CAM').get(0)){
		if(id){$('#camera_'+id).addClass('actifCam');}
	
		$('#NF_LIST_CAM').bind('mousedown',function(){return false;});
		
		$('.basic_cam').bind('mouseenter',function(){
			var _thisNumPic = parseInt($(this).find('.nb_pic_cam').html());	
			
			if(_thisNumPic<2){ var _thisHTML = _thisNumPic+' Photo';} else { var _thisHTML = _thisNumPic+' Photos';}

			openLegend(_thisHTML,$(this),'LEFT');

		});
		$('.basic_cam').bind('mouseleave',function(){
				closeLegend();									   
		});
		
		
		
		if($('#NF_LIST_CAM').height()+$('#NF_LIST_CAM').offset().top + 5  > $('#NF_BANDE').offset().top){
			var newTOP = $('#NF_BANDE').offset().top - $('#NF_LIST_CAM').height() - 5;
			$('#NF_LIST_CAM').css({top:newTOP+'px'});	
		}
		}
}


function START_TIMER(){
		clearTimeout(_TIMERING);
		NF_TIMER.stop();
		NF_TIMER.css({width:0,opacity:1});
		if(curPosPic>=totalPic-1){
			NF_TIMER.css({opacity:0});	
		}
		NF_TIMER.animate({width:'100%'},DELAY_TIMER,'linear');
		playing = true;
		$('#BT_PLAY_PAUSE').removeClass('paused');
		$('#BT_PLAY_PAUSE').html('Pause');
		_TIMERING = setTimeout(function(){					
		if(curPosPic<totalPic-1){
			GO_PICTURE(curPosPic+1,DEFAULTSPEED);	
			//closeLegend();
		}
		
		
			START_TIMER();	
		},DELAY_TIMER);
}


function STOP_TIMER(){
		clearTimeout(_TIMERING);
		NF_TIMER.stop();
		NF_TIMER.css({width:0});
		$('#BT_PLAY_PAUSE').addClass('paused');
		playing = false;
		$('#BT_PLAY_PAUSE').html('Play');
}


function PLAY_PAUSE(){
		if(playing == false){
		START_TIMER();			
		openLegend('Pause',$('#BT_PLAY_PAUSE'),'UP');
		
	}
	else
	{
		STOP_TIMER();	
		openLegend('Play',$('#BT_PLAY_PAUSE'),'UP');		
	}
}


function REMOVE_LOADER(_SPEED){
	$('#NF_LOADER').animate({height:0,opacity:0},function(){$(this).remove()});
}

function initPlayer(_type,id){
ID_SHOW = id;	
$('#NF_PLAYER_CACHE').unbind();	
$('#NF_PLAYER_CACHE').bind('mousedown',function(){return false;});	
$('#NF_PLAYER_CACHE').hide();
	$('.marquee').remove();
	remoteWi = 0;
	BIND_KEYS();	
	associateElements();
	window.scroll(0,0);
	clearTimeout(_TIMER_MAIN_COUNT);
	$('#NF_PANNEL').find('h5').remove();
	$('.WAITING').removeClass('WAITING');
	if(viewTH==true){
		$('#NF_PLAYER,#NF_LOADER').css({height:'625px'});	
		NF_TH_UL_CONTENT.css({height:'136px'});
		NF_TH_UL_CONTENT.addClass('OPEN');
		
		$('#BT_OPEN_CLOSE').addClass('OPEN');
		$('#BT_OPEN_CLOSE').html('Close Thumbnails');
		
		
	}
	
	$('#NF_PANNEL').bind('mousedown',function(){ return false;});
	
	$('#BT_OPEN_CLOSE,#BT_SHOW_ALL').unbind();
	
	$('#BT_OPEN_CLOSE').bind('click',function(){								  
		OPEN_CLOSE_TH();										  
	});
	
	$('#BT_SHOW_ALL').bind('click',function(){
		SHOW_ALL();										  
	});
	
	clearTimeout(timer_bg);
	timer_bg = setTimeout(function(){REMOVE_LOADER(300); initSlider(); },DELAY_LOADER_BG);
	
	if(playing == false){
	STOP_TIMER();
	}
	
	setTimeout(function(){
	if(playing == true){
		START_TIMER();	
	}
	
	DELAY_LOADER = 800;
	DELAY_LOADER_BG = 200;
	},DELAY_LOADER);
	
	
	if(!_typePlayer){
		_typePlayer = _type;
	}
	
	
	creaPicTable();
	
	GO_PICTURE(0,0);	
	_WINDOW.resize(function(){
		_totWI = _WINDOW.width();
	    _totHEI = _WINDOW.height();					
		GO_PICTURE(curPosPic,DEFAULTSPEED);	
		PLACE_ZOOM();
		CHECK_SHOW_ALL();
	});
	
	NF_TH_UL_CONTENT.bind('mousedown',function(){return false;});
	
	
	$('#NF_REMOTE').find('a').bind('mouseenter',function(){
		openLegend($(this).html(),$(this),'UP');	
	});
	
	$('#NF_REMOTE').find('a').bind('mouseleave',function(){
		closeLegend();	
	});
	
	
}

function OPEN_CLOSE_TH(){
	if(viewTH==false){
		$('#NF_PLAYER,#NF_TH_UL_CONTENT').stop();
		$('#NF_PLAYER').animate({height:'625px'},200);	
		NF_TH_UL_CONTENT.animate({height:'136px'},200);
		NF_TH_UL_CONTENT.addClass('OPEN');		
		$('#BT_OPEN_CLOSE').addClass('OPEN');
		$('#BT_OPEN_CLOSE').html('Close Thumbnails');
		viewTH = true;
		openLegend('Close Thumbnails',$('#BT_OPEN_CLOSE'),'UP');
	}
	
	else
	
	{
		$('#NF_PLAYER,#NF_TH_UL_CONTENT').stop();
		$('#NF_PLAYER').animate({height:'485px'},200);	
		NF_TH_UL_CONTENT.animate({height:'0px'},200);
		NF_TH_UL_CONTENT.removeClass('OPEN');		
		$('#BT_OPEN_CLOSE').removeClass('OPEN');
		$('#BT_OPEN_CLOSE').html('Open Thumbnails');
		viewTH = false;
		openLegend('Open Thumbnails',$('#BT_OPEN_CLOSE'),'UP');
	}
	
	
	
	
	
}









function initSlider(){	
		NF_MAIN_UL_CONTENT_JS.onmousedown = function(e){ startSlider(e); return false; }
		NF_PANNEL_JS.onmousedown = function(e){ startSlider(e);  return false;}	
}




function startSlider(e){
if(e){  initMouseX = checkPosX = curMouseX = e.pageX;}
		else
{	initMouseX = checkPosX = curMouseX = event.clientX;		}

	 initControlX = 0;
	 _moveTime = 0;

closeShoutBox();

function setTimeSlider(){_moveTime = _moveTime + 10; }
_timerSlider = setInterval(function(){setTimeSlider();},10);

_noCACHE = 0; 	_noBIND = 0;

NF_MAIN_UL.stop();	  initPOS = NF_MAIN_UL.offset().left;	clearTimeout(timerAllowGoPic); allowGoPic = true;
document.onmousemove = function(e){ slidingPlayer(e); return false; }

}


function slidingPlayer(e){
STOP_TIMER();


if(e){ 	curMouseX = e.pageX;}	else	{	curMouseX = event.clientX;	}

controlX = curMouseX - checkPosX; 	factorDir = -1;

if(controlX<0){controlX = controlX * (-1); factorDir = 1; }
if(controlX>10){allowGoPic = false; if(_noCACHE<1){ document.getElementById('NF_PLAYER_CACHE').style.display = 'block'; _noCACHE = 1;}	}



if(controlX < initControlX){_moveTime = 0;	checkPosX = curMouseX;	}
initControlX = controlX;


NF_MAIN_UL_JS.style.left = Math.round(curMouseX-initMouseX+initPOS)+'px';
document.onmouseup = function(){ stopSliding(); }


}



function stopSliding(){
	clearInterval(_timerSlider);	
	document.getElementById('NF_PLAYER_CACHE').style.display = 'none';
	document.onmousemove = function(){return false};

	if(allowGoPic == false){		
	clearTimeout(timerAllowGoPic);
	timerAllowGoPic = setTimeout(function(){allowGoPic = true;},5);	
	
	var _newPos = 0;
	var _diff = 5000000;	
	var checkX = _totWI * 0.5 - NF_MAIN_UL.offset().left;
	
	var addX = controlX*factorDir;
	
	
	_moveTime = Math.round(_moveTime*1.5);
	
	if(_moveTime<10){_moveTime = 10;}
	addX = Math.ceil(addX * (120 / _moveTime));
	if(addX>149999){addX = 149999;}
	if(addX<-149999){addX = -149999;}
	
	if(_moveTime>=400){ addX = addX * 0;}

	
	checkX = Math.round(checkX + addX);
	
	
	
	
	var _min = 0;	
	var _max = listX.length-1;	
	if(curPosPic<=_max*0.5){
		
	for(var i = _min; i<=_max;i++){
		var thisDiff = listX[i] - checkX; if( thisDiff < 0 ){thisDiff = thisDiff * (-1);}
		if(thisDiff < _diff){ _diff = thisDiff ; _newPos = i; } else {  break; }
	}
	
	
	}
	else
	{
	for(var i = _max; i>=_min;i--){
		var thisDiff = listX[i] - checkX; if( thisDiff < 0 ){thisDiff = thisDiff * (-1);}
		if(thisDiff < _diff){ _diff = thisDiff ; _newPos = i; } else {  break; }	
	}	
		
	}
	
		
		GO_PICTURE(_newPos,DEFAULTSPEED);
		
		
		
	}
	

}








function creaPicTable(){
	var i = 0;	
	MAIN_UL_WI = 0;
	listX = new Array();
	var TH_UL_WI = 0;
	associateElements();
	//$('#debug_1').html($('#debug_2').html());
	//$('#debug_2').html('');
	$('.pictureLi').each(function(){	
		var _self = $(this);
		_self.find('.NUM_PIC').html(i+1);	
		
		MAIN_UL_WI = MAIN_UL_WI+_self.width()+10;
		NF_MAIN_UL.css({width:MAIN_UL_WI+'px'}); 
		
		var main_offset = NF_MAIN_UL.offset().left;
		
		listX[i] = 	Math.round((_self.offset().left + _self.width()*0.5)-main_offset);	
		
		//$('#debug_2').html($('#debug_2').html()+' -&nbsp;'+i+':<strong>'+listX[i]+'</strong>');	
		
		
		i++;			
	});
	
	//$('#debug_2').html($('#debug_2').html()+' - TOTAL : '+listX.length);	
	
	$('.pictureLiTh').each(function(){					
		TH_UL_WI = TH_UL_WI+$(this).width()+10;
		NF_TH_UL.css({width:TH_UL_WI+'px'}); 		
	});
	
	initLinks();
	 
	 
	
	 
	 
}



function initLinks(){
		$('.pictureCACHE, .pictureCACHETH').stop();
		$('.pictureCACHE, .pictureCACHETH').css({opacity:0});
		
		$('.pictureLiTh').stop();
		$('.pictureLiTh').animate({opacity:0.5},150);
		
		$('.pictureLiTh').eq(curPosPic).stop();
		$('.pictureLiTh').eq(curPosPic).animate({opacity:1},150);
		
		var _links = $('.pictureCACHE');
		_links.unbind();
		totalPic = _links.size();
		
		
			_links.bind('click',function(){
			var _thisPos = 	$(this).parent('li').prevAll('.pictureLi').size();
			var _self = $(this);
			
			if(allowGoPic == true){ 	
			if(_thisPos == curPosPic){ ZOOM_PICTURE(_thisPos,true); stopSliding();} 
			
			else
			{
			STOP_TIMER();
			GO_PICTURE(_thisPos,DEFAULTSPEED);
			
			}
 			}
	
		});
		
		
		_links.bind('mouseover',function(){
			var _self = $(this);	
			var _expActif = new RegExp("pictureCACHEACTIF","gi"); 
			if(_expActif.test(_self.attr('class'))==true){
				_self.stop();
				_self.animate({opacity:0.8},300);
			} 
			
			
		
		});
		
		
		_links.bind('mouseleave',function(){
				$(this).stop();
				$(this).animate({opacity:0},300);
		});
		
		
		
		
		
		
			var _links2 = $('.pictureCACHETH');
		_links2.unbind();
		
		
		
			_links2.bind('click',function(){
			var _thisPos = 	$(this).parent('li').prevAll('.pictureLiTh').size();
			var _self = $(this);
			
			if(allowGoPic == true){ 	
			if(_thisPos == curPosPic){ ZOOM_PICTURE(_thisPos,true); stopSliding();} 
			
			else
			{
			
			GO_PICTURE(_thisPos,DEFAULTSPEED);
			STOP_TIMER();
			}
 			}
	
		});
		
		
		_links2.bind('mouseover',function(){
			var _self = $(this);	
			var _expActif = new RegExp("pictureCACHEACTIF","gi"); 
			if(_expActif.test(_self.attr('class'))==true){
				_self.stop();
				_self.animate({opacity:0.8},300);
			} 
			else
			{
				_self.parent('li').stop();	
				_self.parent('li').animate({opacity:1},200);
			}
			
		
		});
		
		
		_links2.bind('mouseleave',function(){
				var _self = $(this);						   
				_self.stop();
				_self.animate({opacity:0},300);
				var _expActif = new RegExp("pictureCACHEACTIF","gi"); 
			if(_expActif.test(_self.attr('class'))==false){
				_self.parent('li').stop();	
				_self.parent('li').animate({opacity:0.5},200);
			}
		});
		
		
		
}


function GO_PICTURE(_NUM,_SPEED){
	_document.unbind('mousemove'); 
	var _totalWi = _totWI;
	
	if(_typePlayer == 'LB'){	
		var shows_infos  = $('.PIC_SHOW_INFOS').eq(_NUM).html();
		$('#NF_SHOW_INFOS').html(shows_infos);
	}
	
	
	
	curPicId = parseInt($('.PIC_ID').eq(_NUM).html());
	
	curLikes = parseInt($('.NB_LIKES').eq(_NUM).html());
	curUnlikes = parseInt($('.NB_UNLIKES').eq(_NUM).html());
	
	$('.NBLIKES').html(curLikes);
	$('.NBUNLIKES').html(curUnlikes);
	
	$('#BT_FB').attr('href','http://www.nowfashion.com/share-picture.php?id='+encodeURIComponent(curPicId));
	
	
	var _newElement = $('.pictureLi').eq(_NUM);
	var _newElement2 = $('.pictureLiTh').eq(_NUM);
	var _newElementWi = _newElement.width();
	
	
	if(remoteWi!=_newElementWi){
	remoteWi=_newElementWi;	
	$('#NF_REMOTE').stop();
	$('#NF_REMOTE').animate({width:remoteWi+'px',marginLeft:Math.round(remoteWi*-0.5)+'px'},_SPEED);
	}
	
	
	
	
	
	if(_NUM!=curPosPic){$('.pictureCACHEACTIF').removeClass('pictureCACHEACTIF');}

	
	_newElement.find('.pictureCACHE').addClass('pictureCACHEACTIF');
	_newElement2.find('.pictureCACHETH').addClass('pictureCACHEACTIF');
	
	$('.pictureLiTh').eq(curPosPic).stop();
	$('.pictureLiTh').eq(curPosPic).animate({opacity:0.5},150);
	_newElement2.stop();
	_newElement2.animate({opacity:1},150);
	
	
	var _newLeft = Math.round(  _totalWi*0.5 - (_newElement.offset().left - NF_MAIN_UL.offset().left)  - _newElement.width() * 0.5 );
	
	var _newLeft2 = Math.round(  _totalWi*0.5 - (_newElement2.offset().left - NF_TH_UL.offset().left)  - _newElement2.width() * 0.5 );
	
	
	NF_MAIN_UL.stop();
	if(_SPEED>5){
	NF_MAIN_UL.animate({left:_newLeft+'px'},_SPEED,'easeOutCirc');	
	}
	else
	{
		NF_MAIN_UL.css({left:_newLeft+'px'});	
	}
	
	NF_TH_UL.stop();
	if(_SPEED>5){
	if(viewTH == true){	
	NF_TH_UL.animate({left:_newLeft2+'px'},_SPEED,'easeOutCirc');	
	}
	else
	{
	NF_TH_UL.css({left:_newLeft2+'px'});	
	}
	
	}
	else
	{
		NF_TH_UL.css({left:_newLeft2+'px'});	
	}
	
	
	curPosPic = _NUM;
	//$('#debug_3').html('newLeft : '+_newLeft);
	
}


function AUTO_ZOOM(){
		ZOOM_PICTURE(curPosPic,true);
}







function ZOOM_PICTURE(_NUM,_SWICH){
	if($('.ZOOM_SRC').eq(_NUM).get(0)){
	UNBIND_KEYS();
	CLOSE_ZOOM();	
	var _ID_MBR_CX = parseInt($('#ID_MBR_CX').html());
	STOP_TIMER();
	_document.unbind('mousemove'); 
	clearTimeout(timerAllowGoPic);
	timerAllowGoPic = setTimeout(function(){allowGoPic = true;},5);
	
	if(_ID_MBR_CX>0){
	closeFrame();
	var _src = $('.ZOOM_SRC').eq(_NUM).html();
	var fb_link = $('#BT_FB').attr('href');


if(_typePlayer == 'LB'){
$('body').prepend('<div id="OVER_ALL_BG_PLAYER" class="NF_ZOOMER LOADING" onclick="CLOSE_ZOOM();"></div><div id="ZOOM_BANDE_BG" class="NF_ZOOMER"></div><div id="ZOOM_BANDE" class="NF_ZOOMER"><ul><li style="float:right;"><a href="javascript:void(0);" class="closezoom" onclick="CLOSE_ZOOM();">Close Zoom</a></li></ul></div><div id="CONTENT_ZOOM" class="NF_ZOOMER"><div class="NUM_PIC">'+(_NUM+1)+'</div><a href="javascript:void(0);" id="ZOOM_LEFT">PREV</a><a href="javascript:void(0);" id="ZOOM_RIGHT">NEXT</a><img src="'+_src+'" id="IMG_ZOOM" onload="SHOW_ZOOM();"></div>');		
}
else
{
	$('body').prepend('<div id="OVER_ALL_BG_PLAYER" class="NF_ZOOMER LOADING" onclick="CLOSE_ZOOM();"></div><div id="ZOOM_BANDE_BG" class="NF_ZOOMER"></div><div id="ZOOM_BANDE" class="NF_ZOOMER"><ul><li><a href="javascript:void(0);" class="liker" onclick="LIKE_PHOTO(1)">I Like (<span class="NBLIKES"></span>)</a></li><li><a href="javascript:void(0);" class="unliker" onclick="LIKE_PHOTO(2)">I Don\'t Like (<span class="NBUNLIKES"></span>)</a></li><li><a href="javascript:void(0);" class="lookbook" onclick="ADD_LOOKBOOK()">Add To My Lookbooks</a></li><li><a href="'+fb_link+'" onclick="FB_SHARING(this.href); return false;" class="facebook">Share On Facebook</a></li><li style="float:right;"><a href="javascript:void(0);" class="closezoom" onclick="CLOSE_ZOOM();">Close Zoom</a></li></ul></div><div id="CONTENT_ZOOM" class="NF_ZOOMER"><div class="NUM_PIC">'+(_NUM+1)+'</div><a href="javascript:void(0);" id="ZOOM_LEFT">PREV</a><a href="javascript:void(0);" id="ZOOM_RIGHT">NEXT</a><img src="'+_src+'" id="IMG_ZOOM" onload="SHOW_ZOOM();"></div>');	
}
	
	
	
	
	
	$('#OVER_ALL_BG_PLAYER').css({opacity:0.9});
	$('#ZOOM_LEFT,#ZOOM_RIGHT').css({opacity:0.6});
	$('#ZOOM_BANDE').css({opacity:0});
	
	$('#ZOOM_BANDE').find('a').bind('mouseenter',function(){
	openLegend($(this).html(),$(this),'UP');
	});
	
	$('#ZOOM_BANDE').find('a').bind('mouseleave',function(){
	closeLegend();
	});
	
	$('#CONTENT_ZOOM').unbind();
	$('#CONTENT_ZOOM').bind('mousedown',function(){return false;});
	
	if(_NUM<1){$('#ZOOM_LEFT').remove();}
	if(_NUM>=totalPic-1){$('#ZOOM_RIGHT').remove();}
	
	$('#ZOOM_LEFT').bind('click',function(){ PREVIOUS_PIC_ZOOM(); });
	$('#ZOOM_RIGHT').bind('click',function(){ NEXT_PIC_ZOOM(); });
	
	if(_SWICH==true){GO_PICTURE(_NUM,1);}
	
	
	
	$('#CONTENT_ZOOM').css({opacity:0});
	
	
	
	}
	
	
	else
	
	{
	
		openFrame('IFRAME-SIGN-IN.php?prov=ZOOM&POS_ZOOM='+encodeURIComponent(_NUM),520);	
		
	}
	
	}
}




function SHOW_ZOOM(){
	$('#OVER_ALL_BG_PLAYER').removeClass('LOADING')
	
	BIND_KEYS_ZOOM();
	
	zoomHEI = $('#IMG_ZOOM').height();
	zoomWI = $('#IMG_ZOOM').width();
	
	
	var maxWI = _totWI;
	var maxHEI = _totHEI-50;
	
	var newWI = zoomWI;
	var newHEI = zoomHEI;
	
	if(newHEI>maxHEI){
		newHEI = maxHEI;
		newWI = Math.round(zoomWI*newHEI/zoomHEI);
	}
	
	if(newWI>maxWI){
		newWI = maxWI;
		newHEI = Math.round(zoomHEI*newWI/zoomWI);
	}
	
	
	var newTOP = Math.round(maxHEI*0.5 - newHEI*0.5);
	var newLEFT = Math.round(maxWI*0.5 - newWI*0.5);
	
	$('#IMG_ZOOM').css({width:newWI+'px',height:newHEI+'px',top:newTOP+'px',left:newLEFT+'px'});
	$('#CONTENT_ZOOM').css({width:newWI+'px',height:newHEI+'px',top:newTOP+'px',left:newLEFT+'px'});
	$('#ZOOM_BANDE').css({width:(newWI-2)+'px',marginLeft:Math.round(((newWI*0.5))*-1)+'px'});
	
	$('#CONTENT_ZOOM').animate({opacity:1},200);
	$('#ZOOM_BANDE').delay(250).animate({bottom:0,opacity:1},300);
	
	
	
	if(newWI<1){
		CLOSE_ZOOM();	
	}
	
}

function PLACE_ZOOM(){
	if($('#CONTENT_ZOOM').get(0)){
		
	var maxWI = _totWI;
	var maxHEI = _totHEI-50;
	
	var newWI = zoomWI;
	var newHEI = zoomHEI;
	
	if(newHEI>maxHEI){
		newHEI = maxHEI;
		newWI = Math.round(zoomWI*newHEI/zoomHEI);
	}
	
	if(newWI>maxWI){
		newWI = maxWI;
		newHEI = Math.round(zoomHEI*newWI/zoomWI);
	}
	
	
	var newTOP = Math.round(maxHEI*0.5 - newHEI*0.5);
	var newLEFT = Math.round(maxWI*0.5 - newWI*0.5);
	
	$('#IMG_ZOOM').css({width:newWI+'px',height:newHEI+'px',top:newTOP+'px',left:newLEFT+'px'});
	$('#CONTENT_ZOOM').css({width:newWI+'px',height:newHEI+'px',top:newTOP+'px',left:newLEFT+'px'});
	$('#ZOOM_BANDE').css({width:(newWI-2)+'px',marginLeft:Math.round(((newWI*0.5))*-1)+'px'});						  
	
	if(newWI<1){
		CLOSE_ZOOM();	
	}
	
	}
}


function CLOSE_ZOOM(){
		BIND_KEYS();
		$('.NF_ZOOMER').remove();
		closeLegend();
}



function LIKE_PHOTO(_type){
	if(!_type){return false;}
	STOP_TIMER();
	if(Get_Cookie('LIKER_'+_typePlayer+'_'+curPicId)){
		openNotify('Your Have Already Voted For This Photo...');
		closeNotify();
		return false;	
	}
	
	_type = parseInt(_type);
	if(_type!=1){_type=2;}
	
	openNotify('Your Vote Is Submitting...',true);	
	$('#NF_ACTIONS').load('NF_LIKER.php?id='+encodeURIComponent(curPicId)+'&type='+encodeURIComponent(_type)+'&typePlayer='+encodeURIComponent(_typePlayer),function(){
		
		_timerNotify = setTimeout(function(){
		openNotify('Thanks For Your Vote!',false,1);	
		closeNotify();
		
		},300);
		
	});
}



function ADD_LOOKBOOK(){
	var _ID_MBR_CX = parseInt($('#ID_MBR_CX').html());
	STOP_TIMER();
	if(_ID_MBR_CX>0){
		openFrame('IFRAME-ADD-LOOKBOOK.php?id='+encodeURIComponent(curPicId),980);	
	}
	else
	{
		openFrame('IFRAME-SIGN-IN.php?prov=LB&POS_LB='+encodeURIComponent(curPosPic),520);	
	}
}


function SHOW_ALL(){
	STOP_TIMER();
	if(totalPic<1){ return false;}
	UNBIND_KEYS();
	$('body').prepend('<a href="javascript:void(0);" id="SHOW_ALL_CLOSER" onclick="CLOSE_SHOW_ALL()">Close</a><div id="SHOW_ALL_BG"></div><ul id="SHOW_ALL_UL"></ul>')	;
	$('#SHOW_ALL_BG').css({opacity:0.9});
	
	var _contentUL = NF_TH_UL.html();
	$('#SHOW_ALL_UL').html(_contentUL);
	$('#SHOW_ALL_BG,#SHOW_ALL_UL').bind('mousedown',function(){ return false;});
	$('#SHOW_ALL_UL').find('li').css({opacity:1});
	
	if($('#SHOW_ALL_UL').height()>_totHEI){
		$('#SHOW_ALL_UL').css({position:'absolute'});
	}
	
	$('#SHOW_ALL_UL').find('.pictureCACHETH').bind('click',function(){
		var _thisPos =  $(this).parent('li').prevAll('.pictureLiTh').size();
		window.scroll(0,0);
		GO_PICTURE(_thisPos,DEFAULTSPEED);	
		CLOSE_SHOW_ALL();		
	});
	
}

function CLOSE_SHOW_ALL(){
	$('#SHOW_ALL_BG,#SHOW_ALL_UL,#SHOW_ALL_CLOSER').remove();
	BIND_KEYS();
}


function CHECK_SHOW_ALL(){
	if($('#SHOW_ALL_UL').height()>_totHEI){
		$('#SHOW_ALL_UL').css({position:'absolute'});
	}
	else
	{
		$('#SHOW_ALL_UL').css({position:'fixed'});	
	}
}


function ADD_LOADER(){
$('#NF_LOADER').remove();
$('#NF_PLAYER').before('<div id="NF_LOADER" style="height:'+Math.round($('#NF_PLAYER').height())+'px"></div>');
}

function LOAD_CAM(id){
	if(_allowSwichCam==false){ return false;}
	_self = $('#camera_'+id);
	var _elem = _self.find('.NF_PUSH');
	if(parseInt(_self.find('.nb_pic_cam').html())<1){
	openNotify('There Is No Picture In This Camera.');	
	closeNotify();
	return false;	
	}
	
	var _expActif = new RegExp("actifCam","gi"); 
	if(_expActif.test(_self.attr('class'))==true){
	if(_elem.get(0)){	
	GO_PICTURE(($('.pictureLi').size()-1),DEFAULTSPEED);
	_elem.animate({marginTop:'-80px',opacity:0},400,'easeOutCirc',function(){_elem.remove()});
	 };
	 return false;
	} 
	
	
	
	_allowSwichCam=false;
	clearTimeout(timer_bg);
	ADD_LOADER();
	
	$('.actifCam').removeClass('actifCam');
	_self.addClass('actifCam');
	
	_elem.animate({marginTop:'-80px',opacity:0},400,'easeOutCirc',function(){_elem.remove()});
	
	$('.WAITING').removeClass('WAITING');
	$('#NF_PANNEL').find('h5').remove();
	
	
	closeLegend();
	$('#NF_PLAYER').load('player.php?ID_CAM_JS='+encodeURIComponent(id),function(){	
		_allowSwichCam=true;
		
		if(_elem.get(0)){	GO_PICTURE(($('.pictureLi').size()-1),DEFAULTSPEED);
		}
		
		
		
	});
	
	
}


function checkCam(id,_typePlayer){
	$('#NF_PLAYER_ACTIONS').load('check_show_cam.php?id='+encodeURIComponent(id)+'&uid='+uniqid());
	setTimeout(function(){checkCam(id,_typePlayer)},_delayCHECK);
}

var NUMPICFAKE = 1;

function checkPushCam(id,nbPICS,_BG){
		var _elem = $('#camera_'+id);
		var _curNBPIC = parseInt(_elem.find('.nb_pic_cam').html());
		var _oldNUM = 0;
		if(_curNBPIC!=nbPICS){
		if(_elem.find('.NF_PUSH').get(0)){	
		_oldNUM = parseInt(_elem.find('.NF_PUSH').find('span').html());
		_elem.find('.NF_PUSH').remove();
		 }
		 
		
		 _elem.find('.background').remove();
		 _elem.prepend('<span class="background" style="background-image:url('+_BG+')"></span>');
		 
		 
		 var _diff = nbPICS + _oldNUM - _curNBPIC;
		 
		 if(_diff<1){
			 return false;
		 }
		 
		_elem.prepend('<div class="NF_PUSH" style="margin-right:-30px; margin-top:15px;">+<span>'+_diff+'</span></div>');
		_elem.find('.nb_pic_cam').html(nbPICS)
		NUMPICFAKE++;
		var _newPUSH = _elem.find('.NF_PUSH');
		_newPUSH.css({opacity:0});
		_newPUSH.animate({opacity:1,marginRight:0,marginTop:0},500,'easeOutCirc');
		
		
		
		
		var _expActif = new RegExp("actifCam","gi"); 
		if(_expActif.test(_elem.attr('class'))==true){
			 REFRESH_CAM(id);		
					
		}
		
		
		
		}
	
	
	
	
}



function loadAllCam(id_show_js){
	if(_allowSwichCam==false){ return false;}
	_self = $('#camera_all');
	
	
	var _expActif = new RegExp("actifCam","gi"); 
	if(_expActif.test(_self.attr('class'))==true){
		return false;
	};
	
	

	_allowSwichCam=false;
	clearTimeout(timer_bg);
	ADD_LOADER();
	
	$('.actifCam').removeClass('actifCam');
	_self.addClass('actifCam');
	
	closeLegend();
	$('#NF_PLAYER').load('player.php?ID_SHOW_JS='+encodeURIComponent(id_show_js),function(){	
																						  
		_allowSwichCam=true;

		
	});
}


function REFRESH_CAM(id){
		$('#NF_PLAYER_ACTIONS').load('player-update-cam.php?ID_CAM_JS='+encodeURIComponent(id)+'&uid='+uniqid(),function(){
			$('#NF_MAIN_UL').append($('#NF_MAIN_UL_CLONE').html());	
			$('#NF_TH_UL').append($('#NF_TH_UL_CLONE').html());	
			$('#NF_MAIN_UL_CLONE,#NF_TH_UL_CLONE').remove();
			var _elem = $('#camera_'+id).find('.NF_PUSH');
			setTimeout(function(){ 
			_elem.animate({marginTop:'-80px',opacity:0},400,'easeOutCirc',function(){_elem.remove()});								

			},2000);
			listX = new Array();
			creaPicTable();
			//initLinks();
		});
}


function initPlayerVoid(_type,firstCam,id){
	ID_SHOW = id;
	$('#NF_PLAYER_CACHE').hide();	
	if(!_typePlayer){
		_typePlayer = _type;
	}
	REMOVE_LOADER(0);
	associateElements();
	$('#NF_REMOTE,.NF_BIG_BTN').remove();
	$('#NF_PANNEL,#NF_MAIN_UL_CONTENT').addClass('WAITING');
	MAIN_COUNT(firstCam);
	$('.actifCam').removeClass('actifCam');
	
}




function MAIN_COUNT(_CAM_ID){

var _CAM = $('#camera_'+_CAM_ID).find('.nb_pic_cam');

var _time = parseInt($('#NF_REST_TIME').html());

$('#NF_PANNEL').find('h3').after('<h5>Live<br />Fashion<br />Show<br />In<br />53 days<br />18 min</h5>');	

var _elem = $('#NF_PANNEL').find('h5');

var _firstCam = $('#NF_PANNEL').find('h5');

	clearTimeout(_TIMER_MAIN_COUNT);

MAIN_REBOURS();

var main_ms = 9;
var _main_time = 0;


var _late_message = 0;

function MAIN_REBOURS(){

var check_time = _time;

if(parseInt(_CAM.html())>0){ 

$('.WAITING').removeClass('WAITING');
$('#NF_PANNEL').find('h5').remove();
LOAD_CAM(_CAM_ID);
STOP_REBOURS(ID_SHOW);
$('#NF_ACTIONS').load('BEGIN-SHOW.php?id='+encodeURIComponent(ID_SHOW));


return false; }

_TIMER_MAIN_COUNT = setTimeout(function(){MAIN_REBOURS();},100);

	

	

	if(_typePlayer=='EVEN'){
	var aff_count = 'Live<br />Event<br />in<br />';
	}
	else
	{
	var aff_count = 'Live<br />Fashion<br />Show<br />in<br />';	
	}

	var _suffixeCount = '';
	
	
	
	
	if(_time>0){main_ms--;} else { main_ms++; }
	if(main_ms<0){
		_time--;	
		main_ms = 9;
	}
	
	if(main_ms>9){
		_time--;	
		main_ms = 0;
	}	
	
	
if(check_time<0){
		check_time = check_time*-1;
		aff_count = 'Live<br />Fashion<br />Show<br />is<br />';
		_suffixeCount = '<br />Late';
		
	if(_late_message<1){
		_late_message = 1;
		
		for(var i=0 ; i<=4; i++){
		$('#NF_BANDE').prepend('<div class="marquee">Fashion Shows Hardly Start At The Official Scheduled Time. Please Be Patient... You Will Be Notified When The Show Starts!</div>');
		_maxMARQUEE = i;
		}
		
		INIT_MARQUEE(0);
		
	}
	
	}	
	
	
	var _day = Math.floor(check_time/24/3600); 
	
	if(_day>0){
	if(_day<2){ aff_count = aff_count + _day+' day <br />'; }else { aff_count = aff_count + _day+' days <br />'; }
	}
	
	var _heure = Math.floor((check_time - (_day*24*3600))/3600);
	
	if(_heure>0){aff_count = aff_count+_heure+'h ';}
	if(_heure<1 && _day>0){aff_count = aff_count+'<br />';}
	var _min = Math.floor((check_time - (_day*24*3600) - (_heure*3600) )/60);
	var _sec = Math.floor((check_time - (_day*24*3600) - (_heure*3600) - (_min*60) ));
	
	if(_min<10){_min='0'+_min;}
	if(_sec<10){_sec='0'+_sec;}
	
	aff_count = aff_count+_min+'\' '+_sec+'" '+main_ms+''+_suffixeCount;
	_elem.html(aff_count);
	

	
	
}

		
		
}


var openStreaming = false;

function openLiveStream(id){
	
	if(openStreaming == true){closeLiveStream(); return false;}
	STOP_TIMER();
	openStreaming = true;
	$('#nf_live_stream').addClass('actif');
	$('body').prepend('<div id="NF_BG_STREAM" class="LOADING"><a href="javascript:void(0);" onclick="closeLiveStream();">Close</a></div><iframe src="STREAMER.php?id='+encodeURIComponent(id)+'" frameborder="0" scrolling="no" height="1" width="1" id="NF_FRAME_STREAMING" name="NF_FRAME_STREAMING" allowtransparency="true"></iframe>');	
	$('#NF_BG_STREAM').css({opacity:0.9});
	$('#NF_FRAME_STREAMING').css({opacity:0});
}

function loadLiveStream(_WI,_HEI){
	$('#NF_BG_STREAM').removeClass('LOADING');
	$('#NF_FRAME_STREAMING').css({width:_WI+'px',marginLeft:Math.round(_WI*(-0.5))+'px',height:_HEI+'px',opacity:1});
	$('#NF_BG_STREAM').css({height:_HEI+'px'});
}

function closeLiveStream(){
	openStreaming = false;
	$('#NF_BG_STREAM').remove();
	$('#NF_FRAME_STREAMING').remove();	
	$('#nf_live_stream').removeClass('actif');
}
