var JokeObj;
JokeObj = function(){
	this.AddVote = function(id){
		var ajax = ObjetoAjax();
		ajax.open("GET",URLWeb+"/Vote.php?id="+id,true);
		ajax.onreadystatechange = function(){
			if(ajax.readyState==4){
				var Response = ajax.responseText;
				if(Response == "ok"){
					var DivVote = document.getElementById("JokeVotes"+id);
					var Total = eval(DivVote.innerHTML) + 1;
					DivVote.innerHTML = Total;
					}
				else{
					alert(Response);
					}
				}
			}
		ajax.send(null);
		}
	this.AddFavorite = function(id){
		var ajax = ObjetoAjax();
		ajax.open("GET",URLWeb+"Favorites.php?Ajax=true&a=add&id="+id,true);
		ajax.onreadystatechange = function(){
			if(ajax.readyState==4){
				var Response = ajax.responseText;
				alert(Response);	
				}
			}
		ajax.send(null);
		}
	this.DeleteFromFavorites = function(id){
		var Confirm = confirm("¿ Realmente deceas borrar este chiste de tus favoritos ?");
		if(Confirm){
			document.location.href = URLWeb+"favoritos/borrar/"+id+".html";
			}
		}
	this.Delete = function(id){
		var Confirm = confirm("¿ Realmente deceas borrar el chiste definitivamente ?");
		if(Confirm){
			//document.location.href = URLWeb+"micuenta/administrar-chistes/editar-"+id+".html";
			document.location.href = URLWeb+"cuenta/administrar-chistes/borrar-"+id+".html";
			}
		}
	}
var Joke = new JokeObj();
function StringReplace(Orig,Search,Replace){
	while(Orig.indexOf(Search)!= -1){
		Orig = Orig.replace(Search,Replace);
		}
	return Orig;
	}	
function SubmitSearch(){	
	var SearchString = document.getElementById("SearchString").value;
	SearchString = StringReplace(SearchString," ","+");
	document.location.href = URLWeb+"buscar/"+SearchString;
	}