function make_http_request() {
        var http_request = false;
        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } 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('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        return http_request;
}
function search_q(){
	var q = document.getElementById('q');
   if(q.value=='Please enter a valid domain!'){
   	 q.value='';
   	 q.style.color='#1C2324';
   }
   if(q.value=='example: google.com'){
     q.value='';
   }
}
function remove_q(){
	var d = document.getElementById('d');
   if(d.value=='Please enter a valid domain!'){
   	 d.value='';
   	 d.style.color='#1C2324';
   }
   if(d.value=='example: www.yoursite.com'){
     d.value='';
   }
}


function subDomain(url) {
 url = url.replace(new RegExp(/^\s+/),""); // START
 url = url.replace(new RegExp(/\s+$/),""); // END
 url = url.replace(new RegExp(/\\/g),"/");
 url = url.replace(new RegExp(/^http\:\/\/|^https\:\/\/|^ftp\:\/\//i),"");
 url = url.replace(new RegExp(/^www\./i),"");
 url = url.replace(new RegExp(/\/(.*)/),"");
 if (url.match(new RegExp(/\.[a-z]{2,3}\.[a-z]{2}$/i))) {
 url = url.replace(new RegExp(/\.[a-z]{2,3}\.[a-z]{2}$/i),"");
 } else if (url.match(new RegExp(/\.[a-z]{2,4}$/i))) {
 url = url.replace(new RegExp(/\.[a-z]{2,4}$/i),"");
 }
 var subDomain = (url.match(new RegExp(/\./g))) ? true : false;
 return(subDomain);
}
function check_domain(){
if(document.getElementById('q').value==''){
document.getElementById('search').innerHTML='<div class="search_title">enter <span>URL</span></div><div class="search_input"><input type="text" name="q" id="q" value="Please enter a valid domain!" onclick="search_q();" style="color: #a7120b;"></div><div class="search_button"><input type="button" name="button" id="button" value="" onclick="check_domain();"></div>';
document.getElementById('q').focus();
}else{
       var q = document.getElementById('q').value;
       q=q.toLowerCase();
       q=q.replace(new RegExp(/^\s+/),"");
       q=q.replace(new RegExp(/\s+$/),"");
       q=q.replace(new RegExp(/^http\:\/\/|^https\:\/\/|^ftp\:\/\//i),"");
       q=q.replace(new RegExp(/^www\./i),"");
       q=q.split("/");
       q=q[0];
       
      var subDomain1=subDomain(q);

    var regexp = /^(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	  if(regexp.test(q) && subDomain1==false){
        
        var url='check.php';
        var http_request=make_http_request();
        document.getElementById('search').innerHTML='<div style="padding-top:20px;text-align:center;"><img src="images/loader_1.gif"><br>This can take up to 60 seconds. Please wait...</div>';
        http_request.onreadystatechange = function() { 
        	 if (http_request.readyState == 4) {
            if (http_request.status == 200) {
 
            	if(http_request.responseText!='')window.location=http_request.responseText;
            	
            	if(http_request.responseText=='')document.getElementById('search').innerHTML='<div class="search_title">enter <span>URL</span></div><div class="search_input"><input type="text" name="q" id="q" value="Please enter a valid domain!" onclick="search_q();" style="color: #a7120b;"></div><div class="search_button"><input type="button" name="button" id="button" value="" onclick="check_domain();"></div>';
            	
            } else {
                alert('There was a problem with the request.');
            }
        }	
      };
        http_request.open('POST', url, true);
        http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');    
        http_request.send('url='+q);   
 }else{
 	  document.getElementById('search').innerHTML='<div class="search_title">enter <span>URL</span></div><div class="search_input"><input type="text" name="q" id="q" value="Please enter a valid domain!" onclick="search_q();" style="color: #a7120b;"></div><div class="search_button"><input type="button" name="button" id="button" value="" onclick="check_domain();"></div>';
 }	
}
}
function update_domain(q_u){
        var url='update.php';
        var http_request=make_http_request();
        document.getElementById('update').innerHTML='<div><img src="images/loader_1.gif"><br>This can take up to 60 seconds. Please wait...</div>';
        http_request.onreadystatechange = function() { 
        	 if (http_request.readyState == 4) {
            if (http_request.status == 200) {
 
            	if(http_request.responseText!='')window.location=http_request.responseText;
            	
            	if(http_request.responseText=='')window.location='./'+q_u;
            	
            } else {
                alert('There was a problem with the request.');
            }
        }	
      };
        http_request.open('POST', url, true);
        http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');    
        http_request.send('url='+q_u);  
}

function remove_domain(){
if(document.getElementById('d').value==''){
document.getElementById('d').value='Please enter a valid domain!';
document.getElementById('d').style.color='#a7120b';
document.getElementById('q').focus();
}else{
	
	
	 var q = document.getElementById('d').value;
       q=q.toLowerCase();
       q=q.replace(new RegExp(/^\s+/),"");
       q=q.replace(new RegExp(/\s+$/),"");
       q=q.replace(new RegExp(/^http\:\/\/|^https\:\/\/|^ftp\:\/\//i),"");
       q=q.replace(new RegExp(/^www\./i),"");
       q=q.split("/");
       q=q[0];
       
      var subDomain1=subDomain(q);

    var regexp = /^(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	  if(regexp.test(q) && subDomain1==false){
        
        var url='remove_domain.php';
        var http_request=make_http_request();
        document.getElementById('remove').innerHTML='<div style="padding-top:20px;text-align:center;"><img src="images/loader_1.gif"><br>Processing domain removal. Please wait...</div>';
        
        http_request.onreadystatechange = function() { 
        	 if (http_request.readyState == 4) {
            if (http_request.status == 200) {
 
               
 
              if(http_request.responseText=='deleted')document.getElementById('remove').innerHTML='<form action="javascript:remove_domain();" method="post"><blockquote>http://<input size="39" value="'+q+'" name="domain" id="d" class="removal_input" onclick="remove_q();"/> <input name="submit" value="Remove URL" type="submit" class="removal_button" /></blockquote></form><br /><blockquote><span style="color: #a7120b;">Your site ('+q+') data has been successfully removed.</span></blockquote><br />';
              if(http_request.responseText=='no_rule')document.getElementById('remove').innerHTML='<form action="javascript:remove_domain();" method="post"><blockquote>http://<input size="39" value="'+q+'" name="domain" id="d" class="removal_input" onclick="remove_q();"/> <input name="submit" value="Remove URL" type="submit" class="removal_button" /></blockquote></form><br /><blockquote><span style="color: #a7120b;">Your site ('+q+') has a robots.txt file, but it seems your robots.txt file is not formatted correctly, or it does not include disallow restrictions to prevent RealwebsiteWorth from indexing your site. Please add the neccessary disallow restrictions.</span></blockquote><br />';
              if(http_request.responseText=='no_robots')document.getElementById('remove').innerHTML='<form action="javascript:remove_domain();" method="post"><blockquote>http://<input size="39" value="'+q+'" name="domain" id="d" class="removal_input" onclick="remove_q();"/> <input name="submit" value="Remove URL" type="submit" class="removal_button" /></blockquote></form><br /><blockquote><span style="color: #a7120b;">There is no robots.txt file at your site ('+q+'). Please create robots.txt file and add the neccessary disallow restrictions.</span></blockquote><br />';
              
            	if(http_request.responseText=='')window.location='./'+q;
            	
            } else {
                alert('There was a problem with the request.');
            }
        }	
      };
        http_request.open('POST', url, true);
        http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');    
        http_request.send('url='+q);
 }else{
 	  document.getElementById('remove').innerHTML='<form action="javascript:remove_domain();" method="post"><blockquote>http://<input size="39" value="Please enter a valid domain!" style="color: #a7120b;" name="domain" id="d" class="removal_input" onclick="remove_q();"/> <input name="submit" value="Remove URL" type="submit" class="removal_button" /></blockquote></form>';
 }	

}
}

function whois_hide_domain(){
if(document.getElementById('d').value==''){
document.getElementById('d').value='Please enter a valid domain!';
document.getElementById('d').style.color='#a7120b';
document.getElementById('q').focus();
}else{
	
	
	 var q = document.getElementById('d').value;
       q=q.toLowerCase();
       q=q.replace(new RegExp(/^\s+/),"");
       q=q.replace(new RegExp(/\s+$/),"");
       q=q.replace(new RegExp(/^http\:\/\/|^https\:\/\/|^ftp\:\/\//i),"");
       q=q.replace(new RegExp(/^www\./i),"");
       q=q.split("/");
       q=q[0];
       
      var subDomain1=subDomain(q);

    var regexp = /^(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	  if(regexp.test(q) && subDomain1==false){
        
        var url='whois_hide_data.php';
        var http_request=make_http_request();
        document.getElementById('whois_hide').innerHTML='<div style="padding-top:20px;text-align:center;"><img src="images/loader_1.gif"><br>Processing whois data hiding. Please wait...</div>';
        
        http_request.onreadystatechange = function() { 
        	 if (http_request.readyState == 4) {
            if (http_request.status == 200) {
 
              if(http_request.responseText=='hidden')document.getElementById('whois_hide').innerHTML='<form action="javascript:whois_hide_domain();" method="post"><blockquote>http://<input size="39" value="'+q+'" name="domain" id="d" class="removal_input" onclick="remove_q();"/> <input name="submit" value="Whois Show/Hide" type="submit" class="removal_button" /></blockquote></form><br /><blockquote><span style="color: #a7120b;">Your site ('+q+') WHOIS data has been successfully hidden. Remove rww.txt file from your server.</span></blockquote><br />';
              if(http_request.responseText=='shown')document.getElementById('whois_hide').innerHTML='<form action="javascript:whois_hide_domain();" method="post"><blockquote>http://<input size="39" value="'+q+'" name="domain" id="d" class="removal_input" onclick="remove_q();"/> <input name="submit" value="Whois Show/Hide" type="submit" class="removal_button" /></blockquote></form><br /><blockquote><span style="color: #a7120b;">Your site ('+q+') WHOIS data has been successfully shown. Remove rww.txt file from your server.</blockquote><br />';
              if(http_request.responseText=='no_file')document.getElementById('whois_hide').innerHTML='<form action="javascript:whois_hide_domain();" method="post"><blockquote>http://<input size="39" value="'+q+'" name="domain" id="d" class="removal_input" onclick="remove_q();"/> <input name="submit" value="Whois Show/Hide" type="submit" class="removal_button" /></blockquote></form><br /><blockquote><span style="color: #a7120b;">There is no rww.txt file at your site ('+q+'). Please create empty rww.txt file.</span></blockquote><br />';
              
            	if(http_request.responseText=='')window.location='./'+q;
            	
            } else {
                alert('There was a problem with the request.');
            }
        }	
      };
        http_request.open('POST', url, true);
        http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');    
        http_request.send('url='+q);
 }else{
 	  document.getElementById('whois_hide').innerHTML='<form action="javascript:whois_hide_domain();" method="post"><blockquote>http://<input size="39" value="Please enter a valid domain!" style="color: #a7120b;" name="domain" id="d" class="removal_input" onclick="remove_q();"/> <input name="submit" value="Whois Show/Hide" type="submit" class="removal_button" /></blockquote></form>';
 }
}
}
function estimated_hide_domain(){
if(document.getElementById('d').value==''){
document.getElementById('d').value='Please enter a valid domain!';
document.getElementById('d').style.color='#a7120b';
document.getElementById('q').focus();
}else{
	
	
	 var q = document.getElementById('d').value;
       q=q.toLowerCase();
       q=q.replace(new RegExp(/^\s+/),"");
       q=q.replace(new RegExp(/\s+$/),"");
       q=q.replace(new RegExp(/^http\:\/\/|^https\:\/\/|^ftp\:\/\//i),"");
       q=q.replace(new RegExp(/^www\./i),"");
       q=q.split("/");
       q=q[0];
       
      var subDomain1=subDomain(q);

    var regexp = /^(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	  if(regexp.test(q) && subDomain1==false){
        
        var url='estimated_hide_data.php';
        var http_request=make_http_request();
        document.getElementById('estimated').innerHTML='<div style="padding-top:20px;text-align:center;"><img src="images/loader_1.gif"><br>Processing estimated data hiding. Please wait...</div>';
        
        http_request.onreadystatechange = function() { 
        	 if (http_request.readyState == 4) {
            if (http_request.status == 200) {
 
              if(http_request.responseText=='hidden')document.getElementById('estimated').innerHTML='<form action="javascript:estimated_hide_domain();" method="post"><blockquote>http://<input size="39" value="'+q+'" name="domain" id="d" class="removal_input" onclick="remove_q();"/> <input name="submit" value="Estimated Show/Hide" type="submit" class="removal_button" /></blockquote></form><br /><blockquote><span style="color: #a7120b;">Your site ('+q+') ESTIMATED data has been successfully hidden. Remove rww.txt file from your server.</span></blockquote><br />';
              if(http_request.responseText=='shown')document.getElementById('estimated').innerHTML='<form action="javascript:estimated_hide_domain();" method="post"><blockquote>http://<input size="39" value="'+q+'" name="domain" id="d" class="removal_input" onclick="remove_q();"/> <input name="submit" value="Estimated Show/Hide" type="submit" class="removal_button" /></blockquote></form><br /><blockquote><span style="color: #a7120b;">Your site ('+q+') ESTIMATED data has been successfully shown. Remove rww.txt file from your server.</blockquote><br />';
              if(http_request.responseText=='no_file')document.getElementById('estimated').innerHTML='<form action="javascript:estimated_hide_domain();" method="post"><blockquote>http://<input size="39" value="'+q+'" name="domain" id="d" class="removal_input" onclick="remove_q();"/> <input name="submit" value="Estimated Show/Hide" type="submit" class="removal_button" /></blockquote></form><br /><blockquote><span style="color: #a7120b;">There is no rww.txt file at your site ('+q+'). Please create empty rww.txt file.</span></blockquote><br />';
              
            	if(http_request.responseText=='')window.location='./'+q;
            	
            } else {
                alert('There was a problem with the request.');
            }
        }	
      };
        http_request.open('POST', url, true);
        http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');    
        http_request.send('url='+q);
 }else{
 	  document.getElementById('estimated').innerHTML='<form action="javascript:estimated_hide_domain();" method="post"><blockquote>http://<input size="39" value="Please enter a valid domain!" style="color: #a7120b;" name="domain" id="d" class="removal_input" onclick="remove_q();"/> <input name="submit" value="Estimated Show/Hide" type="submit" class="removal_button" /></blockquote></form>';
 }
}
}
function widget_color_1_field() {
 document.getElementById('color_inputs').innerHTML='Color 1 #<input value="68C0AF" name="domain" id="c1" class="color_input" maxlength="6" /><br /><br />';
 jscolor.init();
}
function widget_color_2_field() {
 document.getElementById('color_inputs').innerHTML='Color 1 #<input value="68C0AF" name="domain" id="c1" class="color_input" maxlength="6" /><br /><br />Color 2 #<input value="000000" name="domain" id="c2" class="color_input" maxlength="6" /><br /><br />Direction <select name="gd" id="gd" class="font_select"><option value="vertical" selected>vertical</option><option value="horizontal">horizontal</option><option value="rectangle">rectangle</option><option value="ellipse">ellipse</option><option value="ellipse2">ellipse2</option><option value="circle">circle</option><option value="circle2">circle2</option><option value="diamond">diamond</option></select><br /><br /	><br />';
 jscolor.init();
}


function widget_border_color() {
 document.getElementById('border_color_inputs').innerHTML='Border Color #<input value="68C0AF" name="bc" id="bc" class="color_input" maxlength="6" />';
 jscolor.init();
}
function widget_border_color_no() {
 document.getElementById('border_color_inputs').innerHTML='';
}
function widget(){
	
	      document.getElementById('widget').innerHTML='<div style="padding-top:20px;text-align:center;"><img src="images/loader_1.gif"></div>';
	
	      var w=document.getElementById('w').value;
	      var h=document.getElementById('h').value;
	      var pl=document.getElementById('pl').value;
	      var pt=document.getElementById('pt').value;
	      var c1=document.getElementById('c1').value;
	      var c2='';
	      if(document.getElementById('c2'))c2=document.getElementById('c2').value;
	      var gd='';
	      if(document.getElementById('gd'))gd=document.getElementById('gd').value;
	      var f=document.getElementById('f').value;
	      var fs=document.getElementById('fs').value;
	      var fc=document.getElementById('fc').value;
	      var f2=document.getElementById('f2').value;
	      var fs2=document.getElementById('fs2').value;
	      var fc2=document.getElementById('fc2').value;
	      var bc='';
	      if(document.getElementById('bc'))bc=document.getElementById('bc').value;
	      var wt=''; 
	      if(document.getElementById('ip').checked==true)wt+='p';
	      if(document.getElementById('ig').checked==true)wt+='g';
	      if(document.getElementById('iy').checked==true)wt+='y';
	      if(document.getElementById('ia').checked==true)wt+='a';
	      if(document.getElementById('ir').checked==true)wt+='r';
	      if(document.getElementById('iw').checked==true)wt+='w';
	      var url=document.getElementById('url').value;

        document.getElementById('widget').innerHTML='<img src="widget.php?w='+w+'&h='+h+'&pl='+pl+'&pt='+pt+'&c1='+c1+'&c2='+c2+'&gd='+gd+'&f='+f+'&fs='+fs+'&fc='+fc+'&f2='+f2+'&fs2='+fs2+'&fc2='+fc2+'&bc='+bc+'&wt='+wt+'&url='+url+'" border="0">&nbsp;';
        
         document.getElementById('widget_area').innerHTML='&lt;a href=&quot;http://www.realwebsiteworth.com/'+url+'&quot; title=&quot;Powered by RealWebsiteWorth.com&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://www.realwebsiteworth.com/widget.php?w='+w+'&h='+h+'&pl='+pl+'&pt='+pt+'&c1='+c1+'&c2='+c2+'&gd='+gd+'&f='+f+'&fs='+fs+'&fc='+fc+'&f2='+f2+'&fs2='+fs2+'&fc2='+fc2+'&bc='+bc+'&wt='+wt+'&url='+url+'&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/a&gt;';
}