$(document).ready(function(){
	$('#flash-wrapper').find('.module').remove();
	$('#flash').not($('.flash-275, #flash-voicebot, #flash-live-stream, #flash.no_flash.robot-question')).css('height', 485);
	$('.flash-275').css('height', 275);
	$('#flash-voicebot').css('height', 173);
	$('#flash-live-stream').css('height', 274);
	validateCommentForm();
});
$(window).bind("load", function(){  
	$(":submit").click(function(){
		//positionTheFooter();
		$('#footer').css('margin-top', '20px');
	});
});


function equalHeight(group) {
    tallest = 0;
    group.each(function() {
        thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}

/*
*	Validates the comments form
*/

function validateCommentForm(){
	if($("#commentform").size() > 0){
		$("#commentform").validate({
		  	errorPlacement: function(error, element) {
		    	error.hide().insertBefore(element.parent()).fadeIn('slow');
		   	},
			errorElement: "p",
			wrapper: "",
			messages: {
				author: {
					required: "Please enter your name",
					minlength: jQuery.format("At least {0} characters required!")
				},
				email: {
					required: "Please enter a valid email address",
					minlength: jQuery.format("At least {0} characters required!")
				},
				comment: {
					required: "Please enter your comment",
					minlength: jQuery.format("At least {0} characters required!")
				}
			}
		});
			
	}		
}


/*
*
*	Get co-ordinates of flash movie
*/
function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (1) {
            curleft+=obj.offsetLeft;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.x) {
        curleft+=obj.x;
    }
    return curleft;
}

function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (1) {
            curtop+=obj.offsetTop;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.y) {
        curtop+=obj.y;
    }
    return curtop;
}
function getCoords(obj) {
	var flashXPos = findPosX(document.getElementById('flash'));
	var flashYPos = findPosY(document.getElementById('flash'));

    return flashXPos+', '+flashYPos;
}

