//////////////COOOOOOKIEEEEEEEEEEZZZZ....GIMME GIMME GIMME:p/////////////
				//wrote this code way to late at night...don't ask me in the morning about it:P
$(document).ready(function(){
				//one little botton, two little bottons...here zey are:next previous first last - page
				
					function sendGET(pagina_trimisa,variabila,divul){	
						$.ajax({
							  url: pagina_trimisa,
							  type: "GET",
							  data: variabila,
							  
							  statusCode: {
							  	404: function(){
							  		alert('page not found');
							  	}
							  },
					
							  success: function(result){
								 // alert(result);
								$(divul).html(result);
							  }
						});
					}
					function SetCookie(cookieName,cookieValue) {
										 var today = new Date();
										 var expire = new Date();
										 nDays=0.50;
										 expire.setTime(today.getTime() + 3600000*24*nDays);
										 //document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
										 document.cookie = cookieName + '=' + escape(cookieValue) + ";expires="+expire.toGMTString()+',path=/';
				}
				
				function getCookie(c_name){
										var i,x,y,ARRcookies=document.cookie.split(";");
										for (i=0;i<ARRcookies.length;i++)
										{
										  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
										  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
										  x=x.replace(/^\s+|\s+$/g,"");
										  if (x==c_name)
										  {
										    return unescape(y);
										  }
										}
				}
				
			
				function GetOferteSelectate(id_oferta){
									
					var c = getCookie("oferta");
					var oferte = "";
					var exista = 0;
																
					if(c == null || c == ""){
						
						SetCookie("oferta", id_oferta);
					}
					else{
					//check if the cockie has this id
						var c1 = getCookie("oferta").split("_");
						var l = c1.length;
						if(l < 10){
							var i = 0;
							while(i<l){
								if(c1[i] == id_oferta){
									exista = 1;
								//alert("oferta exista deja");
								}
								i++;
							}
							if(exista == 0){
								oferte = getCookie("oferta")+"_"+id_oferta;
								SetCookie("oferta", oferte);
								}
							else{
								alert("Ati selectat deja aceasta oferta");
								return false;
							}	
						}else{
							alert("Nu puteti selecta mai mult de 10 oferte!");
							return false;
						}
					}
					var toate_ofertele = getCookie("oferta");
					//alert(toate_ofertele);
					if(exista != 1){
						//alert(toate_ofertele);
						sendGET("oferte_selectate.php", "oferte="+toate_ofertele ,"#oferte_marcate");
						//alert("been sent");	
					}
				}
								
								
				$(".buton-marcheaza-oferta").click(function() {
					//alert($(this).attr("name"));
					var id_oferta = $(this).attr("name");
					GetOferteSelectate(id_oferta);
				});
								
				$('.buton-marcheaza-oferta').hover(
					function() {
						$(this).css('cursor','pointer');
						},
					function() {
						$(this).css('cursor','auto');
				});
				
				 
								
				
				
});//end on ready state function			

