
function open_heure()
{
	document.getElementById('lightbox_content').style.display    = 'block';
	document.getElementById('lightbox_content').style.top        = '320px';
	if (document.body)
	{
		var larg = (document.body.clientWidth);
	}
	else
	{
		var larg = (window.innerWidth);
	}
	var xx = ( (larg - 747) / 2) +7;
	document.getElementById('lightbox_content').style.left       = xx+'px';
	document.getElementById('lightbox_content').style.width      = '730px';
	document.getElementById('lightbox_content').style.height     = '520px';
	window.onresize = function(event) {
        divposresize('lightbox_content', 7);
        divposresize('pubOko', 600);
    };
}

function open_addHeure(id,nb)
{    
    	var url      = "/index.php?action=ajax:ajax_credit_opendiv";
		var pars 	 = 'id='+id+'&nb='+nb;
		var div_area = "lightbox_content";
		
		var myAjax = new Ajax.Updater(
			div_area, 
			url, 
			{
				method			: 'post', 
				parameters		: pars,
				onComplete		: 
									function ajax_credituse_success()
									{
											open_heure();
									}
			}
		 );
}

function changequantitedecredit(nbheure)
{
	var url 	= '?module=diamancy&action=ajax:get_prix_unitaire';
	var myAjax = new Ajax.Request(
			url,
			{
				method: 'post',
				onComplete		: 
					function ajx_valid(myAjax)
					{
							if (myAjax.responseText == '0')
							{
								if (nbheure > 30)
								{
									document.getElementById('prixunitaire').value = '17';
								}
								else if (nbheure > 4)
								{
									document.getElementById('prixunitaire').value = '19';
								}
								else
								{
									document.getElementById('prixunitaire').value = '22';
								}
							}
							else
								document.getElementById('prixunitaire').value = myAjax.responseText;
								
							document.getElementById('total').value = nbheure * document.getElementById('prixunitaire').value;	
					}

			}
			); 
	
	
}

function close_addHeure(id,nb)
{
	document.getElementById('lightbox_content').style.display    = 'none';
	document.getElementById('lightbox_content').style.top        = '1px';
	document.getElementById('lightbox_content').style.left       = '1px';
	document.getElementById('lightbox_content').style.width      = '1px';
	document.getElementById('lightbox_content').style.height     = '1px';
	window.onresize = function(event) {};
}

function addcredit(nbheure)
{

		var url      = "/index.php?action=ajax:ajax_credit";
		var pars 	 = 'nbheure='+nbheure;

		var myAjax = new Ajax.Request(
			url, 
			{
				method			: 'post', 
				parameters		: pars,
				onComplete		: 
									function ajax_credit_success(myAjax)
									{								
                                            document.getElementById("lightbox_content").innerHTML = myAjax.responseText;
                                            document.getElementById("PAYBOX").submit();
									}
			}
		 );
}

function exec_use_credit(nbheure)
{
		var url      = "/index.php?action=ajax:ajax_credit_use";
		var pars 	 = 'nbheure='+nbheure;
		var div_area = "lightbox_content";
		
		var myAjax = new Ajax.Updater(
			div_area, 
			url, 
			{
				method			: 'post', 
				parameters		: pars,
				onComplete		: 
									function ajax_credituse_success()
									{
											open_heure();
									}
			}
		 );
}


function divposresize(my_box, toto)
{
	if (document.body)
	{
		var larg = (document.body.clientWidth);
	}
	else
	{
		var larg = (window.innerWidth);
	}
	if (larg > 747)
		var xx = ((larg - 747) / 2) + toto;
	else
		var xx = toto;
	document.getElementById(my_box).style.left = xx + 'px';
}

/*
function divposresize(event)
{
		if (document.body)
		{
			var larg = (document.body.clientWidth);
		}
		else
		{
			var larg = (window.innerWidth);
		}
		var xx = ( (larg - 789) / 2) + 15;
		document.getElementById('lightbox_content').style.left       = xx+'px';
}*/