


function alertBoxDialog() {		
	this.oDialog="null";
	this.closeAction="null";
	
	this.show = function(title,content,closeAction) {
		if(closeAction!=undefined)
			this.closeAction=closeAction;
			
		this.oDialog = new YAHOO.widget.Dialog("AlertBox", { 	
											modal:true,
											fixedcenter : true,														 
											visible:false, 
											draggable:true,
											buttons : [ { text:"Fermer", handler:{ fn: this.handleCancel , scope: this} } ]	 
										} ); 
		this.oDialog.setHeader(title); 
		this.oDialog.setBody(content); 
		this.oDialog.setFooter(""); 
		this.oDialog.render("panels");
		this.oDialog.show();			
	}	
		
	this.handleCancel = function() {		
		this.oDialog.destroy();		
		if(this.closeAction!="null")
			eval(this.closeAction);
	}
}	

function confirmBoxDialog() {
	this.button1Action="null";
	this.button2Action="null";
	
	this.show = function(content,button1,button2,button1Action,button2Action,boxWidth) {		
		this.button1Action=button1Action;
		this.button2Action=button2Action;
		if(boxWidth==undefined)
			boxWidth="300px";
		
		
		this.oDialog=new YAHOO.widget.SimpleDialog("confirmBox",  
             { width: boxWidth, 
               fixedcenter: true, 
               visible: false, 
               draggable: false, 
               close: true, 
               text: content, 	          
	               constraintoviewport: true, 
	               buttons : [ 
								{ text:button1, handler:{ fn: this.handlebutton1 , scope: this} },
								{ text:button2 , handler:{ fn: this.handlebutton2 , scope: this} }
							 ]	 
	             } ); 

		this.oDialog.render("panels");
		this.oDialog.show();							 
	}

	this.handlebutton1 = function() {		
		this.oDialog.destroy();		
		if(this.button1Action!="null")
			eval(this.button1Action);
	}	
	this.handlebutton2 = function() {		
		this.oDialog.destroy();		
		if(this.button2Action!="null")
			eval(this.button2Action);
	}	
}


function ajaxPagination(url,container) {
		$.get(url, null,
			function(data){						
				$('#'+container).html(data);
			});		
}

alertBox=new alertBoxDialog();
confirmBox=new confirmBoxDialog();




 function ajaxFileUpload(id) {

	$("#loading")
	.ajaxStart(function(){
		$(this).show();
	})
	.ajaxComplete(function(){
		$(this).hide();
	});
	

	$.ajaxFileUpload
	(
		{
			url:'/uploadgabarit.php?id='+id, 
			secureuri:false,
			fileElementId:'gabarit',
			dataType: 'json',
			success: function (data, status)
			{
				if(typeof(data.error) != 'undefined')
				{
					if(data.error != '')
					{
						alert(data.error);
					}else
					{
						alert(data.msg);
					}
				}
			},
			error: function (data, status, e)
			{
				alert(e);
			}
		}
	)
	
	return false;

}  
		
	
toggleDetails = function (type) {
	switch(type) {
		case "soc":				
			$('#trsoc').show();
			break;
		case "part":
			$('#trsoc').hide();
			break;
	}
}
	
function FormMonCompteSubmit() {
	$('#moncompte').submit();
}





var mailContent="";
function mailPopup(email) {
	$.get('/templates/html/mail.php', {email: email},
		function(content) {						
			oDialog=new mailPopupDialog();
			oDialog.show(email,content);
		});	

}
function mailPopupDialog() {		
	this.oDialog="null";
	
	this.show = function(email,content) {

		
		
		this.oDialog = new YAHOO.widget.Dialog("MailBox", { 	
											modal:true,
											fixedcenter : true,														 
											visible:false, 
											draggable:true,
											buttons : [ { text:"Envoyer", handler:{ fn: this.handleSubmit , scope: this} },
														{ text:"Fermer", handler:{ fn: this.handleCancel , scope: this} }
													  ]	 
										} ); 
		this.oDialog.setHeader('Nous contacter'); 		
		this.oDialog.setBody(content); 
		this.oDialog.setFooter(""); 
		this.oDialog.render("panels");
		this.oDialog.show();			
	}	

	this.handleSubmit = function() {		
		message=$('#message').val();
		from=$('#from').val();
		sujet=$('#sujet').val();
		destinataire=$('#destinataire').val();
		$.get('/mail.php', {message: message, from:from,destinataire:destinataire,sujet:sujet},
			function(content) {			
				if(content==1)
					alertbox.show('Contactez nous','Votre mail à bien été envoyé');
			});
		this.oDialog.destroy();				
	}
	
	this.handleCancel = function() {		
		this.oDialog.destroy();		
		if(this.closeAction!="null")
			eval(this.closeAction);
	}
}	

function mcSignUp() {
	type=$('#type').val();
	societe=$('#societe').val();
	nom=$('#nom').val();
	prenom=$('#prenom').val();
	adresse=$('#adresse').val();
	codepostal=$('#codepostal').val();
	ville=$('#ville').val();
	pays=$('#pays').val();
	email_principal=$('#email_principal').val();
	email_facturation=$('#email_facturation').val();
	
}

function showAssistance() {
	oAssistance=new assistancePopup();
	oAssistance.show();
}

function assistancePopup() {
	this.show = function() {

		this.oDialog = new YAHOO.widget.Dialog("Assistance", { 	
											modal:false,
											fixedcenter : true,														 
											visible:false, 
											width:'200px',
											draggable:true,
											buttons : [ { text:"Fermer", handler:{ fn: this.handleCancel , scope: this} } ]	 
										} ); 
		this.oDialog.setHeader('Assistance en direct'); 		
		this.oDialog.setBody('<iframe src="/live.php" style="width:180px;height:300px;">'); 
		this.oDialog.setFooter("");
		this.oDialog.render("panels");
		
		this.oDialog.show();			
	}	

	
	this.handleCancel = function() {		
		this.oDialog.destroy();		
	}
}

function updateNewsStatus(id) {
		status =$('#'+id).attr('checked');		
		$.get('/admin/news/ajax/updatenewsstatus.php', {id: id, status:status},
			function(content) {						
				if(content==1)
					alertBox.show('Desactivation d\'une nouvelle','La nouvelle à bien été desactivée');
				else
					alertBox.show('Desactivation d\'une nouvelle','Erreur lors de la désactivation de la nouvelle');				
					
				document.location.href='/admin/news';	
			});	
}
