$(document).ready(function(){
	// add a "rel" attrib if Opera 7+
	if(window.opera) {
		if ($(".jqbookmark").attr("rel") != ""){
			$(".jqbookmark").attr("rel","sidebar");
		} 
	}

	$(".jqbookmark").click(function(event){
		event.preventDefault();
		var url = this.href;
		var title = this.title;
		
		if (window.sidebar) { // Mozilla Firefox Bookmark
			window.sidebar.addPanel(title, url,"");
		} else if( window.external ) { // IE Favorite
			window.external.AddFavorite( url, title);
		} else if(window.opera) { // Opera 7+
			return false; // do nothing
		} else { 
			 alert('Unfortunately, this browser does not support the requested action,'
			 + ' please bookmark this page manually.');
		}
	
	});
	
	
});

function is_numeric(input){
    return !isNaN(input);
  }
  
function remove_error(){
	$("#error_div").remove();
}

function remove_succes(){
	$("#succes_div").remove();
}

function succes(msg){
	if(msg == undefined){
		$("body").append("<div id='succes_div'><div style='float:right'><img src='lumanari-images/delete.png' onclick='remove_succes();'></div><strong>SUCCES</strong> !<br><small>Informatiile au fost salvate cu succes</small></div>");
	}
	else{
		$("body").append("<div id='succes_div'><div style='float:right'><img src='lumanari-images/delete.png' onclick='remove_succes();'></div><strong>SUCCES</strong> !<br><small>"+msg+"</small></div>");
	}
	$("#succes_div").css("top", "100px");
    $("#succes_div").fadeIn("fast");
}

function error(ms){
	$("body").append("<div id='error_div'><div style='float:right'><img src='lumanari-images/delete.png' onclick='remove_error();'></div><strong>EROARE</strong> !<br><small>"+ms+"</small></div>");
	$("#error_div").css("top", "100px");
    $("#error_div").fadeIn("fast");
}

function mini_delete(who){
	var accept = 1;
	if( !is_numeric($.trim(who)) ){accept = 0;alert("Acest identificator numeric nu corespunde produselor noastre");}
	//alert("test");
	if(accept==1){
	// ajax
	 $.ajax({
		   type: "POST",
		   url: "cart_mini_delete.php",
		   data: "stergel="+who,	  
		   success: function(msg){ // arata rezultatul				
			   if($.trim(msg)=="da"){	
			   	$("#randul_"+who).fadeOut("slow",function(){
					 $("#randul_"+who).remove();	
					 window.location.href='index.php?cos'
					 });
				 
			   } // end if
		   }// end succes
		 });	
	}
}
