function GotoURL(location) {
 document.getElementById("sysdatform").action=baseDir+location
 document.getElementById("sysdatform").submit();
}
function QuickFindUser() {
 if(document.getElementById("qsearchval").value=="") {
  var t = document.getElementById("QsearchBy").value
  alert("Specify "+t+" please !")
  return
 }
 document.getElementById("sysdatform").action=baseDir+"members/find.php?findby="+document.getElementById("QsearchBy").value+"&find="+document.getElementById("qsearchval").value
// sysdatform.action="test.html";
 document.getElementById("sysdatform").submit()
}  

/* #################################
             USE:
       loadXMLDoc(url,Content)  
       where:      
	url - is url for loading content
	Content - is target of data

*/

var req;
var XMLcontent;

function loadXMLDoc(url,Content) {
	req = null;
	XMLcontent = Content

	
    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest) {
    	try {
			req = new XMLHttpRequest();
        } catch(e) {
			req = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = false;
        	}
		}
    }
	if(req) {
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		req.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
		req.send(null);		
	}
}


function processReqChange() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            // ...processing statements go here...
            document.getElementById("traceAll").innerHTML = req.responseText
             if(document.getElementById("sys_cntdat"))
              document.getElementById("sysdatform").user_expid.value = document.getElementById("sys_cntdat").innerHTML
        } else {
            alert("Lost Connection to the server.\n" +
                req.statusText);
        }
    }
}


// ##############################################
var TraceInterval=null
function TraceUser() {

// alert(document.getElementById("sysdatform").user_expid.value+"&user_id="+document.getElementById("sysdatform").user_id.value)
 if(document.getElementById("sysdatform"))
  loadXMLDoc(baseDir+"statistic/traceusers.php?expid="+document.getElementById("sysdatform").user_expid.value+"&user_id="+document.getElementById("sysdatform").user_id.value,"traceAll");

 clearInterval(TraceInterval)
 TraceInterval=setInterval("TraceUser()",8000)     
}



onload=TraceUser




// ################## COOKIES #######################
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}


// #######################################
// #    MAILBOX FUNCTIONS 
// #######################################
var OpenMailBoxSubject="";
function OpenMailBox(mailname) {
 if(document.getElementById("sysdatform").mail_sys) {
  document.getElementById("sysdatform").action="main.php";
  if(document.getElementById("sysdatform").sel_mailmode)
   document.getElementById("sysdatform").sel_mailmode.value=""  
  document.getElementById("sysdatform").submit()  
   return
 }
 winModalWindow = window.open ("","MailBox", "scrollbars=yes,dependent=yes,width=800,height=520")
 winModalWindow.focus()
 var act = document.getElementById("sysdatform").action
 if(mailname)
  document.getElementById("sysdatform").action = baseDir+"members/mail/main.php?mail_style=1&letter_to="+mailname+"&sel_mailmode=1&Subj="+OpenMailBoxSubject
 else
  document.getElementById("sysdatform").action = baseDir+"members/mail/main.php?mail_style=1"


 document.getElementById("sysdatform").target = "MailBox";
 document.getElementById("sysdatform").submit();
 
 document.getElementById("sysdatform").action=act
 document.getElementById("sysdatform").target="_self";
 OpenMailBoxSubject="";
}

// #########################
// #      OnlineSH
// #########################

function OnlineSH() {
 winModalWindow = window.open ("","OnlineUsers", ",scrollbars=no,dependent=yes,width=260,height=530")
 winModalWindow.focus()
 var act = document.getElementById("sysdatform").action
 var tar = document.getElementById("sysdatform").target 
  document.getElementById("sysdatform").action = baseDir+"members/whoisonline/index.php" 
 document.getElementById("sysdatform").target = "OnlineUsers";
 document.getElementById("sysdatform").submit();
   
 document.getElementById("sysdatform").action=act
 document.getElementById("sysdatform").target=tar
  
}
