// ================================ jump-menu ================================
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
// ================================ jump-menu ================================

// ================================ redirect =================================
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
// ================================ redirect =================================

// ================================ open window ==============================
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
// ================================ redirect =================================

$(function() {
	//$("a[rel^='prettyPhoto']").prettyPhoto({theme: 'facebook'});	
});
// ================================ show window ==============================
function show_en()
{
	$(".show_event").slideToggle('slow');	
}


 $(document).ready(function(){
							
		 
		$.datepicker.setDefaults($.datepicker.regional['']);
		$('#date_pick').datepicker({dateFormat: 'yy-mm-dd'});
		$("#date_pick").datepicker({ autoSize: true });

									
		
		//Cloden recipient entity					
		var counter=1;
		
   		$('#adauga-rec').click(function(){
										
						 counter ++;
						var cloned = $('#table-rec').clone();
						
						//clear values for each input element (text)
						cloned.find('input[type=text]').val('');
						cloned.find('input[type=hidden]').val('');
						cloned.find('input[type=checkbox]').removeAttr('checked');
						
   						//append to element
  						 cloned.appendTo('#table-rec-container').hide().fadeIn("slow");
						
										});
		
		$('.upgrade_package').click(function(){
											 var form_id=$(this).attr('id').replace('upgrade_package_','');
											 $('#upgrade_form_'+form_id).submit();
											 });
		
 });

function add_compl_prod()
{
	var code=$("#cod_prod_compl").val();
	$("<div class='text'>").load("aj_compl_prod.php", {'code':code},function(response) {
																					  
		if(response==false)
		{
      		alert('Codul introdus nu are nici un produs echivalent!');
		}
		else
		{
			
			$("#compl-prod-container").append($(this));
			$("#no-prod-box").css('display','none');
			
		}
} );
}

function add_package_prod()
{
	var code=$("#cod_prod").val();
	var cant=$("#cant_prod").val();
	$("<div class='text'>").load("aj_package_prod.php", {'code':code,'cant':cant},function(response) {
																					  
		if(response==false)
		{
      		alert('Codul introdus nu are ambalaj/recipient echivalent!');
		}
		else
		{
			
			$("#compl-prod-container").append($(this));
			$("#no-prod-box").css('display','none');
			
		}
} );
}


function del_prod_compl(id)
{
	
	$('#prod_'+id).css('display','none');
	$('#prod_'+id).find('input').val('');
}

