var page = '';
var okno = null;
function window_open(page,PosX,PosY,width,height)
{
borderless = false;
if(okno != null && !document.layers)
{
okno.close();
}
if(borderless && !document.layers)
{
okno = window.open(page, "", "fullscreen=0, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=yes, resizable=0");
okno.resizeTo(w, s);
okno.moveTo(PosX, PosY);
}
else
{
okno = window.open(page, "", "menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=yes, resizable=no, copyhistory=no, width=" + width + ", height=" + height + ", left=" + PosX + ", top=" + PosY);
}
okno.focus();
okno = null;
}
function window_open_scroll(page,PosX,PosY,width,height)
{
borderless = false;
if(okno != null && !document.layers)
{
okno.close();
}
if(borderless && !document.layers)
{
okno = window.open(page, "", "fullscreen=0, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=yes, resizable=0");
okno.resizeTo(w, s);
okno.moveTo(PosX, PosY);
}
else
{
okno = window.open(page, "", "menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=yes, resizable=no, copyhistory=no, width=" + width + ", height=" + height + ", left=" + PosX + ", top=" + PosY);
}
okno.focus()
}
function newImage(arg) {
if (document.images) {
rslt = new Image();
rslt.src = arg;
return rslt;
}
}
function changeImages() {
if (document.images && (preloadFlag == true)) {
for (var i=0; i<changeImages.arguments.length; i+=2) {
document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
}
}
}
var preloadFlag = false;
function preloadImages() {
if (document.images) {
topmenu_1_over = newImage("images/topmenu_active_06.jpg");
topmenu_2_over = newImage("images/topmenu_active_08.jpg");
topmenu_3_over = newImage("images/topmenu_active_10.jpg");
topmenu_4_over = newImage("images/topmenu_active_12.jpg");
topmenu_5_over = newImage("images/topmenu_active_14.jpg");
topmenu_6_over = newImage("images/topmenu_active_16.jpg");
preloadFlag = true;
}
}


function openFrameless() {
	var windowW=214; // wide
	var windowH=398; // high
	var windowX = 0; // from left
	var windowY = 0; // from top
	var urlPop = "webcams.php"
	var title =  "Webcams"
	// set this to true if the popup should close
	// upon leaving the launching page; else, false
	var autoclose = true
	// do not edit below this line
	var beIE = document.all?true:false
	var windowW = 0, windowH = 0;
	  if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		windowW = window.innerWidth;
		windowH = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		windowW = document.documentElement.clientWidth;
		windowH = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		windowW = document.body.clientWidth;
		windowH = document.body.clientHeight;
	  }
	 // if (windowW<1000) windowW=1000;
	  //if (windowH<600) windowH=600;  
	  //if ((windowW/windowH)<1.3) windowH=parseInt(windowW/1.3);
	 var sss = ",width="+windowW+",height="+windowH;
	 sss = '';
	if (beIE) {
		NFW = window.open('webcams.php', "Webcams", ',type=fullscreen,scrollbars=no,'+sss);
		//NFW = window.open("","popFrameless","fullscreen,"+s);
		NFW.blur();
		window.focus();
		//NFW.resizeTo(windowW,windowH);
		//NFW.moveTo(windowX,windowY);
		var frameString=""+
		"<html>"+
		"<head>"+
		"<title>"+title+"</title>"+
		"</head>"+
		"<frameset rows='*,0' framespacing=0 border=0 frameborder=0>"+
		"<frame name='top' src='"+urlPop+"' scrolling=auto>"+
		"<frame name='bottom' src='about:blank' scrolling='no'>"+
		"</frameset>"+
		"</html>";
		NFW.document.open();
		NFW.document.write(frameString);
		NFW.document.close();
		}
	else {
		NFW = window.open('webcams.php', "Webcams", ',type=fullscreen,scrollbars,'+sss);
		//NFW = window.open(urlPop,"popFrameless","scrollbars,"+s);
		NFW.blur();
		window.focus();
		//NFW.resizeTo(windowW,windowH);
		//NFW.moveTo(windowX,windowY);
		}
	//NFW.focus();
	if (autoclose) {
		window.onunload = function(){NFW.close();}
	   }
}

function start() {
	preloadImages();
	if(typeof uploadOn!='undefined') uploadOn();
	if(typeof nickAutoOn!='undefined') nickAutoOn();
	if(typeof setCity!='undefined') setCity();
	if(typeof setCityQuick!='undefined') setCityQuick();
	if(typeof addReflections!='undefined') addReflections();
	if(jskomshow) jskomAppear();
	if(typeof processVideo=='function') {
		processVideo();
		return;
	}
	if($('leftsubmenu')) leftsubmenuOn();
	if($('nav_adv_content')) advancedsearchOn();
	if($('nav_ext_content')) extendeddsearchOn();
	if($('about')) aboutCounterOn();
	if($('msgs')) new PeriodicalExecuter(checkMsgs, 5);

	if(typeof justLogged!='undefined') {
		//if(justLogged) openFrameless();
	}
}
var checking = false;
//var myDate=new Date();
//var lastCheckDate = myDate.getFullYear()+'-'+(myDate.getMonth()+1)+'-'+myDate.getDate()+' '+(myDate.getHours()+1)+':'+(myDate.getMinutes()+1);
function checkMsgs() {
if(checking) return;
checking = true;
var uid = $('msgs').attributes['user_id'].value;
if(uid=='') return;
var un = $('msgs').attributes['un'].value;
var reqCM = new JsHttpRequest();
reqCM.onreadystatechange = function() {
if (reqCM.readyState == 4) {
// Write result to page element (_RESULT becomes responseJS). 
$('msgs').update('Messages ('+reqCM.responseJS.il+')');
if(reqCM.responseJS.il>un) {
$('jskom').update('<table width="100%" height="100%" border="0"><tr height="100%"><td height="100%" width="100%" align="center" valign="middle" style="background-color:#000000; color:#ffffff; font-weight:bold;">You have new messages! <a href="user.php?action=wall" style="color:#ffffff; font-weight:bold;">Click here to read them</a></td></tr></table>');
jskomAppear();
}
$('msgs').attributes['un'].value = reqCM.responseJS.il;
checking = false;
// Write debug information too (output becomes responseText).
//$('debug').update('Debug:<br />'+req.responseText);
//$('fileUploadForm').hide();
}
}
// Prepare request object (automatically choose GET or POST).
reqCM.open(null, 'js_ret.php', true);
// Send data to backend.
reqCM.send( { action: 'msgs', user_id: uid } );
}
var peJskom;
var jskomshow = false;
function jskomAppear() {
try{
Effect.Appear('jskom');
}
catch (exc) {
$('jskom').show();
}
peJskom = new PeriodicalExecuter(function(peJskom) {
jskomFadeOut();
}, 5);
}
function jskomFadeOut() {
try{
Effect.Fade('jskom');
}
catch (exc) {
$('jskom').hide();
}
$('jskom').update('');
peJskom.stop();
}
var ls = false;
var na = false;
var ne = false;
lsInProgress = false;
naInProgress = false;
neInProgress = false;
function leftsubmenuOn() {
$('leftsubmenu').hide();
$('leftsubtitle').onclick = function() {
if(lsInProgress) return;
lsInProgress = true;
if(!ls) {
Effect.BlindDown('leftsubmenu',1);
ls = true;
new PeriodicalExecuter(function(pe) {
lsInProgress = false;
pe.stop();
}, 1);
}
else {
Effect.BlindUp('leftsubmenu',1);
ls = false;
new PeriodicalExecuter(function(pe) {
lsInProgress = false;
pe.stop();
}, 1);
}
}
}
function advancedsearchOn() {
$('nav_adv_content').hide();
$('nav_adv_title').onclick = function() {
if(naInProgress) return;
naInProgress = true;
if(!na) {
Effect.BlindDown('nav_adv_content');
na = true;
new PeriodicalExecuter(function(pe) {
naInProgress = false;
pe.stop();
}, 1);
}
else {
Effect.BlindUp('nav_adv_content');
na = false;
new PeriodicalExecuter(function(pe) {
naInProgress = false;
pe.stop();
}, 1);
}
}
}
function extendeddsearchOn() {
$('nav_ext_content').hide();
$('nav_ext_title').onclick = function() {
if(neInProgress) return;
neInProgress = true;
if(!ne) {
Effect.BlindDown('nav_ext_content');
ne = true;
new PeriodicalExecuter(function(pe) {
neInProgress = false;
pe.stop();
}, 1);
}
else {
Effect.BlindUp('nav_ext_content');
ne = false;
new PeriodicalExecuter(function(pe) {
neInProgress = false;
pe.stop();
}, 1);
}
}
}
function aboutCounterOn() {
var remaining = 500;
$('about').onkeyup = function() {
remaining = 500 - $('about').value.length;
if(remaining<0) {
$('about').value = $('about').value.substr(0,500);
remaining = 0;
}
$('about_len').update(remaining);
}
}
function openSmallPlayerNew(videoId)
{
var name = 'small_player_' + videoId;
var url = 'http://www.gayescortclub.com/player.php' + '?videoId=' + videoId + '&showList=false';
window_open(url, 20, 20, 320, 295, false);
}
function updateCities(oSel,optAll) {
var si = oSel.selectedIndex;
var opt = oSel.options;
var country_id = opt[si].value;
//var cities = $('city_id').getElementsByTagName('option');
var cities = oSel.form.city_id.getElementsByTagName('option');
nodes = $A(cities);
nodes.each(function(node) {
del = node.parentNode.removeChild(node);
});
if(optAll===true||oSel.id=='countryquick'||oSel.getAttribute('search')==1) {
var newopt = document.createElement('option');
newopt.setAttribute('value', 0);
newopt.innerHTML = 'All';
oSel.form.city_id.appendChild(newopt);
}
citiesInfo.each(function(city) {
if(city.country_id==country_id) {
//var newopt = new Element('option', { value: city.city_id, 'country_id': city.country_id }).update(city.city_name);
var newopt = document.createElement('option');
newopt.setAttribute('value', city.city_id);
newopt.setAttribute('country_id', city.country_id);
newopt.innerHTML = city.city_name;
//var newopt = '<option city_id="'+city.city_id+'" value="'+city.country_id+'">'+city.city_name+'</option>';
//$("city_id").appendChild(newopt);
if(city.city_id==lastChosenCity) newopt.selected = true;
oSel.form.city_id.appendChild(newopt);
}
});
if(oSel.getAttribute('showNewCityField')==1) {
$('cnd').show();
}
}
function setCityQuick() {
if($('countryquick').options[$('countryquick').selectedIndex].value>0) updateCities($('countryquick'));

}