<?php 
  global $wpdb;
            global $post;
            global $wp_query;



            extract(
                shortcode_atts(
                    array(
                    'pid' => 1
                    ), $atts
                )
            );

            $res = $wpdb->get_row($wpdb->prepare('SELECT * from '. $this->popuptable.' where id= %d' , $pid));

            //$terms = apply_filters('the_content', $res->content);
            // print_r($res);
            $terms = nl2br($res->content);
            $terms = $this->lpShortcode($terms);

            $content = '<div>
                        '. do_shortcode($terms).'
                        <p ><input type="checkbox" name="lp_accept" id="lp_accept" value="1" onclick="jQuery(\'.accept\').toggle();" />I agree to the terms and conditions. now check
                        <input type="submit" name="lp_submit" id="lp_submit" value="Accept" class="accept" style="padding: 15px; display:none;"/></p>
                        <br/>
                    </div>';

            add_thickbox();


?>          





            <div id="thick-box" style="display:none;" >
                 <p> <?php echo $content; ?> </p>
            </div>
          


         <script type="text/javascript">

            jQuery(document).ready(function(){

                  <?php if ($setup_page_cookie) { ?>  
                        //if $setup_page_cookies is ture it mean jquery need to add cookies for this page
                        page_cookies_activate = true;
                        jQuery.cookie('lp_eu_terms_condition__popup_<?php echo $post_id ?>' , 'NOT_ACCEPTED', { expires: 7, path: '/' });


                     <?php } ?>



               if (jQuery.cookie('lp_eu_terms_condition__popup_'+<?php echo $post_id ?>) == "NOT_ACCEPTED") {
                      window.onload=function(){
                        tb_show("", "#TB_inline?width=600&height=550&inlineId=thick-box&modal=true", false);
                    }
                }

                jQuery("#lp_submit").click(function() {
                    jQuery.cookie('lp_eu_terms_condition__popup_'+ <?php echo $post_id ?>, 'ACCEPTED', { expires: 7, path: '/' });
                    jQuery('#lp_accept').prop('checked',false);
                    self.parent.tb_remove();
                });

                jQuery(window).load(function() {
                    if (jQuery.cookie('lp_eu_terms_condition__popup_'+<?php echo $post_id ?>) == null) {
                        if( jQuery(window).width() == 640 ){
                            window_width = 629;
                        }else{
                            window_width = jQuery(window).width();
                        }

                        if( TB_WIDTH > window_width ){
                            jQuery("#TB_window").css({marginTop: 0, marginLeft: 0, width: '90%', left: '5%',  top:'10%', height:'80%'});
                            jQuery("#TB_ajaxContent, #TB_iframeContent").css({width: 'auto', height:'80%'});
                            jQuery("#TB_closeWindowButton").css({fontSize: '1.2em', marginRight: '5px'});
                        }
                        else{
                            jQuery("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: 'auto'});
                        }

                    }
                });

            });
            </script>