/*** date and time ***/

$(document).ready(function() {

    setInterval(function() {
  
        var now = new Date();

        var weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
        var weekday = weekdays[now.getDay()];
        var month = now.getMonth() + 1;
        var day = now.getDate();
        var year = now.getFullYear();
        var hours = now.getHours();
        var minutes = now.getMinutes();
        var seconds = now.getSeconds();
        /* add 0 */
        if (month < 10) { month = '0' + month; }
        if (day < 10) { day = '0' + day; }
        if (hours < 10) { hours = '0' + hours; }
        if (minutes < 10) { minutes = '0' + minutes; }
        if (seconds < 10) { seconds = '0' + seconds; }

        var date = month + '-' + day + '-' + year;
        var time = hours + ':' + minutes + ':' + seconds;
        var holeDate = weekday + ', <br />' + date + ', <br />' + time;

        $('#date_time').html(holeDate);
        $('#date_time_highscore').html(holeDate);
    
    }, 1000);

});


/*** bottom / last updated ***/
$(document).ready(function() {
    $('#bottom').html('<br /><br /><br />&copy;2009. All Rights Reserved. Page last updated: 01-24-2010.');
    $('#background_bottom').html('<br /><br /><br />&copy;2009. All Rights Reserved. Page last updated: 01-24-2010.');
});



/*** drop down ***/

startList = function() {
    if (document.all && document.getElementById) {
        navRoot = document.getElementById('drop_down');
        for (i = 0; i < navRoot.childNodes.length; i++) {
            node = navRoot.childNodes[i];
            if (node.nodeName == 'li') {
                node.onmouseover = function() {
                    this.className += ' over';
                }
                node.onmouseout = function() {
                    this.className = this.className.replace(' over', '');
                }
            }
        }
    }
}
window.onload = startList;


/*$(document).ready(function() {
  $('#drop_down .more').mouseenter(function () {
          $(this).find('ul').show();
      });
  $('#drop_down .more ul').mouseleave(function () {
          $('#drop_down .more ul').hide();
      });
  $('#drop_down .current > a').mouseenter(function () {
          $('#drop_down .more ul').hide();
          $('#drop_down .current > li').show();
      });
});*/



/*** button design ***/

$(document).ready(function() {

    if(checkBrowserName('iPhone'))
    {
      $('.button_small').mousedown(function() {
          $(this).css('background', 'url(../images/form_button_small_iphone.png) no-repeat');
      }).mouseup(function() {
          $(this).css('background', 'url(../images/form_button_small_iphone.png) no-repeat');
      });
      
      $('.button_large').mousedown(function() {
          $(this).css('background', 'url(../images/form_button_large_iphone.png) no-repeat');
      }).mouseup(function() {
          $(this).css('background', 'url(../images/form_button_large_iphone.png) no-repeat');
      });
    }
    else
    {
      $('.button_small').mousedown(function() {
          $(this).css('background', 'url(../images/form_button_small_pressed.png) no-repeat');
      }).mouseup(function() {
          $(this).css('background', 'url(../images/form_button_small_hover.png) no-repeat');
      }).mouseenter(function() {
          $(this).css('background', 'url(../images/form_button_small_hover.png) no-repeat');
      }).mouseleave(function() {
          $(this).css('background', 'url(../images/form_button_small.png) no-repeat');
      });
      
      $('.button_large').mousedown(function() {
          $(this).css('background', 'url(../images/form_button_large_pressed.png) no-repeat');
      }).mouseup(function() {
          $(this).css('background', 'url(../images/form_button_large_hover.png) no-repeat');
      }).mouseenter(function() {
          $(this).css('background', 'url(../images/form_button_large_hover.png) no-repeat');
      }).mouseleave(function() {
          $(this).css('background', 'url(../images/form_button_large.png) no-repeat');
      });
    }

});



/*** pop-up_boxes ***/

$(document).ready(function() {

    $('.pop-ups span').hide();

    $('.pop-ups div').hover(function() {
        $(this).find('span').show();
    }, function() {
        $(this).find('span').hide();
    });

});


/*** contact form ***/

function checkBrowserName(browserName)
      {  
        var agent = navigator.userAgent.toLowerCase();  
        if (agent.indexOf(browserName.toLowerCase())>-1) 
        {  
          return true;  
        }  
        return false;  
      }

$(document).ready(function() {

    $('#contact #firstname').focus();
      
      $('form').submit(function() {
        var request = $('#request').val();
        var captcha_code = $('#captcha_code').val();
        
        if(checkBrowserName('iPhone'))
        {
          if (request == '' && captcha_code == '')
          {
            $('#no_request').css({'color' : 'red', 'margin-top':'-24px'}).html('<span class=\'text1_1\'>Your request is missing!</span>');
            $('#no_request + .request_area').css({'background':'url(../images/form_area_missing.png) no-repeat'});
            $('#no_captcha').css({'color' : 'red', 'margin-top':'-24px'}).html('<span class=\'text1_1\'>Please enter the captcha code!</span>');
            $('#no_captcha + input').css({'background':'url(../images/captcha_field_missing_iphone.png) no-repeat'});
            return false;
          }
          else if (request == '')
          {
            $('#no_request').css({'color' : 'red', 'margin-top':'-24px'}).html('<span class=\'text1_1\'>Your request is missing!</span>');
            $('#no_request + .request_area').css({'background':'url(../images/form_area_missing.png) no-repeat'});
            $('#no_captcha').css({'margin-top':'0'}).html('');
            $('#no_captcha + input').css({'background':'url(../images/captcha_field_iphone.png) no-repeat'});
            return false;
          }
          else if (captcha_code == '')
          {
            $('#no_captcha').css({'color' : 'red', 'margin-top':'-24px'}).html('<span class=\'text1_1\'>Please enter the captcha code!</span>');
            $('#no_captcha + input').css({'background':'url(../images/captcha_field_missing_iphone.png) no-repeat'});
            $('#no_request').css({'margin-top':'0'}).html('');
            $('#no_request + .request_area').css({'background':'url(../images/form_area.png) no-repeat'});
            return false;
          }
          else
          {
            return true;
          }
        }
        else
        {
          if (request == '' && captcha_code == '')
          {
            $('#no_request').css({'color' : 'red', 'margin-top':'-13px'}).html('<span class=\'text1_1\'>Your request is missing!</span>');
            $('#no_request + .request_area').css({'background':'url(../images/form_area_missing.png) no-repeat'});
            $('#no_captcha').css({'color' : 'red', 'margin-top':'-13px'}).html('<span class=\'text1_1\'>Please enter the captcha code!</span>');
            $('#no_captcha + input').css({'background':'url(../images/captcha_field_missing.png) no-repeat'});
            return false;
          }
          else if (request == '')
          {
            $('#no_request').css({'color' : 'red', 'margin-top':'-13px'}).html('<span class=\'text1_1\'>Your request is missing!</span>');
            $('#no_request + .request_area').css({'background':'url(../images/form_area_missing.png) no-repeat'});
            $('#no_captcha').css({'margin-top':'0'}).html('');
            $('#no_captcha + input').css({'background':'url(../images/captcha_field.png) no-repeat'});
            return false;
          }
          else if (captcha_code == '')
          {
            $('#no_captcha').css({'color' : 'red', 'margin-top':'-13px'}).html('<span class=\'text1_1\'>Please enter the captcha code!</span>');
            $('#no_captcha + input').css({'background':'url(../images/captcha_field_missing.png) no-repeat'});
            $('#no_request').css({'margin-top':'0'}).html('');
            $('#no_request + .request_area').css({'background':'url(../images/form_area.png) no-repeat'});
            return false;
          }
          else
          {
            return true;
          }
        }
      });/*form submit function*/
  
});/*document ready function*/