//Dibuja un flash
function incluirFlash(x,y,file,contId)
{
	var so = new SWFObject('/swf/' + file, contId, x,y, '8','');
	so.addParam('scale', 'noscale');
	so.addParam('wmode', 'opaque');
	so.addParam('menu', 'false');
	so.write(contId);
}

function muestraObj(obj)
{
	if(document.getElementById(obj).style.display == 'none')
	{		
		document.getElementById('dvTexto').style.display = 'none';
		document.getElementById('dvOpciones').style.display = 'none';
		document.getElementById('dvMail').style.display = 'none';
		document.getElementById(obj).style.display = '';
	}
	else
	{
		document.getElementById('dvTexto').style.display = '';
		document.getElementById('dvOpciones').style.display = 'none';
		document.getElementById('dvMail').style.display = 'none';
		document.getElementById(obj).style.display = 'none';
	}
	return false;
}
//Mostrar mensaje
function muestraDiv(obj)
{
	document.getElementById('dvFondoNegro').style.display = '';
	document.getElementById(obj).style.display = '';
	return false;
}
function ocultaDiv(obj)
{
	document.getElementById('dvFondoNegro').style.display = 'none';
	document.getElementById(obj).style.display = 'none';
	return false;
}

function testMail(texto)
{
	if(texto.charAt(0) == '@') return false;
	if(texto.charAt(texto.length-1) == '@') return false;
			
	cont = 0;
	punto = false;
	for(i=0;i<texto.length;i++)
	{
		if(texto.charAt(i)=='@') cont ++;
		if(texto.charAt(i)=='.') punto = true;
		if(texto.charAt(i)==' ') return false;	
	}
	if (cont == 1 && punto) return true;
	return false;
}

function addBookmark(url, title)
{
	if (window.sidebar)
		return window.sidebar.addPanel(title, url, "");
	else if ( window.external )
		return window.external.AddFavorite( url, title);
	else if (window.opera && window.print)
		return true;
	return true;
}

function scroll2id(div)
{
	$('html,body').animate({ scrollTop: $('#' + div).offset().top}, 400);
}

function send2friend(frm)
{
	loadPopup('popup-msg.php','msg=<div style="text-align:center;"><img src="/img/load-mini.gif" alt="Espere"><br>Enviando, espere porfavor...</div>');

	$.ajax({
		type: 'POST',
		data: 'url=' + frm.tEnlace.value + '&camp=' + frm.tCamp.value + '&yo=' + frm.tMiNombre.value + '&mimail=' + frm.tMiMail.value + '&el=' + frm.tSuNombre.value + '&sumail=' + frm.tSuMail.value + '&texto=' + frm.tTexto.value,
		url : '/inc/aj/send-mail-share.php',
		success : function (data) 
		{	
			$('#dvPopup').html(data);
		}
	});
}
function send2campRes(frm)
{
	loadPopup('popup-msg.php','msg=<div style="text-align:center;"><img src="/img/load-mini.gif" alt="Espere"><br>Enviando, espere porfavor...</div>');
	acepta=0;
	if(frm.tAcepta.checked){acepta=1;}
	
	$.ajax({
		type: 'POST',
		data: 'camp=' + frm.tCamp.value + '&acepta=' + acepta + '&nombre=' + frm.tNombre.value + '&apellidos=' + frm.tApellidos.value + '&mail=' + frm.tMail.value + '&tlf=' + frm.tTlf.value + '&inicio=' + frm.tFInicio.value + '&fin=' + frm.tFFin.value + '&plazas=' + frm.tPlazas.value + '&info=' + frm.tInfo.value,
		url : '/inc/aj/send-mail-camp-res.php',
		success : function (data) 
		{	
			$('#dvPopup').html(data);
		}
	});

}

function send2campContact(frm)
{
	loadPopup('popup-msg.php','msg=<div style="text-align:center;"><img src="/img/load-mini.gif" alt="Espere"><br>Enviando, espere porfavor...</div>');
	acepta=0;
	if(frm.tAcepta.checked){acepta=1;}
	
	$.ajax({
		type: 'POST',
		data: 'camp=' + frm.tCamp.value + '&acepta=' + acepta + '&nombre=' + frm.tNombre.value + '&apellidos=' + frm.tApellidos.value + '&tlf=' + frm.tTelefono.value + '&mail=' + frm.tMail.value + '&consulta=' + frm.tConsulta.value,
		url : '/inc/aj/send-mail-camp-contact.php',
		success : function (data) 
		{	
			$('#dvPopup').html(data);
			
			$('#tNombre').val('');
			$('#tTelefono').val('');
			$('#tMail').val('');
		}
	});
}

function showPhoneContact(camp)
{	
	loadPopup('popup-msg.php','msg=<div style="text-align:center;"><img src="/img/load-mini.gif" alt="Espere"><br>Espere porfavor...</div>');
	$.ajax({
		type: 'POST',
		data: 'camp=' + camp,
		url : '/inc/aj/show-phone.php',
		success : function (data) 
		{	
			$('#dvPopup').html(data);
		}
	});
}
function showRePass()
{
	loadPopup('popup-msg.php','msg=<div style="text-align:center;"><img src="/img/load-mini.gif" alt="Espere"><br>Espere porfavor...</div>');
	$.ajax({
		type: 'POST',
		data: '',
		url : '/inc/aj/show-re-pass.php',
		success : function (data) 
		{	
			$('#dvPopup').html(data);
		}
	});
}

function sendRePass(frm)
{
	loadPopup('popup-msg.php','msg=<div style="text-align:center;"><img src="/img/load-mini.gif" alt="Espere"><br>Espere porfavor...</div>');
	$.ajax({
		type: 'POST',
		data: 'login=' + frm.tUsr.value + '&mail=' + frm.tMail.value,
		url : '/inc/aj/send-re-pass.php',
		success : function (data) 
		{	
			$('#dvPopup').html(data);
		}
	});
}

function send2SurfdestinyContact(frm)
{
	loadPopup('popup-msg.php','msg=<div style="text-align:center;"><img src="/img/load-mini.gif" alt="Espere"><br>Enviando, espere porfavor...</div>');
	acepta=0;
	if(frm.tAcepta.checked){acepta=1;}
	
	$.ajax({
		type: 'POST',
		data: 'camp=' + frm.tCamp.value + '&acepta=' + acepta + '&nombre=' + frm.tNombre.value + '&apellidos=' + frm.tApellidos.value + '&tlf=' + frm.tTelefono.value + '&mail=' + frm.tMail.value + '&consulta=' + frm.tConsulta.value,
		url : '/inc/aj/send-mail-surfdestiny.php',
		success : function (data) 
		{	
			$('#dvPopup').html(data);
		}
	});
}

function str_replace(busca, repla, orig)
{
	str 	= new String(orig);

	rExp	= "/"+busca+"/g";
	rExp	= eval(rExp);
	newS	= String(repla);

	str = new String(str.replace(rExp, newS));

	return str;
}

function showInfoDestino(img,nombre,desc,url)
{
	$.ajax({
		type: 'POST',
		data: 'img=' + img + '&nombre=' + nombre + '&desc=' + desc + '&url=' + url,
		url : '/inc/aj/map-info-window.php',
		success : function (data) 
		{	
			$('#dvMapResult').animate({'width':'450px'},'fast');
			$('#dvInfoMap').animate({'width':'200px','border':'1px solid #eeeeee'},'fast');
			$('#dvInfoMap').html(data);
		}
	});
}
function hideInfoDestino()
{
	$('#dvInfoMap').html('');
	$('#dvMapResult').animate({'width':'660px'},'fast');
	$('#dvInfoMap').animate({'width':'0px','border':'0'},'fast');
}