function boot() {
    
    // http://perishablepress.com/press/2009/11/09/perfect-pre-tags/
    // only apply to IE  
	if (!/*@cc_on!@*/0) return;  
	// find every element to test  
	var all = document.getElementsByTagName('*'), i = all.length;  
	// fast reverse loop  
	while (i--) {    
		// if the scrollWidth (the real width) is greater than 
		// the visible width, then apply style changes    
		if (all[i].scrollWidth > all[i].offsetWidth) {
			all[i].style['paddingBottom'] = '32px';
			all[i].style['overflowY'] = 'hidden';
		}
	}
}

var LOGININPUTTEXT ="Entrez votre PSEUDO";
var PASSINPUTTEXT ="Entrez votre Mot de passe";

var refop='&nbsp;';
function ofil(ref) {
	if(!ref) ref=refop;
	var txt = jQuery('#boxyofil').html();
	txt = txt.replace('#ref#', ref);
    new Boxy(
     txt, {
    	modal: true,
    	title: 'Laissez un message'
     });

}
function ophone(ref) {
	if(!ref) ref=refop;
	var txt = jQuery('#boxyophone').html();
	txt = txt.replace('#ref#', ref);
    new Boxy(
    	txt, {
    	modal: true,
    	title: 'Contact direct'
     });
};

jQuery(document).ready(function()
{	
	if( document.getElementById('carousel') != null ){

			jQuery('#carousel').infiniteCarousel({
				inView:1,
				imagePath: '/_themes/main/swingv2/js/infinitecarousel/images/',
				textholderHeight : .25,
				padding:'10px',
				thumbnailWidth:'55px',
				thumbnailHeight:'65px'
			});
			jQuery('div.thumb').parent().css({'margin':'0 auto','width':'600px'});
			jQuery('#carouselWrapper > div:eq(1)').css('margin-top','56px');
			jQuery('#carouselWrapper > div:eq(2)').css('margin-top','56px');
	}
	
	if( document.getElementById('sidenav') != null ){
		jQuery('#naviright').sticklr({
			showOn		: 'hover',
			stickTo     : 'right'
		});
	}
	
	if( document.getElementById('list2') != null ){
		jQuery('#aidephotobtn').click(function(){
			// by calling sibling, we can use same div for all demos
			jQuery('#aidephoto').slideToggle();
		});
	}

	if( document.getElementById('boxyophone') != null ){}
	if( document.getElementById('boxyofil') != null ){};
/*
	if( document.getElementById('header_main') != null &&
			document.getElementById('bandeau') != null &&
			( document.getElementById('accueil') != null ||
					document.getElementById('deconexion') != null )
		){

	if( document.getElementById('header_main') != null &&
			document.getElementById('bandeau') != null
		){
*/
		    var newImg = new Image();
		    newImg.src = 'http://www.swingeurope.com/media/images/news/ticker.png';
		    jQuery(newImg).ready(function(){
		    	var h = newImg.height+2;
		    	jQuery("#bandeau").css('display','block');
		    	jQuery("#bandeau").css('height',h+'px');
				jQuery("#scroller_roll1").scroller_roll({
					title_show: 'disable',//enable  disable
		            time_interval: '30',
		            window_background_color: "#000000",
		            window_padding: '1',
		            border_size: '0',
		            border_color: '#0099CC',
		            images_width: newImg.width,
		            images_height: newImg.height,
		            images_margin: '5',
		            title_size: '12',
		            title_color: 'black',
		            show_count: '6'
		        });
				//return {width: newImg.width, height: newImg.height};
		    });
/*		}*/

	var pathArray = window.location.pathname.split( '/' );
	for(var i=0;  i< pathArray.length; i++){
		if( pathArray[i].indexOf('search_results') > -1
		|| pathArray[i].indexOf('users_new') > -1
		){
//alert( jQuery("#columns") );
			//jQuery("#columns").css('min-height', '1300px');
			if( jQuery("#columns").height() < jQuery("#sidebar").height() ){
				var h=jQuery("#sidebar").height();
				jQuery("#columns").css( 'height',h+'px');
				//jQuery("#columns").css( 'overflow','hidden');
			}
		}
	}
	
	swg_show_disclaimer();

	function chat() {
	    new Boxy( jQuery('#chatbox').html(), { modal: true, title: 'Chat webcam visio swingeurope'});
	};
	
	function ophone() {
	    new Boxy( jQuery('#opbox').html(), { modal: true, title: 'Contactez les par téléphone'});
	};
	
	function charte() {
		var b=Boxy.load('/_themes/main/swingv2/popup/pri_policy.html',{ cache:true, title: 'La charte SWING'});
	};

	function newModal() {	
	    new Boxy(
	     jQuery('#forget').html(), {
	    	modal: true,
	    	title: 'Mot de passe oublié',
	    	behaviours: function(c) {
	    	 var myBoxy = this;
	    	 c.find('#frmforget').submit(function() {
	    		 jQuery.post(MAINURL+"join.php", {
	    			 	cmd: 'forgeter',
	    		 	 	your_email: c.find("input[name='forgetmail']").val(),
	    		 	}, function(data) {
	    				myBoxy.setContent( "<div style=\"font-weight:700; text-align:center; color:black; font-size:1.2em; width: 600px; height: 160px\"><br/>"+data+"</div>" );
	    			});
	             return false;
	    	})}
	     });
	};

	if( document.getElementById('nick') != null ){
		jQuery('#login-f').submit(function(e) {
			e.preventDefault();
			return false;
		});
		
		function submitlogin(){
			var mask = /[^_0-9a-zA-Z-*]+$/g;
			var u = jQuery("#nick").val().replace( mask,  '' );
			var p = jQuery("#pwd").val().replace( mask,  '' );
	//
	//alert(u+', '+p);
	//var mask = /^[_0-9a-zA-Z-*]*[_0-9a-zA-Z-*]$/;
	//
			p=p.replace(/(\r\n|\n|\r)/gm,'');
			u=u.replace(/(\r\n|\n|\r)/gm,'');
	//
			p=p.replace(/[\t\v\f\r \u00a0\u2000-\u200b\u2028-\u2029\u3000]+/g,'');
			u=u.replace(/[\t\v\f\r \u00a0\u2000-\u200b\u2028-\u2029\u3000]+/g,'');		
	//
			if ( u!='' && p!='') {
				var notShown = new Boxy('<p>identifiants incorrects</p>',
					{ show: false, modal: true, title: 'Identifiants incorrects',  unloadOnHide: true}
				);
	//
				jQuery.post(MAINURL+"join.php", {
						cmd: 'login',
						user: u,
						password: p
					}, function(data){
						if( data.search(/php/i) > -1 ){
							document.location.href= MAINURL+data;
						} else {
							//alert( notShown );
							notShown.setContent("<div style=\"font-weight:700; text-align:center; color:black; font-size:1.2em; width: 500px; height: 100px\"><br/>"+data+"</div>");
							notShown.show();
							//var box = ;
							;
						}
				});
			}
			return false;
		}
		jQuery('#loginok').click(submitlogin);
		jQuery('#charte').click(charte); 
		jQuery('#chat').click(chat);
		jQuery('#modal').click(newModal);
	}

	if( document.getElementById('searchop') != null ){
		jQuery('#searchop').click(ophone);
	}
	if( document.getElementById('searchopexp') != null ){
		jQuery('#searchopexp').click(ophone);
	}
	
	if( document.getElementById('ashowmessage') != null && typeof asitemsgbox == 'function'){
		//jQuery('#ashowmessage').click(asitemsgbox);
	}
	
	if( typeof sitemsgbox == 'function') {
		sitemsgbox();
	}
	//boot();
	
});

