function Trim(nStr){return nStr.replace(/(^\s*)|(\s*$)/g,"");}
//============================================================

function list_all(chk)
{	document.getElementById("desp").style.display="none";
	document.getElementById("result").style.display="block";
	if(window.XMLHttpRequest){
			http=new XMLHttpRequest();
	}
	else if(window.ActiveXObject){
		http=new ActiveXObject("Microsoft.XMLHTTP");
	}
	var url = "ajax/chk_site.php?chk="+chk;
	http.open("GET", url , true);
	http.onreadystatechange = countryprocess;
	http.send(null);
}

function countryprocess()
{   if (http.readyState == 4){  
		if(http.status==200)  // Split the comma delimited response into an array
        {		if(http.responseText!="No values"){
					document.getElementById("result").innerHTML="";
					document.getElementById("result").innerHTML=http.responseText;	
				}	
				else {	document.getElementById("result").innerHTML="";
				}	
	 	}
   }
}

function list_tag(str)
{   document.getElementById("desp").style.display="none";
	document.getElementById("result").style.display="block";
	if(window.XMLHttpRequest){	
		http=new XMLHttpRequest();
	}
	else if(window.ActiveXObject){
		http=new ActiveXObject("Microsoft.XMLHTTP");
	}
	var url = "ajax/chk_site.php?tag="+str;
	http.open("GET", url , true);
	http.onreadystatechange = countryprocess1;
	http.send(null);
}

function countryprocess1()
{   if (http.readyState == 4) {
		if(http.status==200)     // Split the comma delimited response into an array
        {	if(http.responseText!="No values"){		
					document.getElementById("result").innerHTML="";
					document.getElementById("result").innerHTML=http.responseText;	
			}	
			else{
				document.getElementById("result").innerHTML="";
			}	
	 	}
   }
}

function list_email(str1)
{	document.getElementById("desp").style.display="none";
	document.getElementById("result").style.display="block";
	if(window.XMLHttpRequest){
		http=new XMLHttpRequest();
	}
	else if(window.ActiveXObject){
		http=new ActiveXObject("Microsoft.XMLHTTP");
	}
	var url = "ajax/chk_site.php?chk_mail="+str1;
	http.open("GET", url , true);
	http.onreadystatechange = countryprocess2;
	http.send(null);
}

function countryprocess2()
{	if (http.readyState == 4){
		if(http.status==200){    // Split the comma delimited response into an array
	 		if(http.responseText!="No values"){
				 document.getElementById("result").innerHTML="";
				 document.getElementById("result").innerHTML=http.responseText;	
			}	
			else{
				document.getElementById("result").innerHTML="";
			}	
	 	}
   }
}

function list_ms(str2)
{
	document.getElementById("desp").style.display="none";
	document.getElementById("result").style.display="block";
	if(window.XMLHttpRequest){
		http=new XMLHttpRequest();
	}
	else if(window.ActiveXObject){
		http=new ActiveXObject("Microsoft.XMLHTTP");
	}
	var url = "ajax/chk_site.php?chk_ms="+str2;
	http.open("GET", url , true);
	http.onreadystatechange = countryprocess3;
	http.send(null);
}

function countryprocess3()
{	if (http.readyState == 4) 
	{	if(http.status==200)     // Split the comma delimited response into an array
        {	if(http.responseText!="No values"){
				 document.getElementById("result").innerHTML="";
				 document.getElementById("result").innerHTML=http.responseText;	
			}	
			else{
				document.getElementById("result").innerHTML="";
			}	
	 	}
   }
}

function view_site(url)
{	
 	if(document.getElementById("search_url").value=="")
	 {	alert('Please select the any one URL');
		return false;
	 }
	 else{
		 window.open("view.php?if_id="+url, '_parent');
	 }
}

function chk_sites(bstr)
{	if(window.XMLHttpRequest){
		http=new XMLHttpRequest();
	}
	else if(window.ActiveXObject){
		http=new ActiveXObject("Microsoft.XMLHTTP");
	}
	var url = "ajax/chk_sites.php?chk="+bstr;
	http.open("GET", url , true);
	http.onreadystatechange = sitelist;
	http.send(null);
}

function sitelist()
{	if (http.readyState == 4) 
	{	if(http.status==200)     // Split the comma delimited response into an array
        {	document.getElementById("site_list").length=0;
		   document.getElementById("site_list").options[0]=new Option("---Select Sites---"," ");
		   if(http.responseText!="No values"){	var clist=http.responseText.split("_");
				for(i=0;i<clist.length;i++){	
					var myclist=clist[i].split(",");
					document.getElementById("site_list").options[i+1]=new Option(myclist[0],myclist[1]);
				}
			}	
			else{
				document.getElementById("site_list").length=0;
				document.getElementById("site_list").options[0]=new Option("---Select Sites---"," ");
			}	
	 	}
   }
}

function list_site(url)
{	if (document.getElementById("site_list").value=="")
	{	alert ('Please select the any one URL');
		return false;
	}
	else{
		 window.location='view.php?if_id='+url;  
	}
}

function openInNewWindow() {
 // Change "_blank" to something like "newWindow" to load all links in the same new window
	var newWindow = window.open(this.getAttribute('href'), '_blank');
	newWindow.focus();
	return false;
}

function tchk(cht){
	document.getElementById("ttab1").style.display='none';
	document.getElementById("ttab2").style.display='none';
	document.getElementById("ttab3").style.display='none';
	document.getElementById("ttab4").style.display='none';		  		  		  
	document.getElementById(cht).style.display='block';
}
var id;
var previd="";

function edit_user(y,str)
{	id=str;
	if(window.XMLHttpRequest){
		http_pcde=new XMLHttpRequest();
	}
	else if(window.ActiveXObject){
		http_pcde=new ActiveXObject("Microsoft.XMLHTTP");
	}
	var url='ajax/chk_sites.php?page='+y+'&skey='+str;
	http_pcde.open("GET", url,true);
	http_pcde.onreadystatechange =HttpRes_pcde;
	http_pcde.send("");	
}

function HttpRes_pcde()
{	if (http_pcde.readyState == 4) 
	{	if(http_pcde.status == 200)
		{	var ass=http_pcde.responseText;
			if(previd==""){}
			else{
			document.getElementById("editauthenticate"+previd).innerHTML="";	
			}
			document.getElementById("editauthenticate"+id).style.display='block';
			document.getElementById("editauthenticate"+id).innerHTML="";
			document.getElementById("editauthenticate"+id).innerHTML=ass;
			previd=id;
		}
	} 
} 

function edit_usertag(str,tag)
{	id=str;
	if(window.XMLHttpRequest){
		http_pcde=new XMLHttpRequest();
	}
	else if(window.ActiveXObject){
		http_pcde=new ActiveXObject("Microsoft.XMLHTTP");
	}
	var url='ajax/chk_sites.php?skey='+str+'&tkey='+tag;
	http_pcde.open("GET", url,true);
	http_pcde.onreadystatechange =HttpRes_pcdetag;
	http_pcde.send("");	
}

function HttpRes_pcdetag()
{	if (http_pcde.readyState == 4) 
	{	if(http_pcde.status == 200){
			var ass=http_pcde.responseText;
			if(previd==""){}
			else{
			document.getElementById("editauthenticate"+previd).innerHTML="";	
			}
			document.getElementById("editauthenticate"+id).style.display='block';
			document.getElementById("editauthenticate"+id).innerHTML="";
			document.getElementById("editauthenticate"+id).innerHTML=ass;
			previd=id;
		}
	} 
} 

function plus(id){	
	var showplus=document.getElementById('showplus_'+id).src; 
	var Lastoccurance =  showplus.lastIndexOf('/',showplus);  
	var file 	= showplus.substring(0, Lastoccurance+1);		
	var imgname = showplus.substring(Lastoccurance+1);			
	if(imgname == 'plus.gif'){ 
		document.getElementById('showplus_'+id).src=file+'minus.gif';
		if(previd==""){}
		else{
		document.getElementById("Hidlogininfo_"+previd).style.display='none';
		document.getElementById('showplus_'+previd).src=file+'plus.gif';
		}
		document.getElementById("Hidlogininfo_"+id).style.display='block'; 
		previd=id;
	}else if(imgname == 'minus.gif'){
		document.getElementById('showplus_'+id).src=file+'plus.gif';
		document.getElementById("Hidlogininfo_"+id).style.display="none"; 
	}
}