// JavaScript Document

var allowCloseFrame=true;
var _timerNotify=null;

function trim (myString)
{
if(myString){
return myString.replace(/^\s+/g,'').replace(/\s+$/g,'');
}
else
{
	return '';	
}
} 

function strlen (string) {


    var str=string+'';
    var i=0, chr='', lgth=0;

    if (!this.php_js || !this.php_js.ini || !this.php_js.ini['unicode.semantics'] ||
            this.php_js.ini['unicode.semantics'].local_value.toLowerCase() !== 'on') {
        return string.length;
    }

    var getWholeChar=function (str, i) {
        var code=str.charCodeAt(i);
        var next='', prev='';
        if (0xD800 <= code && code <= 0xDBFF) { // High surrogate (could change last hex to 0xDB7F to treat high private surrogates as single characters)
            if (str.length <= (i+1))  {
                throw 'High surrogate without following low surrogate';
            }
            next=str.charCodeAt(i+1);
            if (0xDC00 > next || next > 0xDFFF) {
                throw 'High surrogate without following low surrogate';
            }
            return str.charAt(i)+str.charAt(i+1);
        } else if (0xDC00 <= code && code <= 0xDFFF) { // Low surrogate
            if (i === 0) {
                throw 'Low surrogate without preceding high surrogate';
            }
            prev=str.charCodeAt(i-1);
            if (0xD800 > prev || prev > 0xDBFF) { //(could change last hex to 0xDB7F to treat high private surrogates as single characters)
                throw 'Low surrogate without preceding high surrogate';
            }
            return false; // We can pass over low surrogates now as the second component in a pair which we have already processed
        }
        return str.charAt(i);
    };

    for (i=0, lgth=0; i < str.length; i++) {
        if ((chr=getWholeChar(str, i)) === false) {
            continue;
        } // Adapt this line at the top of any loop, passing in the whole string and the current iteration and returning a variable to represent the individual character; purpose is to treat the first part of a surrogate pair as the whole character and then ignore the second part
        lgth++;
    }
    return lgth;
}



function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today=new Date();
today.setTime( today.getTime() );

if ( expires )
{
expires=expires * 1000 * 60 * 60 * 24;
}
var expires_date=new Date( today.getTime() + (expires) );

document.cookie=name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}


function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies=document.cookie.split( ';' );
	var a_temp_cookie='';
	var cookie_name='';
	var cookie_value='';
	var b_cookie_found=false; // set boolean t/f default f

	for ( i=0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie=a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name=a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found=true;
			// we need to handle case where cookie has no value but exists (no=sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value=unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie=null;
		cookie_name='';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}




function checkMail(_string)
{
var emailPattern=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}$/;
return emailPattern.test(_string);

} 



var _curLegendHtml='';
var _curLegendElement='';
var _curLegendDirection='';
var _curLegendClass='';
function refreshLegend(){
	if($('#NF_BULLE').get(0)){
		openLegend(_curLegendHtml,_curLegendElement,_curLegendDirection,_curLegendClass,150);	
	}
}

function openLegend(html,element,direction,_class,_SPEED){
	if(!direction){direction = 'DOWN';}
	if(!_SPEED){_SPEED = 150;}
		
	$('#NF_BULLE,#NF_BULLE_ARROW').remove();
	$('body').prepend('<div id="NF_BULLE" class="'+_class+'" style="left:0; top:0;"><div style="padding:5px 8px">'+html+'</div></div><div id="NF_BULLE_ARROW" class="'+direction+' '+_class+'"></div>');	
	
	var bulle = $('#NF_BULLE');
	var arrow = $('#NF_BULLE_ARROW');
	var marginBaseLeft = 0;
	var _totalHei = $(window).height();
	
	var offset = element.offset();
	var bulleHei = bulle.height();
	var bulleWi = bulle.width();
	
	var arrowHEI = arrow.height();
	var arrowWI = arrow.width();
	
	var newLeft = Math.round(offset.left - (bulleWi/2) + (element.width()/2));
	
	var arrowLeft = Math.round(offset.left - (arrowWI/2) + (element.width()/2));
	
	var maxLeft = $(window).width() - bulleWi - 2;
	
	
	if(parseInt(element.css('paddingTop'))>0){	var paddingTop = parseInt(element.css('paddingTop'));	} else {var paddingTop = 0;}
	if(parseInt(element.css('paddingBottom'))>0){	var paddingBottom = parseInt(element.css('paddingBottom'));	} else {var paddingBottom = 0;}
	if(parseInt(element.css('paddingRight'))>0){	var paddingRight = parseInt(element.css('paddingRight'));	} else {var paddingRight = 0;}
	if(parseInt(element.css('paddingLeft'))>0){	var paddingLeft = parseInt(element.css('paddingLeft'));	} else {var paddingLeft = 0;}
	if(parseInt(element.css('borderTopWidth'))>0){	var borderTopWidth = parseInt(element.css('borderTopWidth'));	} else {var borderTopWidth = 0;}
	if(parseInt(element.css('borderBottomWidth'))>0){	var borderBottomWidth = parseInt(element.css('borderBottomWidth'));	} else {var borderBottomWidth = 0;}
	if(parseInt(element.css('borderLeftWidth'))>0){	var borderLeftWidth = parseInt(element.css('borderLeftWidth'));	} else {var borderLeftWidth = 0;}
	if(parseInt(element.css('borderRightWidth'))>0){	var borderRightWidth = parseInt(element.css('borderRightWidth'));	} else {var borderRightWidth = 0;}
	


	
	var elemHei = element.height() + paddingTop + paddingBottom + borderTopWidth + borderBottomWidth;
	var elemWi = element.width() + paddingLeft + paddingRight + borderLeftWidth + borderRightWidth;
	
	
	if(newLeft<2){newLeft=2;}
	if(newLeft>maxLeft){newLeft=maxLeft;}
	
	
	if(direction=='UP'){
	var marginBaseTop = -20;
	var newTop=offset.top - bulleHei - 8 ;		
	var arrowTop = newTop + bulleHei ;	
	}
	
	else
	
	if(direction=='RIGHT'){
	var marginBaseTop = 0;
	marginBaseLeft = 30;
	var newTop=offset.top + Math.round((elemHei/2) - (bulleHei/2));	
	var arrowTop = newTop +  Math.round((bulleHei/2) - (arrowHEI/2)) ;	
	newLeft = Math.round(offset.left + elemWi + 10);
	arrowLeft = newLeft-arrowWI;
	}
	
	else
	
	if(direction=='LEFT'){
	var marginBaseTop = 0;
	marginBaseLeft = -30;
	var newTop=offset.top + Math.round((elemHei/2) - (bulleHei/2));	
	var arrowTop = newTop +  Math.round((bulleHei/2) - (arrowHEI/2));	
	newLeft = Math.round(offset.left - bulleWi - 10);
	arrowLeft = newLeft+bulleWi;
	
	
	
	}
	
	else {
	var marginBaseTop = +20;
	
	
	
	var newTop=offset.top + 8 + elemHei ;	
	var arrowTop = newTop-arrowHEI;	
	}
	
	var bodyScroll = document.documentElement.scrollTop;

	
	if(newTop-bodyScroll<4 && (direction=='LEFT' || direction=='RIGHT')){newTop = bodyScroll+4;}
	if((newTop-bodyScroll)+bulleHei>_totalHei-4  && (direction=='LEFT' || direction=='RIGHT') ){ newTop = (_totalHei - bulleHei) + bodyScroll - 4; }
	
	
	if(_SPEED>149){
	//openLegend(html,element,direction,_class,_SPEED)
	
	if(direction=='LEFT' && newLeft<0){
		openLegend(html,element,'RIGHT',_class,145);
	}
	
	if(direction=='RIGHT' && newLeft+bulleWi>$(window).width()){
		openLegend(html,element,'LEFT',_class,145);
	}
	
	if(direction=='DOWN' && ((newTop+bulleHei)-bodyScroll>$(window).height())){
		openLegend(html,element,'UP',_class,145);
	}
	
	if(direction=='UP' && newTop-bodyScroll<0){
		openLegend(html,element,'DOWN',_class,145);
	}
	
	
	
	}
	
	
	bulle.css({top:newTop,left:newLeft,marginTop:marginBaseTop,marginLeft:marginBaseLeft,opacity:0});	
	arrow.css({top:arrowTop,left:arrowLeft,marginTop:marginBaseTop,marginLeft:marginBaseLeft,opacity:0});
	
	if(_SPEED>10){
	bulle.animate({marginTop:0,marginLeft:0,opacity:1},_SPEED);
	arrow.animate({marginTop:0,marginLeft:0,opacity:1},_SPEED);
	}
	else
	{
	bulle.css({marginTop:0,marginLeft:0,opacity:1});
	arrow.css({marginTop:0,marginLeft:0,opacity:1});	
	}
	
	_curLegendHtml = html;
	_curLegendElement = element;
	_curLegendDirection = direction;
	_curLegendClass = _class;
	
}

function closeLegend(){
	$('#NF_BULLE,#NF_BULLE_ARROW').remove();
}



function rand (min, max) {
 
    var argc=arguments.length;
    if (argc === 0) {
        min=0;
        max=2147483647;    } else if (argc === 1) {
        throw new Error('Warning: rand() expects exactly 2 parameters, 1 given');
    }
    return Math.floor(Math.random() * (max - min + 1)) + min;

}

function uniqid (prefix, more_entropy) {
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    revised by: Kankrelune (http://www.webfaktory.info/)
    // %        note 1: Uses an internal counter (in php_js global) to avoid collision
    // *     example 1: uniqid();
    // *     returns 1: 'a30285b160c14'
    // *     example 2: uniqid('foo');
    // *     returns 2: 'fooa30285b1cd361'
    // *     example 3: uniqid('bar', true);
    // *     returns 3: 'bara20285b23dfd1.31879087'
    if (typeof prefix == 'undefined') {
        prefix="";
    }

    var retId;
    var formatSeed=function (seed, reqWidth) {
        seed=parseInt(seed, 10).toString(16); // to hex str
        if (reqWidth < seed.length) { // so long we split
            return seed.slice(seed.length - reqWidth);
        }
        if (reqWidth > seed.length) { // so short we pad
            return Array(1 + (reqWidth - seed.length)).join('0') + seed;
        }
        return seed;
    };

    // BEGIN REDUNDANT
    if (!this.php_js) {
        this.php_js={};
    }
    // END REDUNDANT
    if (!this.php_js.uniqidSeed) { // init seed with big random int
        this.php_js.uniqidSeed=Math.floor(Math.random() * 0x75bcd15);
    }
    this.php_js.uniqidSeed++;

    retId=prefix; // start with prefix, add current milliseconds hex string
    retId += formatSeed(parseInt(new Date().getTime() / 1000, 10), 8);
    retId += formatSeed(this.php_js.uniqidSeed, 5); // add seed hex string
    if (more_entropy) {
        // for more entropy we add a float lower to 10
        retId += (Math.random() * 10).toFixed(8).toString();
    }

    return retId;
}



function openFrame(_href,_wi,_hei){
		closeFrame();
		if(!_wi){	_wi=450; }
	
		$('body').prepend('<div id="OVERALLBGFRAME" class="LOADING"></div><iframe id="IFRAMEBOX" frameborder="0" style="margin-left:-'+Math.round(_wi*0.5)+'px" height="0" width="'+_wi+'" scrolling="auto" src="'+_href+'"></iframe><a href="javascript:void(0)" id="CLOSERFRAME">CLOSE</a>');
		
		
		$('#OVERALLBGFRAME').css({opacity:0.9});
		$('#IFRAMEBOX').css({opacity:0});
		$('#CLOSERFRAME').css({opacity:0});
		
		$('#OVERALLBGFRAME,#CLOSERFRAME').bind('click',function(){
		closeFrame()
		});
		$('#IFRAMEBOX').bind('load',function(){
				$('#OVERALLBGFRAME').removeClass('LOADING');
				if(!_hei){
					var frame=$("#IFRAMEBOX")[0].contentDocument;
					_hei=$('#POPUP', frame).height()+40;	
					if(_hei>$(window).height()-80){
						_hei=$(window).height()-80
					}
				}
				
				if(_hei<41){ _hei=300;}	
				
				$('#IFRAMEBOX').unbind('load');
				$('#IFRAMEBOX').css({height:_hei+'px',marginTop:Math.round(_hei*-0.5)+'px'});
				
				$('#CLOSERFRAME').css({marginTop:Math.round((_hei*-0.5)-10)+'px',marginLeft:Math.round((_wi*0.5)-14)+'px'});
				
				$('#IFRAMEBOX,#CLOSERFRAME').animate({opacity:1},400);
				
			
				
		})
		
		
		
}

function closeFrame(){
	if(allowCloseFrame==true){
$('#OVERALLBGFRAME, #IFRAMEBOX,#CLOSERFRAME').remove();
	}
}


function resizeFrame(){
		var frame=$("#IFRAMEBOX")[0].contentDocument;
		var _hei=$('#POPUP', frame).height() + 40;
		if(_hei>$(window).height()-80){
						_hei=$(window).height()-80
		}
		
		
		if(_hei<41){ _hei=300;}		
		
		$('#IFRAMEBOX').stop();
		$('#CLOSERFRAME').stop();
		$('#IFRAMEBOX').animate({opacity:1,height:_hei+'px',marginTop:Math.round(_hei*-0.5)+'px'},300);
		$('#CLOSERFRAME').animate({opacity:1,marginTop:Math.round((_hei*-0.5)-10)+'px'},300);
		$('#IFRAMEBOX').unbind('drop');
}

function allowConnect(id,login){
		$('#ID_MBR_CX').html(id);
		$('.NEED_CX,.NEED_CX_').hide();
		$('.my_avatar').html('<img src="http://www.nowfashion.com/uploads/avatars/th_'+id+'.jpg?uid='+uniqid()+'" />');
		$('.IS_CX').show();
		$('#MY_NAME').html('<a href="my-profile.php">'+login+'</a>');
}


function logout(){
	
	openNotify('Your Are Disconnecting...',true);
	$('#NF_ACTIONS').load('LOGOUT.php',function(){
		closeNotify();
		$('#ID_MBR_CX').html(0);
		$('.NEED_CX,.NEED_CX_').show();
		$('.my_avatar').html('');
		$('.IS_CX').hide();
		$('#MY_NAME').html('');
	});
		
}


function openPopUp(_href,_name,_wi,_hei,_resize){
	if(!_resize){_resize='yes';}
	window.open(_href,_name,"directories=no,location=no,menubar=no,resizable="+_resize+",status=no,toolbar=no,width="+_wi+",height="+_hei);
}


function FB_SHARING(_url){
	openPopUp('http://www.facebook.com/sharer.php?src=sp&u='+_url,'FB',700,400,'yes');
}




function openNotify(_html,_load,_speed){
	clearTimeout(_timerNotify);
	
	if(!_speed){_speed=200;}
	if(_speed<1){_speed=1;}
	
	var thisClass='';
	if(_load==true){ thisClass="LOADING"}
	
	deleteNotify();
	
	
	$('body').prepend('<div id="NF_NOTIFY_OVER_ALL"></div><div id="NF_NOTIFY" class="'+thisClass+'"><div class="NOTIFY_PADDER">'+_html+'</div></div>');
	$('#NF_NOTIFY_OVER_ALL').css({opacity:0});
	
	var _NOTI_WI=$('#NF_NOTIFY').width();
	
	$('#NF_NOTIFY').css({marginLeft:Math.round(_NOTI_WI*-0.5)+'px'});
	
	$('#NF_NOTIFY').animate({top:'10px'},_speed,'easeOutCirc');
	$('#NF_NOTIFY,#NF_NOTIFY_OVER_ALL').unbind();
	$('#NF_NOTIFY,#NF_NOTIFY_OVER_ALL').bind('mousedown',function(){return false;});
	
}

function closeNotify(){
	clearTimeout(_timerNotify);
	
	_timerNotify=setTimeout(function(){
		$('#NF_NOTIFY_OVER_ALL').remove();
		$('#NF_NOTIFY').animate({top:'-60px'},150,'easeInCirc',function(){
			deleteNotify();	
		});
			
	},800);
	
}

function deleteNotify(){
	clearTimeout(_timerNotify);
	$('#NF_NOTIFY,#NF_NOTIFY_OVER_ALL').remove();
}



function initSite(){
BLINKING();
dynamicShows();	
keepSlideShows();
LISTING_START();
makeChamps();

$(window).resize(function(){
	refreshLegend();	
});

$(window).scroll(function(){
	refreshLegend();	
});

var timerOtherCx=null;

$('#signInBtn').bind('mouseenter',function(){
clearTimeout(timerOtherCx);	
var thisOffset=$(this).offset().left;	
var btnWi=$(this).width();

$('#other_connect').stop();
$('#other_connect').css({right:Math.round($(window).width()-thisOffset-(btnWi+18))+'px'});	
$('#other_connect').animate({height:'53px'},200);	
		
	
});

$('#other_connect').find('a').bind('click',function(){
	$('#other_connect').css({height:'0'});	
});


$('#signInBtn,#other_connect').bind('mouseleave',function(){
	timerOtherCx=setTimeout(function(){
		$('#other_connect').animate({height:'0'},200);	
	},100);
});

$('#other_connect').bind('mouseenter',function(){
clearTimeout(timerOtherCx);	
});

var _thisVal=trim($('#searchField').val());
if(strlen(_thisVal)<1){  $('#searchField').val('Search...'); }
	
$('#searchField').bind('focus',function(){
	$(this).stop();
	$(this).animate({backgroundColor:'#E00'},400);	
	closeLegend();	
	var _thisVal=trim($(this).val());
	if(_thisVal=='Search...'){ $(this).val('');  }
});

$('#searchField').bind('blur',function(){
	$(this).stop();
	$(this).animate({backgroundColor:'#BBB'},300);
	closeLegend();		
	var _thisVal=trim($(this).val());
	if(strlen(_thisVal)<1){  $(this).val('Search...'); }
	
});


/*
jQuery.getScript('http://platform.twitter.com/widgets.js');
jQuery.getScript('https://apis.google.com/js/plusone.js');
<script src="http://connect.facebook.net/en_US/all.js#appId=133118483439574&amp;xfbml=1"></script>
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>*/




$('.rss').bind('mouseenter',function(){
	openLegend($(this).html(),$(this),'UP');									 
});

$('.rss').bind('mouseleave',function(){
	closeLegend();									 
});

}


function dynamicShows(){
	$('ul.listing-mono-block').find('a').bind('mouseenter',function(){
		$('#infosShows,#infosShowsLeft').remove();	
		var _elem=$(this).parent('li');
		var offset=_elem.offset();
		var _posTop=offset.top;
		var _elemWI=_elem.width();
		var _posLeft=offset.left+_elemWI;
		var _posLeft2=offset.left-3;
		$('body').prepend('<div id="infosShowsLeft" style="top:'+_posTop+'px; left:'+_posLeft2+'px;"></div><div id="infosShows" style="top:'+_posTop+'px; left:'+_posLeft+'px;"><div class="conteneur">'+_elem.find('.infos').html()+'</div></div>');
		
		$('#infosShows').animate({width:'160px'},150);
		
		_elem.css({borderColor:'#400',backgroundColor:'#C00'});
		
	});
	
	$('ul.listing-mono-block').find('a').bind('mouseleave',function(){
		$('#infosShows').stop();														
		$('#infosShows,#infosShowsLeft').remove();												
		var _elem=$(this).parent('li');
		_elem.css({borderColor:'#FFF',backgroundColor:'#FFF'});
		
	});
	
}



function postComment(id,_type){
	
	var _message=trim($('#COMMENT_POST').val());
	if(strlen(_message)<5){
		openNotify('Message Must Be 5 Characters Minimum',false);
		closeNotify();
	}
	else
	if(strlen(_message)>500){
		openNotify('Message Must Be 500 Characters Maximum',false);
		closeNotify();
	}
	
	else
	{	openNotify('Your Comment Is Sending...',true);
		$('#ACTIONS_COMMENTS').load('POST-COMMENTS.php?id='+encodeURIComponent(id)+'&type='+encodeURIComponent(_type)+'&message='+encodeURIComponent(_message),function(){
			$('#COMMENT_POST').val('');	
			closeNotify();
			$('#LIST_COMMENTS').append($('#CLONE_COMMENT').html());
			$('#CLONE_COMMENT').remove();
			$('#LIST_COMMENTS').find('.no_comments').remove();
		});
	}
}



function showCalendar(_date){
	openNotify('Calendar Is Loading...',true,200);
	$('#NF_CALENDAR').load('CALENDAR-WIDGET.php?CALENDAR_DATE='+encodeURIComponent(_date),function(){ deleteNotify(); });
	$('#cal-month-link').attr('href','calendar.php?CALENDAR_DATE='+encodeURIComponent(_date));
	$('#cal-day-link').attr('href','calendar-list.php?CALENDAR_DATE='+encodeURIComponent(_date));
}


function showCalendarList(_date){
	openNotify('Calendar Is Loading...',true,200);
	$('#NF_CALENDAR').load('CALENDAR-WIDGET-LIST.php?CALENDAR_DATE='+encodeURIComponent(_date),function(){ deleteNotify(); });
	$('#cal-month-link').attr('href','calendar.php?CALENDAR_DATE='+encodeURIComponent(_date));
	$('#cal-day-link').attr('href','calendar-list.php?CALENDAR_DATE='+encodeURIComponent(_date));
}



function LISTING_START(){


var WI_1=$('#first_listing_lives').find('ul').width()+40;
var WI_2=$('#next_listing_lives').find('ul').width()+40;

var _baseHei=$('#listing_lives').height();
var _baseWi=$('#listing_lives').width();

var NEXT_WI=WI_1;
if(WI_2>WI_1){ NEXT_WI=WI_2;}

if(NEXT_WI<_baseWi){
	_baseWi=NEXT_WI;
	$('#listing_lives').css({width:_baseWi+'px'});
}

var NEXT_HEI=40+$('#next_listing_lives').find('ul').height();


$('#listing_lives').find('ul').css({width:NEXT_WI+'px'});

var _timerNext=null;

$('#listing_lives').bind('mouseenter',function(){
		$('#listing_lives').stop();
		$('#listing_lives').animate({width:NEXT_WI+'px'},150,'easeOutCirc',function(){
		$('#listing_lives').animate({height:NEXT_HEI+'px'},300,'easeOutCirc');
		});
});

$('#listing_lives').bind('mouseleave',function(){
		$('#listing_lives').stop();
		$('#listing_lives').animate({height:_baseHei+'px'},250,'easeInCirc',function(){
		$('#listing_lives').animate({width:_baseWi+'px'},150,'easeInCirc');
		});
});


START_COUNTS();

	
}


var _timer_counts=new Array();
var this_reste=new Array();
function START_COUNTS(){
	
$('.sub-count').each(function(){
							  
	var this_id=$(this).attr('id').split('c_');
	this_id=parseInt(this_id[1]);
	this_reste[this_id]=parseInt($(this).next('.sub-reste').html());	
	
	SUB_REBOURS(this_id);
	
	
});
	


function SUB_REBOURS(id){

var check_time=this_reste[id];
_timer_counts[id]=setTimeout(function(){SUB_REBOURS(id);},1000);

if(check_time<0){
check_time=check_time*-1;
var aff_count='Live is ';
var _suffixeCount=' Late';
}
else
{
var aff_count='Live in ';	
var _suffixeCount='';
}

var _day=Math.floor(check_time/24/3600); 
	
	if(_day>0){
	if(_day<2){ aff_count=aff_count + _day+' day '; }else { aff_count=aff_count + _day+' days '; }
	}

var _heure=Math.floor((check_time - (_day*24*3600))/3600);
	
	if(_heure>0){aff_count=aff_count+_heure+'h ';}
	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+'"'+_suffixeCount;


this_reste[id]--;

$('#c_'+id).html(aff_count);	
	
}

	
}

function STOP_REBOURS(id){
		clearTimeout(_timer_counts[id]);
		$('#c_'+id).html(' IS LIVE!');	
		$('#c_'+id).addClass('blink');
		BLINKING();
}


var _displayBlink=true;
var intervallBlink=null;
function BLINKING(){
clearInterval(intervallBlink);	
if($('.blink').size()<1){ return false;}
intervallBlink=setInterval(function(){blinkIt();},600);
}

function blinkIt() {
	if(_displayBlink==true){$('.blink').css({opacity:0}); _displayBlink=false; }
	else {$('.blink').css({opacity:1});  _displayBlink=true; }
}




function keepSlideShows(){
	
	
	
	$('.NF_SLIDESHOW').each(function(){
		var _self=$(this);
		var _selfUL=_self.find('.NF_SLIDESHOW_CONTENT');	
		 _self.find('img').css({opacity:0});	
		 
		 var _minHEI=2000;
		 var _maxWI=0;
		 
		 _selfUL.find('li').each(function(){
		var _self2=$(this); 
		 var _thisWI=_self2.find('img').width();
		 var _thisHEI=_self2.find('img').height();
		 
		 _self2.css({width:_thisWI+'px',height:_thisHEI+'px'});	
		 
		 if(_thisWI>_maxWI){_maxWI=_thisWI;}
		  if(_thisHEI<_minHEI){_minHEI=_thisHEI;}
		 
		 
		 });
		 
		 
		 if(_maxWI>665){_maxWI=665;}
		 
		 _self.css({width:_maxWI+'px',height:_minHEI+'px'});
		 _selfUL.css({width:_maxWI+'px',height:_minHEI+'px'});	
			var _max_img=_self.find('img').size()-1;
			
			
			var _curIMG=Math.floor(rand(0,_max_img));
		
		
		 _self.find('img:eq('+_curIMG+')').css({opacity:1,zIndex:1});
		
		function swichImg(){
			
			var _nextImg=_curIMG+1;
			if(_nextImg>_max_img){_nextImg=0;}
			
			var _curElem=_self.find('img:eq('+_curIMG+')');
			var _nextElem=_self.find('img:eq('+_nextImg+')');
			
			_nextElem.stop();
			_curElem.stop();
			
			_curElem.css({zIndex:1});
			_nextElem.css({opacity:0,zIndex:3});
			_nextElem.animate({opacity:1},600);
			_curElem.animate({opacity:0},800);
			_curIMG=_nextImg;
			
			_timerSlideShow=setTimeout(function(){swichImg()},4000);
			
				
		}
		
		if(_max_img > 0){ setTimeout(function(){swichImg()},4000);}
		
		
		
		
	});
	
	
	
	
	
}



function filterDesigners(){

var filters=trim($('#filter_designer').val());
var n_res=0;
var _exp=RegExp(filters,"gi"); 

$('.select-designers').find('a').each(function(){
	if(_exp.test($(this).html())==true){  $(this).show(); n_res++;	} else { $(this).hide();	}
});

if(n_res<1){$('#no_res_designer').show();} else {$('#no_res_designer').hide();}
	
}


function makeChamps(){	
	
$('input').each(function(){
var _title=trim($(this).attr('title'));
$(this).attr('title','');
if(!trim($(this).val())){
	$(this).val(_title);	
}

$(this).bind('focus',function(){
if(trim($(this).val()) == _title){
	$(this).val('');	
}
});

$(this).bind('blur',function(){
if(!trim($(this).val())){
	$(this).val(_title);	
}
else
{
		$(this).val(trim($(this).val()));
}
});
});	
}



function updateProfilePicture(_src,_src2){
	$('#profileNoPicture').hide();
	$('.optionsProfilePicture').show();
	$('#profilePicture').html('<img src="'+_src+'" alt="" />');	
	$('.my_avatar,.my_avatar_bg').css({backgroundImage:'none'});
	$('.my_avatar,.my_avatar_bg').html('<img src="'+_src2+'" alt="" />');
}


function deleteProfilePicture(){
if(confirm('Are you sure to delete your profile picture ?')){		
	$('#profilePicture').html('');	
	$('#profilePicture').load('delete-profile-picture.php',function(){
	$('#profilePicture').html('');
	$('#profileNoPicture').show();	
	$('.my_avatar,.my_avatar_bg').html('');
	$('.my_avatar,.my_avatar_bg').css({backgroundImage:'none'});
	});
}
}


function faceBookConnect(){
	openNotify('Facebook Authentication...',true,200);	
	$('#NF_ACTIONS').load('FB-AUTH.php',function(){
	deleteNotify();		
	});
}

function deleteLookbook(id){
	closeLegend();
	if(confirm("Are You Sure To Delete This Lookbook ?")){
		$('#LB_ID_'+id).html('This Lookbook is Deleting, Please Wait...');
		$('#LB_ID_'+id).load('delete-lookbook.php?id='+encodeURIComponent(id),function(){
		$('#LB_ID_'+id).slideUp(200,function(){	$('#LB_ID_'+id).remove();	});
		});
		
	}
		
}



function saveLBPositions(id){
var _listeIds='';
$('#sortable').find('li').each(function(){
	
var tarID=$(this).attr('id');	
tarID=tarID.split('picture_lb_');
	
_listeIds=_listeIds+','+tarID[1];
	
openNotify('Saving Order...',true,200);	
	
	
});

$('#LB_actions').load('reorder-lb.php?id='+encodeURIComponent(id)+'&ids='+encodeURIComponent(_listeIds),function(){
closeNotify();	
});
	
}



function deletePictureLB(id){
if(confirm("Are You Sure to Delete This Photo ?")){		
$('#picture_lb_'+id).load('delete-picture-lb.php?id='+encodeURIComponent(id));
$('#picture_lb_'+id).remove();	
}
}


function deleteLine(id,_href,message){
if(!message){ message='Are you sure to delete this entry ?';}	
	if(confirm(message)){		
		$('#line-'+id).html('This Entry is Deleting...');
		$('#line-'+id).load(_href,function(){
		$('#line-'+id).slideUp(200,function(){$(this).remove();});				
		});
		
	}
}



function renameCat(id,name){
	$('#line-'+id).find('.catName').html(name);
	
}




function searcher(){
	
	var keywords=trim($('#searchField').val());	
	var allow=false;
	keywords=keywords.split(' ');
	if(keywords.length>0){
	for(var i=0; i<=keywords.length-1;i++){
		var _thisWord=trim(keywords[i]);
		if(strlen(_thisWord)>=3 && _thisWord != 'Search...'){allow=true; break;}		
	}
	}
	
	
	
	if(allow == true){
		closeLegend();	
		openNotify('Your Request is Submitting...',true,200);
		document.getElementById('search').submit();
	}
	else
	{
		openLegend('Please Enter a Minimum of 3 Characters Per Keyword',$('#searchField'),'UP');
	}
		
}
