// TFLIB.JS
// GLOBALS:
var Sess = "";
var Dip = "";
var GLang = "";
var GUser = "";
var GCurPage = "";
var Scrw = "0";
var Scrh = "0";
var HOMEPAGE = "http://www.holidayflints.com/";
var PrevId = "";
var GSPrevId = "";
var CurPicNdx = 0;
var GCcode = "";
var GRegioncode = "";
var GTown = "";

btngoon = new Image();
btngoon.src = "pics/btngoon.png";
btngooff = new Image();
btngooff.src = "pics/btngooff.png";

btnlefton = new Image();
btnlefton.src = "pics/btnlefton.png";
btnleftoff = new Image();
btnleftoff.src = "pics/btnleftoff.png";

btnrighton = new Image();
btnrighton.src = "pics/btnrighton.png";
btnrightoff = new Image();
btnrightoff.src = "pics/btnrightoff.png";

mnuon = new Image();
mnuon.src = "pics/mnuon.png";
mnuoff = new Image();
mnuoff.src = "pics/mnuoff.png";

function GetW()
{
	if (typeof( window.innerWidth ) == 'number' ) 
		//Non-IE
		Scrw = window.innerWidth; // - 20;
	else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
		//IE 6+ in 'standards compliant mode'
		Scrw = document.documentElement.clientWidth; //-16;
	else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
		//IE 4 compatible
		Scrw = document.body.clientWidth; // -16;
}
function GetH()
{
	if (parseInt(navigator.appVersion)>3)
	{
		if (navigator.appName=='Netscape')
			winH = window.innerHeight;
		if (navigator.appName.indexOf('Microsoft')!=-1)
			winH = document.body.offsetHeight;
	}
	Scrh = winH - 100;
}
function showform(theForm,a,b)
{
	var txt = "Form name: " + theForm.name + "\r\n";
	txt += "theForm.elements.length = "+theForm.elements.length+"\r\n";
	for (var i=0; i<theForm.elements.length; i++)
		txt += theForm.elements[i].name + " = " + theForm.elements[i].value + "\r\n";
	txt += "a: "+a+"\r\n";
	txt += "b: "+b+"\r\n";
	alert(txt);
}
// === EMAIL VALIDATION =================================================================================================================================
function echeck(str) 
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	if (str.indexOf(at)==-1)
	   return(true);
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		return(true);
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		return(true);
	if (str.indexOf(at,(lat+1))!=-1)
		return(true);
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		return(true);
	if (str.indexOf(dot,(lat+2))==-1)
		return(true);
	if (str.indexOf(" ")!=-1)
		return(true);
	return (false);					
}

// ===================================================================================================================
// === COOKIES
// ===================================================================================================================
function getCookie(c_name)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
		{ 
			c_start=c_start + c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}
function setCookie(c_name,value,expiredays)
{
	var exdate = new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+";expires="+exdate.toGMTString();
}
function UserCookie()
{
	var rts = getCookie('gluser');
	if (rts != null && rts != "")	// cookie exists: we use that session instead (but Php does NOT know)
	{
		if (rts.length > 5)
			GUser = rts;
	}
	else
		GUser = "";
//	alert("GUsercookie: "+GUser);
}
function SessCookie()
{
	var rts = getCookie('glsess');
	if (rts != null && rts != "")	// cookie exists: we use that session instead (but Php does NOT know)
	{
		if (rts.length > 5)
			Sess = rts;
	}
	else
		Sess = "";
//	alert("Sesscookie: "+Sess);
}
function DelSessCookie()
{
	setCookie("glsess","",-1);
}
function DelUserCookie()
{
	setCookie("gluser","",-1);
}
function js_setlang(lang)
{
//	alert ("Setting language to: "+lang);
	GLang = lang;
	setCookie("gllang",GLang,30);
	window.location.reload();
}
function LangCookie()
{
	var rts = getCookie('gllang');
	if (rts != null && rts != "")	// cookie exists: we use that session instead (but Php does NOT know)
	{
		if (rts.length > 1)
			GLang = rts;
	}
	else
	{
		GLang = "en";
		setCookie("gllang","en",30);
	}
}

// =========================================================================
// === NAVBAR
// =========================================================================
function js_home()
{
//	alert ("js_home");
	window.location = HOMEPAGE;
}
function js_myhome()
{
//	alert ("js_myhome "+GCurPage);
	if (GCurPage == "profile")
	{
		sajax_target_id = 'main';
		x_p_myhome(Sess); 
		sajax_target_id = '';
	}
	else
		window.location = HOMEPAGE+"glprofile.php?sub=mh";
}
function js_myprofile()
{
//	alert ("js_myprofile "+GCurPage);
	if (GCurPage == "profile")
	{
		sajax_target_id = 'main';
		x_p_myprofile(Sess); 
		sajax_target_id = '';
	}
	else
		window.location = HOMEPAGE+"glprofile.php?sub=mp";
}
function js_join(ref)
{
//	alert ("js_join");
	if (ref != "")
		window.location = HOMEPAGE+"glregister.php?c="+ref;
	else
		window.location = HOMEPAGE+"glregister.php";
}
function js_browse()
{
	window.location = HOMEPAGE+"glbrowse.php";
}
function js_chat()
{
	window.location = HOMEPAGE+"glchat.php";
}
function js_personals()
{
	window.location = HOMEPAGE+"glpersonals.php";
}
function js_affiliates()
{
	window.location = HOMEPAGE+"glaffiliates.php";
}
function js_advertise()
{
	window.location = HOMEPAGE+"gladvertise.php";
}
function js_ad_submit(theForm)
{
/*
	var x = theForm.elements['name'].value;
	if (x == "")
	{
		var ename = "Web2Coders";
		sajax_target_id = 'main';
		x_p_flyers_form(Sess,ename); 
		sajax_target_id = '';
	}
	else
*/
		theForm.submit();
}
function js_set_radio_flyer(x)
{
	var val = x.value;
	var y = document.getElementById('flyer');
	y.value = val;
}
function js_set_radio_leaflet(x)
{
	var val = x.value;
	var y = document.getElementById('leaflet');
	y.value = val;
}
function js_flyer_submit(theForm)
{
	showform(theForm,"js_flyer_submit",0);
	var l = theForm.elements['leaflet'].value;
	var f = theForm.elements['flyer'].value;
	var ename = theForm.elements['ename'].value;
	sajax_target_id = 'main';
	x_p_flyers_make(Sess,l,f,ename); 
	sajax_target_id = '';
}
function js_tos()
{
	window.location = HOMEPAGE+"gltos.php";
}
function js_ps()
{
	window.location = HOMEPAGE+"glps.php";
}
// ===================================================================================================================
// === LOGIN
// ===================================================================================================================
function js_login_form(s)
{
//	alert("js_login_form: "+s);
	Sess = s;
	js_pop_open(280,200,130,"login");
	setTimeout("js_field_user()",2000);
}
function js_field_user()
{
	var x = document.getElementById("user");
	x.focus();
}
function js_recover_pwd(user)
{
	sajax_target_id = 'popcontents';
	x_p_recover_pwd(user); 
	sajax_target_id = '';
}
function js_login(theForm)
{
	if (theForm.elements['user'].value == "")
		return;
	if (theForm.elements['pwd'].value == "")
		return;
	txt = "";
	Sess = theForm.elements['s'].value;	// the session just created.
	GUser = theForm.elements['user'].value;
	var txt = "user="+theForm.elements['user'].value;
	txt += "&pwd="+theForm.elements['pwd'].value;
	txt += "&s="+Sess;
//	alert ("js_login: "+txt);
	sajax_target_id = 'login';
	x_p_login(txt); // Hello usernam, welcome back
	sajax_target_id = '';
	setTimeout("js_check_logged()",5000);
//	settimeout("window.location = HOMEPAGE+'glprofile.php';",2000);
}
function js_check_logged()
{
	if (!document.getElementById("logstatus"))
	{
		alert ("No Logstatus");
		return;
	}
	var x = document.getElementById("logstatus");
	var msg = x.value;
//	alert ("logstatus: "+msg);
	if (msg == "wuser")
		js_login_form(Sess);
	else if (msg == "logged")
	{
		sajax_target_id = 'login'; 
		x_p_logoff_form("",Sess); 
		sajax_target_id = '';
		setCookie("glsess",Sess,1);
		setCookie("gllang",GLang,30);
		setCookie("gluser",GUser,1);
		window.location = HOMEPAGE+"glprofile.php";
	}
	else if (msg == "trans")
	{
		sajax_target_id = 'login'; 
		x_p_logoff_form("",Sess); 
		sajax_target_id = '';
		setCookie("glsess",Sess,1);
		setCookie("gllang",GLang,30);
		setCookie("gluser",GUser,1);
		window.location = HOMEPAGE+"gladmin.php";
	}
}
function js_logoff()
{
//	alert ("js_logoff");
	sajax_target_id = 'login'; //login?
	x_p_logoff(Sess); 
	sajax_target_id = '';
	DelSessCookie();
	DelUserCookie();
	Sess = "";
	GUser = "";
	window.location = HOMEPAGE;
}
function js_auto_log()
{
	sajax_target_id = 'login'; 
	x_p_logoff_form(GUser,Sess); 
	sajax_target_id = '';
}
// =========================================================================
// === USERS REGISTRATION
// =========================================================================
function js_refresh_regions(ccode)
{
	alert("refresh region: "+ccode);
}
function js_change_country(ccode)
{
//	alert("js_change_country to "+ccode);
	sajax_target_id = 'popinfo'; 
	x_p_warn_msg("newregion"); 
	sajax_target_id = '';
	sajax_target_id = 'regions'; 
	x_p_list_provinces(ccode); 
	sajax_target_id = '';
	setTimeout("js_clear_popinfo()",2500);
}
function js_clear_popinfo()
{
	sajax_target_id = 'popinfo'; 
	x_p_pop_clear(); 
	sajax_target_id = '';
}
function js_clear_poperr()
{
	sajax_target_id = 'poperr'; 
	x_p_pop_clear(); 
	sajax_target_id = '';
}
function js_change_region(ccode,regioncode)
{
//	alert ("Changing region to "+regioncode+"in "+ccode+"\n"+"updating list in id=citytown");
	sajax_target_id = 'popinfo'; 
	x_p_warn_msg("newtowns"); 
	sajax_target_id = '';
	sajax_target_id = 'citytown'; 
	x_p_list_towns(ccode,regioncode,""); 
	sajax_target_id = '';
	setTimeout("js_clear_popinfo()",2500);
}
function js_check_avail(theForm)
{
	var name = theForm.elements['user'].value;
	if (name == "")
		return;
//	alert ("checkavail "+name);
	sajax_target_id = 'poperr'; 
	x_p_check_avail(name,GLang); 
	sajax_target_id = '';
}
function js_check_username(name)
{
	if (name == "")
	{
		pop_err("Please, enter a username, min 6 char alphanumeric only.","user");	
		return true;
	}
	var User_N = name;
	User_N = User_N.toLowerCase();	// LOWERCASE ONLY
	var patt1 = /\W/g;
	var uu = "";
	uu = User_N.match(patt1);
	if (uu != null)
	{
		pop_err("Username in Alphanumeric only!","user");	
		return true;
	}
	if (User_N.length < 6)
	{
		pop_err("Username: Six characters or more!","user");
		return true;
	}
	return false;
}
function js_check_passwords(theForm)
{
	var p = theForm.elements["pwd"];
	var pwd = p.value;
	pwd = pwd.toLowerCase();	// LOWERCASE ONLY
	p.value = pwd;
//	alert ("pwd = "+pwd);
	if (p.value == "")
	{
		pop_err("Please, enter a Password.","pwd");
		return true;
	}
	else
	{
		var patt1 = /\W/g;
		var uu = "";
		uu = pwd.match(patt1);
		if (uu != null)
		{
			pop_err("Pwd must be 6+ Alphanumeric only.","pwd");
			return true;
		}
		if (pwd.length < 6)
		{
			pop_err("Pwd must be 6 characters or more.","pwd");
			return true;
		}
		var rp = theForm.elements["rpwd"];
		var rpw = rp.value;
		rpw = rpw.toLowerCase();
		rp.value = rpw;
//		alert ("rpw: "+rpw);
		if (rpw == "")
		{
			pop_err("Please, repeat your password","rpwd");
			return true;
		}
		if (p.value != rpw && rpw != "")
		{
			pop_err("ERROR: your two passwords are not indentical","rpwd");
			return true;
		}
	}
	return false;
}
function js_check_email(theForm)
{
	var email = theForm.elements["email"].value;
	if (echeck(email))
	{
		pop_err("Please, enter a valid email address.","email");
		return true;
	}
	return false;
}
function js_check_user_form(theForm)
{
//	alert ("Checking username");
	if (js_check_username(theForm.elements['user'].value)) return true;
//	alert ("Checking passwords");
	if (js_check_passwords(theForm)) return true;
//	alert ("Checking email");
	if (js_check_email(theForm)) return true;
//	alert ("All checks passed");
	return false;
}
function js_new_user(theForm)
{
//	showform(theForm,"js_new_user calling js_check_user_form",0);
//	if (js_check_user_form(theForm)) return true;
	js_adjust_checkboxes(theForm);
	Sess = theForm.elements['s'].value;
	GUser = theForm.elements['user'].value;
	var txt = "";
	for (var i=0; i<theForm.elements.length; i++)
		txt += theForm.elements[i].name + "=" + theForm.elements[i].value + "&";
	txt += "lang="+GLang;
//	alert("Registering with: "+txt);
	sajax_target_id = 'main'; 
	x_p_new_user(txt); 
	sajax_target_id = '';
	if (GLang == "")
		GLang = "en";
	setCookie('glsess',Sess,1);
	setCookie('gllang',GLang,30);
	setCookie('gluser',GUser,1);
	setTimeout("js_my_profile()",5000);
}
function js_my_profile()
{
	window.location = HOMEPAGE+"glprofile.php?sub=mp";
}
function js_buy_member(typ)
{
//	alert ("Buying membership of type: "+typ);
	sajax_target_id = 'main'; 
	x_p_buy_member(Sess,typ); 
	sajax_target_id = '';
}
function js_pay_ms(theForm)
{
//	alert ("Form to payment Gateway:");
//	showform(theForm,"js_pay_ms",0);
	theForm.submit();
}
function js_free_ms(theForm)
{
//	alert ("Free membership");
//	showform(theForm,"js_free_ms",0);
	setCookie("glsess",Sess,1);
// registered: go to my home page...
	window.location = HOMEPAGE + "glprofile.php";
}
function pop_err(txt,field)
{
//	alert ("pop_err "+txt+", field:"+field);
	sajax_target_id = 'poperr'; 
	x_p_pop_err(txt); 
	sajax_target_id = '';
	document.getElementById(field).focus();
}
function js_user_mydetails()
{
//	alert("js_user_mydetails -> sdregister");
	window.location = HOMEPAGE + "sdregister.php";
}
function js_user_update_details(theForm)
{
//	showform(theForm,"js_user_update_details",0);
	if (theForm.elements['npwd'].value != theForm.elements['rnpwd'].value)
	{
		pop_err("Unequal New Passwords! Try again","pwd");
		return;
	}
	var email = theForm.elements['email'].value;
	if (echeck(email))
	{
		pop_err("Please, enter a valid Email!","email");
		return;
	}
	// ADJUST CHECKBOXES
//	alert("Adjusting checkboxes");
	js_adjust_checkboxes(theForm);
//	alert ("CheckBoxes adjusted");
	var txt = "";
	for (var i=0; i<theForm.elements.length; i++)
		txt += theForm.elements[i].name + "=" + theForm.elements[i].value + "&";
	txt += "s="+Sess+"&";
//	alert ("txt: "+txt);
	sajax_target_id = 'main';
	x_p_user_update_details(txt); 
	sajax_target_id = '';
}
function js_adjust_checkboxes(theForm)
{
	if (theForm.elements['swoman'].checked)
		theForm.elements['swoman'].value = "T";
	else
		theForm.elements['swoman'].value = "F";
	if (theForm.elements['sman'].checked)
		theForm.elements['sman'].value = "T";
	else
		theForm.elements['sman'].value = "F";
	if (theForm.elements['scouplemf'].checked)
		theForm.elements['scouplemf'].value = "T";
	else
		theForm.elements['scouplemf'].value = "F";
	if (theForm.elements['scouplem'].checked)
		theForm.elements['scouplem'].value = "T";
	else
		theForm.elements['scouplem'].value = "F";
	if (theForm.elements['scouplef'].checked)
		theForm.elements['scouplef'].value = "T";
	else
		theForm.elements['scouplef'].value = "F";
	if (theForm.elements['sgroup'].checked)
		theForm.elements['sgroup'].value = "T";
	else
		theForm.elements['sgroup'].value = "F";
	if (theForm.elements['sts'].checked)
		theForm.elements['sts'].value = "T";
	else
		theForm.elements['sts'].value = "F";
	if (theForm.elements['chat'].checked)
		theForm.elements['chat'].value = "T";
	else
		theForm.elements['chat'].value = "F";
	if (theForm.elements['discreet'].checked)
		theForm.elements['discreet'].value = "T";
	else
		theForm.elements['discreet'].value = "F";
	if (theForm.elements['one2one'].checked)
		theForm.elements['one2one'].value = "T";
	else
		theForm.elements['one2one'].value = "F";
	if (theForm.elements['groupsex'].checked)
		theForm.elements['groupsex'].value = "T";
	else
		theForm.elements['groupsex'].value = "F";
	if (theForm.elements['alternative'].checked)
		theForm.elements['alternative'].value = "T";
	else
		theForm.elements['alternative'].value = "F";
}
function js_sel_country(val,id)	//id: me or them
{
//	alert ("js_sel_country, list regions: val="+val+", id:"+id);
	GCcode = val;
	// LIST REGIONS FOR CCODE IN IDREGION
	var trgid = id + "region"; //meregion
	sajax_target_id = trgid;
	x_p_list_regions(id,GCcode);  //mycountry, myregion, ccode
	sajax_target_id = '';
}
function js_sel_region(val,id)
{
//	alert ("js_sel_region, list towns: val="+val+", id:"+id);
	GRegioncode = val;
	// LIST TOWNS FOR GCode and GRegioncode IN  IDTOWN
	var trgid = id + "town";
	sajax_target_id = trgid;
	x_p_list_towns(id,GCcode,GRegioncode); 	// mytown
	sajax_target_id = '';
}
// =========================================================================
// === PERSONALS
// =========================================================================
function js_pers_ad_form()
{
	sajax_target_id = "main";
	x_p_pers_ad_form(Sess,GLang);
	sajax_target_id = '';
}
function js_pers_ad_insert(theForm)
{
	// CHECK THE FORM!!!
//	showform(theForm,"js_pers_ad_insert",0);
	var txt = "";
	for (var i=0; i<theForm.elements.length; i++)
		txt += theForm.elements[i].name + "=" + theForm.elements[i].value + "&";
	txt += "s="+Sess+"&";
	sajax_target_id = "main";
	x_p_pers_ad_insert(GLang,txt);
	sajax_target_id = '';
}
// =========================================================================
// === ADMIN
// =========================================================================
function js_admin()
{
	window.location = HOMEPAGE+"gladmin.php";
}
// =========================================================================
// === CONTACTS
// =========================================================================
function js_contacts()
{
	window.location = HOMEPAGE+"glcontacts.php";
}
function js_contact_send(theForm)
{
//	showform(theForm,0,0);
	var txt = "";
	for (var i=0; i<theForm.elements.length; i++)
		txt += theForm.elements[i].name + "=" + theForm.elements[i].value + "&";
	txt += "s="+Sess+"&";
	sajax_target_id = 'main';
	x_p_contact_send(txt); 
	sajax_target_id = '';
}
// =========================================================================
// === CATEGORIES
// =========================================================================

// =========================================================================
// === TOS
// =========================================================================

// =========================================================================
// === COMMON
// =========================================================================
function js_jumpto(anchor)
{
	window.location = HOMEPAGE+anchor;
}
function js_sdarken(x,txt)
{
	if (GSPrevId != "")
		GSPrevId.style.backgroundImage = "url(pics/staboff.gif)";	// WORKS ON ALL PASSING "THIS"
	x.style.backgroundImage = "url(pics/stabon.gif)";	// WORKS ON ALL PASSING "THIS"
	var dst = document.getElementById("searching");
	dst.value = txt;
	GSPrevId = x;
}
function js_btn100_down(x)
{

}
function js_btn100_up(x)
{

}
function js_left_down(x)
{
	x.style.backgroundImage = "url(pics/btnlefton.png)";
}
function js_left_up(x)
{
	x.style.backgroundImage = "url(pics/btnleftoff.png)";
}
function js_right_down(x)
{
	x.style.backgroundImage = "url(pics/btnrighton.png)";
}
function js_right_up(x)
{
	x.style.backgroundImage = "url(pics/btnrightoff.png)";
}
function js_prev_pic()
{
	var duser = document.getElementById("duser").value;
	var picndx = document.getElementById("picndx").value;
	var siz = document.getElementById("dsize").value;
//	alert ("duser: "+duser+", picndx: "+picndx+", siz: "+siz);
	if (picndx == 0)
		picndx = siz-1;
	else
		picndx--;
	// UPDATE FIELD
	document.getElementById("picndx").value = picndx;
	// Show picture in pubpic.
	sajax_target_id = 'pubpic';
	x_p_show_pic(duser,picndx); 
	sajax_target_id = '';	
}
function js_next_pic()
{
	var duser = document.getElementById("duser").value;
	var picndx = document.getElementById("picndx").value;
	var siz = document.getElementById("dsize").value;
//	alert ("duser: "+duser+", picndx: "+picndx+", siz: "+siz);
	if (picndx == (siz-1))
		picndx = 0;
	else
		picndx++;
	// UPDATE FIELD
	document.getElementById("picndx").value = picndx;
//	alert ("New pic: "+picndx);
	// Show picture in pubpic.
	sajax_target_id = 'pubpic';
	x_p_show_pic(duser,picndx); 
	sajax_target_id = '';	
}
function js_album_prev_pic()
{
	var duser = document.getElementById("albumuser").value;
	var picndx = document.getElementById("albumndx").value;
	var siz = document.getElementById("albumsize").value;
//	alert ("duser: "+duser+", picndx: "+picndx+", siz: "+siz);
	if (picndx == 0)
		picndx = siz-1;
	else
		picndx--;
	// UPDATE FIELD
	document.getElementById("albumndx").value = picndx;
	// Show picture in pubpic.
	sajax_target_id = 'albumpic';
	x_p_album_show_pic(duser,picndx); 
	sajax_target_id = '';	
}
function js_album_next_pic()
{
	var duser = document.getElementById("albumuser").value;
	var picndx = document.getElementById("albumndx").value;
	var siz = document.getElementById("albumsize").value;
//	alert ("duser: "+duser+", picndx: "+picndx+", siz: "+siz);
	if (picndx == (siz-1))
		picndx = 0;
	else
		picndx++;
	// UPDATE FIELD
	document.getElementById("albumndx").value = picndx;
//	alert ("New pic: "+picndx);
	// Show picture in pubpic.
	sajax_target_id = 'albumpic';
	x_p_album_show_pic(duser,picndx); 
	sajax_target_id = '';	
}
function js_show_profile(user)
{
	window.location = "glprofile.php?u="+user;
//	sajax_target_id = 'main';
//	x_p_profileform(Sess,user); 
//	sajax_target_id = '';	
}
// === POP-UP ============================================================
function js_pop_form(w)
{
//	alert("js_pop_form");
	GetW();
	GetH();
	var yScroll = getPageScroll();
	if (document.getElementById("popup"))
		var x = document.getElementById("popup");
	else
	{
		alert("FATAL ERROR: popup div does not exist");
		return;
	}	
	var t = eval(yScroll + 280);
	var l = eval((Scrw - w) / 2);
//	alert ("t: "+t+", l: "+l);
	x.style.top = t;
	x.style.left = l;
	x.style.visibility = "visible";
//	alert("top: "+x.style.top+" - left: "+x.style.left);
}
function getPageScroll()
{
	var yScroll;
	if (self.pageYOffset) 
		yScroll = self.pageYOffset;
	else if (document.documentElement && document.documentElement.scrollTop) // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	else if (document.body) // all other Explorers
		yScroll = document.body.scrollTop;
	return yScroll;
}
function js_close_pop()
{
//	alert ("js_close_pop");
	var x = document.getElementById("popup");
	x.style.visibility = "hidden";
}
function js_intro_form()	// Only accessible to Current user
{
	sajax_target_id = 'popup';
	x_p_intro_form(Sess); 
	sajax_target_id = '';	
	js_pop_form(600);
}
function js_intro_change()
{
//	alert("js_intro_change");
	var x = document.getElementById("lng");
	var lang = x.value;	// only EN, ES, PT
//	alert ("js_intro_change to: "+lang);
	sajax_target_id = 'introtxt';
	x_p_intro_change(Sess,lang); 
	sajax_target_id = '';	
}
function js_intro_save(theForm)
{
	var intro = theForm.elements['introtxt'].value;
	var lng = theForm.elements['lng'].value;
	GUser = theForm.elements['user'].value;
//	alert ("Saving intro for "+GUser+", in "+lng+"\r\n"+intro);
	sajax_target_id = 'popup';
	x_p_intro_save(Sess,intro,lng); 
	sajax_target_id = '';	
	setTimeout("updintro()",1000);
	js_close_pop();
}
function updintro()
{
	sajax_target_id = 'intro';
	x_p_intro(Sess,GUser); 
	sajax_target_id = '';
}
function js_info_form()	// Only accessible to Current user
{
	sajax_target_id = 'popup';
	x_p_info_form(Sess); 
	sajax_target_id = '';	
	js_pop_form(500);
}
function js_info_save(theForm)
{
//	showform (theForm,"js_info_form",0);
	if (theForm.elements['speaken'].checked)
		theForm.elements['speaken'].value = "en|";
	else
		theForm.elements['speaken'].value = "";
	if (theForm.elements['speakes'].checked)
		theForm.elements['speakes'].value = "es|";
	else
		theForm.elements['speakes'].value = "";
	if (theForm.elements['speakpt'].checked)
		theForm.elements['speakpt'].value = "pt|";
	else
		theForm.elements['speakpt'].value = "";
	var txt = "";
	for (var i=0; i<theForm.elements.length; i++)
		txt += theForm.elements[i].name + "=" + theForm.elements[i].value + "&";
	GUser = theForm.elements['user'].value;
	sajax_target_id = 'popup';
	x_p_info_save(Sess,txt); 
	sajax_target_id = '';
	setTimeout(updinfo(),1000);
	js_close_pop();
}
function updinfo()
{
	sajax_target_id = 'infopanel';
	x_p_info(Sess,GUser); 
	sajax_target_id = '';
}
// =========================================================================
// === AVATAR
// =========================================================================
function js_avatar_create()
{
	sajax_target_id = 'popup';
	x_p_avatar_create(Sess); 
	sajax_target_id = '';	
	js_pop_form(600);
}
function js_crop_avt(s,u,fname,x,y)
{
	Sess = s;
	GUser = u;
	sajax_target_id = "myavatar"; 
	x_p_crop_avt(Sess,GUser,fname,x,y); 
	sajax_target_id = '';
}
function js_avatar_refresh(user)
{
	sajax_target_id = "my_avatar";
	x_p_avatar_refresh(user); 
	sajax_target_id = '';
	sajax_target_id = "profstatus";
	x_p_status_update(Sess,GUser,"avatar"); 
	sajax_target_id = '';
}
function js_mypubimg()
{
	sajax_target_id = 'popup';
	x_p_mypubimg(Sess); 
	sajax_target_id = '';	
	js_pop_form(600);
}
function js_mypics()
{
	sajax_target_id = 'popup';
	x_p_mypics(Sess); 
	sajax_target_id = '';	
	js_pop_form(600);
}
// =============================================================================
function js_mnu_down(x)
{
	x.style.backgroundImage = "url(pics/mnuon.png)";
}
function js_mnu_up(x)
{
	x.style.backgroundImage = "url(pics/mnuoff.png)";
}
function js_pubpic_upload()
{
	alert ("js_public_upload");
	sajax_target_id = 'popup';
	x_p_pubpic_upload(Sess); 
	sajax_target_id = '';	
	js_pop_form(600);
}
function js_pubpic_send(theForm)
{
//	showform(theForm,"js_pubpic_send",0);
	theForm.submit();
}
function js_affil_submit(theForm)
{
//	showform(theForm,"js_affil_submit",0);
	var txt = "";
	for (var i=0; i<theForm.elements.length; i++)
		txt += theForm.elements[i].name + "=" + theForm.elements[i].value + "&";
	sajax_target_id = 'code';
	x_p_affil_submit(txt); 
	sajax_target_id = '';	
	
}
function js_set_img(x)
{
	var val = x.value;
	var y = document.getElementById('banner');
	y.value = val;
}
/*
// =========================================================================
// === POP WINDOW
// =========================================================================
function js_pop_open(top,w,h,f)
{
	GetW();
	GetH();
//	alert(Scrw+" x "+Scrh);
	var yScroll = getPageScroll();
//	alert("Page scroll: "+yScroll);
	sajax_target_id = 'pop';
	switch (f)
	{
		case "login":
			x_p_pop_open(Scrw,Scrh,f,Sess); 
			break;
		case "register":
			x_p_register_form(Sess,"new");
			break;
		case "mydetails":
			x_p_user_mydetails(Sess);
			break;
		case "contact":
			x_p_contact_form(Sess);
			break;
		case "tos":
			x_p_tos(Sess);
			break;
		case "ps":
			x_p_ps(Sess);
			break;
	}
	sajax_target_id = '';
	var x = document.getElementById("pop");
	var t = yScroll + top;
	x.style.top = t;
	var l = eval((Scrw - w - 40) / 2);
	x.style.position = "absolute";
	x.style.left = l;
	x.style.width = w+40;
	x.style.height = h+40;
	sajax_target_id = 'pop'; 
	x.style.visibility = "visible";
}
function getPageScroll()
{
	var yScroll;
	if (self.pageYOffset) 
		yScroll = self.pageYOffset;
	else if (document.documentElement && document.documentElement.scrollTop) // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	else if (document.body) // all other Explorers
		yScroll = document.body.scrollTop;
	return yScroll;
}
function js_pop_close()
{
	var x = document.getElementById("pop");
	x.style.visibility = "hidden";
	sajax_target_id = 'pop';
	x_p_pop_clear(); 
	sajax_target_id = '';
}
*/