// JavaScript Document
var ajax = new sack();

//TRIM FUNCTION
function trim(strText) {
  // this will get rid of leading spaces
  while (strText.substring(0,1) == ' ')
   strText = strText.substring(1, strText.length);

  // this will get rid of trailing spaces
  while (strText.substring(strText.length-1,strText.length) == ' ')
   strText = strText.substring(0, strText.length-1);
  var pos=0;
  var tevePos=0;
  while(strText.indexOf("\n",pos)>-1)
  {
   tevePos=strText.indexOf("\n",pos)
   pos=tevePos+1
  }
    return strText;
}

//===============Key Restrict============
 function keyRestrict(e, validchars)
 {
  var key='', keychar='';
  key = getKeyCode(e);
  if (key == null) return true;
  keychar = String.fromCharCode(key);
  keychar = keychar.toLowerCase();
  validchars = validchars.toLowerCase();
  if (validchars.indexOf(keychar) != -1)
   return true;
  if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
   return true;
  //alert("Plese enter a valid character.");
  return false;
 }

 function getKeyCode(e)
 {
  if (window.event)
   return window.event.keyCode;
  else if (e)
   return e.which;
  else
   return null;
 }

function check_domain()
{
	if(trim(document.getElementById('domain').value) != '')
	{
		document.getElementById("error_msg").innerHTML = '';
		document.getElementById('search_message').innerHTML = '<img src="http://www.diadem.co.in/images/ajax-loader.gif" alt="Searching...." style="margin: 0 0 0 120px;">';
		
		ajax.setVar("domain", document.getElementById('domain').value);
		
		ajax.method= 'POST';
		ajax.requestFile = "http://www.diadem.co.in/domain_search/domain_search.php";	// Specifying which file to get
		ajax.element = 'search_message'; // ID to be over written with response content
		//ajax.onCompletion = SHOW_PAGE;	// Specify function that will be executed after file has been found
		ajax.runAJAX();
	}
	else
		document.getElementById("error_msg").innerHTML = "Please enter a domain name";
}
/*function SHOW_PAGE()
{
	var content = ajax.response;
	document.getElementById('search_message').innerHTML = content;
}*/


function check_domain_offers()
{
	if(trim(document.getElementById('domain').value) != '')
	{
		document.getElementById("error_msg").innerHTML = '';
		document.getElementById('search_message').innerHTML = '<img src="http://www.diadem.co.in/images/ajax-loader.gif" alt="Searching...." style="margin: 0 0 0 120px;">';
		
		ajax.setVar("domain", document.getElementById('domain').value);
		ajax.setVar("ext", document.getElementById('ext').value);
		
		ajax.method= 'POST';
		ajax.requestFile = "http://www.diadem.co.in/domain_search/domain_search_offers.php";	// Specifying which file to get
		ajax.element = 'search_message'; // ID to be over written with response content
		//ajax.onCompletion = SHOW_PAGE;	// Specify function that will be executed after file has been found
		ajax.runAJAX();
	}
	else
		document.getElementById("error_msg").innerHTML = "Please enter a domain name";
}
/*function SHOW_PAGE()
{
	var content = ajax.response;
	document.getElementById('search_message').innerHTML = content;
}*/