// JavaScript Document
  $(function () {
			var tabContainers = $('div.tabs > div');
			tabContainers.hide().filter(':first').show();
			
			$('div.tabs ul.tabNavigation a').click(function () {
				tabContainers.hide();
				tabContainers.filter(this.hash).show();
				$('div.tabs ul.tabNavigation a').removeClass('selected');
				$(this).addClass('selected');
				return false;
			}).filter(':first').click();
		});
 
		function checkContact()
		{
			if($("input[name=nume]").val() == ""){
						 $("input[name=nume]").focus(); 	
						 alert("Nu ati introdus numele!");
						 return false;
			}
			else if($("input[name=e_mail]").val() == "")
			{
					 $("input[name=e_mail]").focus(); 	
					 alert("Nu ati introdus adresa de email!");
					 return false;
			}
		}
	
	
	
this.imagePreview = function(){	
	/* CONFIG */
		
		xOffset = 10;
		yOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
 		
		var c = (this.t != "") ? "<br/>" + this.t : "";
 		
		$("body").append("<p id='preview'><img src='"+ this.rel +"' alt='Image preview' width='400'/>"+ c +"</p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


// starting the script on page load
$(document).ready(function(){
	imagePreview();
});

function selectModel(value)
{  
    $.ajax({
		      type     : "GET",
			  url      : "ajax/ajax.php",
			  data     : "pachet_model_id="+value,
			  success  : function(html){
				  
			            splitvars = html.split("##############");
						
						$("#pret_comanda").html(splitvars[0]);
						
				        
						
					    checks = document.getElementsByName("extra[]");
						
						for(i=0; i< checks.length; i++)
						{
						    checks[i].checked = false;
						}
		 	  }
		   })	
	
	$("#pagini_edit, .pags").css("display", "none");
						
	$("#email_edit").css("display", "none");
	
  	showPagini(value);
	showEmail(value);
}

function showPagini(value)
{
   	  $.ajax({
		      type     : "GET",
			  url      : "ajax/ajax.php",
			  data     : "pachet_pag_id="+value,
			  success  : function(html){
		                 $("#pagini").show("slow")
						 .html(html);
			  }
		   })	
}

function showEmail(value)
{
   	  $.ajax({
		      type     : "GET",
			  url      : "ajax/ajax.php",
			  data     : "pachet_email_id="+value,
			  success  : function(html){
		                  $("#email").show("slow")
						  .html(html);
			  }
		   })	
}

function ExtraPret(value)
{  
     if($('#'+value).is(':checked')) check = "da"; 
	 else check = "nu";

           $.ajax({
		      type     : "GET",
			  url      : "ajax/ajax.php",
			  data     : "extra_pret_id="+$('#'+value).val()+"&check="+check,
			  success  : function(html){
		                $("#pret_comanda").html(html);  
			  }
		   })	 	
}

function showDiv(id, id2)
{
   	 $("#"+id).show("slow");
	 $("#"+id2).hide();
}


function addPachetVal(val)
{
	 document.pachete.pachet_id.value = val;
	 
	 document.pachete.submit();
}

function ComandaModel(val)
{
	 document.model_form.model_id.value = val;
	
	document.model_form.submit();
}

