
Tengo un problema que para las nociones que tengo de Javascript me es imposible de solucionar.
El problema se repite en 2 códigos:
En el 1º;
He copiado un código en JS para crear una cuentras atrás para el lanzamiento de mi web.
el código es el siguiente;
Código PHP:
<script>
//variables que determinan la fecha y hora final de la cuenta atras
toYear=2012;
toMonth=03;
toDay=15;
toHour=10;
toMinute=00;
toSecond=00;
function countDown()
{
new_year=0;
new_month=0;
new_day=0;
new_hour=0;
new_minute=0;
new_second=0;
actual_date=new Date();
if(actual_date.getFullYear()>toYear)
{
//si ya nos hemos pasado del año, mostramos los valores a 0
form.second.value=0;
form.minute.value=0;
form.hour.value=0;
form.day.value=0;
form.month.value=0;
form.year.value=0;
}else{
new_second=new_second+toSecond-actual_date.getSeconds();
if(new_second<0)
{
new_second=60+new_second;
new_minute=-1;
}
form.second.value=new_second;
new_minute=new_minute+toMinute-actual_date.getMinutes();
if(new_minute<0)
{
new_minute=60+new_minute;
new_hour=-1;
}
form.minute.value=new_minute;
new_hour=new_hour+toHour-actual_date.getHours();
if(new_hour<0)
{
new_hour=24+new_hour;
new_day=-1;
}
form.hour.value=new_hour;
new_day=new_day+toDay-actual_date.getDate();
if(new_day<0)
{
x=actual_date.getMonth();
if(x==0||x==2||x==4||x==6||x==7||x==9||x==11){new_day=31+new_day;}
if(x==3||x==5||x==8||x==10){new_day=30+new_day;}
if(x==1)
{
//comprobamos si es un año bisiesto...
if(actual_date.getYear()/4-Math.floor(actual_date.getYear()/4)==0)
{
actual_date=29+actual_date;
}else{
actual_date=28+actual_date;
}
}
}
form.day.value=new_day;
new_month=-1;
new_month=new_month+toMonth-actual_date.getMonth();
if(new_month<0)
{
new_month=11+new_month;
new_year=-1;
}
form.month.value=new_month;
new_year=new_year+toYear-actual_date.getFullYear();
if(new_year<0)
{
form.year.value=0;
}else{
form.year.value=new_year;
//vuelve a ejecutar la funcion dentro de 1000 milisegundos = 1 segundo
setTimeout("countDown()",1000);
}
}
}
</script>
En el 2º;
Este es sobre google maps;
Código PHP:
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
<script type="text/javascript">
function initialize() {
var latlng = new google.maps.LatLng(varlat, varlong);
var settings = {
zoom: 15,
center: latlng,
mapTypeControl: true,
mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
navigationControl: true,
navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
mapTypeId: google.maps.MapTypeId.ROADMAP};
var map = new google.maps.Map(document.getElementById("map_canvas"), settings);
var contentString = '<div id="content">'+
'<div id="siteNotice">'+
'</div>'+
'<h1 id="firstHeading" class="firstHeading">Høgenhaug</h1>'+
'<div id="bodyContent">'+
'<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>'+
'</div>'+
'</div>';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
var companyImage = new google.maps.MarkerImage('../../../images/general/iconos/mapgoogle/logo.png',
new google.maps.Size(100,50),
new google.maps.Point(0,0),
new google.maps.Point(50,50)
);
var companyShadow = new google.maps.MarkerImage('../../../images/general/iconos/mapgoogle/logo_shadow.png',
new google.maps.Size(130,50),
new google.maps.Point(0,0),
new google.maps.Point(65, 50));
var companyPos = new google.maps.LatLng(varlat, varlong);
var companyMarker = new google.maps.Marker({
position: companyPos,
map: map,
icon: companyImage,
shadow: companyShadow,
title:"Høgenhaug",
zIndex: 1});
google.maps.event.addListener(companyMarker, 'click', function() {
infowindow.open(map,companyMarker);
});
}
</script>
Me imagino que ambos problemas están relacionados... ¿Alguien me puede guiar?
Un saludo muy grande y gracias de antemano!
