jQuery.noConflict();

jQuery(document).ready(function() {
	jQuery(function(){
		jQuery("#cere_acum_dialog").dialog({
			bgiframe : true,
			autoOpen : false,
			height : 260,
			width : 300,
			modal : false,
			buttons: {
				'Trimite': function() {
					saveCereAcum();
				},
				'Renunta': function() {
					jQuery(this).dialog('close');
				}
			}
		});
	});
});

function cere_acum(premiu)
{
	jQuery('#dialog_error').hide();
	jQuery('#dialog_error_text').html('');
	jQuery('#dialog_nume').val(nume_elev);
	jQuery('#dialog_mesajul').val('Doresc sa intru in posesia premiului urmator: ' + premiu);
	jQuery('#dialog_premiu').val(premiu);
	jQuery('#cere_acum_dialog').dialog('option', 'title', 'Cere Acum');	
	jQuery('#cere_acum_dialog').dialog('open');
}

function saveCereAcum(){
	jQuery('#dialog_error').hide();
	jQuery('#dialog_error_text').html('');
	var numele = jQuery('#dialog_nume').val();
	var mesaj = jQuery('#dialog_mesajul').val();
	if(numele.length == 0)
	{
		jQuery('#dialog_error_text').html('Nu ati introdus numele');
		jQuery('#dialog_error').show();
	} else if(mesaj.length == 0) {
		jQuery('#dialog_error_text').html('Nu ati introdus mesajul');
		jQuery('#dialog_error').show();
	} else {
		jQuery.ajax({
			cache:'false',
			type:'POST',
			url:'catalog_premii.ajax.php',
			data:
			{
				op: 'send',
				premiu: jQuery('#dialog_premiu').val(),
				nume: numele,
				mesaj: mesaj
			},
			success: function(msg)
			{
				if (msg.substr(0, 2) == 'ok')
				{
					jQuery('#dialog_error_text').html('Cererea ta a fost trimisa');
					jQuery('#dialog_error').show();
					//window.setTimeout('jQuery("#cere_acum_dialog").dialog("close")', 2000);
				} else{
					jQuery('#dialog_error').show();
					jQuery('#dialog_error_text').html(msg);
				}
			}
		});
	}
}

function tab_premii_disponibile(obj)
{
	$$('ul.tabs li').each(function(s) { s.className = ''; });
	$(obj).className = 'activ';
	
	$('premii_achizitionate').hide();
	$('premii_disponibile').show();
}

function tab_premii_achizitionate(obj)
{
	$$('ul.tabs li').each(function(s) { s.className = ''; });
	$(obj).className = 'activ';

	$('premii_disponibile').hide();
	$('premii_achizitionate').show();
}

