function Xmlhtc(){
var httprequest=false
if (window.XMLHttpRequest){ // if Mozilla, Safari etc
httprequest=new XMLHttpRequest()
if (httprequest.overrideMimeType)
httprequest.overrideMimeType('text/xml')
}
else if (window.ActiveXObject){ // if IE
try {
httprequest=new ActiveXObject("Msxml2.XMLHTTP");
} 
catch (e){
try{
httprequest=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){}
}
}
return httprequest
}
var httpcrOb = Xmlhtc();

//////////////////
function waitact(){
document.getElementById('alldiv').innerHTML = '<img src="http://lrtweet.com/image/ajax-loader.gif" border="0" /> Please wait';

}

var idrepzalo;
var steledirep="no";
function editrep(idrepz,typedit){

idrepzalo=idrepz;

if(typedit=="shwform"){
	if(steledirep=="yes"){
		alert("You are already modify reply");
					return;
	}
	urlz="http://lrtweet.com/fun.php?act=editrep";
	
	senrtyp="idrep="+idrepz;
	steledirep="yes";
}
else{
	if(document.getElementById('mylo').value=="" || document.getElementById('tywri').value==""){
		alert("Please write any thing");
					return;
	}	
	urlz="http://lrtweet.com/fun.php?act=doneeditrep";	
	steledirep="no";
	senrtyp="idrep="+idrepz;
	senrtyp += '&mylo=' + document.getElementById('mylo').value;
	senrtyp += '&tywri=' + document.getElementById('tywri').value;
	
}	
	

	document.getElementById(idrepz).innerHTML = '<img src="http://lrtweet.com/image/ajax-loader.gif" border="0" /> Please wait';
	      if (httpcrOb.readyState == 4 || httpcrOb.readyState == 0) {
                    httpcrOb.open("POST", urlz, true);
					httpcrOb.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
						
					
					httpcrOb.onreadystatechange = handtoedac; 
					httpcrOb.send(senrtyp);
					
					
				}
				
}
function tweetdone(idrepz){
	
window.open('http://twitter.com/home?status='+encodeURI(document.getElementById('message').value));
canceditrep(idrepz,'no');
}
function tweetdonenot(idrepz){
//for not user	
steledirep="no";
window.open('http://twitter.com/home?status='+encodeURI(document.getElementById('message').value));
}
function tweet(idrepz){
idrepzalo=idrepz;	
	if(steledirep=="yes"){
		alert("You are already modify reply");
					return;
	}
	steledirep="yes";
document.getElementById(idrepz).innerHTML = '<img src="http://lrtweet.com/image/ajax-loader.gif" border="0" /> Please wait';
	      if (httpcrOb.readyState == 4 || httpcrOb.readyState == 0) {
                    httpcrOb.open("POST", "http://lrtweet.com/fun.php?act=tweet", true);
					httpcrOb.setRequestHeader('Content-Type','application/x-www-form-urlencoded');					
					httpcrOb.onreadystatechange = handtoedac; 
					senrtyp="idrep="+idrepz;
					httpcrOb.send(senrtyp);
					
					
				}
}

function textCounter(field) {
var maxlimit=140;
var countfield=document.getElementById('remLen');
	
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else
countfield.firstChild.data = maxlimit - field.value.length;
}

function canceditrep(idrepz,typedit){
idrepzalo=idrepz;	
document.getElementById(idrepz).innerHTML = '<img src="http://lrtweet.com/image/ajax-loader.gif" border="0" /> Please wait';
	      if (httpcrOb.readyState == 4 || httpcrOb.readyState == 0) {
			  steledirep="no";
                    httpcrOb.open("POST", "http://lrtweet.com/fun.php?act=canseditrep", true);
					httpcrOb.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
						
					
					httpcrOb.onreadystatechange = handtoedac; 
					senrtyp="idrep="+idrepz;
					httpcrOb.send(senrtyp);
					
					
				}
}
function handtoedac(){

if(httpcrOb.readyState == 4){
document.getElementById(idrepzalo).innerHTML= httpcrOb.responseText;
}

}

function delrep(idrepz){
	if(steledirep=="yes"){
		alert("You are already modify reply");
					return;
	}	
if(window.confirm("Sure you want to delete this reply ("+idrepz+")")) {
  
}
else
{
return;
}	
idrepzalo=idrepz;
	document.getElementById(idrepz).innerHTML = '<img src="http://lrtweet.com/image/ajax-loader.gif" border="0" /> Please wait';
	      if (httpcrOb.readyState == 4 || httpcrOb.readyState == 0) {
                    httpcrOb.open("POST", 'http://lrtweet.com/fun.php?act=delrep&idrep='+idrepz, true);
					httpcrOb.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
					httpcrOb.onreadystatechange = handtolact; 
					var param = 'idrep=' + idrepz;
					httpcrOb.send(param);
					
					
				}
				//cloceidrep(idrepz);
}
var fromdelrep='';
function handtolact(){		
if (httpcrOb.readyState == 4) {	
	
	fromdelrep="fromdelrep";
manag();	
 }
 
}

function logout(){
	      if (httpcrOb.readyState == 4 || httpcrOb.readyState == 0) {
                    httpcrOb.open("POST", 'http://lrtweet.com/fun.php?act=logout', true);
					httpcrOb.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
					httpcrOb.onreadystatechange = handelsnewuser; 
					httpcrOb.send(null);
					waitact();
				}
}
function login(){
	var remmperz;
	if(document.getElementById('username').value=="" || document.getElementById('password').value==""){
		alert("Please complete all fields");
					return;
	}
	if (document.getElementById('remmperz').checked==true){
    remmperz="yes";
    }
	else
	{
	remmperz="no";	
	}
	      if (httpcrOb.readyState == 4 || httpcrOb.readyState == 0) {
                    httpcrOb.open("POST", 'http://lrtweet.com/fun.php?act=login', true);
					httpcrOb.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
					httpcrOb.onreadystatechange = handelsnewuser; 
					var param = 'username=' + document.getElementById('username').value;
					param += '&password=' + document.getElementById('password').value;
					param += '&remmperz=' + remmperz;
					httpcrOb.send(param);
					waitact();
				}
}


function addmuser(){
	if(document.getElementById('username').value=="" || document.getElementById('password').value=="" || document.getElementById('email').value==""){
		alert("Please complete all fields");
					return;
	}
	      if (httpcrOb.readyState == 4 || httpcrOb.readyState == 0) {
                    httpcrOb.open("POST", 'http://lrtweet.com/fun.php?act=newuser', true);
					httpcrOb.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
					httpcrOb.onreadystatechange = handelsnewuser; 
					var param = 'username=' + document.getElementById('username').value;
					param += '&password=' + document.getElementById('password').value;
					param += '&email=' + document.getElementById('email').value;
					httpcrOb.send(param);
					waitact();
				}
}
function handelsnewuser(){

if(httpcrOb.readyState == 4){


	
	
    	 xmldoc = httpcrOb.responseXML;
		
		var bglam = xmldoc.getElementsByTagName("alartings"); 
	
	    var lenbigr = bglam.length;
		
	for (i = 0; i < lenbigr; i++) {
	     var almsgtgnm = bglam[i].getElementsByTagName("almsg");
		 var usernameztag = bglam[i].getElementsByTagName("usernamez");
		
		
		var almsgval = almsgtgnm[0].firstChild.nodeValue;
		var usernamezval = usernameztag[0].firstChild.nodeValue;
		}
			
			
		
			
	if(usernamezval=="nonesp"){
document.getElementById("alldiv").innerHTML= almsgval;		
	}
	else{
		
		
document.getElementById("topparwel").innerHTML= usernamezval;		
document.getElementById("alldiv").innerHTML= almsgval;		
		
		
	}

}




}


				
function addrep(){
	if(document.getElementById('mylo').value=="" || document.getElementById('tywri').value==""){
		alert("Please write any thing");
		return;			
	}
	else{
	if(document.getElementById('myfile').value.length > 0){
	document.getElementById('fmylo').submit();	
	return;	
	}
	else{
	      if (httpcrOb.readyState == 4 || httpcrOb.readyState == 0) {
                    httpcrOb.open("POST", 'http://lrtweet.com/fun.php?act=addl', true);
					httpcrOb.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
					httpcrOb.onreadystatechange = handels; 
					var param = 'mylo=' + document.getElementById('mylo').value;
					param += '&tywri=' + document.getElementById('tywri').value;
					httpcrOb.send(param);
					waitact();
				}
			}
		}
}
function startiz(){
waitact();
 if (httpcrOb.readyState == 4 || httpcrOb.readyState == 0) {
                    httpcrOb.open("POST", 'http://lrtweet.com/fun.php?act=startiz', true);
					httpcrOb.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
					httpcrOb.onreadystatechange = handels; 
					httpcrOb.send(null);
					fromdelrep="not";
				}
				
}				
function manag(){
	 
 steledirep="no";
	      if (httpcrOb.readyState == 4 || httpcrOb.readyState == 0) {
                    httpcrOb.open("POST", 'http://lrtweet.com/fun.php?act=maneg', true);
					httpcrOb.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
					httpcrOb.onreadystatechange = handels; 
					httpcrOb.send(null);
					if(fromdelrep!="fromdelrep"){waitact();}
				}
}
				
function pages(frompage){
	 
 steledirep="no";
	      if (httpcrOb.readyState == 4 || httpcrOb.readyState == 0) {
                    httpcrOb.open("POST", 'http://lrtweet.com/fun.php?act=pages', true);
					httpcrOb.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
					httpcrOb.onreadystatechange = handels; 
					var param = 'frompage=' + frompage;
					httpcrOb.send(param);
					fromdelrep="not";
					waitact();
				}
}
function resetc(wijt){	 
 steledirep="no";
 if(wijt=="rest1"){
if(document.getElementById('email').value==""){
		alert("Please complete all fields");
		return;			
	}
param = 'email=' + document.getElementById('email').value;	
ulral="http://lrtweet.com/fun.php?act=resetc";		 
 }
 else
 {
if(document.getElementById('code').value==""){
		alert("Please complete all fields");
		return;			
	}
param = 'code=' + document.getElementById('code').value + '&email=' + document.getElementById('email').value;	
ulral="http://lrtweet.com/fun.php?act=donreset";		 
	 
	 
 }
 	
	
	      if (httpcrOb.readyState == 4 || httpcrOb.readyState == 0) {
                    httpcrOb.open("POST", ulral, true);
					httpcrOb.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
					httpcrOb.onreadystatechange = handels; 
					
					httpcrOb.send(param);
					fromdelrep="not";
					waitact();
				}
			
		
}
				
function handels(){
		
if (httpcrOb.readyState == 4) {
if(fromdelrep=="fromdelrep"){	
document.getElementById(idrepzalo).style.display = 'none';	
fromdelrep="";
idrepzalo="";
}
document.getElementById('alldiv').innerHTML = httpcrOb.responseText;	
	
 }

}				
function shwform(whatf){
 if (httpcrOb.readyState == 4 || httpcrOb.readyState == 0) {
                    httpcrOb.open("POST", 'http://lrtweet.com/fun.php?act=swform', true);
					httpcrOb.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
					httpcrOb.onreadystatechange = handels; 
					var param = 'whatf=' + whatf;
					httpcrOb.send(param);
					waitact();
				}		
}				
