function Trim(s)
{
  while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
  {
    s = s.substring(1,s.length);
  }
  while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
  {
    s = s.substring(0,s.length-1);
  }
  return s;
}

function getHTTPObject()
{
    if(window.XMLHttpRequest)
      {
          xmlhttp=new XMLHttpRequest()
      }
    else if(window.ActiveXObject)
      {
          try
        {
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
        }
        catch(e)
        {
            alert("your browser does n't support ajax");    
        }
      }
    return xmlhttp;
}
var http = getHTTPObject();

function Insert_site_table()
{
    var url=document.getElementById('url').value;
    //var url=document.getElementById('iSiteId').value;

    var vUrl='sitetable.php?url_text='+url;
    alert(vUrl);
    var isWorking = false;
    if(!isWorking)
    {
        http.open("POST", vUrl , true);
        isWorking = true;
        http.onreadystatechange = handlreplyresponsesitetable;
        http.send(null);
    }  
}

function handlreplyresponsesitetable()
{
    if(http.readyState == 4)
    {
        isWorking = false;
        var valResponse;
        valResponse = http.responseText;
       // alert(valResponse);
        if(valResponse!="")
        {
        document.getElementById('iSiteId').value=Trim(valResponse);
        }
    }
}


//*********************************** Ranking*****************************
function empty(){
	
	document.getElementById('perScore').innerHTML="";
	document.getElementById('visibility').innerHTML="";
	document.getElementById('technical').innerHTML="";
	document.getElementById('common').innerHTML="";
	document.getElementById('content').innerHTML="";
	document.getElementById('validation').innerHTML="";
	document.getElementById('check').innerHTML="";
document.getElementById('right').style.display="none";
}

//#############################################3 test Url #################################3


function test(){
	empty();
	document.getElementById('goGif').style.display="block"; 
 var url=document.getElementById('url').value;

//var iSiteId=document.getElementById('iSiteId').value;
//alert(iSiteId);
    var vUrl='test.php?url_text='+url;//+'&iSiteId='+iSiteId;
    var isWorking = false;
    if(!isWorking)
    {
        http.open("POST", vUrl , true);
        isWorking = true;
        http.onreadystatechange = handlreplyresponsetest;
        http.send(null);
    }
}

//##################################################################################
function handlreplyresponsetest()
{
	
    if(http.readyState == 4)
    {
        isWorking = false;
        var valResponse="";
        var splitval="";
        valResponse = http.responseText;
		
		//alert(valResponse);
		if(valResponse=="0"){
			document.getElementById('goGif').style.display="none";
		 document.getElementById('check').innerHTML="Please Enter a Valid Website Address...";
		 //	document.getElementById('goGif').innerHTML=""; 
   document.getElementById('right').style.display="none";
   document.getElementById('show_position').style.display="none";
   document.getElementById("keywordShow").style.display="none";
		}else{
		document.getElementById('check').innerHTML="";
	 document.getElementById('right').style.display="none";
		getresponse_yahoo();
		}
	        
    }
	
	
}

//#####################################################################3

function getresponse_yahoo()
{
	
	
	
	//show_null_list();
	
	
	//show_null_list();
//	snapshot();
   // Insert_site_table();
  document.getElementById('goGif').style.display="block"; 
   document.getElementById('right').style.display="none";
   document.getElementById('show_position').style.display="none"
   document.getElementById("keywordShow").style.display="none";
   
    var url=document.getElementById('url').value;
//var iSiteId=document.getElementById('iSiteId').value;
//alert(iSiteId);
    var vUrl='yahoo.php?url_text='+url;//+'&iSiteId='+iSiteId;
    var isWorking = false;
    if(!isWorking)
    {
        http.open("POST", vUrl , true);
        isWorking = true;
        http.onreadystatechange = handlreplyresponseyahoo;
        http.send(null);
    }
}

function handlreplyresponseyahoo()
{
    if(http.readyState == 4)
    {
        isWorking = false;
        var valResponse="";
        var splitval="";
        valResponse = http.responseText;
		//alert(valResponse);
		document.getElementById('perScore').style.display="block";
       document.getElementById('perScore').innerHTML=valResponse;
	   document.getElementById('visibility').style.display="block";
	   visibility_score();
	   
       // splitval=valResponse.split("||||");
   //     alert(splitval.length);
     //   alert(splitval[0]);
        
        if(valResponse==0)
        {
        }
        else if(valResponse==1)
        {
        }
    }
	
	
}


//############################ Visibility #################################


function visibility_score()
{

   // Insert_site_table();
  
    
    var url=document.getElementById('url').value;

//alert(iSiteId);

    var vUrl='visibility.php?url_text='+url;//+'&iSiteId='+iSiteId;
    var isWorking = false;
    if(!isWorking)
    {
        http.open("POST", vUrl , true);
        isWorking = true;
		
        http.onreadystatechange = handlreplyresponsevisibility;
        http.send(null);
    }
}



function handlreplyresponsevisibility()
{
    if(http.readyState == 4)
    {
        isWorking = false;
        var valResponse="";
        var splitval="";
        valResponse = http.responseText;
		
	
	//alert("dsd");
       document.getElementById('visibility').innerHTML=valResponse;
	   
	 technical_score();
//	   document.getElementById('goGif').style.display="none";
       // splitval=valResponse.split("||||");
      // alert(splitval.length);
     //   alert(splitval[0]);
        
        if(valResponse==0)
        {
        }
        else if(valResponse==1)
        {
        }
    }
}



//####################### Technical ################################

function technical_score()
{
	
   // Insert_site_table();
    
    var url=document.getElementById('url').value;
//var iSiteId=document.getElementById('iSiteId').value;
//alert(iSiteId);
    var vUrl='technical.php?url_text='+url;//+'&iSiteId='+iSiteId;
    var isWorking = false;
    if(!isWorking)
    {
        http.open("POST", vUrl , true);
        isWorking = true;
		
        http.onreadystatechange = handlreplyresponsetechnical;
        http.send(null);
    }
}



function handlreplyresponsetechnical()
{
    if(http.readyState == 4)
    {
        isWorking = false;
        var valResponse="";
        var splitval="";
        valResponse = http.responseText;
		
       document.getElementById('technical').innerHTML=valResponse;
	 
	   validation_score();
//	    
       // splitval=valResponse.split("||||");
      // alert(splitval.length);
     //   alert(splitval[0]);
        
        if(valResponse==0)
        {
        }
        else if(valResponse==1)
        {
        }
    }
}









//********************************** Validation *********************************************8


function validation_score()
{
	
   // Insert_site_table();
    
    var url=document.getElementById('url').value;
//var iSiteId=document.getElementById('iSiteId').value;
//alert(iSiteId);
    var vUrl='validation.php?url_text='+url;//+'&iSiteId='+iSiteId;
    var isWorking = false;
    if(!isWorking)
    {
        http.open("POST", vUrl , true);
        isWorking = true;
		
        http.onreadystatechange = handlreplyresponsevalidation;
        http.send(null);
    }
}



function handlreplyresponsevalidation()
{
    if(http.readyState == 4)
    {
        isWorking = false;
        var valResponse="";
        var splitval="";
        valResponse = http.responseText;
		
       document.getElementById('validation').innerHTML=valResponse;
	   
	   common_score();
       // splitval=valResponse.split("||||");
      // alert(splitval.length);
     //   alert(splitval[0]);
        
        if(valResponse==0)
        {
        }
        else if(valResponse==1)
        {
        }
    }
}



//***************************************************************************

function common_score()
{
	
   // Insert_site_table();
    
    var url=document.getElementById('url').value;
//var iSiteId=document.getElementById('iSiteId').value;
//alert(iSiteId);
    var vUrl='common.php?url_text='+url;//+'&iSiteId='+iSiteId;
    var isWorking = false;
    if(!isWorking)
    {
        http.open("POST", vUrl , true);
        isWorking = true;
		
        http.onreadystatechange = handlreplyresponsecommon;
        http.send(null);
    }
}



function handlreplyresponsecommon()
{
    if(http.readyState == 4)
    {
        isWorking = false;
        var valResponse="";
        var splitval="";
        valResponse = http.responseText;
			
       document.getElementById('common').innerHTML=valResponse;
	   
	   content_score();
       // splitval=valResponse.split("||||");
      // alert(splitval.length);
     //   alert(splitval[0]);
        
        if(valResponse==0)
        {
        }
        else if(valResponse==1)
        {
        }
    }
}




//content*******************************************************8




function content_score()
{
	
   // Insert_site_table();
    
    var url=document.getElementById('url').value;
//var iSiteId=document.getElementById('iSiteId').value;
//alert(iSiteId);
    var vUrl='content.php?url_text='+url;//+'&iSiteId='+iSiteId;
    var isWorking = false;
    if(!isWorking)
    {
        http.open("POST", vUrl , true);
        isWorking = true;
		
        http.onreadystatechange = handlreplyresponsecontent;
        http.send(null);
    }
}







function handlreplyresponsecontent()
{
    if(http.readyState == 4)
    {
        isWorking = false;
        var valResponse="";
        var splitval="";
        valResponse = http.responseText;
			
       document.getElementById('content').innerHTML=valResponse;
	   
	    document.getElementById('goGif').style.display="none";
		 document.getElementById('right').style.display="block";
		 document.getElementById('show_position').style.display="block";
		
       // splitval=valResponse.split("||||");
      // alert(splitval.length);
     //   alert(splitval[0]);
        
        if(valResponse==0)
        {
        }
        else if(valResponse==1)
        {
        }
    }
}





//##################################################################

function show_null_list(){
	
	// var url=document.getElementById('url').value;

//alert(iSiteId);


    var vUrl='shouNullList.php';//+'&iSiteId='+iSiteId;
    var isWorking = false;
    if(!isWorking)
    {
        http.open("POST", vUrl , true);
        isWorking = true;
		
        http.onreadystatechange = handlreplyresponseshownulist;
        http.send(null);
    }
}

//####################################################################





function handlreplyresponseshownulist()
{
    if(http.readyState == 4)
    {
        isWorking = false;
        var valResponse="";
        var splitval="";
        valResponse = http.responseText;
		
       document.getElementById('show_list').innerHTML="sadfasd";
	//   technical_score();
//	   document.getElementById('goGif').style.display="none";
       // splitval=valResponse.split("||||");
      // alert(splitval.length);
     //   alert(splitval[0]);
        
        if(valResponse==0)
        {
        }
        else if(valResponse==1)
        {
        }
    }
}

//####################################################################

function snapshot(){
	
	// var url=document.getElementById('url').value;

//alert(iSiteId);
 var url=document.getElementById('url').value;

//alert(iSiteId);

    var vUrl='snap.php?url_text='+url;//+'&iSiteId='+iSiteId;
      var isWorking = false;
    if(!isWorking)
    {
        http.open("POST", vUrl , true);
        isWorking = true;
		
        http.onreadystatechange = handlreplyresponsesnapshot;
        http.send(null);
    }
}

//####################################################################





function handlreplyresponsesnapshot()
{
    if(http.readyState == 4)
    {
        isWorking = false;
        var valResponse="";
        var splitval="";
        valResponse = http.responseText;
		
       document.getElementById('snapshot').innerHTML=valResponse;
	  
//	   document.getElementById('goGif').style.display="none";
       // splitval=valResponse.split("||||");
      // alert(splitval.length);
     //   alert(splitval[0]);
        
        if(valResponse==0)
        {
        }
        else if(valResponse==1)
        {
        }
    }
}

//########################################################################


//###############################3 null ####################################

//############################ Visibility #################################


function visibility_score()
{
	
   // Insert_site_table();
  
    
    var url=document.getElementById('url').value;

//alert(iSiteId);

    var vUrl='visibility.php?url_text='+url;//+'&iSiteId='+iSiteId;
    var isWorking = false;
    if(!isWorking)
    {
        http.open("POST", vUrl , true);
        isWorking = true;
		
        http.onreadystatechange = handlreplyresponsevisibility;
        http.send(null);
    }
}



function handlreplyresponsevisibility()
{
    if(http.readyState == 4)
    {
        isWorking = false;
        var valResponse="";
        var splitval="";
        valResponse = http.responseText;
		
	
       document.getElementById('visibility').innerHTML=valResponse;
	 technical_score();
//	   document.getElementById('goGif').style.display="none";
       // splitval=valResponse.split("||||");
      // alert(splitval.length);
     //   alert(splitval[0]);
        
        if(valResponse==0)
        {
        }
        else if(valResponse==1)
        {
        }
    }
}



//####################### Technical ################################

function technical_score()
{
	
   // Insert_site_table();
    
    var url=document.getElementById('url').value;
//var iSiteId=document.getElementById('iSiteId').value;
//alert(iSiteId);
    var vUrl='technical.php?url_text='+url;//+'&iSiteId='+iSiteId;
    var isWorking = false;
    if(!isWorking)
    {
        http.open("POST", vUrl , true);
        isWorking = true;
		
        http.onreadystatechange = handlreplyresponsetechnical;
        http.send(null);
    }
}



function handlreplyresponsetechnical()
{
    if(http.readyState == 4)
    {
        isWorking = false;
        var valResponse="";
        var splitval="";
        valResponse = http.responseText;
		
       document.getElementById('technical').innerHTML=valResponse;
	   validation_score();
//	    
       // splitval=valResponse.split("||||");
      // alert(splitval.length);
     //   alert(splitval[0]);
        
        if(valResponse==0)
        {
        }
        else if(valResponse==1)
        {
        }
    }
}









//********************************** Validation *********************************************8


function validation_score()
{
	
   // Insert_site_table();
    
    var url=document.getElementById('url').value;
//var iSiteId=document.getElementById('iSiteId').value;
//alert(iSiteId);
    var vUrl='validation.php?url_text='+url;//+'&iSiteId='+iSiteId;
    var isWorking = false;
    if(!isWorking)
    {
        http.open("POST", vUrl , true);
        isWorking = true;
		
        http.onreadystatechange = handlreplyresponsevalidation;
        http.send(null);
    }
}



function handlreplyresponsevalidation()
{
    if(http.readyState == 4)
    {
        isWorking = false;
        var valResponse="";
        var splitval="";
        valResponse = http.responseText;
		
       document.getElementById('validation').innerHTML=valResponse;
	   common_score();
       // splitval=valResponse.split("||||");
      // alert(splitval.length);
     //   alert(splitval[0]);
        
        if(valResponse==0)
        {
        }
        else if(valResponse==1)
        {
        }
    }
}



//***************************************************************************

function common_score()
{
	
   // Insert_site_table();
    
    var url=document.getElementById('url').value;
//var iSiteId=document.getElementById('iSiteId').value;
//alert(iSiteId);
    var vUrl='common.php?url_text='+url;//+'&iSiteId='+iSiteId;
    var isWorking = false;
    if(!isWorking)
    {
        http.open("POST", vUrl , true);
        isWorking = true;
		
        http.onreadystatechange = handlreplyresponsecommon;
        http.send(null);
    }
}



function handlreplyresponsecommon()
{
    if(http.readyState == 4)
    {
        isWorking = false;
        var valResponse="";
        var splitval="";
        valResponse = http.responseText;
		
       document.getElementById('common').innerHTML=valResponse;
	   content_score();
       // splitval=valResponse.split("||||");
      // alert(splitval.length);
     //   alert(splitval[0]);
        
        if(valResponse==0)
        {
        }
        else if(valResponse==1)
        {
        }
    }
}




//content*******************************************************8




function content_score()
{
	
   // Insert_site_table();
    
    var url=document.getElementById('url').value;
//var iSiteId=document.getElementById('iSiteId').value;
//alert(iSiteId);
    var vUrl='content.php?url_text='+url;//+'&iSiteId='+iSiteId;
    var isWorking = false;
    if(!isWorking)
    {
        http.open("POST", vUrl , true);
        isWorking = true;
		
        http.onreadystatechange = handlreplyresponsecontent;
        http.send(null);
    }
}







function handlreplyresponsecontent()
{
    if(http.readyState == 4)
    {
        isWorking = false;
        var valResponse="";
        var splitval="";
        valResponse = http.responseText;
		
       document.getElementById('content').innerHTML=valResponse;
	   
	    document.getElementById('goGif').style.display="none";
		 document.getElementById('right').style.display="block";
		 document.getElementById('show_position').style.display="block";
		
       // splitval=valResponse.split("||||");
      // alert(splitval.length);
     //   alert(splitval[0]);
        
        if(valResponse==0)
        {
        }
        else if(valResponse==1)
        {
        }
    }
}





//##################################################################

function show_null_list(){
	
	// var url=document.getElementById('url').value;

//alert(iSiteId);


    var vUrl='shouNullList.php';//+'&iSiteId='+iSiteId;
    var isWorking = false;
    if(!isWorking)
    {
        http.open("POST", vUrl , true);
        isWorking = true;
		
        http.onreadystatechange = handlreplyresponseshownulist;
        http.send(null);
    }
}
//#################################################################