/* Author: 

*/

$(document).ready(function(){


//clear input

$("#clear-me").clearInput();
     

						   
//collapsible dealer table//

$('.hidable').hide();
    $('#dealers h2').addClass('openlist');

    $('#dealers h2').toggle(

        function(){
            $(this).next('.hidable').fadeIn();
            $(this).addClass('closelist');
            $(this).removeClass('openlist');
        },

        function(){
            $(this).next('.hidable').fadeOut();
            $(this).removeClass('closelist');
            $(this).addClass('openlist');
        }
        );//end of toggle
	
//end of dealer script//

	  $('#nav li').hover(
        function () {
            //show its submenu
            $('ul', this).slideDown(100);
 
        },
        function () {
            //hide its submenu
            $('ul', this).slideUp(100);        
        }
    );
	  
 $('#nav li').hover(
        function () {
            //show its submenu
            $('ul', this).slideDown(100);
 
        },
        function () {
            //hide its submenu
            $('ul', this).slideUp(100);        
        }
    );
 
 //Youtube close button position
    $('#close_btn').css('top', ( $(window).height()/2-$('#youtube-player').height()/2))-20;
    $('#close_btn').css('left', $(window).width()/2+$('#youtube-player').width()/2);

    //Youtube iframe position
    $('#youtube-player').css('top',  $(window).height()/2-$('#youtube-player').height()/2);
    $('#youtube-player').css('left', $(window).width()/2-$('#youtube-player').width()/2);

    //change position if the window is resized
    $(window).resize(function(){
        $('#youtube-player').css('top',  $(window).height()/2-$('#youtube-player').height()/2);
        $('#youtube-player').css('left', $(window).width()/2-$('#youtube-player').width()/2);
    });

	 $(window).resize(function(){
        $('#close_btn').css('top', ( $(window).height()/2-$('#youtube-player').height()/2))-20;
        $('#close_btn').css('left', $(window).width()/2+$('#youtube-player').width()/2);
    });

    //bind click event to youtube video button
    $('#index_vid').click(function(e){
        $('#cover').fadeIn();
        $('#youtube-player').fadeIn();
		$('#close_btn').fadeIn();
        e.preventDefault();
    })

	    //bind click event to youtube video button
    $('#close_btn').click(function(e){
        $('#cover').fadeOut();
        $('#youtube-player').fadeOut();
		$('#close_btn').fadeOut();
    })

$('#cover').click(function(){
    $('#close_btn').click();
});

 
 
 
	
		})

























