var numero = '';
var perfil = 0;
var spltUrl = location.href.split('#');
var aurl = spltUrl[1];
//alert(location.href);


Event.observe(document, 'DOMContentLoaded', function(e) {
      onReady("");
    });



function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}


function decode_utf8( s )
{
  return decodeURIComponent( escape( s ) );
}


function onReady(str) {


if (spltUrl.length > 1) { 

$('ContenedorIzq_1').innerHTML = $('loading').value; 
navigate('ajax-'+aurl); 
return;
}

		var spltUrl2 = location.href.split('.com/');
		var aurl2 = spltUrl2[1];
				
				if (str.length > 0) {
				
				document.cookie = "type=1";
				document.cookie = "referer="+str; location.href = 'http://www.llamameamor.com';
				return;
				}
				
	if  ( aurl2.indexOf("anunciarse-proceso")==-1 && aurl2.indexOf("anunciantes")==-1) {
	
	
	var c ='';
	if (getCookie('type') == 1) {
	c = getCookie('referer')
	} else {
	c = decode_utf8(getCookie('referer'));
	}
	
		if (c.length > 0) {

			navigate('ajax-'+c);
			
			document.cookie = "referer=";
			document.cookie = "type=";
		} else {

			if (location.href != 'http://www.llamameamor.com/' && location.href != 'http://www.llamameamor.com') {
				if (aurl2.length > 0) { document.cookie = "referer="+aurl2; location.href = 'http://www.llamameamor.com'; }
			}
		}
	}
}

function ucwords( str ) {
    return (str+'').replace(/^(.)|\s(.)/g, function ( $1 ) { return $1.toUpperCase ( ); } );
}

function navigate(url) {

	var spltUrl2 = location.href.split('.com/');
	var aurl2 = spltUrl2[1];
		
	if (aurl2.indexOf("anunciarse-proceso")!=-1 || aurl2.indexOf("anunciantes")!=-1) {

onReady(url.replace("ajax-",""));
return;
	}

	var block = 0;
	
	$('ContenedorIzq_1').innerHTML = $('loading').value; 
	$('loading').show();
	

	titulo = url.replace(/(.html|-|menu|ajax|[0-9])/g, " "); 
	titulo = ucwords(titulo.replace(/^\s+|\s+$/g,''));

		document.title = 'llamameamor - Contactos eróticos en España, Agencia de publicidad scort, | '+titulo;
		

		

	if (url.match(/ajax-([0-9]+)-(mujeres|hombres|parejas|transexuales)-escorts-de-(.+).html/) != null) {
		block = 1;
		//navigatemenu('ajax-menu-inicio.html');

		
	} else if (url.match(/ajax-escorts-(inicio|mujeres|hombres|parejas|transexuales)-menu.html/) != null) {
		str = url.replace('-escorts-','-menu-');
		str = str.replace('-menu.html','.html');

		navigatemenu(str);
		url = url.replace('-menu.html','.html');
	
		
	} else if (url.match(/ajax-(zona-mix|revista|clubes|anunciarse-escorts).html/) != null) {
	navigatemenu('ajax-menu-inicio.html');
	} else if (url.match(/ajax-escorts-inicio.html/) != null) {
		navigatemenu('ajax-menu-inicio.html');
	}
	
	if (url.match(/ajax-([0-9]+)-(mujer|hombre|pareja|transexual)-(.+)-de-(.+).html/) != null) {
		$('publicidad').innerHTML = '';
		perfil = 1;
		block = 1;
	} else {
		$('publicidad').innerHTML = '<a href="anunciarse.html" onclick="navigate("ajax-anunciarse.html"); return false;"><img src="images/banner_publicitario.jpg" width="797" border="0" height="200" /></a>';
		perfil = 0;
	}

	new Ajax.Request(
			url, { 
			method: 'get',
			onSuccess: function(transport) { 

				$('ContenedorIzq_1').innerHTML = transport.responseText; 
				if (perfil == 1) {	
					$('text').show();
					$('num').show();
					
					if ($('vid').value == 1) {
						flowplayer("player", "jscript/flowplayer-3.0.3.swf",  { clip:{ autoPlay: false,  autoBuffering: true  } }); 
					}
				}
				
				
				if (url.substr(5).indexOf("panel")==-1) { new Effect.ScrollTo('botonera'); }

				location.href = '#'+url.substr(5);
				
			}
		}
	);
}

function fncmostrar(tipo, id) {

	var num = document.getElementById('num').innerHTML = $('numero').value;
	var text = document.getElementById('text').innerHTML = '';
	new Ajax.Request('index.php?ajax=num&tipo='+tipo+'&id='+id, { 
		method: 'get'
	});
}
function rst(request, name) {
	
if ($('correo').value.length == 0 || $('correo').value == 'correo@ejemplo.com') {
	new Effect.Shake('textocorreo'); 
} else {
	
	 str = 'index.php?ajax=mail&request='+request+'&name='+name+'&correo='+$('correo').value;

	new Ajax.Request(str, { 
		method: 'get'
	});

$('textocorreo').innerHTML='<br><font color="#000"><b>¡Gracias por recomendarme!</b></a>';


	}


	}
	
	
	
	
function navigatemenu(url) {

			new Ajax.Request(url, { 
		method: 'get',
		onSuccess: function(transport) { $('ContenedorCiudades').innerHTML = transport.responseText;}
	});

}








function fncPublicidad(i) {

	var typ = document.getElementById('pub').selectedIndex;
if (i == 2) { typ = 0; }
	var ayuda0 = Array('- Anuncio b&aacute;sico en la p&aacute;gina Web <br>- Hasta <b>4</b> fotograf&iacute;as.', 
	'- Anuncio <b>destacado</b> en portada de la Web.<br>- Hasta <b>8 fotograf&iacute;as</b><br>- Posibilidad de subir un <b>v&iacute;deo</b>.',
	'- Banner <b>giratorio destacado</b> en portada de la Web.<br>- Hasta <b>8 fotograf&iacute;as</b><br>- Posibilidad de subir un <b>v&iacute;deo</b>.',
	'- Incluye la <b>tarifa 2</b><br>- Banner <b>170x600 en el lateral (portada)</b>..', 
	'- Inlcuye la <b>tarifa 2</b><br>- Banner <b>797x167 en portada</b>.<br>- Gratis <b>tarifa 1 gratis</b> el siguiente més.');
var ayuda1 = Array('Tarifa 1',
	'Tarifa 2',
	'Tarifa 3',
	'Tarifa 4',
	'Tarifa 5');

	$('ayuda').innerHTML = eval("ayuda"+tipoTarifas+"["+typ+"]");
	var opt = 'no';
	if (typ > 0) {
		opt = 'ok';
		}
		for (i=5;i<=8;++i) {

			document.getElementById('ffoto'+i).src="images/"+opt+".jpg";

		}
	
	
	
}

var tipoTarifas = 0;
	function fncTarifas() {
		

var tar0 = Array('Tarifa 1 (24,90 €/mes)', 'Tarifa 2 (39,90 €/mes)', 'Tarifa 3 (69,90 €/mes)', 'Tarifa 4 (99,90 €/mes)', 'Tarifa 5 (59,90 €/mes)');
var tar1 = Array('Tarifa 1 (149,90 €/mes)','Tarifa 2 (214,90 €/mes)','Tarifa 3 (329,90 €/mes)','Tarifa 4 (490,90 €/mes)','Tarifa 5 (890,90 €/mes)');
	


	
	 tipoTarifas = document.getElementById('tarifa').selectedIndex;


	
              var sel = '<select id="pub" name="pub" class="User" onchange="fncPublicidad(1);">';

			  eval ("var m = tar"+tipoTarifas+".length;");
			  for (i=0;i<m;++i) {
				  sel += '<option value="'+i+'">'+eval("tar"+tipoTarifas+"["+i+"]")+'</option>';
			  }
			  
              sel += '</select>';
			  

$('con_pub').innerHTML = sel;
fncPublicidad(2);
	}
	
	
	function fncValidar(frm) {
		


		var cmposstr='';
		var campos = new Array('nombre', 'poblacion', 'texto', 'telefono');
		
		for (i=0;i<campos.length;++i) {
		
			if (document.getElementById(campos[i]).value.length == 0) {
				cmposstr = cmposstr+campos[i]+", ";
				
				 
			}
		}

		
		if (cmposstr.length > 1) {
			cmposstr = cmposstr.substr(0,cmposstr.length-2);
			alert('Los siguientes campos no fueron completados: '+cmposstr+'.');
			return false;
		}
		
	return true;

	}
