
if (typeof(setUpClearInput) == 'undefined') { 
	function setUpClearInput() {
	/* Vide les inputs */
		//Lors de la prise de focus
		$('.clear-input').focus(function()
		{
	 
			//Initialisation de l'objet
			var obj = $(this);
	 
			//On stock la valeur actuelle de l'input
			var tmp_value = $(this).val();
	 
			//Creation d'un attribut rel qui va stocker notre valeur initiale
			if (obj.attr('rel') == undefined)
			{
				obj.attr('rel', obj.val());
			}
	 
			//Si la valeur de notre input est égale à notre valeur stockée dans l'attribut rel,
			//Nous effacons la valeur de notre input
			if (obj.val() == obj.attr('rel'))
			{
				obj.val('');
			}
		});
	 
		//Lors de la perte de focus
		$('.clear-input').blur(function()
		{
			//Initialisation de l'objet
			var obj = $(this);
	 
			//Initialise la valeur initiale
			var initial_value = obj.attr('rel');
	 
			/** Vous pouvez ajouter d'autres tests ici..... */
	 
			//Si la valeur de notre input est null, on affiche la valeur initiale
			if (obj.val() == "")
			{
				obj.val(initial_value);
			}
		});
	}
} // if type of setUpClearInput 

jQuery(document).ready(function()
{
	 setUpClearInput();
 
	/*jQuery("input[type=file]").filestyle(
	 {
	 image: mediaPath + "/design/front_office_demainjecree/images/file-button-fr.png",
	 imageheight: 27,
	 imagewidth: 73,
	 width: 100
	 });*/
 
	/* Colorbox */
	jQuery('#member-profile-section .add-contact-button, #addContact, #organism-network .add-contact-button, #event .add-contact-button').colorbox(
	{
		iframe: true,
		width: '600px',
		height: '580px'
	});
 
	jQuery('#url-forgotten-password').colorbox(
	{
		iframe: true,
		width: '700px',
		height: '260px'
	});
 
	jQuery('.delete-item').live('click', function()
	{
		jQuery.fn.colorbox(
		{
			open: true,
			html: '<div class="popin-success"><p>' + deleteItem + '.</p></div>',
			width: '350px',
			height: '115px'
		});
	});
 
	/*jQuery('.modify-contact').live('click', function()
	{
		var contactHref = jQuery(this).attr('href');
 
		jQuery.fn.colorbox(
		{
			open: true,
			href: contactHref
		});
 
		return false;
	});*/
 
	jQuery('.modify-contact').colorbox();
 
 
	jQuery('#member-project').addClass("corner-parent");
	jQuery('#member-project').prepend('<span class="tl-corner"></span><span class="tr-corner"></span><span class="bl-corner"></span><span class="br-corner"></span>');
 
 
	/* Validation */
	jQuery('#contact-us form, #appointment form, #fRecommand, #ideabox form, #event-container form, #login-form, #password-field form, #subscription-form form, #message-new form, .invitation-area form').validationEngine();
 
 
	/* Open in a new tab */
	jQuery('.open-new-tab').openNewTab(frontOfficePath);
 
	/* Characters left */
	jQuery('#CONTENT_TITLE').maxlength({'feedback': '#CONTENT_TITLE_CHAR_LEFT'});
	jQuery('#CONTENT_EVENT_HOURLY').maxlength({'feedback': '#CONTENT_EVENT_HOURLY_CHAR_LEFT'});
	jQuery('#CONTENT_EVENT_LOCATION').maxlength({'feedback': '#CONTENT_EVENT_LOCATION_CHAR_LEFT'});
	jQuery('#CONTENT_EVENT_ZIPCODE').maxlength({'feedback': '#CONTENT_EVENT_ZIPCODE_CHAR_LEFT_CHAR_LEFT'});
	jQuery('#CONTENT_EVENT_CITY').maxlength({'feedback': '#CONTENT_EVENT_CITY_CHAR_LEFT'});
	jQuery('#CONTENT_URL2').maxlength({'feedback': '#CONTENT_URL2_CHAR_LEFT'});
	jQuery('#CONTENT_EVENT_ADDRESS').maxlength({'feedback': '#CONTENT_EVENT_ADDRESS_CHAR_LEFT'});
 
	/* Numeric available only */
	jQuery('#CONTENT_EVENT_ZIPCODE').numeric();




//Externalisation des scripts////////////////////////////
    //FAQ
 
    //onglet
    $('#referentiel .onglets div ul div li a').live('click', function(){
        $('#referentiel .onglets div ul div li').each(function(){
            $(this).removeClass('active');
            $('#referentiel .inner').hide();
        });
        $(this).parent('li').addClass('active');
        //$('#'+$(this).attr('rel')).show();
 
        var c = $('#faqcategories li a.selected').attr('id');
        var o = $('#order1').attr('class') ? $('#order1').attr('class') : '';
        var type = 'type1';
        if ($(this).hasClass('type2')) {
 			var type = 'type2';
 		}
        ajaxFunction = 'FaqList';
        blockId = 'referentiel';
        action = 'listFaq';
		type = type.replace(" ", "");
        var arr = {
            "c": c,
            "type": type
        }
        xajax_call(ajaxFunction, action, blockId, arr);
 
        return false;
    });
 
    //filtre dans ref
    $('#referentiel-answer div.exchange-sort-list input').live('click', function(){
 
        var c = $('#faqcategories li a.selected').attr('id');
        var o = $(this).attr('class') ? $(this).attr('class') : '';
        var type = $('#referentiel .onglets li.active a').attr('class') ? $('#referentiel .onglets li.active a').attr('class') : '';
 
        ajaxFunction = 'FaqList';
        blockId = 'referentiel';
        action = 'listFaq';
        var arr = {
            "c": c,
            "type": type,
            "order": o
        }
        xajax_call(ajaxFunction, action, blockId, arr);
 
        return false;
    });
 
    //categorie
    jQuery('#faqcategories li a').click(function(){
        //ajout une class select sur le a
 
        $('#faqcategories li a').removeClass('selected');
        $('#faqcategories li a').css('color','#666666');
        $(this).addClass('selected');
        $(this).css('color','#3896DA');
        var c = $(this).attr('id');
 
        //var type = $('#referentiel .onglets li.active a').attr('class') ? $('#referentiel .onglets li.active a').attr('class') : 'type1';
 		var type = 'type1'; // par defaut
        if ($('#referentiel .onglets li.active a').hasClass('type2')) {
 			var type = 'type2';
 		}
 		        
        ajaxFunction = 'FaqList';
        blockId = 'referentiel';
        action = 'listFaq';
        var arr = {
            "c": c,
            "type": type
        }
        xajax_call(ajaxFunction, action, blockId, arr);
        return false;
    });
 
 	jQuery(".link-category-title").click(function(){
        var c = $(this).attr('id');
 
        var type = $('#referentiel .onglets li.active a').attr('class') ? $('#referentiel .onglets li.active a').attr('class') : 'type1';
 
        ajaxFunction = 'FaqList';
        blockId = 'referentiel';
        action = 'listFaq';
        var arr = {
            "c": c,
            "type": type
        }
        xajax_call(ajaxFunction, action, blockId, arr);
        return false;
	});
     
   
 
    //DashBoard
    jQuery('#my_questions #question-filter').live('change', function(){
        var t = $(this).val();
        var ajaxFunction = 'FaqDashboard';
        var blockId = 'my_questions';
        var action = 'listFaq';
        var arr = {
            s: t
        };
        xajax_call(ajaxFunction, action, blockId, arr);
    });
 
 
    jQuery('#MyQuestions, #MyResponses').live('click', function(){
        jQuery('#MyQuestions, #MyResponses').removeClass("active");
        jQuery('#my_questions .inner').hide();
 
 
        $(this).parent().addClass("active");
        //$('#'+$(this).attr("id")+'-Content').show();
        var tp = $(this).attr('class');
        var ajaxFunction = 'FaqDashboard';
        var blockId = 'my_questions';
        var action = 'listFaq';
        var arr = {
            type: tp
        };
        xajax_call(ajaxFunction, action, blockId, arr);
 
        return false;
    });
 
    jQuery('#my_questions .remove').live('click', function(){
        var del = confirm("Confirmez vous la suppression ?");
        if (del) {
            var i = $(this).attr('id');
            $(this).parent().parent('li').css('display', 'none');
            var ajaxFunction = 'FaqDashboard';
            var blockId = '';
            var action = 'removeDashboard';
            var arr = {
                id: i
            };
            xajax_call(ajaxFunction, action, blockId, arr);
        }
 
        return false;
    });
        
    // FIN FAQ    
 
	jQuery(".delete-faq-question").live('click', function(){
		var del = confirm("Confirmez vous la suppression ?");
		if (del) {
          	var questionId = jQuery(this).attr("id");
            $(this).parent().parent('li').css('display', 'none');
            var ajaxFunction = 'FaqDashboard';
			 var blockId = '';
            var action = 'removeDashboard';
            var arr = {
                id: questionId
            };
            xajax_call(ajaxFunction, action, blockId, arr);
        }
		return false;
	});

 
//PAGINATION
    jQuery('.pagination a').live('click', function(){
 
 
        var id = $(this).attr('class');
        var ajaxFunction = jQuery("#ajaxFunction").val();
        var blockId = jQuery("#blockId").val();
        var action = jQuery("#action").val();
        var arr = {
            "p": id
        };
 
        if (ajaxFunction && blockId && action) {
 
            xajax_call(ajaxFunction, action, blockId, arr);
            return false;
        }
 
    });


});
  
 


