// JavaScript Document

jQuery.fn.setttval = function(value){
	
	if(value!==''){
		return this.each(function() {				  
			var $this = jQuery(this);
			$this.val(value);
		});
	}
	
};

var selectArray = new Object();
var oldshow = '';
var oldclickshow = '';
var rconf = true;
if ( jQuery.browser.msie ) {
	var clicktrig = 'mousedown'
}else{
	var clicktrig = 'click'
}

selectArray['Category A - Meat Product'] = ".cf-fs1";
selectArray['Category B - Dairy Product'] = ".cf-fs2";
selectArray['Category C  - Baked & Confectionary Product'] = ".cf-fs3";
selectArray['Category D - Drink Product'] = ".cf-fs4";
selectArray['Category E - Fish & Seafood Product'] = ".cf-fs5";
selectArray['Category F - Horticulture'] = ".cf-fs6";
selectArray['Category G - Speciality Foods'] = ".cf-fs7";
selectArray['Category H - Food For Health'] = '.cf-fs8';

jQuery(document).ready( function () {

   jQuery("[id=cf36_field_3-2]").click( function() {
      jQuery(".cf-fs1").show("slow");
   });
   jQuery("[id=cf36_field_3-1]").click( function() {
     jQuery(".cf-fs1").hide("slow");
   });
   jQuery("#sendbutton46").attr("disabled", "disabled");
   jQuery("#cf46_field_3").change(function () {
     jQuery("#cf46_field_3 option:selected").each(function () {
       jQuery("#sendbutton46").attr("disabled", "disabled");
       jQuery('#cforms46form :checked').attr('checked',false);
       if ( oldshow != '' ) {
         jQuery(oldshow).hide("slow");
       }
       jQuery(selectArray[jQuery(this).val()]).show("slow");
       oldshow=selectArray[jQuery(this).val()];
      });

   });
 
   jQuery("#cforms46form .cf-fs3 input").click( function() {
          if(oldclickshow != this){
            jQuery(oldshow).attr("checked", false);
         }else{
            jQuery("#sendbutton46").attr("disabled", "disabled");
         }
         oldclickshow=this;
   });

  jQuery(".entryButton").click( function() {
    window.location.replace("http://www.truetaste.tv/index.php/enter-this-year/");
  });

  jQuery("#cforms46form input").click( function() {
    if((jQuery(this).attr('type') == "radio" || jQuery(this).attr('type') == "checkbox") && (jQuery(this).attr("checked") == true)){
      jQuery("#sendbutton46").removeAttr("disabled");
    }
   });
  
  jQuery("[id=cf29_field_3-2]").click( function() {
    jQuery(".cf-fs1").show("slow");
  });
  jQuery("[id=cf29_field_3-1]").click( function() {
    jQuery(".cf-fs1").hide("slow");
  });
  jQuery("#sendbutton25").attr("disabled", "disabled");
  jQuery("#cforms25form input#cf25_field_46").click( function() {
    if((jQuery(this).attr('type') == "checkbox") && (jQuery(this).attr('id') != "cf25_field_12")){
      var thischeck = this;
      if(oldshow != this){
        jQuery(oldshow).attr("checked", false);
      }else{
        jQuery("#sendbutton25").attr("disabled", "disabled");
      }
      oldshow=this;
    }
  });
  jQuery("#cforms25form input").click( function() {
    if((jQuery(this).attr('type') == "radio" || jQuery(this).attr('type') == "checkbox") && (jQuery(this).attr('id') != "cf25_field_12") && (jQuery(this).attr("checked") == true)){
      jQuery("#sendbutton25").removeAttr("disabled");
    }
  });

  jQuery("#cforms25form input#cf25_field_10").click( function() {
    if(jQuery(this).is(':checked')) {
      jQuery("fieldset.cf-fs3").show('slow');
    }else{
      jQuery("fieldset.cf-fs3").hide('slow');
    }
  });

  /*if(jQuery('input[name=cf32_field_3]').is(':checked')) {
    var id = jQuery('input[name=cf32_field_3]:checked').attr('id');
    supplementry(id);
  }

  jQuery('form input[name=cf32_field_3]').click( function(){
    var id = jQuery(this).attr('id');
    supplementry(id);
  });

  function supplementry(id) {
  
    if(id.substr(id.length -3, 1) == '3') {
      jQuery('.cf-fs2').show('slow');
    }

    if(id.substr(id.length -1, 1) == '2') {
      jQuery('#li-32-18, #li-32-19, #li-32-34').show();
      jQuery('#li-32-16').hide();
    } else if(id.substr(id.length -1, 1) == '6') {
      jQuery('#li-32-16').show();
      jQuery('#li-32-18, #li-32-19, #li-32-34').hide();
    } else {
      jQuery('#li-32-18, #li-32-19, #li-32-34, #li-32-16').hide();
    }
  };*/

  jQuery("[id=cf37_field_3-2]").click( function() {
    jQuery(".cf-fs1").show("slow");
  });
  
  jQuery("[id=cf37_field_3-1]").click( function() {
    jQuery(".cf-fs1").hide("slow");
  });
  
  jQuery("#sendbutton37").attr("disabled", "disabled");
  
  jQuery("#cforms37form input").click( function() {
    if((jQuery(this).attr('type') == "checkbox") && (jQuery(this).attr('id') != "cf37_field_12")){
      var thischeck = this;
      if(oldshow != this){
        jQuery(oldshow).attr("checked", false);
      }else{
        jQuery("#sendbutton37").attr("disabled", "disabled");
      }
      oldshow=this;
    }
  });
  
  jQuery("#cforms37form input").click( function() {
    if((jQuery(this).attr('type') == "radio" || jQuery(this).attr('type') == "checkbox") && (jQuery(this).attr('id') != "cf37_field_12") && (jQuery(this).attr("checked") == true)){
      jQuery("#sendbutton37").removeAttr("disabled");
    }
  });
jQuery('form.cform').filter(function(index){
	var mid = jQuery(this).attr('id');
	return (mid == 37 || mid == 32);
}).each(
	function(){
		jQuery.get("/form_autocomplete.php", { "func": "form_autocomplete" },function(data){
    if(data) {
      
      jQuery("#sendbutton37").removeAttr("disabled");
      
      if(data.nomination == '0') {
        jQuery('#cf36_field_3-1').attr('checked', true);
        jQuery('#cf29_field_3-1').attr('checked', true);
        jQuery('#cf37_field_3-1').attr('checked', true);
      } else if(data.nomination == '1') {
        jQuery('#cf36_field_3-2').attr('checked', true);
        jQuery('form#cforms36form .cf-fs1').show();
        jQuery('#cf29_field_3-2').attr('checked', true);
        jQuery('form#cforms29form .cf-fs1').show();
        jQuery('#cf37_field_3-2').attr('checked', true);
        jQuery('form#cforms37form .cf-fs1').show();
      }
      jQuery('#cf36_field_6').setttval(data.nominator_name);
      jQuery('#cf36_field_7').setttval(data.nominator_telephone);
      jQuery('#cf36_field_8').setttval(data.nominator_address1);
      jQuery('#cf36_field_9').setttval(data.nominator_address2);
      jQuery('#cf36_field_10').setttval(data.nominator_address3);
      jQuery('#cf36_field_11').setttval(data.nominator_postcode);
      jQuery('#cf36_field_12:not(.cf_error)').setttval(data.nominator_email);
      jQuery("input[value='" + data.entrant_title + "']").attr("checked", true);
      jQuery('#cf36_field_15:not(.cf_error)').setttval(data.entrant_forename);
      jQuery('#cf36_field_16:not(.cf_error)').setttval(data.entrant_surname);
      jQuery('#cf36_field_17:not(.cf_error)').setttval(data.entrant_job);
      jQuery('#cf36_field_18:not(.cf_error)').setttval(data.entrant_business);
      
      
      jQuery('#cf2_field_3:not(.cf_error)').setttval(data.business_address1);
      jQuery('#cf2_field_4:not(.cf_error)').setttval(data.business_address2);
      jQuery('#cf2_field_5:not(.cf_error)').setttval(data.business_address3);
      jQuery('#cf2_field_6:not(.cf_error)').setttval(data.business_postcode);
      jQuery('#cf2_field_7:not(.cf_error)').setttval(data.business_type);
      jQuery('#cf2_field_8:not(.cf_error)').setttval(data.business_telephone);
      jQuery('#cf2_field_9').setttval(data.business_fax);
      jQuery('#cf2_field_10:not(.cf_error)').setttval(data.business_email);
      jQuery('#cf2_field_11').setttval(data.business_website);
      jQuery("input[value='" + data.business_location + "']").attr("checked", true);
      
      jQuery("input[value='" + data.business_type_select + "']").attr("checked", true);
      jQuery('#cf3_field_5').setttval(data.business_type_text);
      jQuery('#cf3_field_6:not(.cf_error)').setttval(data.business_employees);
      
      jQuery('#cf40_field_4').setttval(data.business_food_acc);
      jQuery('#cf40_field_6').setttval(data.business_env_acc);
      
      jQuery('#cf29_field_6').setttval(data.nominator_name);
      jQuery('#cf29_field_7').setttval(data.nominator_telephone);
      jQuery('#cf29_field_8').setttval(data.nominator_address1);
      jQuery('#cf29_field_9').setttval(data.nominator_address2);
      jQuery('#cf29_field_10').setttval(data.nominator_address3);
      jQuery('#cf29_field_11').setttval(data.nominator_postcode);
      jQuery('#cf29_field_12:not(.cf_error)').setttval(data.nominator_email);
      jQuery("input[value='" + data.entrant_title + "']").attr("checked", true);
      jQuery('#cf29_field_15:not(.cf_error)').setttval(data.entrant_forename);
      jQuery('#cf29_field_16:not(.cf_error)').setttval(data.entrant_surname);
      jQuery('#cf29_field_17:not(.cf_error)').setttval(data.entrant_job);
      jQuery('#cf29_field_18:not(.cf_error)').setttval(data.entrant_business);
      
      
      jQuery('#cf30_field_3:not(.cf_error)').setttval(data.business_address1);
      jQuery('#cf30_field_4:not(.cf_error)').setttval(data.business_address2);
      jQuery('#cf30_field_5:not(.cf_error)').setttval(data.business_address3);
      jQuery('#cf30_field_6:not(.cf_error)').setttval(data.business_postcode);
      jQuery('#cf30_field_7:not(.cf_error)').setttval(data.business_type);
      jQuery('#cf30_field_8:not(.cf_error)').setttval(data.business_telephone);
      jQuery('#cf30_field_9').setttval(data.business_fax);
      jQuery('#cf30_field_10:not(.cf_error)').setttval(data.business_email);
      jQuery('#cf30_field_11').setttval(data.business_website);
      jQuery("input[value='" + data.business_location + "']").attr("checked", true);
      
      jQuery("input[value='" + data.business_type_select + "']").attr("checked", true);
      jQuery('#cf31_field_5').setttval(data.business_type_text);
      jQuery('#cf31_field_6:not(.cf_error)').setttval(data.business_employees);
      
      jQuery('#cf42_field_4').setttval(data.business_food_acc);
      jQuery('#cf42_field_6').setttval(data.business_env_acc);
      
      jQuery('#cf37_field_6').setttval(data.nominator_name);
      jQuery('#cf37_field_7').setttval(data.nominator_telephone);
      jQuery('#cf37_field_8').setttval(data.nominator_address1);
      jQuery('#cf37_field_9').setttval(data.nominator_address2);
      jQuery('#cf37_field_10').setttval(data.nominator_address3);
      jQuery('#cf37_field_11').setttval(data.nominator_postcode);
      jQuery('#cf37_field_12:not(.cf_error)').setttval(data.nominator_email);
      jQuery("input[value='" + data.entrant_title + "']").attr("checked", true);
      jQuery('#cf37_field_15:not(.cf_error)').setttval(data.entrant_forename);
      jQuery('#cf37_field_16:not(.cf_error)').setttval(data.entrant_surname);
      jQuery('#cf37_field_17:not(.cf_error)').setttval(data.entrant_job);
      jQuery('#cf37_field_18:not(.cf_error)').setttval(data.entrant_business);
      
      
      jQuery('#cf22_field_3:not(.cf_error)').setttval(data.business_address1);
      jQuery('#cf22_field_4:not(.cf_error)').setttval(data.business_address2);
      jQuery('#cf22_field_5:not(.cf_error)').setttval(data.business_address3);
      jQuery('#cf22_field_6:not(.cf_error)').setttval(data.business_postcode);
      jQuery('#cf22_field_7:not(.cf_error)').setttval(data.business_type);
      jQuery('#cf22_field_8:not(.cf_error)').setttval(data.business_telephone);
      jQuery('#cf22_field_9').setttval(data.business_fax);
      jQuery('#cf22_field_10:not(.cf_error)').setttval(data.business_email);
      jQuery('#cf22_field_11').setttval(data.business_website);
      jQuery("input[value='" + data.business_location + "']").attr("checked", true);
      
      jQuery("input[value='" + data.business_type_select + "']").attr("checked", true);
      jQuery('#cf23_field_5').setttval(data.business_type_text);
      jQuery('#cf23_field_6:not(.cf_error)').setttval(data.business_employees);
      
      jQuery('#cf43_field_4').setttval(data.business_food_acc);
      jQuery('#cf43_field_6').setttval(data.business_env_acc);
    }
  }, "json");
	}
);
  
  
  /*
   * FORM 32 -- Category L-P page 5.
   */
   
   var form32dependentfields = {
	   	'cf32_field_3' : {
						1 : new Array(3,7,8,9,10,11,12,14,15,16,25,26,27,29,30,31,32,34,35,39,40,42,43,45,47,48,49,50,51,53,54,55),
						2 : new Array(3,8,9,10,11,14,15,16,20,21,22,23,34,35,36,37,39,40,42,43,45,47,48,49,50,53,54,55),
						3 : new Array(3,7,8,9,10,11,12,14,15,16,25,26,27,29,30,31,32,34,35,39,40,42,43,45,47,48,49,50,51,53,54,55),
						4 : new Array(3,7,8,9,10,11,12,14,15,16,18,25,26,27,29,30,31,32,34,35,39,40,42,43,45,47,48,49,50,51,53,54,55),
						5 : new Array(3,7,8,9,10,11,12,14,15,16,25,26,27,29,30,31,32,34,35,39,40,42,43,45,47,48,49,50,51,53,54,55),
						6 : new Array(3,7,8,9,10,11,12,14,15,16,17,25,26,27,29,30,31,32,34,35,39,40,42,43,45,47,48,49,50,51,53,54,55)
						},
		'cf32_field_58':new Array(58,61,62,63,64,65,66,67,68),
		'cf32_field_71': {
						1 : new Array(71,77,78,79,81,82,83,86,87,88,89,90,91,92,93,94,96,97,98,100,101,102,104,105,106),
						2 : new Array(71,117,118,119,120,122,123,124,127,128,129,130,131,132,133,134,135,137,138,139,141,142,143,145,146,147),
						3 : new Array(71,117,118,119,120,122,123,124,127,128,129,130,131,132,133,134,135,137,138,139,141,142,143,145,146,147),
						4 : new Array(71,155,156,157,159,160,161,164,165,166,167,168,169,170,171,172,174,175,176,178,179,180,182,183,184)
						},
		'cf32_field_187':new Array(187,190,191,192,193,194,195,196,197,198,200,201,202,203,204,205,206,208,209,210)
   };
   
  // alert(typeof(form32dependentfields['cf32_field_187']))
  
 //alert(jQuery.isArray(form32dependentfields['cf32_field_3']))
 //alert(toString.call(form32dependentfields['cf32_field_3']) === "[object Object]")
   
  
  
  // FIELDSET 1 -- Category L.
  function form32GetArray(no) {
    var hide = null;
    
    switch ( no ) {
      case '1':
        hide = new Array(
          '#li-32-17',
          '#li-32-18',
          '#li-32-19',
          '#li-32-20',
          '#li-32-21',
          '#li-32-22',
          '#li-32-23',
          '#li-32-36',
          '#li-32-37'
        );
        break;
      case '2':
        hide = new Array(
          '#li-32-7',
          '#li-32-12',
          '#li-32-17',
          '#li-32-18',
          '#li-32-24',
          '#li-32-25',
          '#li-32-26',
          '#li-32-27',
          '#li-32-28',
          '#li-32-29',
          '#li-32-30',
          '#li-32-31',
          '#li-32-32',
          '#li-32-51'
        );
        break;
      case '3':
        hide = new Array(
          '#li-32-17',
          '#li-32-18',
          '#li-32-19',
          '#li-32-20',
          '#li-32-21',
          '#li-32-22',
          '#li-32-23',
          '#li-32-36',
          '#li-32-37'
        );
        break;
      case '4':
        hide = new Array(
          '#li-32-17',
          '#li-32-19',
          '#li-32-20',
          '#li-32-21',
          '#li-32-22',
          '#li-32-23',
          '#li-32-36',
          '#li-32-37'
        );
        break;
      case '5':
        hide = new Array(
          '#li-32-17',
          '#li-32-18',
          '#li-32-19',
          '#li-32-20',
          '#li-32-21',
          '#li-32-22',
          '#li-32-23',
          '#li-32-36',
          '#li-32-37'
        );
        break;
      case '6':
        hide = new Array(
          '#li-32-18',
          '#li-32-19',
          '#li-32-20',
          '#li-32-21',
          '#li-32-22',
          '#li-32-23',
          '#li-32-36',
          '#li-32-37'
        );
        break;
    }

    return hide;
  }
  
  // show CATEGORY L
  jQuery('#cforms32form .cf-fs1 input').bind(clicktrig, function(event) {
	if(oldclickshow != this){	
		
		
		form32HideFieldsets(this);
		var trconf = rconf;
		rconf = false;
		if(trconf==true){
			jQuery(this).trigger('triggerclick')
			jQuery(this).attr('checked',true);
		}else{
			event.preventDefault();
			jQuery(this).attr('checked',false);
			return false
		}
	}
		oldclickshow = this
	});
  
  	jQuery('#cforms32form .cf-fs1 input').bind('triggerclick', function() {
		jQuery('#cforms32form .cf-fs2 li').each(function() {
		  jQuery(this).css('display','list-item');
		});
		
		var id = jQuery(this).attr('id');
		id = id.split('-');
		id = id[1];
		
		var toHide = form32GetArray(id);
		
		jQuery('#cforms32form .cf-fs2').show('slow');
		
		if ( toHide != null ) {
		  while( toHide.length > 0 ) {
			var hide = toHide.pop();
			jQuery('#cforms32form .cf-fs2 li'+hide).css('display','none');
		  }
		}
	});
	  
  // show CATEGORY M
  jQuery("#cforms32form input#cf32_field_58").bind(clicktrig, function(event) {
	if(oldclickshow != this){
		
		form32HideFieldsets(this);
		var trconf = rconf;
		rconf = false;
		if(trconf==true){
			jQuery(this).trigger('triggerclick')
			jQuery(this).attr('checked',true);
		}else{
			event.preventDefault();
			jQuery(this).attr('checked',false);
			return false
		}
	}
	
	oldclickshow = this
  });
  
  jQuery("#cforms32form input#cf32_field_58").bind('triggerclick', function() {
		if(jQuery(this).is(':checked')) {
		  jQuery("fieldset.cf-fs4").show('slow');
		}
	});
  
  // show CATEGORY N
  jQuery('#cforms32form input[name=cf32_field_71]').bind(clicktrig, function(event) {
	
	if(oldclickshow != this){	
		
		
		form32HideFieldsets(this);
		var trconf = rconf;
		rconf = false;
		if(trconf==true){
			jQuery(this).trigger('triggerclick')
			jQuery(this).attr('checked',true);
		}else{
			event.preventDefault();
			jQuery(this).attr('checked',false);
			return false
		}
	}
	oldclickshow = this
  });
  
  jQuery('#cforms32form input[name=cf32_field_71]').bind('triggerclick', function() {
		var eid = jQuery(this).attr('id');
		if ( eid == 'cf32_field_71-1' ) {
		  jQuery('fieldset.cf-fs6').show('slow');
		} else if ( ( eid == 'cf32_field_71-2' ) || ( eid == 'cf32_field_71-3' ) ) {
		  jQuery('fieldset.cf-fs7').show('slow');
		} else if ( eid == 'cf32_field_71-4' ) {
		  jQuery('fieldset.cf-fs8').show('slow');
		}
	});
  
  // show CATEGORY O
  jQuery('#cf32_field_187').bind(clicktrig, function(event) {
	if(oldclickshow != this){	
	
		
		form32HideFieldsets(this);
		var trconf = rconf;
		rconf = false;
		if(trconf==true){
			jQuery(this).trigger('triggerclick')
			jQuery(this).attr('checked',true);
		}else{
			event.preventDefault();
			jQuery(this).attr('checked',false);
			return false
		}
	}
	oldclickshow = this
  });
  
 jQuery('#cf32_field_187').bind('triggerclick', function() {
		if ( jQuery(this).is(':checked') ) {
		  jQuery('fieldset.cf-fs10').show('slow');
		}
	});
  
  // hide OTHERS
  function form32HideFieldsets(element) {
	if(rconf == false){
		rconf=confirm("Only one category selection is permitted on each submission, if you change category now information entered at previous stages will remain, but some of the supplementary information you have completed on this screen may be discarded. Are you sure you wish to continue?");
	}
	if (rconf==true){
	
		var eid = jQuery(element).parents('li').attr('id');
		/*var ename = jQuery(element).attr('name');
		var evalue = jQuery(element).val();*/
		var noemptyarray = new Array();
		var indexid = jQuery(element).attr('id');
		indexidarray = indexid.split('-');
		indexname = indexidarray[0];
		indexid = indexidarray[indexidarray.length-1];
		if(typeof(form32dependentfields[indexname]) !== 'undefined'){
			if(jQuery.isArray(form32dependentfields[indexname])){
				nocleararray = form32dependentfields[indexname];
			}else{
				if(typeof(form32dependentfields[indexname][indexid]) !== 'undefined'){
					nocleararray = form32dependentfields[indexname][indexid];
				}
			}
		};
		var nocleararrayids = new Array();
		var len=nocleararray.length;
		for(var i=0; i<len; i++) {
			var fieldindex = nocleararray[i];
			nocleararrayids[i] = "cf32_field_"+nocleararray[i];
		}
		
		
		
		
		
		var toHide = new Array(
		  'fieldset.cf-fs2',
		  'fieldset.cf-fs4',
		  'fieldset.cf-fs6',
		  'fieldset.cf-fs7',
		  'fieldset.cf-fs8',
		  'fieldset.cf-fs10'
		);
		while ( toHide.length > 0 ) {
			  hide = toHide.pop();
			  //jQuery(hide+' input[type=text]').val('');
			  jQuery(hide+' input[type=text]').filter(function(index) {
				return jQuery.inArray(((jQuery(this).attr('id')).split('-'))[0], nocleararrayids) === -1;
			}).val('');
			  jQuery(hide+' input[type=checkbox]').filter(function(index) {
				return jQuery.inArray(((jQuery(this).attr('id')).split('-'))[0], nocleararrayids) === -1;
			}).attr('checked',false);
			  
			  jQuery(hide+' textarea').filter(function(index) {
				return jQuery.inArray(((jQuery(this).attr('id')).split('-'))[0], nocleararrayids) === -1;
			}).val('');
			  jQuery(hide+' input[type=radio]').filter(function(index) {
				return jQuery.inArray(((jQuery(this).attr('id')).split('-'))[0], nocleararrayids) === -1;
			}).attr('checked',false);
			  jQuery(hide+' input[type=file]').filter(function(index) {
				return jQuery.inArray(((jQuery(this).attr('id')).split('-'))[0], nocleararrayids) === -1;
			}).val('');
			  jQuery(hide).hide('slow');
		}
		
		if ( eid != 'li-32-3items' ) {
		  jQuery('#li-32-3items input').attr('checked',false);
		}
		if ( eid != 'li-32-58' ) {
		  jQuery('#li-32-58 input').attr('checked',false);
		}
		if ( eid != 'li-32-71items' ) {
		  jQuery('#li-32-71items input').attr('checked',false);
		}
		if ( eid != 'li-32-187' ) {
		  jQuery('#li-32-187 input').attr('checked',false);
		}
	  }
  }
   
   
   
   
   
   
   
   if(jQuery('body').find('#usermessage32a')){
	  var toClick = new Array(
      '#li-32-3items',
      '#li-32-58',
      '#li-32-71items',
      '#li-32-187'
    );
	 
	  while ( toClick.length > 0 ) {
		  checkclick = toClick.pop();
		  
	 	 jQuery(checkclick+" input:checked").trigger('triggerclick').attr('checked',true);
	  }
   }

  
  // END FORM 32

//PREVIEW FUNCTIONALITY
  
  jQuery('.preview').click(function(){
	  var form_data = jQuery('form').serialize();
	  jQuery.get( '/form_serialise.php', {async: 'false', data: form_data} );
	  jQuery('a.thickbox').click();
  });
  
  jQuery('input.preview').each(function(){
	  jQuery('p.cf-sb').addClass('preview-submit');
	  jQuery(this).parent('li').addClass('preview-submit');
  });
  
  
  //END PREVIEW FUNCTIONALITY

});
