

function LoadFlash(url)
{
	document.getElementById("fchat").innerHTML = ' \
	<object id="fplayer" name="fplayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" \
	codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ chat_width +'" height="'+ chat_height +'"> \
	<param name="movie" value="'+ url +'"> \
	<param name="quality" value="high"> \
	<param name="loop" value="false"> \
	<param name="scale" value="exactfit"> \
	<param name="allowscriptaccess" value="always"> \
	<param name="bgcolor" value="#000000"> \
	<embed name="fplayer" src="'+ url +'" width="0" height="0" loop="false" type="application/x-shockwave-flash" \
	pluginspage="http://www.macromedia.com/go/getflashplayer" bgcolor="#EFEFEF" quality="high" scale="exactfit" swLiveConnect="true" allowScriptAccess="always"></embed> \
	</object>';	
}

function StartMediaPlayer(url){
	document.getElementById("buyTime").innerHTML = '';
	document.getElementById("mplayer").innerHTML = '\
	<OBJECT ID="MediaPlayer" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="'+ video_width +'" height="'+ video_height +'" > \
	<param name="URL" value="'+url+'"> \
	<param name="AutoStart" value="false"> \
	<param name="uiMode" value="none"> \
	<param name="stretchtofit" value="true"> \
	<param name="enableContextMenu" value="true"> \
	<embed type="application/x-mplayer2" name="MediaPlayer" FileName="' + url + '" ShowControls="0" ShowStatusBar="0" ShowDisplay="0" ShowPositionControls="0" ShowTracker="0" width="'+ video_width +'" height="'+ video_height +'" BufferingTime="1000" AutoStart="1"></embed> \
	</OBJECT>';
	var agt=navigator.userAgent.toLowerCase();
	if(agt.indexOf("windows") != -1){//need activex for these functions
		var mp = document.getElementById("MediaPlayer");		
		mp.network.bufferingTime = 1000;//overide the default 5 second, but we still end up with ~ 3 seconds
		mp.controls.play();//now start the feed after we set the buffer time
	}
	document.getElementById("fplayer").focus();//only works for ie
}

function RemoveMediaPlayer()
{
	document.getElementById("mplayer").innerHTML = '';
}

var mode;// 1=Free Chat, 2=Group Chat, 3=Private Chat
var obj = '';
function confirmPPM()
{
	
	if(document.getElementById("radiobutton1") && document.getElementById("radiobutton1").checked)
		mode = 1;
	else if(document.getElementById("radiobutton2") && document.getElementById("radiobutton2").checked)
		mode = 2;//
	else 
		mode = 3;			

	if(mode == 1){
		startChat();
	}else{
		var ppm = '';
		if(mode == 2){
			ppm = host_info_mode2;
		}else{
			ppm = host_info_mode3;
		}
		
		obj = document.getElementById("floater_box");
		obj.innerHTML = "<table BORDER=0 CELLPADDING=0 CELLSPACING=0 bgcolor='#C3C3C3' width='400' height='200' cellpadding='0' cellspacing='1'> \
		<tr><td bgcolor='#000000' align='center' height='50'><b>I Agree to the charges of "+ppm+" per minute</b><br><br><br> \
		<input type='button' value='Enter Video Chat' onClick='startChat()'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='button' value='Cancel' onClick='obj.style.visibility=\"hidden\";'></td> \
		</tr></table>";
		if (self.innerWidth)
			frameWidth = self.innerWidth;
		else if (document.documentElement && document.documentElement.clientWidth)
			frameWidth = document.documentElement.clientWidth;
		else if (document.body)
			frameWidth = document.body.clientWidth;
		else
			frameWidth = screen.width;			

		obj.style.left = (frameWidth / 2) - 200 + "px";
		obj.style.top = "150px";

		obj.style.visibility = "visible";
	}
}

var myWindow = '';
function buyTime()
{
	var str = "left=0,screenX=0,top=0,screenY=0,resizable,width=640,height=480";
	if(!myWindow || myWindow.closed)
		myWindow = window.open("buytime.php","",str);		
}

function showBalance()
{
	location.href="videochat.php?balance=1";	
}

function startChat()
{
	location.href= "videochat.php?mode_request="+mode;
}

function message(mess)
{	
	location.href="videochat.php?mess="+mess;
}

function displayPng(strPath) {
	var agt=navigator.userAgent.toLowerCase();
	var is_major = parseInt(navigator.appVersion);
	var is_minor = parseFloat(navigator.appVersion);
	var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	var is_mac = (agt.indexOf("mac")!=-1);
	if (is_ie && !is_mac) {
		document.write('<div style="height:240px; width:318px;  filter:progid:DXImageTransform.Microsoft.AlphaImageLoader (src=\''+strPath+'\', sizingMethod=\'scale\')"></div>');
	} else {
		document.write('<img src="'+strPath+'" width="318" height="240" border="0" />');
	}
}

function fplayer_DoFSCommand(command, args) {
	if (command == "audioMute") {//ie only
		var agt=navigator.userAgent.toLowerCase();
		if(agt.indexOf("windows") != -1){//need activex for these functions
			var mp = document.getElementById("MediaPlayer");
			mp.settings.mute = args;//mute - unmute audio
		}
  	}
}

//parse href for message
location.url = /\?.+/.exec(location.href);
location.url = location.url?(location.url[0].substring(1).split('&')):[];
	
for (var i=0,len=location.url.length;i<len;i++){
	var nameValuePair = location.url[i].split('=');
	location.url[nameValuePair[0]]=unescape(nameValuePair[1]);
}

if(location.url['mess'])//change screen message if flash chat sends a message
	mess_png = "images/message" + location.url['mess'] + ".png";

