/*function openCalendar(FormElement){
	var calendarwindow;
	url = "calendar.html?formname=resform&formelement=" + FormElement;
	calendarwindow = window.open(url,"thewindow","toolbar=no,LEFT=700,TOP=400,WIDTH=180,HEIGHT=150,status=no,scrollbars=no,resize=no,menubar=no");
	calendarwindow.focus();
}*/
var headID = document.getElementsByTagName("head")[0];         
var newScript = document.createElement('script');
newScript.type = 'text/javascript';
newScript.src = '/scripts/blockui.js';
headID.appendChild(newScript);

function bottle() {
    if (!$('#bottle').length)
        $('body').append('<div id="bottle" style="display:none;"></div>');

    $('#bottle').load('/bottle.php').click($.unblockUI);

    $.blockUI({
        message: $('#bottle'),
        css: { 
            padding:        0, 
            margin:         0, 
            width:          '30%', 
            top:            ($(window).height() - $('#bottle').height()) / 2, 
            left:           ($(window).width() - $('#bottle').width()) / 2, 
            textAlign:      'center', 
            color:          '#000', 
            border:         'none', 
            backgroundColor:'transparent', 
            cursor:         'pointer' 
        },
        overlayCSS:  {
            cursor:          'pointer',
            backgroundColor: '#000', 
            opacity:         0.3 
        }
    });
    $('.blockOverlay').click($.unblockUI); 
}

function createRollovers() {
    var onText = "_on",
        offText = "_off";
 
    $('img.rollover').each( function() {

        var onImg = $(this).attr('src').replace(offText,onText),
            offImg = $(this).attr('src').replace(onText,offText);
        
        $(this).bind('mouseenter', function () {
            $(this).attr('src', onImg );
        });
        $(this).bind('mouseleave', function () {
            $(this).attr('src', offImg );
        });
    });
 
    return;
}

function createLinkTargets() {
    $('a.newWindow').each( function() {
        $(this).bind( 'click', function () {
            var newWindow = window.open($(this).attr('href'));
            return false;
        });
    });
    return;
}

function clearText(){
    if ($(this).defaultValue == $(this).value) {
	    $(this).value = ''
    } else if ($(this).value == '') {
	    $(this).value = $(this).defaultValue
    };
}

$(document).ready(function () {
    createRollovers();
    createLinkTargets();
    
    //$( 'input[type="text"]' ).bind( 'focusin', clearText() );
    //$( 'input[type="text"]' ).bind( 'focusout', clearText() );
    $('#bookingDate').datepicker();
    
    $('#bookingDate').bind('click', function () {
    	window.location.href = '#footer';
    });
    $('#bookingPickerButton').bind('click', function() {
    	window.location.href = '#footer';
    	$('#bookingDate').datepicker('show');
    });
});
