<?php
if(!defined('AUTHACCESS')){echo "Not Allowed";exit();}
	global $link_thumb_to_offsite_model_chat;
	echo $modelisoffline;
	if(empty($page_model['username'])){$page_model['username']="";}
	if(empty($page_model['stream_width'])){$page_model['stream_width']=1;}
	if(empty($page_model['stream_height'])){$page_model['stream_height']=1;}
	$mname = $page_model['username'];
	$ln = strlen($mname);
	$nend = substr($mname,$ln-3);
	if ($nend == "_sc"){
		$ln = strlen($mname) - 3;
		$mname = substr($mname,0,$ln);
	}
?>
<?php 
	global $w,$h,$wpt,$wpt2,$hpt,$dh;
	$w = $page_model['stream_width'];
	$h = $page_model['stream_height'];
	function xxx($dw) {
		global $w,$h,$wpt,$wpt2,$hpt,$dh;
		if($h == 0){$h=1;}
		$r = $w/$h;
		$w = floor($dh*$r);
		$wpt = floor(($w/$dw)  * 100);
		if($wpt > 75){
			$wpt = 72;
			$hpt = 70;
			$wpt2 = 25;
		}else{
			$hpt = 100;
			$wpt2 = 98 - $wpt;
		}

		echo "width:$wpt%;";
	}
	$dh = 650;
?>
<style>
.content_main {padding-left:10px;padding-right:10px;}
.camiframe {
	width:100%;
	height:650px;
	border:none;
}
.camdivcont {
	padding:10px;
	border:solid #000 4px;
	border-radius:10px;	
	background:#333;
	text-align:center;
	margin-top:3em;
	margin-bottom:2em;
	margin-left:auto;
	margin-right:auto;
	background: linear-gradient(#312c2c,#211e1e,#1c1a1a, #292525,#433e3e,#333030,#453f3f,#312c2c, #080808,#232020);
	box-sizing:border-box;
	height:670px;
	clear:both;
	max-width:1500px;
	margin-left:auto;
	margin-right:auto;
}
.camdiv {
	position:relative;
	width:90%;
	height:650px;
	padding:0;
	margin-bottom:20px;
	clear:both;
	margin-left:auto;
	margin-right:auto;
}
.camdiv2 {
<?php $w = $page_model['stream_width'];$h = $page_model['stream_height'];$dw = 1500;xxx($dw); ?>
	display:inline-block;
	margin-left:2px;
	vertical-align:top;
}
.chatdiv2 {
	<?php echo "width:$wpt2%;"; ?>
	<?php echo "height:$hpt%;"; ?>
	display:inline-block;
	vertical-align:top;
}

@media(max-width:1450px) {
	.camdiv2 { 
		<?php $w = $page_model['stream_width'];$h = $page_model['stream_height'];$dw = 1450;xxx($dw); ?>
	}
	.chatdiv2 {
		<?php echo "width:$wpt2%;"; ?>
		<?php echo "height:$hpt%;"; ?>
	}
}
@media(max-width:1400px) {
	.camdiv2 { 
		<?php  $w = $page_model['stream_width'];$h = $page_model['stream_height'];$dw = 1400;xxx($dw); ?>
	}
	.chatdiv2 {
		<?php echo "width:$wpt2%;"; ?>
		<?php echo "height:$hpt%;"; ?>
	}
}
@media(max-width:1350px) {
	.camdiv2 { 
		<?php $w = $page_model['stream_width'];$h = $page_model['stream_height'];$dw = 1350;xxx($dw); ?>
	}
	.chatdiv2 {
		<?php echo "width:$wpt2%;"; ?>
		<?php echo "height:$hpt%;"; ?>
	}
}
@media(max-width:1300px) {
	.camdiv2 { 
		<?php $w = $page_model['stream_width'];$h = $page_model['stream_height'];$dw = 1300;xxx($dw); ?>
	}
	.chatdiv2 {
		<?php echo "width:$wpt2%;"; ?>
		<?php echo "height:$hpt%;"; ?>
	}
}
@media(max-width:1250px) {
	.camdiv2 { 
		<?php $w = $page_model['stream_width'];$h = $page_model['stream_height'];$dw = 1250;xxx($dw); ?>
	}
	.chatdiv2 {
		<?php echo "width:$wpt2%;"; ?>
		<?php echo "height:$hpt%;"; ?>
	}
}
@media(max-width:1200px) {
	.camdiv2 { 
		<?php $w = $page_model['stream_width'];$h = $page_model['stream_height'];$dw = 1200;xxx($dw); ?>
	}
	.chatdiv2 {
		<?php echo "width:$wpt2%;"; ?>
		<?php echo "height:$hpt%;"; ?>
	}
}
@media(max-width:1150px) {
	.camdiv2 { 
		<?php $w = $page_model['stream_width'];$h = $page_model['stream_height'];$dw = 1150;xxx($dw); ?>
	}
	.chatdiv2 {
		<?php echo "width:$wpt2%;"; ?>
		<?php echo "height:$hpt%;"; ?>
	}
}
@media(max-width:1100px) {
	.camdiv2 { 
		<?php $w = $page_model['stream_width'];$h = $page_model['stream_height'];$dw = 1100;xxx($dw); ?>
	}
	.chatdiv2 {
		<?php echo "width:$wpt2%;"; ?>
		<?php echo "height:$hpt%;"; ?>
	}
}
@media(max-width:950px) {
	.camdiv2 { 
		<?php $w = $page_model['stream_width'];$h = $page_model['stream_height'];$dw = 950;xxx($dw); ?>
	}
	.chatdiv2 {
		<?php echo "width:$wpt2%;"; ?>
		<?php echo "height:$hpt%;"; ?>
	}
}
@media(max-width:900px) {
	.camdiv2 { 
		<?php $w = $page_model['stream_width'];$h = $page_model['stream_height'];$dw = 900;xxx($dw); ?>
	}
	.chatdiv2 {
		<?php echo "width:$wpt2%;"; ?>
		<?php echo "height:$hpt%;"; ?>
	}
}
@media(max-width:850px) {
	.camdivcont {
		height:750px;
	}
	.camdiv2 { 
		<?php $dh = 450; $w = $page_model['stream_width'];$h = $page_model['stream_height'];$dw = 850;xxx($dw); ?>
	}

	.camdiv2 {
	 	display:block;
	 	margin-left:auto;
	 	margin-right:auto;
	 }
	.chatdiv2 {
	 	display:block;
	 	height:300px;
		<?php $dh = 450; $w = $page_model['stream_width'];$h = $page_model['stream_height'];$dw = 850;xxx($dw); ?>
		min-width:276px;
	 	margin-left:auto;
	 	margin-right:auto;
	}
	
}
@media(max-width:600px) {

}
@media(max-width:400px) {

}
</style>

<div id=modelinfo class=minfo>
	<div class=musername><?php echo ucfirst($page_model['username']); ?> </div>
</div><!-- modelinfo -->



 

<?php

$strchatID = $extra_data['stripchat_id'];

$stripchatplayer =<<<SCP
 <!-- first of all, download script itself, id attribute is important -->
  <script
    id="SCChatScript"
    type="text/javascript"
    src="https://creative.rmhfrtnd.com/widgets/Chat/lib.js"
  ></script>


  <!-- finally, run the chat instance -->
  <script type="text/javascript">
    // 1. create chat instance

    const chat = new StripchatChat({
      modelName: "$mname",
      userId: "$strchatID",
      // ...any other Chat creative params
    });


    // 2. mount it on prepared container

    chat.mount(document.getElementById('chat-container')).then((app) => {
      // 3. use it

      /*
      app
        .setParams({ modelName: 'ANOTHER_MODEL_NAME' })
        .then(() => {
          // OK
        })
        .catch(() => {
          // Model must be perform private show right now, try later
        });
      */

      // 4. remove it

      // app.destroy();
    })

  </script>
  
   <!-- first of all, download script itself, id attribute is important -->
  <script
    id="SCPlayerScript"
    type="text/javascript"
    src="https://creative.rmhfrtnd.com/widgets/Player/lib.js"
  ></script>



  <!-- finally, run the player instance -->
  <script type="text/javascript">
    // 1. create player instance

    const player = new StripchatPlayer({
      modelName: "$mname",
      userId: "$strchatID",
      strict: 1,
      showModal: 'signup',
      autoplay: 'all',
    });


    // 2. mount it on prepared container

    player.mount(document.getElementById('player-container')).then((app) => {
      // 3. use it

      /*
      app
        .setParams({ modelName: 'ANOTHER_MODEL_NAME' })
        .then(() => {
          // OK
        })
        .catch(() => {
          // Model must be perform private show right now, try later
        });
      */

      // 4. remove it

      // app.destroy();
    })

  </script>
SCP;
?>
<?php		

	if(empty($modelisoffline)){
		if( $page_model['sponsor'] == "stripchat")  {
			echo "<div class=camdivcont >
					<div class=\"camdiv2\" id=\"player-container\"></div>
					<div class=\"chatdiv2\" id=\"chat-container\"></div>
				</div>";			
			echo $stripchatplayer;
		}	
		else {
		
			if (in_array($page_model['sponsor'],$link_thumb_to_offsite_model_chat)) {

			} else {
				echo '<div id=camdiv class=camdiv >
						<iframe id=camscroll class="camiframe" src="' . $this_iframe . '"></iframe>
					</div> 	';
			}
		}
	}
	
	if (!empty($page_model['gender'])) {	
		if ($page_model['gender'] == "f") {$page_model['gender'] = "Female";}
		if ($page_model['gender'] == "c") {$page_model['gender'] = "Couple";}
		if ($page_model['gender'] == "m") {$page_model['gender'] = "Male";}
		if ($page_model['gender'] == "trans") {$page_model['gender'] = "Trans";}
		if ($page_model['gender'] == "s") {$page_model['gender'] = "Trans";}
		if ($page_model['gender'] == "t") {$page_model['gender'] = "Trans";}
	} else {
		$page_model['gender'] = "";
	}
?>
<div id=modelinfo class=minfo>
	<div class=musername><?php echo $page_model['username']; ?></div>

<?php
	if (!empty($page_model['topic'])) { echo "<div class=mtopic>" . $page_model['topic']  . "</div>\n"; }
	if (!empty($page_model['turns_on'])) { echo "<div class=turns_on>" . $page_model['turns_on']  . "</div>\n"; }
	if (!empty($page_model['turns_off'])) { echo "<div class=turns_off>" . $page_model['turns_off']  . "</div>\n"; }

	if (!empty($page_model['tags'])) {

		echo "\n<div style=\"clear:both;\" id=modelinfotags class=minfotags>\n";
		foreach($page_model['tags'] as $t) {
		
			$t = preg_replace('/ /', "-", $t);
			if (!empty($t)) {
				if ( (strlen($t) > 3) || (strtolower($t) == "fat") || (strtolower($t) == "bbw") ) {
					echo "<a class=taglink href=\"$site_directory/search/$media_type/" . $feed . "/$t" . $theme . "\"><span class=mtag>$t</span> </a>"	;
				}
			}

		}
		echo "</div><!-- modelinfotags -->\n";

	}
?>
</div><!-- modelinfo -->
<div class=related_box>
<div class=related_box_heading>Related </div>
<?php
if (!empty($related_model)) {
	foreach($related_model as $v) {
		if (in_array($v['sponsor'], $link_thumb_to_offsite_model_chat) ) {
					$modelpagelink = thbcell_html($v);
			//$modelpagelink =  "<a href=" . $v['iframe_src'] . "><img class=related_thb src=" . $v['thumb'] . " </img></a>";
			//$modelpagelink = $v['iframe_src'];
		} else {
			$modelpagelink = thbcell_html($v);
		
			//$modelpagelink = $site_directory . "/cams/" . $feed . "/model_profile/" . $v['username'] . $theme;
		}
		echo $modelpagelink;
	}
}



?>
</div>
