// prepare the form when the DOM is ready 
$(document).ready(function() { 
    var options = { 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse,  // post-submit callback 
        url: 'ajax/process.php?c=google'// override for form's 'action' attribute 
    }; 
    var options1 = { 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse,  // post-submit callback 
        url: 'ajax/process.php?c=yahoo'// override for form's 'action' attribute 
    };
    var options2 = { 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse,  // post-submit callback 
        url: 'ajax/process.php?c=allweb'// override for form's 'action' attribute 
    };
    var options3 = { 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse,  // post-submit callback 
        url: 'ajax/process.php?c=dgoogle'// override for form's 'action' attribute 
    };
    var options4 = { 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse,  // post-submit callback 
        url: 'ajax/process.php?c=dmoz'// override for form's 'action' attribute 
    };	
    var options5 = { 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse,  // post-submit callback 
        url: 'ajax/process.php?c=dyahoo'// override for form's 'action' attribute 
    };	  
    var options6 = { 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse,  // post-submit callback 
        url: 'ajax/process.php?c=dage'// override for form's 'action' attribute 
    };
    var options7 = { 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse,  // post-submit callback 
        url: 'ajax/process.php?c=dhistory'// override for form's 'action' attribute 
    };	
    var options8 = { 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse,  // post-submit callback 
        url: 'ajax/process.php?c=wcom'// override for form's 'action' attribute 
    };
    
    var options9 = { 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse,  // post-submit callback 
        url: 'ajax/process.php?c=wnet'// override for form's 'action' attribute 
    };
	
    var options10 = { 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse,  // post-submit callback 
        url: 'ajax/process.php?c=worg'// override for form's 'action' attribute 
    };
	
    var options11 = { 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse,  // post-submit callback 
        url: 'ajax/process.php?c=winfo'// override for form's 'action' attribute 
    };
    var options12 = { 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse,  // post-submit callback 
        url: 'ajax/process.php?c=wbiz'// override for form's 'action' attribute 
    };			    
		 	 
    var options13 = { 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse,  // post-submit callback 
        url: 'ajax/process.php?c=googlerank'// override for form's 'action' attribute 
    };	
    var options14 = { 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse,  // post-submit callback 
        url: 'ajax/process.php?c=googlerankw'// override for form's 'action' attribute 
    };			    
		    
    $('#btnGo').click(function() {
    	$("#pagerank").show();
		$('#form1').ajaxSubmit(options); 
    	$('#form1').ajaxSubmit(options1); 
    	$('#form1').ajaxSubmit(options2);
    	$('#form1').ajaxSubmit(options3);
    	$('#form1').ajaxSubmit(options4);
    	$('#form1').ajaxSubmit(options5);
    	$('#form1').ajaxSubmit(options6);
    	$('#form1').ajaxSubmit(options7);
    	$('#form1').ajaxSubmit(options8);
    	$('#form1').ajaxSubmit(options9);
    	$('#form1').ajaxSubmit(options10);
    	$('#form1').ajaxSubmit(options11);
    	$('#form1').ajaxSubmit(options12);
		$('#form1').ajaxSubmit(options13);	
		$('#form1').ajaxSubmit(options14);									    	
    });

}); 

// pre-submit callback 
function showRequest(formData, jqForm, options) { 
    // formData is an array; here we use $.param to convert it to a string to display it 
    // but the form plugin does this for you automatically when it submits the data 
    $("#btnGo").attr("disabled", "true"); 
	var queryString = $.param(formData); 

	 $("#lg").html('<img src="images/loading.gif">');
	 $("#ly").html('<img src="images/loading.gif">');
	 $("#latw").html('<img src="images/loading.gif">');
	 $("#ltotal").html('<span id="total">0</span>');
	 $("#w-com").html('<img src="images/loading.gif">');
	 $("#w-net").html('<img src="images/loading.gif">');
	 $("#w-org").html('<img src="images/loading.gif">');
	 $("#w-info").html('<img src="images/loading.gif">');
	 $("#w-biz").html('<img src="images/loading.gif">');	
     
    return true; 
} 
 
// post-submit callback 
function showResponse(responseXML, statusText)  { 

	var total=0;
	 url=escape($("#txtUrl").val());
 
	 domain=$("#txtUrl").val();
	 domain=domain.replace("http://","");
	 domain=domain.replace("www.","");
	 domain=escape(domain); 	
	 array = (responseXML.match(/(.*?)#(.*?)$/));
	 idd=array[1];
	 value=array[2];
	 if(idd=='resultGooglePageRank'){
		 $("#lg").html('<a href="http://www.google.com/search?q=link:www.'+domain+'&filter=0" target="_blank"><span id="gnum">'+value+'</span></a>'); 
		oldvalue=$("#total").text();
		currency = value;
		total = Number(currency.replace(/[^0-9\.]+/g,""))+Number(oldvalue.replace(/[^0-9\.]+/g,""));	
		$("#ltotal").html('<span id="total">'+total+"</span>");	
	 }else if(idd=='resultYahooRank'){
	 	$("#ly").html('<a href="http://siteexplorer.search.yahoo.com/search?p=http%3A%2F%2Fwww.'+domain+'&bwm=i&bwms=p&bwmf=u&fr=sfp&fr2=seo-rd-se" target="_blank"><span id="ynum">'+value+'</span></a>'); 
		oldvalue=$("#total").text();
		currency = value;
		total = Number(currency.replace(/[^0-9\.]+/g,""))+Number(oldvalue.replace(/[^0-9\.]+/g,""));	
		$("#ltotal").html('<span id="total">'+total+"</span>");	 
			 	
	 }else if(idd=='resultallWebRank'){
	 	$("#latw").html('<a href="http://www.alltheweb.com/search?cat=web&cs=utf-8&q=link%3Ahttp%3A%2F%2Fwww.'+domain+'&_sb_lang=any" target="_blank"><span id="anum">'+value+'</span></a>'); 
		oldvalue=$("#total").text();
		currency = value;
		total = Number(currency.replace(/[^0-9\.]+/g,""))+Number(oldvalue.replace(/[^0-9\.]+/g,""));	
		$("#ltotal").html('<span id="total">'+total+"</span>");	 	
	 }else if(idd=='dmoz'){
	 	$("#dmozcontent").html(value); 
	 }else if(idd=='dgoogle'){
	 	$("#dgooglecontent").html(value); 
	 }else if(idd=='dyahoo'){
	 	$("#dyahoocontent").html(value); 
	 }else if(idd=='dage'){
	 	$("#dagecontent").html(value); 
	 }else if(idd=='dhistory'){
	 	$("#dhistorycontent").html(value); 
	 }else if(idd=='wcom'){
	 	$("#w-com").html(value); 
 	 }else if(idd=='wnet'){
	 	$("#w-net").html(value); 
 	 }else if(idd=='worg'){
	 	$("#w-org").html(value);
 	 }else if(idd=='winfo'){
	 	$("#w-info").html(value);
 	 }else if(idd=='wbiz'){
	 	$("#w-biz").html(value);
 	 }else if(idd=='googlerank'){
	 	
	 	
		var page_rank='<font color="#000099">www.'+domain+'</font><font color="red">'+value+'/10</font>'; 
	 	$("#googlerank").html(page_rank);
	 	
		$("#grnum").html(value);
	 	
		 value=parseInt(value)*5;
		$("#gimg").html('<img height="4" border="0" width="'+value+'" style="display: block;" src="images/prpix.gif"/>');
	 	
 	 }else if(idd=='googlerankw'){
		page_rank2='<font color="#000099">www.'+domain+'</font><font color="red">'+value+'/10</font>'; 	 	      $("#googlerankw").html(page_rank2);
		$("#gwnum").html(value);
		value=parseInt(value)*5;
		$("#gwimg").html('<img height="4" border="0" width="'+value+'" style="display: block;" alt="" src="images/prpix.gif"/>');		
 	 }
 	 
	 $("#btnGo").removeAttr("disabled");  
} 