function displayRow(captionRow){
    var row = document.getElementById(captionRow);
	//var row = captionRow;
    if (row.style.display == '') row.style.display = 'none';
    else row.style.display = '';
}
 
function fto_preview_reload () {
	var f = document.getElementById('preview_frame');
	f.contentWindow.location.reload(true);
}

function fto_ajax_reload () {
	var poststr = jQuery("#fto_form").serialize();
	var nonce = jQuery("#_ajax_nonce").val() ;
	jQuery.post(jQuery("#refresh").attr("alt"),{action: 'fto_ajax_refresh', _ajax_nonce:nonce, data: poststr}, 
	   function(Data) {fto_preview_reload();}  
	
	);
		
	return false;
}






jQuery(document).ready(function(){
				
		jQuery('#footer_options').hide();
		jQuery('#preview').hide();
  		jQuery("#refresh").click( fto_ajax_reload);
		jQuery("#preview_h3").click(
										function() {if (jQuery("#preview").is(':hidden')){ jQuery("#preview").toggle("medium");fto_ajax_reload(); }else{jQuery("#preview").toggle("medium");} }
		);
//First lines stolen from WP Super Cache by Donncha O Caoimh (http://ocaoimh.ie/) 
//Clicking header opens fieldset options
    
		jQuery("fieldset h3").css("cursor","pointer").click(function(){
			jQuery(this).parent("fieldset").find("table").toggle("medium");
	   
		});
		
		if(jQuery('#hide_1').attr('checked'))  {
			jQuery('#hide_1_box').hide();
			jQuery('.header_color').attr('disabled','');
			jQuery('.header_color').css('background-color','#fff');
		}else{ 
			jQuery('#hide_1_box').show();
			jQuery('.header_color').attr('disabled','disabled');
			jQuery('.header_color').attr('value','');
			jQuery('.header_color').css('background-color','#eee');
		}
		
		
		if(jQuery('#hide_2').attr('checked'))  jQuery('#hide_2_box').hide(); else jQuery('#hide_2_box').show();
		if(jQuery('#hide_3').attr('checked'))  jQuery('#hide_3_box').hide(); else jQuery('#hide_3_box').show();
		if(jQuery('#hide_4').attr('checked'))  jQuery('#hide_4_box,#hide_4_box_2,#hide_4_box_3').hide(); else jQuery('#hide_4_box,#hide_4_box_2,#hide_4_box_3').show();
		if(jQuery('#hide_5').attr('checked'))  jQuery('#hide_5_box').hide(); else jQuery('#hide_5_box').show();
		
		
		jQuery('#hide_1').change(function() {
		if(jQuery('#hide_1').attr('checked')) {
			jQuery('#hide_1_box').hide();
			jQuery('.header_color').attr('disabled','');
			jQuery('.header_color').attr('value','');
			jQuery('.header_color').css('background-color','#fff');
		}else{
			jQuery('#hide_1_box').show();
			jQuery('.header_color').attr('disabled','disabled');
			jQuery('.header_color').attr('value','');
			jQuery('.header_color').css('background-color','#eee');
		}
		return true;
		});
		 
		jQuery('#hide_2').change(function() {
		if(jQuery('#hide_2').attr('checked'))
			jQuery('#hide_2_box').hide();
		else
			jQuery('#hide_2_box').show();
		return true;
		});
		 
		jQuery('#hide_3').change(function() {
		if(jQuery('#hide_3').attr('checked'))
			jQuery('#hide_3_box').hide();
		else
			jQuery('#hide_3_box').show();
		return true;
		});
		 
		jQuery('#hide_4').change(function() {
		if(jQuery('#hide_4').attr('checked'))
			jQuery('#hide_4_box,#hide_4_box_2,#hide_4_box_3').hide();
			
		else
			jQuery('#hide_4_box,#hide_4_box_2,#hide_4_box_3').show();
		return true;
		});
				
		jQuery('#hide_5').change(function() {
		if(jQuery('#hide_5').attr('checked'))
			jQuery('#hide_5_box').hide();
		else
			jQuery('#hide_5_box').show();
		return true;
		});
      });


