(function($) {
$.fn.jqpooop = function(){
    this.each( function(){
			alert(this);
    });
}

$.fn.jqpooop.options_default = {
		 Unique:true,
		 Top:0,
		 Left:0,
		 Mensaje:"Ninguno",
		 Position:"absolute",
		 Ajax:" ",
		 Id:"Id",
		 Left:"true",
		 Width:500,
		 Height:300,
		 Headmsg:"Alert message"
	},
$.extend({
	'load':function(urlajax){
		$.ajax({
			'url':urlajax,
			'cache': false,
			'dataType': 'html',
			'type':'GET',
			success: function(msg) {
				if (opc.Mensaje  == "") {
					var wd = 278;
					var hg = 120;
					var tabla = "url(./imagenes/tablaopina.png) no-repeat transparent";
					var nombre = "popup_opina";
				} else {
					var wd = 524;
					var hg = 320;
					var tabla = "url(./imagenes/tablaemail.png) no-repeat transparent";
					var nombre = "popup_email";
				}
				
				$('<div id="'+ opc.Id +'" class=\''+nombre+'\'><p>'+ msg +'</p><button id="botonpop'+ opc.Id +'" onclick="$(this).parent().remove()"><img src="imagenes/close.gif"/></button></div>').appendTo(document.body);
				var w = window.innerWidth ||document.documentElement.clientWidth || document.body.clientWidth;
				var h = window.innerHeight ||document.documentElement.clientHeight || document.body.clientHeight;
						
				w1 = wd;
				h1 = hg;
				$('#'+opc.Id).css("top",h1+"px");
				$('#'+opc.Id).css("left",w1+"px");
				$('#'+opc.Id).css("display","");
				$('#'+opc.Id).css("z-index","1000");
				$('#'+opc.Id).css("position","absolute");
				$('#'+opc.Id).css("background", tabla);
			}
		})
	}
});
$.jqpooop=function(options_user)
	{
		opc = $.extend( $.fn.jqpooop.options_default,options_user );
		if(opc.Unique==true && $('#'+opc.Id).length) { return false; }
		if(opc.Ajax!=''){
			this.load(opc.Ajax);	
				return false;
		}
		this.msg(opc.Mensaje);	
				return false;
	},
$.close=function(options_user)
	{
		opc = $.extend( $.fn.jqpooop.options_default,options_user );
		$('#'+opc.Id).remove();
	}
})(jQuery);


function enviar_amigo(localidad,provincia,pais,continente) {
	var mail2 = $("#mail2").val();
	var nombre = $("#nombre").val();
	if (mail2 == "") return;
	if (nombre == "") return;
	$.post("./email.php",{localidad:localidad,provincia:provincia,pais:pais,continente:continente,mail2:mail2,nombre:nombre},function(datos) {
		$("#formulario_email").parent().remove();});
}

function enviar_opinion() {
	var name = $("#name").val();
	var email_address = $("#email_address").val();
	var comments = $("#comments").val();
	if (name == "") return;
	if (email_address == "") return;
	if (comments == "") return;
	$.post("./opina.php",{name:name,email_address:email_address,comments:comments},function(datos) {
		$("#tabla_opinion_usuario").parent().remove();});
}

