// JavaScript Document

function chcol(){
	//alert(window.document.getElementById("colour").style.backgroundColor);
	if(document.getElementById("colour").style.backgroundColor == "#ff766a" || document.getElementById("colour").style.backgroundColor == "rgb(255, 118, 106)"){
		//alert(document.getElementById("colour").style.backgroundColor);
		document.getElementById("colour").style.backgroundColor = "#68BDFF";
		markcol = 'blu';
	}
	else if(document.getElementById("colour").style.backgroundColor == "#68bdff" || document.getElementById("colour").style.backgroundColor == "rgb(104, 189, 255)"){
		document.getElementById("colour").style.backgroundColor = "#93ff68";
		markcol ='gre';
	}
	else if(document.getElementById("colour").style.backgroundColor == "#93ff68" || document.getElementById("colour").style.backgroundColor == "rgb(147, 255, 104)"){
		document.getElementById("colour").style.backgroundColor = "#fa6900";
		markcol ='ora';
	}
	else if(document.getElementById("colour").style.backgroundColor == "#fa6900" || document.getElementById("colour").style.backgroundColor == "rgb(250, 105, 0)"){
		document.getElementById("colour").style.backgroundColor = "#ff68d6";
		markcol ='pin';
	}
	else if(document.getElementById("colour").style.backgroundColor == "#ff68d6" || document.getElementById("colour").style.backgroundColor == "rgb(255, 104, 214)"){
		document.getElementById("colour").style.backgroundColor = "#c168ff";
		markcol ='vio';
	}
	else if(document.getElementById("colour").style.backgroundColor == "#c168ff" || document.getElementById("colour").style.backgroundColor == "rgb(193, 104, 255)"){
		document.getElementById("colour").style.backgroundColor = "#ffef68";
		markcol ='yel';
	}
	else if(document.getElementById("colour").style.backgroundColor == "#ffef68" || document.getElementById("colour").style.backgroundColor == "rgb(255, 239, 104)"){
		document.getElementById("colour").style.backgroundColor = "#ff766a";
		markcol ='std';
	}
}

//Special DnD for CrippleFox
function getStyle(oElm, strCssRule){
    var strValue = "";
    if(document.defaultView && document.defaultView.getComputedStyle){
        var css = document.defaultView.getComputedStyle(oElm, null);
        strValue = css ? css.getPropertyValue(strCssRule) : null;
    }
    else if(oElm.currentStyle){
        strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
            return p1.toUpperCase();
        });
        strValue = oElm.currentStyle[strCssRule];
    }
    return strValue;
}


function Draggable(el)
{
  var xDelta = 0, yDelta = 0;
  var xStart = 0, yStart = 0;

  // remove the events
  function enddrag()
  {
    document.onmouseup = null;
    document.onmousemove = null;
  }

  // fire each time it's dragged
  function drag(e)
  {
    e = e || window.event;
    xDelta = xStart - parseInt(e.clientX);
    yDelta = yStart - parseInt(e.clientY);
    xStart = parseInt(e.clientX);
    yStart = parseInt(e.clientY);
    el.style.top = (parseInt(el.style.top) - yDelta) + 'px';
    el.style.left = (parseInt(el.style.left) - xDelta) + 'px';
  }

  // initiate the drag
  function md(e)
  {
    e = e || window.event;
    xStart = parseInt(e.clientX);
    yStart = parseInt(e.clientY);
    el.style.top = parseInt(getStyle(el,'top')) + 'px';
    el.style.left = parseInt(getStyle(el,'left')) + 'px';
    document.onmouseup = enddrag;
    document.onmousemove = drag;
    return false;
  }

  // tie it into the element
  el.onmousedown = md;

}

//Normal Browser DnD

var Drag = {

obj : null,

init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
{
o.onmousedown = Drag.start;

o.hmode = bSwapHorzRef ? false : true ;
o.vmode = bSwapVertRef ? false : true ;

o.root = oRoot && oRoot != null ? oRoot : o ;

if (o.hmode && isNaN(parseInt(o.root.style.left ))) o.root.style.left = "0px";
if (o.vmode && isNaN(parseInt(o.root.style.top ))) o.root.style.top = "0px";
if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right = "0px";
if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

o.minX = typeof minX != 'undefined' ? minX : null;
o.minY = typeof minY != 'undefined' ? minY : null;
o.maxX = typeof maxX != 'undefined' ? maxX : null;
o.maxY = typeof maxY != 'undefined' ? maxY : null;

o.xMapper = fXMapper ? fXMapper : null;
o.yMapper = fYMapper ? fYMapper : null;

o.root.onDragStart = new Function();
o.root.onDragEnd = new Function();
o.root.onDrag = new Function();
},

start : function(e)
{
var o = Drag.obj = this;
e = Drag.fixE(e);
var y = parseInt(o.vmode ? o.root.style.top : o.root.style.bottom);
var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
o.root.onDragStart(x, y);

o.lastMouseX = e.clientX;
o.lastMouseY = e.clientY;

if (o.hmode) {
if (o.minX != null) o.minMouseX = e.clientX - x + o.minX;
if (o.maxX != null) o.maxMouseX = o.minMouseX + o.maxX - o.minX;
} else {
if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
}

if (o.vmode) {
if (o.minY != null) o.minMouseY = e.clientY - y + o.minY;
if (o.maxY != null) o.maxMouseY = o.minMouseY + o.maxY - o.minY;
} else {
if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
}

document.onmousemove = Drag.drag;
document.onmouseup = Drag.end;

return false;
},

drag : function(e)
{
e = Drag.fixE(e);
var o = Drag.obj;

var ey = e.clientY;
var ex = e.clientX;
var y = parseInt(o.vmode ? o.root.style.top : o.root.style.bottom);
var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
var nx, ny;

if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

if (o.xMapper) nx = o.xMapper(y)
else if (o.yMapper) ny = o.yMapper(x)

Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
Drag.obj.lastMouseX = ex;
Drag.obj.lastMouseY = ey;

Drag.obj.root.onDrag(nx, ny);
return false;
},

end : function()
{
document.onmousemove = null;
document.onmouseup = null;
Drag.obj.root.onDragEnd( parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), 
parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
Drag.obj = null;
},

fixE : function(e)
{
if (typeof e == 'undefined') e = window.event;
if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
return e;
}
};

var map;
var username;
var newmark;
var markcol ='std';
var http_request = false;
var http_request2 = false;
var pup=false;

function initAJAX() {
	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
			// zu dieser Zeile siehe weiter unten
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen');
		return false;
	}
}

function initAJAX2() {
	http_request2 = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request2 = new XMLHttpRequest();
		if (http_request2.overrideMimeType) {
			http_request2.overrideMimeType('text/xml');
			// zu dieser Zeile siehe weiter unten
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request2 = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request2 = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request2) {
		alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen');
		return false;
	}
}

function Login(button) {
	http_request = false;
	var url = "./scripts/login.php";
	//alert(button);
	initAJAX();
	//alert("postAJAX");
	http_request.onreadystatechange = setlogin;
	http_request.open('POST', url, true);
	if(button=='exit'){
		var sendvar="SubmitIt="+encodeURI(button);
		setTimeout("removeNM()",300);
		setTimeout("finishsecond()",400);
	}else if(button=='save'){
		var sendvar="SubmitIt="+encodeURI(button)+"&newpos="+encodeURI( document.getElementById('newpos').value )+"&datei="+encodeURI( document.getElementById('datei').value )+"&descri="+encodeURI( document.getElementById('descri').value );
	}else if(button=='savep'){
		pup=true;
		var sendvar="SubmitIt=save&newpos="+encodeURI( document.getElementById('newpos').value )+"&datei="+encodeURI( document.getElementById('datei').value )+"&descri="+encodeURI( document.getElementById('descri').value )+"&imgid=up";
	}else{
		var sendvar="SubmitIt="+encodeURI(button)+"&txtLogin="+encodeURI( document.getElementById('txtLogin').value )+"&txtPW="+encodeURI( document.getElementById('txtPW').value );
	}
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", sendvar.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(sendvar);
}

function fsearch(button,itype,usrnm) {
	http_request = false;
	var url = "./scripts/search.php";
	//alert(button);
	initAJAX();
	http_request.onreadystatechange = setsearch;
	http_request.open('POST', url, true);
	
	if(usrnm==''){
		var susertotrace = document.getElementById('txtSearch').value;
	}else{
		var susertotrace = usrnm;
	}
	if(itype == 'you'){
		susertotrace=username;
	}
	var sendvar="SubmitIt="+encodeURI(button)+"&txtSearch="+encodeURI( susertotrace )+"&itype="+encodeURI(itype);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", sendvar.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(sendvar);
}

function gethelp(button) {
	http_request = false;
	var url = "./scripts/help.php";
	initAJAX();
	http_request.onreadystatechange = function help() {
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
				var result = http_request.responseText;
				document.getElementById('help_con').innerHTML = result;
			} else {
				alert('Your request was invalid!');
			}
		}
		
	}
	http_request.open('POST', url, true);
	var sendvar="content="+encodeURI(button);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", sendvar.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(sendvar);
}

function getusrs(page,usrpro) {
	http_request2 = false;
	var url = "./scripts/users.php";
	initAJAX2();
	http_request2.onreadystatechange = function usrs() {
		if (http_request2.readyState == 4) {
			if (http_request2.status == 200) {
				var result2 = http_request2.responseText;
				document.getElementById('user_con').innerHTML = result2;
			} else {
				alert('Your request was invalid!');
			}
		}
	}
	http_request2.open('POST', url, true);
	if(usrpro!=''){
		var sendvar="page="+encodeURI(page)+"&profile="+encodeURI(usrpro);
		document.getElementById('livecontainer').style.visibility = "hidden";
		setTimeout("setpromark()", 500);
	}else{
		var sendvar="page="+encodeURI(page)+"&profile=-1";
		document.getElementById('livecontainer').style.visibility = "visible";
	}
	http_request2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request2.setRequestHeader("Content-length", sendvar.length);
	http_request2.setRequestHeader("Connection", "close");
	http_request2.send(sendvar);
}

function getlive(liveword) {
	http_request2 = false;
	var url = "./scripts/users.php";
	initAJAX2();
	http_request2.onreadystatechange = function usrs() {
		if (http_request2.readyState == 4) {
			if (http_request2.status == 200) {
				var result2 = http_request2.responseText;
				document.getElementById('user_con').innerHTML = result2;
			} else {
				alert('Your request was invalid!');
			}
		}
	}
	http_request2.open('POST', url, true);
	if(liveword!=''){
		var sendvar="liveword="+encodeURI(liveword)+"&profile=-1";
		setTimeout("setpromark()", 500);
	}else{
		var sendvar="liveword="+encodeURI("%")+"&profile=-1";
	}
	http_request2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request2.setRequestHeader("Content-length", sendvar.length);
	http_request2.setRequestHeader("Connection", "close");
	http_request2.send(sendvar);
}

function getusername() {
	http_request = false;
	var url = "./scripts/username.php";
	initAJAX();
	http_request.onreadystatechange = gun;
	http_request.open('POST', url, true);
	var sendvar="dummy=dummy";
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", sendvar.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(sendvar);
}

function gun() {
//alert('xxx');
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			username = http_request.responseText;
			if (username == ''){
				username=-1;
			}
			//alert('UN: '+username);
		} else {
			alert('Your request was invalid!');
		}
	}
}
	
function setlogin() {
	
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			//alert(http_request.responseText);
			var result = http_request.responseText;
			//alert('1');
			document.getElementById('jip_login').innerHTML = result;
			setTimeout("finishsecond()",200);
			if(pup==true)
			{
				pup=false;
				var imgfid =document.getElementById('imgid').innerHTML;
				window.open("scripts/picupload.php?tpid="+imgfid,"","scrollbars=no,status=no,toolbar=no,location=no,directories=no,resizable=no,menubar=no,width=400,height=150");
			}
			var fthree = String(result).substring(0,3);
			//alert(fthree);
			if (fthree == "You"){
				setTimeout('getusername()',200);
				setTimeout('setyoumark()',500);
			}
		} else {
			alert('Your request was invalid!');
		}
	}
}

function propicupload(){
	window.open("scripts/picupload.php?tpid=prousr","","scrollbars=no,status=no,toolbar=no,location=no,directories=no,resizable=no,menubar=no,width=400,height=150");	
}

function propicdel(){
	edidel('del','pic');
	alert("Your picture has been removed.");
}

function setyoumark(){
	fsearch('Add','you','dummy');
}

function setsearch() {
	if (http_request.readyState == 4) {	
		if (http_request.status == 200) {
			//alert(http_request.responseText);
			var mc = getMC();
			var mz = getMZ();
			var mt = getMT();
			//alert(mc+";"+mz+";"+mt);
			//alert(http_request.responseText);
			eval(http_request.responseText);
			//alert("AFTER");
		} else {
			alert('Your request was invalid!');
		}
	}
}

function del_it(id){
	if (confirm("Do you really want to delete this entry?\nThis will hidde all current Traces but yours    "))
	{
		document.getElementById('del'+id).disabled=true;
		edidel('delete',id);
	}
	else
	{
		
	}	
}

function ed_it(id){
	if(document.getElementById('ed'+id).value=="EDIT")
	{
		document.getElementById('ed'+id).value="SAVE";
		var cont = document.getElementById('ol'+id).innerHTML;
		cont = cont.replace(/<BR>/g, "\n");
		document.getElementById('ol'+id).innerHTML = "<textarea name='edit"+id+"'>"+cont+"</textarea>";
	}
	else
	{
		if (confirm("Do you really want to edit this entry?\nThis will hidde all current Traces but yours    "))
		{
			document.getElementById('ed'+id).disabled=true;
			edidel('edit',id);
		}
		else
		{
			
		}	
	}
}

function edidel(func,id) {
	http_request = false;
	var url = "./scripts/edit.php";
	initAJAX();
	http_request.onreadystatechange = function ed_it() {
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
				var result = http_request.responseText;
				if(id!='pic'){
					setTimeout("fsearch('Trace','you','dummy')",1000);
					alert(result);		
				}
			} else {
				alert('Your request was invalid!');
			}
		}
	}
	http_request.open('POST', url, true);
	if(func == 'edit'){
		var tempcont = document.getElementById('edit'+id).value;
		var sendvar="function="+encodeURI(func)+"&id="+encodeURI(id)+"&cnt="+encodeURI(tempcont);
		//alert(sendvar);
	}else{
		var sendvar="function="+encodeURI(func)+"&id="+encodeURI(id);
	}
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", sendvar.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(sendvar);
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function P7AniMagic(el,x,y,a,b,c,s) { //v2.9 PVII-Project Seven Development
 var xx,yy,i,g,elo=el,f="",m=false,d="",pa='px';if(document.layers||window.opera){pa='';}
 x=parseInt(x);y=parseInt(y);var t='g.p7Magic=setTimeout("P7AniMagic(\''+elo+'\','; 
 if((g=MM_findObj(el))!=null){d=(document.layers)?g:g.style;}else{return;}
 if(parseInt(s)>0){eval(t+x+','+y+','+a+','+b+','+c+',0)",' + s+')');return;}
 xx=parseInt(d.left);if(isNaN(xx)){if(g.currentStyle){xx=parseInt(g.currentStyle.left);
 }else if(document.defaultView&&document.defaultView.getComputedStyle){
 xx=parseInt(document.defaultView.getComputedStyle(g,"").getPropertyValue("left"));}
 if(isNaN(xx)){xx=0;}}yy=parseInt(d.top);if(isNaN(yy)){if(g.currentStyle){yy=parseInt(g.currentStyle.top);
 }else if(document.defaultView&&document.defaultView.getComputedStyle){
 yy=parseInt(document.defaultView.getComputedStyle(g,"").getPropertyValue("top"));}
 if(isNaN(yy)){yy=0;}}if(c==1){x+=xx;y+=yy;m=true;c=0;}else if(c==2){m=false;
 if(g.p7Magic){clearTimeout(g.p7Magic);}}else{i=parseInt(a);if(g.p7Magic){clearTimeout(g.p7Magic);}
 if(xx<x){xx+=i;m=true;if(xx>x){xx=x;}}if(xx>x){xx-=i;m=true;if(xx<x){xx=x;}}
 if(yy<y){yy+=i;m=true;if(yy>y){yy=y;}}if(yy>y){yy-=i;m=true;if(yy<y){yy=y;}}}
 if(m){d.left=xx+pa;d.top=yy+pa;eval(t+x+','+y+','+a+','+b+','+c+',0)",'+b+')');}
}

var bsave = 0;
var tof = false;
var rescnt = 0;
function puttoform(){
	document.getElementById("datei").value = document.getElementById("datei_o").value;
	document.getElementById("descri").value = document.getElementById("descri_o").value;
}
function getMC(){
	//alert(map.getCenter());
	return map.getCenter();
}
function getMZ(){
	return map.getZoom();
}
function getMT(){
	return map.getCurrentMapType();
}
function removeNM(){
	document.getElementById("edit").style.visibility ="hidden";
	newmark.hide();
	document.frmLogin.cmd_add.value="Add new entry";
	tof=false;
	bsave=0
}
function addnp(){
		//alert("2");
		if(bsave==0){
			//alert("3");
			var mc = map.getCenter();
			newmark = addmarker(mc,"yel",true);
			map.addOverlay(newmark);
			bsave=1;
			//alert("0");
			if (document.getElementById)
			{
					  document.getElementById("edit").style.visibility ="visible";
					  
			}    
			else if (document.all)
			{
					
					  document.all("edit").style.visibility ="visible";
			}    
			else if (document.layers)    
			{
					
					  document.layers("edit").style.visibility ="visible";
			}
			document.frmLogin.cmd_add.value="save";
		}
		else
		{
			//alert("4");
			if(document.getElementById('imup').checked==true)
			{
				Login('savep');
			}else{
				Login('save');
			}
			setTimeout("finishaddnp()", 1500);
		}
}

function setpositions(){
	//var map = new GMap2(document.getElementById("map"));
	map.addOverlay(new GMarker(new GPoint(20, 100)));
}

function finishaddnp(){
	document.getElementById("datei_o").value="";
	document.getElementById("descri_o").value="";
	removeNM();
	fsearch('Trace','you',username);
}
			
function load() {
	if (GBrowserIsCompatible()) {
		//map.setCenter(new GLatLng(37.4419, -122.1419), 13);
		map.enableScrollWheelZoom();
		map.enableDoubleClickZoom();
		map.enableContinuousZoom();
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		/*map.addMapType(G_SATELLITE_3D_MAP); Google Earth Update - 20080531 */
		if (window.navigator.userAgent.indexOf('MSIE') != -1){
			map.setCenter(new GLatLng(25,20), 2, G_HYBRID_MAP);
		}else if(window.navigator.userAgent.indexOf('Opera') != -1){
			map.setCenter(new GLatLng(20,20), 2, G_HYBRID_MAP);
		}else{
			map.setCenter(new GLatLng(25,20), 2, G_HYBRID_MAP);
		}
	}
}		  
function shwcnt(){
	if (window.navigator.userAgent.indexOf('MSIE') != -1){
		document.getElementById("results").style.top = "40px";
		document.getElementById("results").style.left = "16px";
		document.getElementById("scell").style.height = "50px";
		document.getElementById("seach_tab").style.position = "relative";
		document.getElementById("seach_tab").style.top = "-14px";
	}
	else
	{
		document.getElementById("results").style.position = "relative";
		document.getElementById("results").style.top = "0px";
		document.getElementById("results").style.left = "0px";
	}
	document.getElementById("search").style.height = "100px";
	if(rescnt>0){
		document.getElementById("results").innerHTML = "<br>I found " + rescnt + " entries for this user";
	}else{
		document.getElementById("results").innerHTML = "<br>I didn't found any entries for such user ( <? echo $txtSearch; ?>)";
	}
	document.getElementById("results").style.visibility ="visible";
}
function setmarker(lat,lng,info,itype){
var point = new GLatLng(lat,lng);
var marker = addmarker(point,itype,false);
//new GMarker(point);
GEvent.addListener(marker, "click", function() { 
	marker.openInfoWindowHtml(info);
}); 
return marker;
}
function addmarker(cepoint,itype,drag){
//alert(cepoint + ";" + itype + ";" + drag);
	var point = cepoint;
	var TypeIcon = new GIcon(G_DEFAULT_ICON);
	TypeIcon.image = "http://tracealife.com/images/markers/marker"+itype+".png";// Set up our GMarkerOptions object
	var markerOptions = { icon:TypeIcon,draggable:drag };
	var newmarker = new GMarker(point, markerOptions);
	if(drag==true){
		document.frmLogin.newpos.value = newmarker.getLatLng();
		GEvent.addListener(newmarker, "dragend", function() { 
			document.frmLogin.newpos.value = newmarker.getLatLng();
		}); 
	}
	return newmarker;
}

function finishfirst(){
	//alert(username);
	Login('main');
}

function editpro(button){
	if(button=='act'){
		document.getElementById('edipro').innerHTML ="<img src=\"images/icons/savedit.png\" width=\"48\" height=\"48\" onClick=\"javascript:editpro('save_act');\" alt=\"save profile...\" />";
		
		var pname = document.getElementById('edit_pname').innerHTML;
		var sname = document.getElementById('edit_sname').innerHTML;
		var sex = document.getElementById('edit_sex').innerHTML;
		var byear = document.getElementById('edit_byear').innerHTML;
		var loc = document.getElementById('edit_loc').innerHTML;
		
		document.getElementById('edit_pname').innerHTML = "<input id='txt_pname' type='text' value='"+pname+"'>";
		document.getElementById('edit_sname').innerHTML = "<input id='txt_sname' type='text' value='"+sname+"'>";
		if(sex=="Male"){
			document.getElementById('edit_sex').innerHTML = "<select id=\"txt_sex\" id=\"txt_sex\"><option value=\"0\" selected=\"selected\">Male</option><option value=\"1\">Female</option></select>";
		}else{
			document.getElementById('edit_sex').innerHTML = "<select name=\"txt_sex\" id=\"txt_sex\"><option value=\"0\">Male</option><option value=\"1\" selected=\"selected\">Female</option></select>";
		}	
		document.getElementById('edit_byear').innerHTML = "<input id='txt_byear' type='text' value='"+byear+"'>";
		document.getElementById('edit_loc').innerHTML = "<input id='txt_loc' type='text' value='"+loc+"'>";
	}else if(button=='about'){
		var aboutme = document.getElementById('aboutcnt').innerHTML;
		aboutme = aboutme.replace(/<BR>/g, "\n");
		document.getElementById('proabout').innerHTML = "<textarea name=\"txt_about\" id=\"txt_about\" cols=\"35\" rows=\"5\">"+aboutme+"</textarea><br /><img src=\"images/icons/savedit.png\" width=\"48\" height=\"48\" onClick=\"javascript:editpro('save_about');\" alt=\"save 'About Me'...\" />";
	}else if(button=='save_about'){
		profile('about_pro');
	}else if(button=='save_act'){
		profile('std_pro');
		//document.getElementById('edipro').innerHTML ="<img src=../../build/scripts/js//"images/icons/edit.png/" width=\"48\" height=\"48\" onClick=\"javascript:editpro('act');\" alt=\"edit profile...\" />";
	}
}

function profile(profunc) {
	http_request = false;
	var url = "./scripts/proedit.php";
	initAJAX();
	http_request.onreadystatechange = function pro_it() {
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
				var result = http_request.responseText;
				//alert(result);
				eval(result);
			} else {
				alert('Your request was invalid!');
			}
		}
	}
	http_request.open('POST', url, true);
	
	if(profunc=='std_pro'){
		var pname = document.getElementById('txt_pname').value;
		var sname = document.getElementById('txt_sname').value;
		var sex = document.getElementById('txt_sex').value;
		var byear = document.getElementById('txt_byear').value;
		var loc = document.getElementById('txt_loc').value;

		var sendvar="function="+encodeURI(profunc)+"&pname="+encodeURI(pname)+"&sname="+encodeURI(sname)+"&sex="+encodeURI(sex)+"&byear="+encodeURI(byear)+"&loc="+encodeURI(loc);
	}else if(profunc=='about_pro'){
		var about = document.getElementById('txt_about').value;
		var sendvar="function="+encodeURI(profunc)+"&about="+encodeURI(about);
	}else{
		var sendvar="function="+encodeURI(profunc);
	}
	
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", sendvar.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(sendvar);
}
