
/**

1. What do we need?

- First of all, all menus are residing over one another.
- When mouseenters over the Menu, it should call a 


1. create an 

*/
function initialize_menu() 
{
	//The following code is used for sidebar widget tool.
	if($('domain') != null) 
	{
	//Attach Keypress Event to the Domain Textbox
		$('domain').addEvent('keypress',function(e) {
			
			if(e.keyCode==13) {
				e = new Event(e).stop();
				submitPR();
			}

		});

		$('submitGetPR').addEvent('click', function(e) {
				e = new Event(e).stop();
				submitPR();	 
		});

	}

}
var requesting = false;

function submitPR() {
	    

		//if(requesting==true) return;

		try
		{
		
		var url = pluginurl + "pr.php";

		}
		catch(e)
		{
			
		}
			
		var dval = "";
		var captcha = "";
	    
		try
		{
			dval = $('domain').value;
			captcha = $('captcha').value;
		}
		catch (e)
		{
		}
		if(dval==null || dval=="" || dval=="http://") {
			alert('Please provide a valid domainname');
			return;
		}
		/**
		 * The simple way for an Ajax request, use onRequest/onComplete/onFailure
		 * to do add your own Ajax depended code.
		 */
					 
		 new Ajax(url, {
			method: 'get',
			data: 'domain=' + $('domain').value + '&aj=1',
			update: $('results'),
					
			onRequest: function() {
				$('msg').innerHTML = '<img src="'+pluginurl +'/images/ball.gif" />';
				$('rankcodetextarea').value = "";
				$('results').innerHTML = "";
				//requesting = true;
			},
			onFailure: function() {

				$('msg').innerHTML = 'Sorry! Request could not be completed. Please try again later. ';
			},
			onComplete: function() {

				response = this.response.text;
				$('msg').innerHTML = "";
				$('results').innerHTML = "This is how siterank image will appear on your site <div style='align:left;'><br/>" + response + "</div><br/>You may copy the html code below to show this image on your site." ;
				$('rankcodetextarea').value = response;
				
			}
		}).request();
		
		

		return false;

}
function onselection(obj) {
	if(obj.value) {
		obj.selectionStart=0;
		obj.selectionEnd=obj.value.length;
	}
}



window.addEvent('load', initialize_menu );