<?php
$base_qt_url = 'https://rental.software/quotes/';
if(strpos(get_site_url(), 'localhost') !== false){
    $base_qt_url = 'http://localhost/io/bugs/quotes/';
    //$base_qt_url = 'http://localhost/jbug/trunk/quotes/';
}
$seconds_to_cache = 0;
if($seconds_to_cache<=0) $nocache = ", no-cache";
$ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT";
header("Expires: $ts");
//header("Pragma: cache");
header("Pragma: no-cache");
header("Cache-Control: max-age=$seconds_to_cache".$nocache);
//setcookie("wpSGCacheBypass", 1, time()+3600,"/");
setcookie(
        "wpSGCacheBypass",
        1,
        [
                'expires'  => time() + 3600,
                'path'     => '/',
                'domain'   => '',         // leave empty to use current host; set explicitly if needed
                'secure'   => true,       // only send over HTTPS
                'httponly' => true,       // inaccessible to JS
                'samesite' => 'Lax'       // or 'Strict' or 'None' (None requires Secure)
        ]
);

add_filter( 'wp_robots', function( $robots ) {
    $robots['noindex'] = true;
    return $robots;
} );

//note - WP returns 404 of post/get param contain https://codex.wordpress.org/Reserved_Terms
$wp_reserved = Array();
$wp_reserved[] = 'attachment';
$wp_reserved[] = 'attachment_id';
$wp_reserved[] = 'author';
$wp_reserved[] = 'author_name';
$wp_reserved[] = 'calendar';
$wp_reserved[] = 'cat';
$wp_reserved[] = 'category';
$wp_reserved[] = 'category__and';
$wp_reserved[] = 'category__in';
$wp_reserved[] = 'category__not_in';
$wp_reserved[] = 'category_name';
$wp_reserved[] = 'comments_per_page';
$wp_reserved[] = 'comments_popup';
$wp_reserved[] = 'custom';
$wp_reserved[] = 'customize_messenger_channel';
$wp_reserved[] = 'customized';
$wp_reserved[] = 'cpage';
$wp_reserved[] = 'day';
$wp_reserved[] = 'debug';
$wp_reserved[] = 'embed';
$wp_reserved[] = 'error';
$wp_reserved[] = 'exact';
$wp_reserved[] = 'feed';
$wp_reserved[] = 'hour';
$wp_reserved[] = 'link_category';
$wp_reserved[] = 'm';
$wp_reserved[] = 'minute';
$wp_reserved[] = 'monthnum';
$wp_reserved[] = 'more';
$wp_reserved[] = 'name';
$wp_reserved[] = 'nav_menu';
$wp_reserved[] = 'nonce';
$wp_reserved[] = 'nopaging';
$wp_reserved[] = 'offset';
$wp_reserved[] = 'order';
$wp_reserved[] = 'orderby';
$wp_reserved[] = 'p';
$wp_reserved[] = 'page';
$wp_reserved[] = 'page_id';
$wp_reserved[] = 'paged';
$wp_reserved[] = 'pagename';
$wp_reserved[] = 'pb';
$wp_reserved[] = 'perm';
$wp_reserved[] = 'post';
$wp_reserved[] = 'post__in';
$wp_reserved[] = 'post__not_in';
$wp_reserved[] = 'post_format';
$wp_reserved[] = 'post_mime_type';
$wp_reserved[] = 'post_status';
$wp_reserved[] = 'post_tag';
$wp_reserved[] = 'post_type';
$wp_reserved[] = 'posts';
$wp_reserved[] = 'posts_per_archive_page';
$wp_reserved[] = 'posts_per_page';
$wp_reserved[] = 'preview';
$wp_reserved[] = 'robots';
$wp_reserved[] = 's';
$wp_reserved[] = 'search';
$wp_reserved[] = 'second';
$wp_reserved[] = 'sentence';
$wp_reserved[] = 'showposts';
$wp_reserved[] = 'static';
$wp_reserved[] = 'subpost';
$wp_reserved[] = 'subpost_id';
$wp_reserved[] = 'tag';
$wp_reserved[] = 'tag__and';
$wp_reserved[] = 'tag__in';
$wp_reserved[] = 'tag__not_in';
$wp_reserved[] = 'tag_id';
$wp_reserved[] = 'tag_slug__and';
$wp_reserved[] = 'tag_slug__in';
$wp_reserved[] = 'taxonomy';
$wp_reserved[] = 'tb';
$wp_reserved[] = 'term';
$wp_reserved[] = 'terms';
$wp_reserved[] = 'theme';
$wp_reserved[] = 'title';
$wp_reserved[] = 'type';
$wp_reserved[] = 'w';
$wp_reserved[] = 'withcomments';
$wp_reserved[] = 'withoutcomments';
$wp_reserved[] = 'year';

//print_r($_SERVER);
//$io_locationid = get_option('io_locationid');
$io_pagename = get_option('io_pagename');

$page_name = urlencode($io_pagename);//'Demo+Rentals+LLC';
$page_name = '&name='.$page_name;

//$page_type = 'quoteme';//defined in the theme page
//$params = '&'.$_SERVER['QUERY_STRING'];
$params = '&' . ltrim($_SERVER['QUERY_STRING'], '&');
$params = preg_replace('/(^|&)nowrap(?:=[^&]*)?/i', '', $params); // remove any nowrap
$params = preg_replace('/&&+/', '&', $params);
$params = preg_replace('/\?&/', '?', $params);
$params = rtrim($params, '&');

if(get_option('io_multistep')=='on'){
    $params = str_replace('wp_checkout=0','',$params);
    $params .= '&wp_checkout=1';
}elseif(get_option('io_multistep')=='off'){
    $params = str_replace('wp_checkout=1','',$params);
}
//allows the single-page check-out to be available
if(strpos($params,'&wp_checkout=2')!==FALSE){
    $params = str_replace('wp_checkout=1','',$params);
    $params .= '&wp_checkout=0';
}
$params = str_replace('?&','?',$params);
$params = str_replace('&&','&',$params);
//$params = str_replace('&nowrap=1','',$params);//need to remove it or it won't redirect back

if(strpos($params,'io_name=')!==FALSE){
    $page_name = '';//override with passed in one
    $params = str_replace('io_name=','name=',$params);
}
// IO-28339 add additional
// IO-28339 get via function
$io_url_params = get_option('io_url_params');
if ($io_url_params !== null) {
    $io_url_params = json_decode($io_url_params, true);
    if (is_array($io_url_params)) {
        foreach ($io_url_params as $io_url_param) {
            if (isset($_COOKIE[$io_url_param['urlparam_cookiename']]) && strpos($params, '&' . $io_url_param['urlparam_paramname'] . '=') === FALSE) {
                $params .= '&' . $io_url_param['urlparam_paramname'] . '=' . urlencode(stripslashes($_COOKIE[$io_url_param['urlparam_cookiename']]));
            }
        }
    }
}
if(isset($_COOKIE['quoteid']) && strpos($params,'&qid=')===FALSE) $params.='&qid='.$_COOKIE['quoteid'];
if(isset($_COOKIE['contactid']) && strpos($params,'&cid=')===FALSE) $params.='&cid='.$_COOKIE['contactid'];
$cust_ip = $_SERVER['REMOTE_ADDR'];
if(!empty($_SERVER['HTTP_CLIENT_IP']) && filter_var($_SERVER['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP)) $cust_ip = $_SERVER['HTTP_CLIENT_IP'];
if(!empty($_SERVER['HTTP_X_FORWARDED_FOR']) && filter_var($_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP)) $cust_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
if(!empty($_SERVER['HTTP_X_SUCURI_CLIENTIP']) && filter_var($_SERVER['HTTP_X_SUCURI_CLIENTIP'], FILTER_VALIDATE_IP)) $cust_ip = $_SERVER['HTTP_X_SUCURI_CLIENTIP'];
$ips = explode(',', $cust_ip, 2);
$cust_ip = urlencode(trim($ips[0]));
// Want to keep these hidden from our ajax call.
//if(strpos($params,'&io_custip=')===FALSE) $params.='&io_custip='.$cust_ip;
//if(isset($_COOKIE['guid']) && strpos($params,'&io_custguid=')===FALSE) $params.='&io_custguid='.$_COOKIE['guid'];
$link = $base_qt_url.$page_type.'.php?nowrap=1'.$page_name.$params;
$guid = isset($_COOKIE['guid']) ? $_COOKIE['guid'] : '';
$link .= '&io_custip='.$cust_ip.'&io_custguid='.$guid;
//echo $link;exit;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {

    foreach($_POST as $k=>$v){
        if(strpos($k,'iowp_')!==FALSE){
            $_POST[str_replace('iowp_','',$k)] = $v;
            unset($_POST[$k]);
        }else{//if(get_magic_quotes_gpc()){
            $_POST[$k] = stripslashes($_POST[$k]);
        }
    }

    // IO-24152 Since the tmp file from $_FILES will be cleared by the time we run quoteme.php, lets encode it here and pass it along in post.
    if(!empty($_FILES)){
        $_POST['uploaded_file_data'] = [];
        foreach ($_FILES as $n => $file) {
            $file_path = $file['tmp_name'];
            $file_path = trim($file_path);
            if(empty($file_path)) continue;
            $img = file_get_contents($file_path);
            $file_enc = base64_encode($img);
            $_POST['uploaded_file_data'][] = array("name"=>$file['name'],"base64_enc"=>$file_enc);
        }
    }

    function curlResponseHeaderCallback($ch, $headerLine) {
        if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) {
            //echo $headerLine;
            header($headerLine,false);
            //setcookie('test',1);
        }
        return strlen($headerLine); // Needed by curl
    }
    $curl_url = $link;
    $ch = curl_init();
    //curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);
    curl_setopt($ch, CURLOPT_HEADERFUNCTION, "curlResponseHeaderCallback");
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($_POST));
    // Append IP and GUID here so the information is passed via curl, but is not passed over during ajax call.
    curl_setopt($ch, CURLOPT_URL, $curl_url);
    $html = curl_exec($ch);
    //get new redirected URL so our posts point to the right spot
    $old_link = $curl_url;//old_link = page we are posting to
    $link_fromcurl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); //new link var is the page we are redirecting to
    //#6327 redirect URL
    $link_local = $link_fromcurl;
    $site_url = get_site_url();
    $link_local = str_replace($base_qt_url.'quote_done.php',$site_url.'/io_quotedone/',$link_local);
    $link_local = str_replace($base_qt_url.'quote_confirm.php',$site_url.'/io_quoteconfirm/',$link_local);
    $link_local = str_replace($base_qt_url.'contractme.php',$site_url.'/io_contract/',$link_local);
    $link_local = str_replace('https://eventoffice.io/quotes/quote_done.php',$site_url.'/io_quotedone/',$link_local);
    $link_local = str_replace('https://eventoffice.io/quotes/quote_confirm.php',$site_url.'/io_quoteconfirm/',$link_local);
    $link_local = str_replace('https://eventoffice.io/quotes/contractme.php',$site_url.'/io_contract/',$link_local);
    $link_local = str_replace('https://www.inflatableoffice.com/quotes/quote_done.php',$site_url.'/io_quotedone/',$link_local);
    $link_local = str_replace('https://www.inflatableoffice.com/quotes/quote_confirm.php',$site_url.'/io_quoteconfirm/',$link_local);
    $link_local = str_replace('https://www.inflatableoffice.com/quotes/contractme.php',$site_url.'/io_contract/',$link_local);
    if($link_fromcurl<>$old_link){
        $link_local = str_replace('name=','io_name=',$link_local);
        $link_local = str_replace('&nowrap=1','',$link_local);
        header('Location: ' . $link_local);
        exit;
    }
}else{
    //$html = file_get_contents($link);
    $ctx = stream_context_create(['http'=>[
            'timeout'=>30,
            'header'=>"Connection: close\r\nUser-Agent: ".$_SERVER['HTTP_USER_AGENT']."\r\n",
    ]]);
    $html = @file_get_contents($link, false, $ctx);

    if(empty($html)){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $link);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        // IO-25490: Allow cURL to follow redirects via Location header
        // Additional considerations for this cURL call: CURLOPT_MAXREDIRS,
        // CURLOPT_TIMEOUT, CURLOPT_CONNECTTIMEOUT
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        $html = curl_exec($ch);
        curl_close($ch);
    }
    if(empty($html)){
        // IO-29000
        $link = str_replace('&nowrap=1','',$link);
        $link = str_replace('nowrap=1','',$link);
        $link .= "&no_redirect=1";
        header('Location: ' . $link);//unable to host locally due to firewall or something
        exit;
    }
}

//$html = preg_replace("/<!DOCTYPE([^>]*)>/", " ", $html);
$dom = new DOMDocument;
$encod  = mb_detect_encoding($html,["UTF-8", "ASCII", "ISO-8859-1", "Windows-1252", "UTF-16", "UTF-32"]);;
$headpos = mb_strpos($html,'<head>');
if(FALSE=== $headpos)
    $headpos= mb_strpos($html,'<HEAD>');
if(FALSE!== $headpos) {
    $headpos+=6;
    $html = mb_substr($html,0,$headpos) . '<meta http-equiv="Content-Type" content="text/html; charset='.$encod.'">' .mb_substr($html,$headpos);
}
$html=mb_convert_encoding($html, 'HTML-ENTITIES', $encod);
if(!empty($html)) @$dom->loadHTML($html, LIBXML_HTML_NODEFDTD);
$tags = $dom->getElementsByTagName('a');
foreach($tags as $a) {
    $url=$a->getAttribute('href');
    if(empty($url) | strpos($url,'javascript:')!==FALSE | substr($url,0,1)=='#' | substr($url,0,4)=='http') continue;
    $url = add_base_url($url,$base_qt_url);
    $a->setAttribute('href',$url);
}
$tags = $dom->getElementsByTagName('link');
foreach($tags as $a) {
    $url=$a->getAttribute('href');
    if(empty($url) | strpos($url,'javascript:')!==FALSE | substr($url,0,1)=='#' | substr($url,0,4)=='http') continue;
    $url = add_base_url($url,$base_qt_url);
    $a->setAttribute('href',$url);
}
$tags = $dom->getElementsByTagName('script');
foreach($tags as $a) {
    $url=$a->getAttribute('src');
    if(empty($url) | strpos($url,'javascript:')!==FALSE | substr($url,0,1)=='#' | substr($url,0,4)=='http') continue;
    //skip bootstrap and jquery bc they break some things (menu, re-expanding...)
    //if(strpos($url,"bootstrap.min.js")!==FALSE) continue;
    $url = add_base_url($url,$base_qt_url);
    $a->setAttribute('src',$url);
}
$tags = $dom->getElementsByTagName('form');
foreach($tags as $a) {
    $url=$a->getAttribute('action');
    if(strpos($url,'javascript:')!==FALSE | substr($url,0,1)=='#') continue;
    // ../include/square/sq_nonce.php
    if(strpos($url,'sq_nonce.php') !== FALSE) $url = str_replace("..",'https://rental.software',$url);
    //echo 'url:'.$url;
    //echo 'sn:'.$_SERVER['SERVER_NAME'];
    //echo 'lnk:'.$link;
    if(empty($url) | strpos($url,'inflatableoffice.com/quotes') !== FALSE | strpos($url,'rental.software/quotes') !== FALSE | strpos($url,$base_qt_url) !== false){
        $sn = $_SERVER['SERVER_NAME'];
        if($sn=='_') $sn = $_SERVER['HTTP_HOST'];
        $dir = dirname($_SERVER['REQUEST_URI']);
        $dir = str_replace('io_quoteform','',$dir);
        $dir = str_replace('io_quoteconfirm','',$dir);
        $dir = str_replace('io_contract','',$dir);
        $dir = str_replace('io_contactform','',$dir);
        $dir = str_replace('io_receipt','',$dir);
        $dir = str_replace('io_vendor','',$dir);
        $dir = str_replace('io_quotedone','',$dir);
        $dir = rtrim($dir,'/');
        $url = str_replace($base_qt_url,'//'.$sn.$dir.'/',$link);//want to post to itself
    }
    $url = str_replace('quoteme.php','io_quoteform/',$url);
    $url = str_replace('quote_confirm.php','io_quoteconfirm/',$url);
    $url = str_replace('contractme.php','io_contract/',$url);
    $url = str_replace('contactme.php','io_contactform/',$url);
    $url = str_replace('receipt.php','io_receipt/',$url);
    $url = str_replace('vendorme.php','io_vendor/',$url);
    $url = str_replace('quote_done.php','io_quotedone/',$url);

    $url = str_replace('name=','io_name=',$url);//remove name=Demo+Rentals+LLC
    $url = str_replace('&nowrap=1','',$url);
    $url = str_replace('&wp_checkout=1','',$url);

    $url = preg_replace('/(&|\?)io_custip=[^&]*/', '', $url);
    $url = preg_replace('/(&|\?)io_custguid=[^&]*/', '', $url);
    // Fix the URL to ensure the query string is correct
    $url = preg_replace('/\?&/', '?', $url);
    $url = rtrim($url, '&');

    $a->setAttribute('action',$url);
}

//stupid wp screws up if "name" or "email" are in form (and many others)
$tags = $dom->getElementsByTagName('input');
foreach($tags as $a) {
    $name=$a->getAttribute('name');
    if(in_array($name,$wp_reserved)) $a->setAttribute('name','iowp_'.$name);
}
$tags = $dom->getElementsByTagName('textarea');
foreach($tags as $a) {
    $name=$a->getAttribute('name');
    if(in_array($name,$wp_reserved)) $a->setAttribute('name','iowp_'.$name);
}
$tags = $dom->getElementsByTagName('select');
foreach($tags as $a) {
    $name=$a->getAttribute('name');
    if(in_array($name,$wp_reserved)) $a->setAttribute('name','iowp_'.$name);
}

$html = $dom->saveHTML();
$search=Array('<html>','</html>','<head>','</head>','<body>','</body>',);
$replace='';
$html=str_replace($search,$replace,$html);

$html.='<script src="'.plugin_dir_url(__FILE__).'js/bootstrap.min.js?v=1" type="text/jscript"></script>';


function add_base_url($url,$base){
    if(strpos($url,'mailto:')!==FALSE | strpos($url,'tel:')!==FALSE | strpos($url,'javascript:')!==FALSE | strpos($url,'sms:')!==FALSE | $url=='#' | empty($url)) return $url;
    $url_arr = parse_url($url);
    if(empty($url_arr['host'])){
        $url = $base . $url;
    }
    return $url;
}







$out1='';
ob_start();
get_header();
$out1 = ob_get_contents();
ob_end_clean();
$out1 = str_replace('fa ico-twitter','fab ico-twitter',$out1);
$out1 = str_replace('fa ico-facebook','fab ico-facebook',$out1);
$out1 = str_replace('fa ico-youtube','fab ico-youtube',$out1);
$out1 = str_replace('fa ico-instagram','fab ico-instagram',$out1);

$out1 = str_replace('fa fa-search','fas fa-search',$out1);
$out1 = str_replace('fa fa-envelope-o','fas fa-envelope',$out1);
$out1 = str_replace('fa fa-envelope','fas fa-envelope',$out1);
$out1 = str_replace('fa fa-phone','fas fa-phone',$out1);
$out1 = str_replace('fa fa-send-o','fab fa-telegram-plane',$out1);
$out1 = str_replace('fa fa-paper-plane-o','fab fa-telegram-plane',$out1);
$out1 = str_replace('fa fa-facebook-official','fab fa-facebook-square',$out1);
$out1 = str_replace('fa fa-facebook','fab fa-facebook',$out1);
$out1 = str_replace('fa fa-twitter','fab fa-twitter',$out1);
$out1 = str_replace('fa fa-instagram','fab fa-instagram',$out1);
$out1 = str_replace('fa fa-youtube','fab fa-youtube',$out1);
$out1 = str_replace('fa fa-google','fab fa-google',$out1);
$out1 = str_replace('fa fa-linkedin','fab fa-linkedin',$out1);
$out1 = str_replace('fa fa-','fas fa-',$out1);
$out1 = str_replace('class="fa ','class="fas ',$out1);
$out1 = str_replace('<i class="fa">','<i class="fas fa-chevron-down">',$out1);
echo $out1;

?>

    <div class="welcome-wrap" id="main-content">
        <div class="container io_sc_container">
            <div class="welcome io_sc_welcome"><br>
                <?php
                echo $html;
                ?>
            </div>
        </div>
    </div>

    <script>

        // If theme is one of basic themes then inject Bootstrap dropdown nav menu fix
        <?php
        $theme = wp_get_theme();
        if($theme == "IO- Dark" || $theme == "IO- Green" || $theme == "IO- Original" || $theme == "IO- Red" || $theme == "IO- Wedding" || $theme == "IO- Yellow") {
            echo 'let dropDownArea = document.querySelector(".navbar-collapse");
            dropDownArea.setAttribute("aria-expanded", "false");
            let btnToggle = document.querySelector(".navbar-toggle");
            btnToggle.addEventListener("click", function(e) {
                $(dropDownArea).slideToggle("slow");
            });';
        }
        ?>

        <?php

        // Bootstrap dropdown menu quote item fix, only needed on quote page
        if($page_type=='quoteme') {
            echo 'anchorArray = document.querySelectorAll(".io a");
        var i;
        var anchorElem;
        for (i = 0; i < anchorArray.length; i++) {
            anchorElem = anchorArray[i];
            if (anchorElem.className == "accordion-toggle") {
                anchorElem.addEventListener("click", function(e) {
                    e.preventDefault();
                });
            }
        }';
        };

        ?>
    </script>

<?php
// If contact page, add contact button placement fix for mobile
if($page_type=='contactme') {
    echo '<style>
                .io_sc_container {
                    width: auto;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                }
                .io legend {
                    text-align: center;
                }
                .io .form-horizontal .form-actions {
                    padding: 20px 0px;
                }
                .io button.btn.btn-large, .io input[type="submit"].btn.btn-large {
                    display: block;
                    margin: auto;
                }
                div.hidden-print {
                    padding-left: 20px;
                    padding-right: 20px;
                }
                @media screen and (max-width: 768px) {
                    .io .form-horizontal .control-label {
                        width: 20vw;
                    }
                    .io .form-horizontal .controls {
                        margin-left: 90px;
                    }
                    .io .form-actions {
                        margin-bottom: -20px;
                    }
                }
              </style>';
};
?>

<?php
// If contact page on Create or IO-Premium inject this additional styling and script, EXCEPT premium site My Jumping Jubilee
$IOsite_name = get_blogInfo('name');

if(($page_type=='contactme' && $theme=='Create' && $IOsite_name!='Jumping Jubilee')||($page_type=='contactme' && $theme=='IO-Premium')) {
    echo '
    <script>
        var slidePanelIO = document.getElementById("slide-panel");
        var slidePanelIOOpen = document.getElementById("menu-toggle-open");
        var slidePanelIOClose = document.getElementById("menu-toggle-close");
        slidePanelIO.style.transform = "translateX(100vw)";
        slidePanelIO.style.visibility = "visible";
        var panelState;
        
        slidePanelIOOpen.addEventListener("click", function(e) {
            panelState = slidePanelIO.style.transform;
            if (panelState == "translateX(100vw)") {
                slidePanelIO.style.transform = "translateX(0vw)";
            } else {
                slidePanelIO.style.transform = "translateX(100vw)";
            }
        });
        
        slidePanelIOClose.addEventListener("click", function(e) {
            panelState = slidePanelIO.style.transform;
            if (panelState == "translateX(0vw)") {
                slidePanelIO.style.transform = "translateX(100vw)";
            } else {
                slidePanelIO.style.transform = "translateX(0vw)";
            }
        });
        
    </script>';
};
if(($page_type=='contactme' && $theme=='Create' && $IOsite_name=='Jumping Jubilee')||($page_type=='contactme' && $theme=='IO-Premium')) {
    echo '
    <script>
        var slidePanelIO = document.getElementById("slide-panel");
        var slidePanelIOOpen = document.getElementById("menu-toggle-open");
        var slidePanelIOClose = document.getElementById("menu-toggle-close");
        slidePanelIO.style.transform = "translateX(115vw)";
        slidePanelIO.style.visibility = "visible";
        slidePanelIOClose.style.right = "50px";
        var panelState;
        
        slidePanelIOOpen.addEventListener("click", function(e) {
            panelState = slidePanelIO.style.transform;
            if (panelState == "translateX(115vw)") {
                slidePanelIO.style.transform = "translateX(10vw)";
            } else {
                slidePanelIO.style.transform = "translateX(115vw)";
            }
        });
        
        slidePanelIOClose.addEventListener("click", function(e) {
            panelState = slidePanelIO.style.transform;
            if (panelState == "translateX(10vw)") {
                slidePanelIO.style.transform = "translateX(115vw)";
            } else {
                slidePanelIO.style.transform = "translateX(10vw)";
            }
        });
        
    </script>';
};
?>

<?php
if($page_type=='quoteme') {
    echo '<style>

        .io_sc_container {
            margin: auto;
        }
        #io_contactform{
            display:none;
        }
        a[href*="io_quoteform"]{
        display:none;
        }
    
    </style>';
};
?>

<?php
if(($page_type=='quoteme' || $page_type=='contactme') && $theme=='IO- Green') {
    echo '<style>
        
        .menu-wrap {
            margin-top: 55px;
        }
        
        </style>';
}
?>

<?php
if(($page_type=='quoteme' || $page_type=='contactme') && $theme=='IO- Yellow') {
    echo '<style>
        
        .menu-wrap .nav li a {
            font-family: "Roboto Condensed", sans-serif;
            font-size: 20px;
            font-weight: 300;
        }
        
        </style>';
}
?>

    <div class="btm-sec">


<?php

if(strpos($page_name,'Jump+Start+Party+Rentals')!==FALSE | get_option('io_username')=='JumpStart'){
    //no footer
}else{
    //everyone else
    $out1='';
    ob_start();
    get_footer();
    $out1 = ob_get_contents();
    ob_end_clean();
    $out1 = str_replace('fa ico-twitter','fab ico-twitter',$out1);
    $out1 = str_replace('fa ico-facebook','fab ico-facebook',$out1);
    $out1 = str_replace('fa ico-youtube','fab ico-youtube',$out1);
    $out1 = str_replace('fa ico-instagram','fab ico-instagram',$out1);

    $out1 = str_replace('fa fa-search','fas fa-search',$out1);
    $out1 = str_replace('fa fa-envelope-o','fas fa-envelope',$out1);
    $out1 = str_replace('fa fa-envelope','fas fa-envelope',$out1);
    $out1 = str_replace('fa fa-phone','fas fa-phone',$out1);
    $out1 = str_replace('fa fa-send-o','fab fa-telegram-plane',$out1);
    $out1 = str_replace('fa fa-paper-plane-o','fab fa-telegram-plane',$out1);
    $out1 = str_replace('fa fa-facebook-official','fab fa-facebook-square',$out1);
    $out1 = str_replace('fa fa-facebook','fab fa-facebook',$out1);
    $out1 = str_replace('fa fa-twitter','fab fa-twitter',$out1);
    $out1 = str_replace('fa fa-instagram','fab fa-instagram',$out1);
    $out1 = str_replace('fa fa-youtube','fab fa-youtube',$out1);
    $out1 = str_replace('fa fa-google','fab fa-google',$out1);
    $out1 = str_replace('fa fa-linkedin','fab fa-linkedin',$out1);
    $out1 = str_replace('fa fa-','fas fa-',$out1);
    $out1 = str_replace('class="fa ','class="fas ',$out1);
    echo $out1;
}