function popTB(caption, url, callback) {
	// height check goes here
	var h=$(window).height();
	if (h<750) { return true; }
	tb_show(caption, url, false, callback);
	return false;
}

var popFun = function() {
	//hide that annoying title bar
	//and do some other CSS manipulations
	$("#TB_title").css({display:"none"});
	$("p.pop, #formcontainer p, .column_checkboxes > p").css({
		"line-height":"1.1em",
		"margin":"2px 0 0px 0"
		});
	$("#.column_checkboxes").css({"margin":"2px 5px"});
	$("#TB_ajaxContent #two_column_wrap").css({height:"auto", "margin-botom":"0px"});
	//validate petition form
	var options = {
		target:	'#response',
		beforeSubmit: preSubmit,
		success: successCallback
	};
	$("#petition_form").validate({
		rules: {
			first_name: "required",
			last_name: "required",
			email: {
				required:true,
				email:true
			},
			zip: {
				required:true,
				minlength:5,
				maxlength:5,
				number:true
			}
		},
		messages: {
			first_name: "Please enter your first name",
			last_name: "Please enter your last name",
			email: "Please enter a valid email address",
			zip: "Please enter a 5 digit zip code"
		},
		submitHandler: function(form) {
			$(form).ajaxSubmit(options);
		}
	});
};	

var vidPop = function() {
	//some stylee action
	$("#TB_title").css({display:"none"});
	$("#TB_ajaxContent").css({"background-color":"#111"});
	//close button handler
	$("#close_me").click(function() {
		tb_remove();
	});
	
	// make the transparent png close button work in IE55 and IE6
	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
	if ($.browser.msie && (ie55 || ie6)) {
		var iepng = '/static/img/closex.png';
		$("#close_me").css('background-image', 'none');
		$("#close_me").get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iepng + "',sizingMethod='scale')";
	}

	var so = new SWFObject("http://mediamattersaction.org/static/freeride/flash/mediaplayer.swf", "display_video", '640', '380', '7');
	so.addParam('allowfullscreen', 'false');
	so.addParam('wmode', 'opaque');
	so.addVariable('file', 'http://mediamattersaction.org/static/video/fear-and-loathing-640x360.flv');
	so.addVariable('image', 'http://mediamattersaction.org/static/img/reports/fearandloathing/dummy-vid-screenshot.jpg');
	so.addVariable('usefullscreen', 'false');
	so.addVariable('showicons', 'true');
	so.addVariable('width', '640');
	so.addVariable('height', '380');
	so.addVariable('autostart', 'true');
	so.write('big_video');
};

function preSubmit() {
	$("#response").show();
	$("#formcontainer").hide();

	$("#TB_window").animate({height:'200px'}, 200);
	$("#TB_ajaxContent").animate({height:'155px'},200);
	$("#TB_iframeContent").animate({height:'200px'},200);
}
function successCallback() {
	$("#TB_window").animate({height:'600px'}, 200);
	$("#TB_ajaxContent").animate({height:'555px'},200);
	$("#TB_iframeContent").animate({height:'600px'},200);
	
}   

