var _GLOBAL = {};
_GLOBAL.transaction_key = null;
_GLOBAL.report_id = null;
_GLOBAL.domain_1 = null;
_GLOBAL.domain_2 = null;
_GLOBAL.domain_3 = null;
_GLOBAL.keyword_1 = null;
_GLOBAL.keyword_2 = null;
_GLOBAL.keyword_3 = null;
_GLOBAL.company_name = null;
_GLOBAL.email = null;
_GLOBAL.load_text = '<img id="loading" src="/_IMAGES/ajax_loading_small.gif" /> Loading...';

//##########################################################################################

//--> Begin Function :: ValidateForm

	function ValidateForm(){
		
		if(document.$("domain_1").value == ""){
			alert("Please specify a url!!");
			return;
		}

		if(document.$("captcha_code").value == ""){
			alert("Please enter a code");
			return;
		}		
		
		var SubmitData = {};
		SubmitData["name_first"] 	= document.$("name_first").value;
		SubmitData["name_last"] 	= document.$("name_last").value;
		SubmitData["email"] 		= document.$("email").value;
		SubmitData["phone"] 		= document.$("phone").value;
		SubmitData["url"] 			= document.$("domain_1").value;
		SubmitData["comment"] 		= "domain_1:"+ document.$("domain_1").value +"\n";
		SubmitData["comment"] 		+= "domain_2:"+ document.$("domain_2").value +"\n";
		SubmitData["comment"] 		+= "domain_3:"+ document.$("domain_3").value +"\n";
		SubmitData["comment"] 		+= "keyword_1:"+ document.$("keyword_1").value +"\n";
		SubmitData["comment"] 		+= "keyword_2:"+ document.$("keyword_2").value +"\n";
		SubmitData["comment"] 		+= "keyword_3:"+ document.$("keyword_3").value +"\n";
		SubmitData["comment"]	 	+= "company_name:"+ document.$("company_name").value +"\n";
		SubmitData["source_id"] 	= "109";
		SubmitLead(SubmitData);
		
		//set values
		_GLOBAL.domain_1 		= document.$("domain_1").value;
		_GLOBAL.domain_2 		= document.$("domain_2").value;
		_GLOBAL.domain_3 		= document.$("domain_3").value;
		_GLOBAL.keyword_1 		= document.$("keyword_1").value;
		_GLOBAL.keyword_2 		= document.$("keyword_2").value;
		_GLOBAL.keyword_3 		= document.$("keyword_3").value;
		_GLOBAL.company_name 	= document.$("company_name").value;
		_GLOBAL.email 			= document.$("email").value;
		_GLOBAL.captcha_code    = document.$("captcha_code").value;
		
		//set inverted values
		_GLOBAL[_GLOBAL.domain_1] 		= "domain_1";
		_GLOBAL[_GLOBAL.domain_2]  		= "domain_2";
		_GLOBAL[_GLOBAL.domain_3]  		= "domain_3";
		_GLOBAL[_GLOBAL.keyword_1] 		= "keyword_1";
		_GLOBAL[_GLOBAL.keyword_2] 		= "keyword_2";
		_GLOBAL[_GLOBAL.keyword_3] 		= "keyword_3";
		_GLOBAL[_GLOBAL.company_name] 	= "company_name";
		_GLOBAL[_GLOBAL.email] 			= "email";
		
		//sequence out queues
		AddToQueue("GetTransactionKey()");
		AddToQueue("GetReportID()");
		AddToQueue("GetReport()");
		
		//execute queue
		ExecuteQueue();
	}

//--> End Function :: ValidateForm

//##########################################################################################

//--> Begin Function :: GetReport

	function GetReport() {
		
		if(_GLOBAL.transaction_key != null && _GLOBAL.report_id != null){
			
			SetInnerHTMLById("company_name_content", _GLOBAL.company_name);
			SetInnerHTMLById("domain_1_name", _GLOBAL.domain_1);
			
			//document.$('download_link').innerHTML = '<a href=\"#stop\" name=\"stop\" onclick=\"StopQueue()\">Stop</a>';
			document.$('field_container').style.display = "none";
			document.$('website_list_container').style.display = "none";
			document.$('report_container').style.display = "";
			
			AddToQueue("ShowQuickLoad(true)");
			
			//loading text
			AddToQueue("SetInnerHTMLById('domain_1_reg_date_created','" + _GLOBAL.load_text + "');_GLOBAL.queue_continue = true;");	
			AddToQueue("GetDomainInfo('" + _GLOBAL.domain_1 + "','" + _GLOBAL.report_id + "','" + _GLOBAL.transaction_key + "','domain_1')");

			if(_GLOBAL.domain_2 != ""){
				AddToQueue("SetInnerHTMLById('domain_2_reg_date_created','" + _GLOBAL.load_text + "');_GLOBAL.queue_continue = true;");	
				AddToQueue("GetDomainInfo('" + _GLOBAL.domain_2 + "','" + _GLOBAL.report_id + "','" + _GLOBAL.transaction_key + "','domain_2')");
			}
			
			if(_GLOBAL.domain_3 != ""){
				AddToQueue("SetInnerHTMLById('domain_3_reg_date_created','" + _GLOBAL.load_text + "');_GLOBAL.queue_continue = true;");	
				AddToQueue("GetDomainInfo('" + _GLOBAL.domain_3 + "','" + _GLOBAL.report_id + "','" + _GLOBAL.transaction_key + "','domain_3')");
			}
			
			if(_GLOBAL.keyword_1 != ""){
				AddToQueue("GetKeywordRanking('" + _GLOBAL.domain_1 + "','" + _GLOBAL.keyword_1 + "','" + _GLOBAL.report_id + "','" + _GLOBAL.transaction_key + "','keyword_1')");
			}
			
			if(_GLOBAL.keyword_2 != ""){
				AddToQueue("GetKeywordRanking('" + _GLOBAL.domain_1 + "','" + _GLOBAL.keyword_2 + "','" + _GLOBAL.report_id + "','" + _GLOBAL.transaction_key + "','keyword_2')");
			}
			
			if(_GLOBAL.keyword_3 != ""){
				AddToQueue("GetKeywordRanking('" + _GLOBAL.domain_1 + "','" + _GLOBAL.keyword_3 + "','" + _GLOBAL.report_id + "','" + _GLOBAL.transaction_key + "','keyword_3')");
			}
			
			AddToQueue("GetYahooIndexedPagesResult('" + _GLOBAL.domain_1 + "','" + _GLOBAL.report_id + "','" + _GLOBAL.transaction_key + "','domain_1')");
			AddToQueue("GetGoogleIndexedPagesResult('" + _GLOBAL.domain_1 + "','" + _GLOBAL.report_id + "','" + _GLOBAL.transaction_key + "','domain_1')");

			//AddToQueue("GetImageAltTags('" + _GLOBAL.domain_1 + "','" + _GLOBAL.report_id + "','" + _GLOBAL.transaction_key + "','domain_1')");
			//AddToQueue("GetHeaderTags('" + _GLOBAL.domain_1 + "','" + _GLOBAL.report_id + "','" + _GLOBAL.transaction_key + "','domain_1')");
			AddToQueue("GetTags('" + _GLOBAL.domain_1 + "','" + _GLOBAL.report_id + "','" + _GLOBAL.transaction_key + "','domain_1')");
			//GetTags(domain, report_id, transaction_key, field)
			
			AddToQueue("SetInnerHTMLById('download_link','<a href=\"#here\" onclick=\"ViewReport();\">Download Report</a>'); _GLOBAL.queue_continue = true;");
			
			AddToQueue("ShowQuickLoad(false)");			
			
			AddToQueue("ShadeScreen(true)");
			
			//release queue
			_GLOBAL.queue_continue = true;
			
			//execute queue
			ExecuteQueue();
			
		}else{
			RefreshCaptcha();
			document.$("captcha_code").value = "";					
			document.$("captcha_alert").innerHTML = "Incorrect Code.";	
		}
	
	}
	
//--> End Function :: GetReport

//##########################################################################################

//--> Begin Function :: ViewReport

	function ViewReport(report_id){
		ShadeScreen(false);
		window.open("/seo-tools/domain-trust.aspx?r=archive&print_friendly=true&report_id=" + _GLOBAL.report_id ,'','scrollbars=yes,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
	}
	
//--> End Function :: ViewReport

//##########################################################################################

//--> Begin Function :: GetTags

	function GetTags(domain, report_id, transaction_key, field){
		var MyAjax = new powerHTTP();
		
		MyAjax._current_domain = domain;
		
	//begin handling loading
		MyAjax.loading = function() {};
	//end handling loading
	
	//begin handling response
		MyAjax.complete = function(response) {
			if(MyAjax.was_successful()) {
				
				//eval into response
				var Response = eval('(' + response.text + ')');
				
				//test for scraping
				if(Response.is_success == "true"){
					
					//build header results
					var HeaderTagResults = Response.header_tags;
					var Headers_ResultTable = document.$('header_result_table');
					var Headers_ResultRows = "";
					var Headers_HeaderRow = '<tr class="header"><td>Source</td><td>Alt</td></tr>';
					var Headers_NoResults = '<tr><td>No Results.</td><td>&#160;</td></tr>';
					var Alt = "";
					
					for(var i = 1 ; i <= 10 ; i++) {
						try{
							Alt = (Alt == "alt" ? "" : "alt");
							if(HeaderTagResults[i] != undefined){
								Headers_ResultRows += '<tr class="' + Alt + '"><td>' + HeaderTagResults[i].tag + '</td><td>' + HeaderTagResults[i].contents + '</td></tr>';
							}
						}catch(err){
							AlertError(err, "LineNumber: 392", true);	
						}
					}
					
					if(Headers_ResultRows == ""){
						Headers_ResultRows = Headers_NoResults;
					}
					
					try{
						var Headers_ResultsTableData = '<table  width="100%" border="0" cellpadding="0" cellspacing="0" class="result_table">' + Headers_HeaderRow + Headers_ResultRows + '</table>';
						Headers_ResultTable.innerHTML = Headers_ResultsTableData;
					}catch(err){
						AlertError(err, "LineNumber: 418", true);
					}
					
					//build image results
					var ImageTagResults = Response.image_tags;
					var Image_ResultTable = document.$('image_alt_result_table');
					var Image_HeaderRow = '<tr class="header"><td>Source</td><td>Alt</td></tr>';
					var Image_NoResults = '<tr><td>No Results.</td><td>&#160;</td><td>&#160;</td></tr>';
					var Image_ResultRows = "";
					Alt = "";
					
					for(var i = 1 ; i <= 10 ; i++) {
						try{
							Alt = (Alt == "alt" ? "" : "alt");
							if(ImageTagResults[i] != undefined){
								Image_ResultRows += '<tr class="' + Alt + '"><td>' + ImageTagResults[i].source + '</td><td>' + ImageTagResults[i].alt + '</td></tr>';
							}
						}catch(err){
							AlertError(err, "LineNumber: 392", true);	
						}
					}
					
					if(Image_ResultRows == ""){
						Image_ResultRows = Image_NoResults;
					}
					
					try{
						var Image_ResultsTableData = '<table  width="100%" border="0" cellpadding="0" cellspacing="0" class="result_table">' + Image_HeaderRow + Image_ResultRows + '</table>';
						Image_ResultTable.innerHTML = Image_ResultsTableData;
					}catch(err){
						AlertError(err, "LineNumber: 418", true);
					}
				}
			}
			
			//release queue
			_GLOBAL.queue_continue = true;
			
		};
	//end handling response

	//begin execute request
		var Data = new Array();
		Data.push("field=" + field);
		Data.push("domain=" + domain);
		Data.push("report_id=" + report_id);
		Data.push("transaction_key=" + transaction_key);
		var myPostData = Data.join("&");
		MyAjax.post("/seo-tools/domain-trust.html?r=get_tags", myPostData);	
	//end execute request
	}

//--> End Function :: GetTags

//##########################################################################################

//--> Begin Function :: GetHeaderTags
	
	function GetHeaderTags(domain, report_id, transaction_key, field){

		var MyAjax = new powerHTTP();
		
		MyAjax._current_domain = domain;
		
	//begin handling loading
		MyAjax.loading = function() {};
	//end handling loading
	
	//begin handling response
		MyAjax.complete = function(response) {
			if(MyAjax.was_successful()) {
				
				//eval into response
				var Response = eval('(' + response.text + ')');

				AddToDebugConsole("GetHeaderTags", "164", response.text);
				
				//test for scraping
				if(Response.is_success == "true"){
					
					var ResultTable = document.$('header_result_table');
					var ResultRows = "";
					var HeaderRow = '<tr class="header"><td>Source</td><td>Alt</td></tr>';
					var NoResults = '<tr><td>No Results.</td><td>&#160;</td></tr>';
					var Results = Response.results;
					var Alt = "";
					
					//build results
					for(var i = 1 ; i <= 10 ; i++) {
						try{
							Alt = (Alt == "alt" ? "" : "alt");
							if(Response.results[i] != undefined){
								ResultRows += '<tr class="' + Alt + '"><td>' + Response.results[i].tag + '</td><td>' + Response.results[i].contents + '</td></tr>';
							}
						}catch(err){
							AlertError(err, "LineNumber: 392", true);	
						}
					}
					
					if(ResultRows == ""){
						ResultRows = NoResults;
					}
					
					try{
						var ResultsTableData = '<table  width="100%" border="0" cellpadding="0" cellspacing="0" class="result_table">' + HeaderRow + ResultRows + '</table>';
						ResultTable.innerHTML = ResultsTableData;
					}catch(err){
						AlertError(err, "LineNumber: 418", true);
					}
				}
			}
			
			//release queue
			_GLOBAL.queue_continue = true;
			
		};
	//end handling response

	//begin execute request
		var Data = new Array();
		Data.push("field=" + field);
		Data.push("domain=" + domain);
		Data.push("report_id=" + report_id);
		Data.push("transaction_key=" + transaction_key);
		var myPostData = Data.join("&");
		MyAjax.post("/seo-tools/domain-trust.html?r=get_header_tags", myPostData);	
	//end execute request
	
	}

//--> End Function :: GetHeaderTags

//##########################################################################################

//--> Begin Function :: GetImageAltTags
	
	function GetImageAltTags(domain, report_id, transaction_key, field){

		var MyAjax = new powerHTTP();
		
		MyAjax._current_domain = domain;
		
	//begin handling loading
		MyAjax.loading = function() {};
	//end handling loading
	
	//begin handling response
		MyAjax.complete = function(response) {
			if(MyAjax.was_successful()) {
				
				//eval into response
				var Response = eval('(' + response.text + ')');
				
				//test for scraping
				if(Response.is_success == "true"){
					
					var ResultTable = document.$('image_alt_result_table');
					var HeaderRow = '<tr class="header"><td>Source</td><td>Alt</td></tr>';
					var NoResults = '<tr><td>No Results.</td><td>&#160;</td><td>&#160;</td></tr>';
					var ResultRows = "";
					var Results = Response.results;
					var Alt = "";
					
					//build results
					for(var i = 1 ; i <= 10 ; i++) {
						try{
							Alt = (Alt == "alt" ? "" : "alt");
							if(Response.results[i] != undefined){
								ResultRows += '<tr class="' + Alt + '"><td>' + Response.results[i].source + '</td><td>' + Response.results[i].alt + '</td></tr>';
							}
						}catch(err){
							AlertError(err, "LineNumber: 392", true);	
						}
					}
					
					if(ResultRows == ""){
						ResultRows = NoResults;
					}
					
					try{
						var ResultsTableData = '<table  width="100%" border="0" cellpadding="0" cellspacing="0" class="result_table">' + HeaderRow + ResultRows + '</table>';
						ResultTable.innerHTML = ResultsTableData;
					}catch(err){
						AlertError(err, "LineNumber: 418", true);
					}
				}
			}

			
			//release queue
			_GLOBAL.queue_continue = true;
			
		};
	//end handling response

	//begin execute request
		var Data = new Array();
		Data.push("field=" + field);
		Data.push("domain=" + domain);
		Data.push("report_id=" + report_id);
		Data.push("transaction_key=" + transaction_key);
		var myPostData = Data.join("&");
		MyAjax.post("/seo-tools/domain-trust.html?r=get_image_alt_tags", myPostData);	
	//end execute request
	}
	
//--> End Function :: GetImageAltTags

//##########################################################################################

//--> Begin Function :: GetYahooIndexedPagesResult

	function GetYahooIndexedPagesResult(domain, report_id, transaction_key, field){
		var MyAjax = new powerHTTP();
		
		MyAjax._current_domain = domain;
		
	//begin handling loading
		MyAjax.loading = function() {};
	//end handling loading
	
	//begin handling response
		MyAjax.complete = function(response) {
			if(MyAjax.was_successful()) {
				
				//eval into response
				var Response = eval('(' + response.text + ')');
				
				//test for scraping
				if(Response.is_success == "true"){
					
					AddToDebugConsole("GetYahooIndexedPagesResult", "327", response.text);

					var ResultTable = document.$('yahoo_indexed_pages_result_table');
					var HeaderRow = '<tr class="header"><td>&#160;</td><td>Title</td><td>URL</td></tr>';
					var ResultRows = "";
					var NoResults = '<tr><td>&#160;</td><td>No Results.</td><td>&#160;</td></tr>';
					var Results = Response.results;
					var Alt = "";
					
					//build results
					for(var i = 1 ; i <= 10 ; i++) {
						try{
							Alt = (Alt == "alt" ? "" : "alt");
							if(Response.results[i] != undefined){
								ResultRows += '<tr class="' + Alt + '"><td>' +  i  + '.</td><td>' + Response.results[i].title + '</td><td>' + Response.results[i].url + '</td></tr>';
							}
						}catch(err){
							AlertError(err, "LineNumber: 392", true);	
						}
					}
					
					if(ResultRows == ""){
						ResultRows = NoResults;
					}
					
					try{
						var ResultsTableData = '<table  width="100%" border="0" cellpadding="0" cellspacing="0" class="result_table">' + HeaderRow + ResultRows + '</table>';
						ResultTable.innerHTML = ResultsTableData;
					}catch(err){
						AlertError(err, "LineNumber: 418", true);
					}
				}else{
					//error
				}
			}
			else {
				//error
			}
			
			//release queue
			_GLOBAL.queue_continue = true;
		};
	//end handling response

	//begin execute request
		var Data = new Array();
		Data.push("field=" + field);
		Data.push("domain=" + domain);
		Data.push("report_id=" + report_id);
		Data.push("transaction_key=" + transaction_key);
		var myPostData = Data.join("&");
		MyAjax.post("/seo-tools/domain-trust.html?r=get_yahoo_indexed_pages_result", myPostData);	
	//end execute request		
	}
	
//--> End Function :: GetYahooIndexedPagesResult

//##########################################################################################

//--> Begin Function :: GetGoogleIndexedPagesResult

	function GetGoogleIndexedPagesResult(domain, report_id, transaction_key, field){

		var MyAjax = new powerHTTP();
		
		MyAjax._current_domain = domain;
		
	//begin handling loading
		MyAjax.loading = function() {};
	//end handling loading
	
	//begin handling response
		MyAjax.complete = function(response) {
			if(MyAjax.was_successful()) {
				
				//eval into response
				var Response = eval('(' + response.text + ')');
				
				//test for scraping
				if(Response.is_success == "true"){
					
					var ResultTable = document.$('google_indexed_pages_result_table');
					var HeaderRow = '<tr class="header"><td>&#160;</td><td>Title</td><td>URL</td></tr>';
					var ResultRows = "";
					var NoResults = '<tr><td>&#160;</td><td>No Results.</td><td>&#160;</td></tr>';
					var Results = Response.results;
					var Alt = "";
					
					//build results
					for(var i = 1 ; i <= 10 ; i++) {
						try{
							Alt = (Alt == "alt" ? "" : "alt");
							if(Response.results[i] != undefined){
								ResultRows += '<tr class="' + Alt + '"><td>' +  i  + '.</td><td>' + Response.results[i].title + '</td><td>' + Response.results[i].url + '</td></tr>';
							}
						}catch(err){
							AlertError(err, "LineNumber: 392", true);	
						}
					}
					
					if(ResultRows == ""){
						ResultRows = NoResults;
					}
					
					try{
						var ResultsTableData = '<table  width="100%" border="0" cellpadding="0" cellspacing="0" class="result_table">' + HeaderRow + ResultRows + '</table>';
						ResultTable.innerHTML = ResultsTableData;
					}catch(err){
						AlertError(err, "LineNumber: 418", true);
					}
					
				}else{
					//error
				}
			}
			else {
				//error
			}
			
			//release queue
			_GLOBAL.queue_continue = true;
			
		};
	//end handling response

	//begin execute request
		var Data = new Array();
		Data.push("field=" + field);
		Data.push("domain=" + domain);
		Data.push("report_id=" + report_id);
		Data.push("transaction_key=" + transaction_key);
		var myPostData = Data.join("&");
		MyAjax.post("/seo-tools/domain-trust.html?r=get_google_indexed_pages_result", myPostData);	
	//end execute request
	
	}
	
//--> End Function :: GetGoogleIndexedPagesResult

//##########################################################################################

//--> Begin Function :: GetKeywordRanking

	function GetKeywordRanking(domain, keyword, report_id, transaction_key, field){
		
		var MyAjax = new powerHTTP();
		
		MyAjax._current_domain = domain;
		MyAjax._current_keyword = keyword;
		
	//begin handling loading
		MyAjax.loading = function() {};
	//end handling loading
	
	//begin handling response
		MyAjax.complete = function(response) {
			if(MyAjax.was_successful()) {
				
				//eval into response
				var Response = eval('(' + response.text + ')');
				
				//get element id
				var keyword_id = _GLOBAL[this._current_keyword];
				
				//test for scraping
				if(Response.is_success == "true"){
					SetInnerHTMLById(keyword_id + "_name", this._current_keyword);
					SetInnerHTMLById(keyword_id + "_msn_rank", Response.msn_rank);
					SetInnerHTMLById(keyword_id + "_yahoo_rank", Response.yahoo_rank);
					SetInnerHTMLById(keyword_id + "_google_rank", Response.google_rank);
				}else{
					//error
				}
			}
			else {
				//error
			}
			
			//release queue
			_GLOBAL.queue_continue = true;
			
		};
	//end handling response

	//begin execute request
		var Data = new Array();
		Data.push("field=" + field);
		Data.push("domain=" + domain);
		Data.push("keyword=" + keyword);
		Data.push("report_id=" + report_id);
		Data.push("transaction_key=" + transaction_key);
		var myPostData = Data.join("&");
		MyAjax.post("/seo-tools/domain-trust.html?r=get_keyword_ranking", myPostData);	
	//end execute request
	
	}
	
//--> End Function :: GetKeywordRanking

//##########################################################################################

//--> Begin Function :: FillSpan

	function FillSpan(ID, Content){
		SetInnerHTMLById(ID, decodeURIComponent(Content));
	}

//--> End Function :: FillSpan

//##########################################################################################

//--> Begin Function :: ExpandSpan

	function ExpandSpan(Content, PreviewLength){
		
		if(Content.length > PreviewLength){
			var PreviewContent = Content.substring(0, PreviewLength);
			var its_random = Math.floor(Math.random() * 5000);
			var ReturnData = "<span id=\"" + its_random + "\">";
			ReturnData += PreviewContent;
			ReturnData += "...<b onclick=\"FillSpan('" + its_random + "','" + encodeURIComponent(Content) + "');\">more</b>";
			ReturnData += "</span>";
		}else{
			ReturnData = Content;
		}
		return ReturnData;
	}
	
//--> End Function :: ExpandSpan

//##########################################################################################

//--> Begin Function :: GetDomainInfo

	function GetDomainInfo(domain, report_id, transaction_key, field){
		
		var MyAjax = new powerHTTP();
		
		MyAjax._current_domain = domain;
		
	//begin handling loading
		MyAjax.loading = function() {};
	//end handling loading
	
	//begin handling response
		MyAjax.complete = function(response) {
			if(MyAjax.was_successful()) {
				
				//eval into response
				var Response = eval('(' + response.text + ')');
				
				//get element id
				var domain_id = _GLOBAL[this._current_domain];
				
				//test for scraping
				if(Response.is_success == "true"){
					SetInnerHTMLById(domain_id + "_name", this._current_domain);
					SetInnerHTMLById(domain_id + "_reg_date_created", Response.reg_date_created);
					SetInnerHTMLById(domain_id + "_reg_date_expires", Response.reg_date_expires);
					SetInnerHTMLById(domain_id + "_registrar", Response.registrar);
					SetInnerHTMLById(domain_id + "_archive_start_date", Response.archive_start_date);
					SetInnerHTMLById(domain_id + "_page_rank", Response.page_rank);
					SetInnerHTMLById(domain_id + "_google_inbound_links", Response.google_inbound_links);
					SetInnerHTMLById(domain_id + "_google_indexed_pages", Response.google_indexed_pages);
					SetInnerHTMLById(domain_id + "_yahoo_inbound_links", Response.yahoo_inbound_links);
					SetInnerHTMLById(domain_id + "_yahoo_indexed_pages", Response.yahoo_indexed_pages);
					SetInnerHTMLById(domain_id + "_digg_rank", Response.digg_rank);
					SetInnerHTMLById(domain_id + "_delicious_rank", Response.delicious_rank);
					SetInnerHTMLById(domain_id + "_technorati_rank", Response.technorati_rank);
					SetInnerHTMLById(domain_id + "_alexa_rank", Response.alexa_rank);
					SetInnerHTMLById(domain_id + "_title", ExpandSpan(Response.title, 20));
					SetInnerHTMLById(domain_id + "_description", ExpandSpan(Response.description, 20));
					SetInnerHTMLById(domain_id + "_keywords", ExpandSpan(Response.keywords, 20));
					SetInnerHTMLById(domain_id + "_google_analytics", Response.google_analytics);
				}else{
					//error
				}
			}
			else {
				//error
			}
			
			//release queue
			_GLOBAL.queue_continue = true;
			
		};
	//end handling response

	//begin execute request	
		var Data = new Array();
		Data.push("field=" + field);
		Data.push("domain=" + domain);
		Data.push("report_id=" + report_id);
		Data.push("transaction_key=" + transaction_key);
		var myPostData = Data.join("&");
		MyAjax.post("/seo-tools/domain-trust.html?r=get_domain_info", myPostData);	
	//end execute request
	}

//--> End Function :: GetDomainInfo

//##########################################################################################

//--> Begin Function :: GetReportID

	function GetReportID() {
		
		var MyAjax = new powerHTTP();
		
	//begin handling loading
		MyAjax.loading = function() {};
	//end handling loading
	
	//begin handling response
		MyAjax.complete = function(response) {
			if(MyAjax.was_successful()) {
				
				//eval into response
				var Response = eval('(' + response.text + ')');
				
				if(Response.is_success == "true"){				
					_GLOBAL.report_id = Response.report_id;
				}else{
					_GLOBAL.report_id = null;
				}
			}
			else {
				_GLOBAL.report_id = null;
			}
			
			//release queue
			_GLOBAL.queue_continue = true;
		};
	//end handling response

	//begin execute request	
		var Data = new Array();
		Data.push("domain_1=" 			+ _GLOBAL.domain_1);
		Data.push("domain_2=" 			+ _GLOBAL.domain_2);
		Data.push("domain_3=" 			+ _GLOBAL.domain_3);
		Data.push("keyword_1=" 			+ _GLOBAL.keyword_1);
		Data.push("keyword_2=" 			+ _GLOBAL.keyword_2);
		Data.push("keyword_3=" 			+ _GLOBAL.keyword_3);
		Data.push("company_name=" 		+ _GLOBAL.company_name);
		Data.push("email=" 				+ _GLOBAL.email);
		Data.push("transaction_key=" 	+ _GLOBAL.transaction_key);
		var myPostData = Data.join("&");
		MyAjax.post("/seo-tools/domain-trust.html?r=get_report_id", myPostData);	
	//end execute request
	}
	
//--> End Function :: GetReport

//##########################################################################################

//--> Begin Function :: GetTransactionKey
	
	function GetTransactionKey() {
		
		var MyAjax = new powerHTTP();
		
	//begin handling loading
		MyAjax.loading = function() {};
	//end handling loading
	
	//begin handling response
		MyAjax.complete = function(response) {
			if(MyAjax.was_successful()) {
				
				//eval into response
				var Response = eval('(' + response.text + ')');
				
				//test for scraping
				if(Response.is_success == "false"){				
					_GLOBAL.transaction_key = null;
				}else{
					_GLOBAL.transaction_key = Response.transaction_key;
				}
			}
			else {
				_GLOBAL.transaction_key = null;
			}
			
			//release queue
			_GLOBAL.queue_continue = true;
		};
	//end handling response

	//begin execute request	
		var Data = new Array();
		Data.push("captcha_code=" + _GLOBAL.captcha_code);
		var myPostData = Data.join("&");
		MyAjax.post("/seo-tools/_captcha.aspx?r=get_transaction_key", myPostData);	
	//end execute request
	}
	
//--> End Function :: GetTransactionKey

//##########################################################################################

//--> Begin Function :: RefreshCaptcha

	function RefreshCaptcha(){
		var its_random = new Date().getTime();
		document.$("captcha").setAttribute('src', '/seo-tools/_captcha.aspx?' + its_random);	
	}
	
//--> End Function :: RefreshCaptcha

//##########################################################################################

//--> Begin Function :: SetInnerHTMLById

	function SetInnerHTMLById(id, html){
		if(html == ""){
			html = "&#160;";	
		}
		var Elements = document.getElementsByTagName("*");
		for(var i = 0 ; i < Elements.length ; i++) {
			if(Elements[i].id == id){
				try{
					Elements[i].innerHTML = html;
				}catch(err){
					AlertError(err, "LineNumber: 680", true);
				}
			}
		}

	}

//--> End Function :: SetInnerHTMLById

//##########################################################################################

//--> Begin Function :: AddToQueue

	_GLOBAL.queue = new Array();
	_GLOBAL.queue_continue = true;
	function AddToQueue(obj){
		_GLOBAL.queue.push(obj);
	}
	
//--> End Function :: AddToQueue

//##########################################################################################

//--> Begin Function :: ExecuteQueue
	
	function ExecuteQueue(){
		
		//is the queue empty?
		if(_GLOBAL.queue.length == 0) {
			return;
		//is the engine busy?
		}else if(_GLOBAL.queue_continue == false) {
			//call the queue sender in another 10 m.s.
			setTimeout("ExecuteQueue()", 100);
		}
		else{
			
			//dont execute until the function called sets to true
			_GLOBAL.queue_continue = false;
			
			//shift off current function
			var CurrentCall = _GLOBAL.queue.shift();
			
			AddToDebugConsole("ExecuteQueue", "719", CurrentCall.replace('/','\/'));
			
			//execute
			eval(CurrentCall);
			
			if(_GLOBAL.queue.length > 0){
				ExecuteQueue();
			}
		}
			
	}
	
//--> End Function :: ExecuteQueue

//##########################################################################################

