﻿
$.clientCoords = function() {
    var dimensions = { width: 0, height: 0, offsetTop: 0 };
    if (document.documentElement) {
        dimensions.width = document.documentElement.offsetWidth;
        dimensions.height = document.documentElement.offsetHeight;
        dimensions.offsetTop = document.documentElement.offsetTop;
    } else if (window.innerWidth && window.innerHeight) {
        dimensions.width = window.innerWidth;
        dimensions.height = window.innerHeight;
        dimensions.offsetTop = 0;
    }
    return dimensions;
}

function setAdPosition() {
    var w = $.clientCoords().width;
    var h = $.clientCoords().height;

    var adW = ((w - 820) / 2) + 820 + 10;

   
    //alert(adW);
    $('#ad').css('left', adW + 'px');

    var sTop = $(window).scrollTop();
    if (sTop >= 154) {
        $('#ad').css('top', sTop - 154 + 10 + 'px');
    } else { $('#ad').css('top', '10px');  }
}

/* dom ready */
$(function() {

    $('#cboTo').change(function() {
        var si = this.selectedIndex;
        if (si > 14) {
            $('#isToAirport').val('N');
        } else {
            $('#isToAirport').val('Y');
        }
        //alert($('#isToAirport').val());
    });

    $('#cboFrom').change(function() {
        var si2 = this.selectedIndex;
        if (si2 > 14) {
            $('#isFromAirport').val('N');
        } else {
            $('#isFromAirport').val('Y');
        }

       // alert($('#isFromAirport').val());
    });
	
	
	$('.txtDatetime').datepicker({ closeAtTop: false, currentText: 'Now', gotoCurrent: true, dateFormat: 'dd/mm/yy', minDate: 'Now' });

    var currentTime = new Date()
    var month = currentTime.getMonth() + 1
    var day = currentTime.getDate()
    var year = currentTime.getFullYear()

    //$('.txtDatetime').val(day + "/" + month + "/" + year);

    /*$.get('/Includes/ad.htm', 'html', function(data) {
        $('.w100').append(data);
        setAdPosition();
        //alert(data);
    });*/


    
    $(window).scroll(function(e) {
        //var offset = $('#ad').offset();
        //e.stopPropagation();
        //$('#ad').scroll().height;
        //$('#ad').scrollTop();


        //document.getElementById('ad').offsetTop = '10px';
        setAdPosition();
    });

    function doSomething() {
        setAdPosition();
    };

    var resizeTimer = null;
    $(window).bind('resize', function() {
        if (resizeTimer) clearTimeout(resizeTimer);
        resizeTimer = setTimeout(doSomething, 10);
    });



    /* $.post("http://weather.yahoo.com/London-United-Kingdom/UKXX0085/forecast.html?unit=c", function(data) {
    //var html = $('.forecast-temp', data).html();
    alert(data);
    });*/

    /*$("#links").load("/Main_Page #jq-p-Getting-Started li");*/


     $('input[name=rbCarType]:checked').each(function() {
        $('.ct').removeClass("selected");
        $(this).parent().addClass("selected");
    });


    $('.ct').click(function() {

        $('.ct').removeClass("selected");
        $(this).addClass("selected");

        $(this).children().attr('checked', true);

    });

    /*$('input[name=rbCarType]').change(function() {
    $('.ct').removeClass("selected");
    $(this).prev().addClass("selected");
    });*/

});



jQuery.isEmpty = function(mixedVar) {
    return (!mixedVar || !mixedVar.length || !mixedVar == '0');
}; 





function __trackEvent(category,action,labal,value){
    pageTracker._trackEvent(category,action,labal,value);
}
