var refreshonline = 1;
var sessionid = '', username = '', camid = '', stream = '';
var parenturl = 'http://www.1-adultchat.tv/';
var lang_hcloading = 'Hardcore chat is loading ...';

function whoisonline(){
	if (refreshonline != 1){
		return;
	}
	if (top.opener.location.href.indexOf("whoisonline.asp")){
		top.opener.location.reload(); 
	}
	else {
		if (top.opener.parent.main != null && top.opener.parent.main.location.href.indexOf("whoisonline.asp")){
			top.opener.parent.main.location.reload();
		}
	}
}

function fullscreen(){
	window.moveTo(0,0);
	window.resizeTo(screen.width,screen.height-60);
	window.focus();
}

function chatwindow(){
	window.resizeTo(640,560);
	window.moveTo((screen.width-640)/2,(screen.height-500)/2);
	window.focus();
}

function tkc_getVSID(vsid){
	window.open('sixchat/getvideo.php?vsid='+ vsid +'&sid='+ sessionid +'&username='+ username +'&cam_id='+ camid +'&stream='+ stream, 'camera');
}

function tkc_chatSysMessage(msgType){
	if (arguments[1])
	{
		var info = arguments[1];
	}
	switch(msgType){
		case 'buy_coins':
			top.location = 'abo.asp';
			break;
		case 'listing':
		case 'logout':
		case 'kicked':
		case 'cam_offline':
			top.location = 'offline.asp?chat=1' + (msgType == 'logout' && info == 'Girl is OFFLINE' ? '&force_offline=1' : '');
			break;
		case 'cam_in_hc':
			top.location = 'hardcore_wait.asp?nocontinue=1';
			break;
		case 'joined_fc':
		case 'joined_hc':
			break;
		case 'update_coins':
			showcoins(info);
			break;
		case 'connection_failed':
			break;
	}
}
function showcoins(coins){
	if (top.statusfrm != null)
		if (top.statusfrm.document.getElementById("coins") != null)
			top.statusfrm.document.getElementById("coins").innerHTML = coins;
	
	if (document.getElementById("coins") != null)
		document.getElementById("coins").innerHTML = coins;
	
	if (coins.charAt(0) == 'b')
		return;
	else {
		if (this.updatecoins != null)
			updatecoins(coins);
		else
			if ((top.opener != null)&&(top.opener.top != null)){
				if (top.opener.top.menu_main != null)
					element = top.opener.top;
				else
					element = top.opener.top.mainframe;
				if (element != null && element.menu_main != null)
					if (element.menu_main.document.getElementById("coins") != null)
						element.menu_main.document.getElementById("coins").value = coins;
			}
	}
}

function hcrequestok(result){
	switch (result){
		case 2:
			if (top.topfrm.document.getElementById("hcrequestlink") != null){
				top.topfrm.document.getElementById('hcrequestlink').innerHTML = lang_hcloading;
				top.topfrm.document.getElementById('hcrequestlink').onClick = null;
				myImage = new Image(1, 1);
				myImage.src = "chat_hcrequest.asp";
			}
			break;
		default:
			alert('Hardcore request error - '+ result);
			break;
	}
}

function hcrequesterr(result){
	alert('Hardcore request error');
}

function startcam(param)
{
	param = param.replace('http://www.px24.com/loader.asp', 'http://www.px24.com/flashclient/load_client.php');
	param += "&disableFullScreen=1";
	if (document.getElementById("pxchat"))
	{
		document.getElementById("pxchat").src = param;
	}
	else
	{
		document.getElementById("MediaPlayer").fileName = param;
	}
}

function newhcrequest(){
	if ((parent == null) || (parent.chat == null)){
		return true;
	}
	parent.chat.rpc2_TKC_requestHC(); 
	parent.chat.hcrequestok(2);
	return false;
}
function startmytimer(){
	if (top.opener.top != null){
		if (top.opener.top.mainframe != null){
			if (top.opener.top.mainframe.menu_main != null){
				top.opener.top.mainframe.menu_main.startTimer();
			}
		}
		else{
			if (top.opener.top.menu_main != null){
				top.opener.top.menu_main.startTimer();
			}
		}
	}
}
