<?php

function Plugin_bannerTypeHtml_interstitialads_interstitialadsComponent_Delivery_adRender(&$aBanner, $zoneId=0, $source='', $ct0='', $withText=false, $logClick=true, $logView=true, $useAlt=false, $loc, $referer)
{


if($zoneId == 0)
	{
		
	$conf = $GLOBALS['_MAX']['CONF'];
    $aBanner['bannerContent'] = $imageUrl = adRenderBuildFileUrl($aBanner, $useAlt);	
    $prepend = (!empty($aBanner['prepend']) && $useAppend) ? $aBanner['prepend'] : '';
    $append = (!empty($aBanner['append']) && $useAppend) ? $aBanner['append'] : '';

    // Create the image tag..
    if (!empty($imageUrl)) {
		
        $imgStatus = empty($clickTag) && !empty($status) ? $status : '';
        $width = !empty($aBanner['width']) ? $aBanner['width'] : 0;
        $height = !empty($aBanner['height']) ? $aBanner['height'] : 0;
        $alt = !empty($aBanner['alt']) ? htmlspecialchars($aBanner['alt'], ENT_QUOTES) : '';
        $imageTag = "$clickTag<img src='".htmlspecialchars($imageUrl, ENT_QUOTES)."' width='$width' height='$height' alt='$alt' title='$alt' border='0'$imgStatus />$clickTagEnd";
    } else {
        $imageTag = '';
    }
    
    $bannerText = $withText && !empty($aBanner['bannertext']) ? "<br />$clickTag" . htmlspecialchars($aBanner['bannertext'], ENT_QUOTES) . "$clickTagEnd" : '';
     $beaconTag = ($logView && $conf['logging']['adImpressions']) ? _adRenderImageBeacon($aBanner, $zoneId, $source, $loc, $referer) : '';
    return $prepend . $imageTag . $bannerText . $beaconTag . $append;
	
	}
	else
	{
		
		
	$confimg= 	$GLOBALS['_MAX']['CONF']['webpath']['images'];
	
	//~ $jspath= 	$GLOBALS['_MAX']['CONF']['webpath']['delivery']."/js/";

	$conf = $GLOBALS['_MAX']['CONF'];
    $aBanner['bannerContent'] = $imageUrl = adRenderBuildFileUrl($aBanner, $useAlt);
    
    $destinationUrl = _adRenderBuildClickUrl($aBanner, $zoneId, $source, $ct0, $logClick);
    $LogUrl = _adRenderBuildLogUrl($aBanner, $zoneId, $source = '', $loc = '', $referer = '', $amp = '&amp;', $fallBack = false);
 
    
    $image1="http://".$confimg."/".$aBanner['filename'];
 
	

    
      // Create the image tag..
    if (!empty($imageUrl)) {
		
        $imgStatus = empty($clickTag) && !empty($status) ? $status : '';
        $width = !empty($aBanner['width']) ? $aBanner['width'] : 0;
        $height = !empty($aBanner['height']) ? $aBanner['height'] : 0;
        $alt = !empty($aBanner['alt']) ? htmlspecialchars($aBanner['alt'], ENT_QUOTES) : '';
        
        $imageTag = "$clickTag<img src='".htmlspecialchars($imageUrl, ENT_QUOTES)."' width='$width' height='$height' alt='$alt' title='$alt' border='0'$imgStatus />$clickTagEnd";
		
		
		$conf = $GLOBALS['_MAX']['CONF'];
		$dj_protocol = $GLOBALS['_MAX']['SSL_REQUEST'] ? "https://" : "http://" ;
    	$close_button = $dj_protocol.$conf['webpath']['admin'];
 
		
		$content = " <style type='text/css'>
							.banner
							{
							z-index:999;
							}
					</style>
						
<link rel='stylesheet' href='https://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.css' />	
						
<div id='mypage' data-role='page'  data-theme='b'> 
<div class='content' data-role='content'> 
<div class='banner'  style='position: relative; left: 0; top: 0; width:100%; height:100%;' >  
<img src = '".$LogUrl."' style='overflow:hidden;display:none'>
<img class='close' src=".$close_button."/plugins/interstitialAds/images/close.png style='height: 30px; width:30px;position: absolute; z-index: 10000; cursor: pointer;  top: 0px; right: 0px;' onclick='return closeinter()'/>

<a href='".$destinationUrl."' target='blank'>
<img id='picture' src=".$image1." style='position: relative; top: 0; left: 0; width:100%; height:100%;' width='100%'; height='100%'; border='0' alt='' title=''/></a>
</div>
</div></div>
<script>	
							
							var banner = document.getElementsByClassName('banner')[0];
							var close = document.getElementsByClassName('close')[0];
								
								function intershow()
							{
								
									banner.style.display='block';
									
										
							}

									function closeinter()
									{
										banner.style.display='none';
									 }

						intershow();
							
						</script>
					
					";

		return $content	;
   
    } 
    
    
		
	
		
	}
    		
}

if (!function_exists('adRenderBuildFileUrl')) 
 {
function adRenderBuildFileUrl($aBanner, $useAlt = false, $params = '')
{
	$aBanner['type'] = 'web';
	 $conf = $GLOBALS['_MAX']['CONF'];
    $fileUrl = '';
   
        $fileName = $useAlt ? $aBanner['alt_filename'] : $aBanner['filename'];
        $params = !empty($params) ? $params : '';
        if (!empty($fileName)) {
                $fileUrl = _adRenderBuildImageUrlPrefix() . "/{$fileName}";
                if (!empty($params)) {
                    $fileUrl .= "?{$params}";
                }
        }
    
    return $fileUrl;
}
}

if (!function_exists('adRenderBuildImageUrlAdmin')) 
 {
function adRenderBuildImageUrlAdmin()
{
    $conf = $GLOBALS['_MAX']['CONF'];
    return $GLOBALS['_MAX']['SSL_REQUEST'] ? 'https://' . $conf['webpath']['imagesSSL'] : 'http://' .  $conf['webpath']['admin'];
}
}

?>
