function frank_footer_adjuster() {
    var myHeight = $('#Frank #content2').height() - 60;
    if ( myHeight < 60 )
        myHeight = 0;
    $('#Frank #pushdown').height( myHeight );
} 

function prepare_popups() {
    adjustPosition();
    
    if ( $('#burst') ) {
        $('#burst').fadeIn();    
        $('#burst').bind( "click", function() {
            $('#burst').toggle();
        });
    }
    
    if ( $('#print_container') ) {
        $('#print_container').fadeIn();
    }
    
    $(window).bind("scroll", function(){ adjustPosition(); } );
    $(window).bind("resize", function(){ adjustPosition(); } );    
}

function prepare_print() {
    if ( $('#burst') )
        $('#burst').hide();
    $('#print_container').hide();
    window.print();
    if ( $('#burst') )
        $('#burst').show();
    $('#print_container').show();
}

function adjustPosition() {
    if ( $('#burst') ) {
        $('#burst').css( "top", $(window).scrollTop() );
        $('#burst').css( "left", $(window).scrollLeft() );
    }
    
    if ( $('#print_container') ) {
        $('#print_container').css("top",$(window).scrollTop() );
        $('#print_container').css( "left", $(window).width() - $('#print_container').width() + $(window).scrollLeft()  - 30 );
    }
}

function validateForm() {
    
    var myErrors = new Array();
    var ctr = 0;
    var msg = "";
    
    if ( $('#customer-name').val() == "" ) myErrors[ctr++] = 'Full Name';
    if ( $('#customer-address').val() == "" ) myErrors[ctr++] = 'Address';
    if ( $('#customer-city').val() == "" ) myErrors[ctr++] = 'City';
    if ( $('#customer-state').val() == "" ) myErrors[ctr++] = 'State';
    if ( $('#customer-zip').val() == "" ) myErrors[ctr++] = 'Zip Code';
    if ( $('#customer-phone').val() == "" ) myErrors[ctr++] = 'Phone Number';
    if ( $('#customer-fax').val() == "" ) myErrors[ctr++] = 'Fax Number';
    if ( $('#customer-email').val() == "" ) myErrors[ctr++] = 'Email Address';
    if ( $('#customer-ccard-number').val() == "" ) myErrors[ctr++] = 'Credit Card Number';
    if ( $('#customer-ccard-expDate').val() == "" ) myErrors[ctr++] = 'Credit Card Expiration Date';
   
    if ( ctr > 0 ) {
        msg += "<p>Your form is not complete. Please fill in the following form fields:</p>"
        msg += "<ul>";
    
        for( var index = 0; index < ctr; index++ )
            msg += "<li class='error'>" + myErrors[index] + "</li>";
            
        msg += "</ul>";
        
        $(window).scrollTop(0);
        $(window).scrollLeft( ( $(window).width() / 2 ) - ( $('#error-container').width() / 2 ) );
        $('#error-container').html( msg ).show();
        
        return false;
    } else {
        return true;
    }
}  

function popup() {
	centerEverything();
			
	//$('#video object').css('display', 'none');
	$('#popup').css('left', $(window).scrollLeft() );
	$('#popup').css('top', $(window).scrollTop() );			
			
	$('#popup').css('display', 'block');
	$('#grayout').css('display', 'block');
			
	$(window).bind("scroll", function() {
		$('#popup').css('top', Math.abs( $(window).scrollTop() ) );
		$('#popup').css('left', Math.abs( $(window).scrollLeft() ) );
	});
			
	$(window).resize( function() { centerEverything(); });			
	$('#grayout').click( function(){ closePopup(); });	
}
		
function centerEverything() {
	$('#grayout').height( $(document).height() );
	$('#grayout').width( $(document).width() );
	$('#popup').css('margin-top', Math.abs($(window).height() / 2 - 198) );			
	$('#popup').css('margin-left', Math.abs($(window).width() / 2 - 486) );
}
		
function closePopup() {
	$('#popup').css('display', 'none');
	$('#grayout').css('display', 'none');
	$(window).unbind('scroll');
	$(window).unbind('resize');
	
	$.ajax( {
		type: "GET",
		url: "includes/video.php",
		success: function(msg) {
			$('#video').append(msg);
		}
	});
}