// JavaScript Document

// validation search
function validateSearch(theForm)
{
  var reason = "";
  if(trim(theForm.search_store.value)=="")
  {
	  reason +='Please Enter What.\n';
  }
  if(trim(theForm.search_location.value)=="")
  {
	  reason +='Please Enter Where.';
  }

  if (reason != "")
  {
     alert("Some fields need correction:\n\n" + reason);
     return false;
   }
   theForm.submit();
   return true;
}
function validateSearchComm(theForm)
{
  var reason = "";
  if(trim(theForm.search_location.value)=="")
  {
	  reason +='Please Enter Location.';
  }

  if (reason != "")
  {
     alert("Some fields need correction:\n\n" + reason);
     return false;
   }
   theForm.submit();
   return true;
}


// validation for faq START

function validateNumber(theForm)
{
  var reason = "";

   reason += validatePhone(theForm.dest_number,"Please enter destination number","The destination number contains illegal characters","Please enter valid destination number e.g. 0800 108 8883");
    if (reason != "") {
    alert("Some fields need correction:\n\n" + reason);
    return false;
  }
  return true;
}

function validateFaq(theForm)
{
var reason = "";

  reason += validateEmpty(theForm.question_txt,"Please enter your question");
  reason += validateEmail(theForm.email_txt);
  reason += validateEmpty(theForm.name_txt,"Please enter your name");

    if (reason != "") {
    alert("Some fields need correction:\n\n" + reason);
    return false;
  }
  return true;
}
// validation for faq END

// validation for comment START
function validateComment(theForm)
{
var reason = "";

  reason += validateEmpty(theForm.name_txt,"Please enter your name");
  reason += validateEmail(theForm.email_txt);
  reason += validateEmpty(theForm.comment_text,"Please enter your comment");

    if (reason != "") {
    alert("Some fields need correction:\n\n" + reason);
    return false;
  }
  return true;
}
// validation for comment END

// validate rating
function validateRating(theForm)
{
var reason = "";
  reason += validateEmpty(theForm.name_txt,"Please enter your name");
  reason += validateEmail(theForm.email_txt);

    if (reason != "") {
    alert("Some fields need correction:\n\n" + reason);
    return false;
  }

  document.rate.submit();
  return true;
}

// validate send mail to all START
function validateSendMailToAll(theForm)
{
var reason = "";
  reason += validateEmpty(theForm.name_txt,"Please enter your name");
  reason += validateEmail(theForm.email_txt);
  reason += validatePhone(theForm.tele_txt,"Please enter phone number","The phone number contains illegal characters","Please enter valid phone number e.g. 0800 108 8883");
  reason += validateEmpty(theForm.subject_txt,"Please enter subject");

    if (reason != "") {
    alert("Some fields need correction:\n\n" + reason);
    return false;
  }

  document.send_mail_all_frm.submit();
  return true;
}
// validate send mail to all END

// validation for contact us START
function validateContactUs(theForm)
{
var reason = "";

  reason += validateEmpty(theForm.name_txt,"Please enter your name");
  reason += validateEmail(theForm.email_txt);
  reason += validateEmpty_textarea(theForm.info_text,"Please enter your query");

    if (reason != "") {
    alert("Some fields need correction:\n\n" + reason);
    return false;
  }

  //document.theForm.submit();
  return true;
}
// validation for contact us END

// validation for myServicesAdd  START
function validateMyServicesAdd(theForm)
{
var reason = "";

  reason += validateEmpty(theForm.service_txt,"Please enter your service name");
  reason += validateEmpty_FCKEditer(FCKeditorAPI.GetInstance('description_text'),"Please enter service description");

    if (reason != "") {
    alert("Some fields need correction:\n\n" + reason);
    return false;
  }

  return true;
}
// validation for myServicesAdd  END

// validation for Service Highlight  START
function validateServiceHighlight(theForm)
{
var reason = "";
  reason += validateEmpty_FCKEditer(FCKeditorAPI.GetInstance('description_text'),"Please enter service description");
    if (reason != "") {
    alert("Some fields need correction:\n\n" + reason);
    return false;
  }

  return true;
}
// validation for mService Highlight  END

// validation for myServicesEdit  START
function validateMyServicesEdit(theForm)
{
var reason = "";

  reason += validateEmpty(theForm.service_txt,"Please enter your service name");
  reason += validateEmpty_FCKEditer(FCKeditorAPI.GetInstance('description_text'),"Please enter service description");

    if (reason != "") {
    alert("Some fields need correction:\n\n" + reason);
    return false;
  }

  return true;
}
// validation for myServicesEdit  END

// validation for login START
function validateLogin(theForm)
{
var reason = "";

  reason += validateUsername(theForm.username_txt);
  reason += validatePassword(theForm.password_txt);

    if (reason != "") {
    alert("Some fields need correction:\n\n" + reason);
    return false;
  }

  return true;

}
function validURL(fld)
{
	var error = "";
	var theurl=fld.value;
	//var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/	
	var tomatch= /^(ht|f)tps?:\/\/[a-z0-9-\.]+\.[a-z]{2,4}\/?([^\s<>\#%"\,\{\}\\|\\\^\[\]`]+)?$/
		
	if (tomatch.test(theurl))
    {
		fld.parentNode.className = 'contact_input'
		fld.className = 'inputbg';		
	}
	else
	{
  	    fld.parentNode.className = 'contact_input_err'
		fld.className = 'inputbg_err';
		error = "Please enter valid URL.\n";
		fld.focus();
    	return error;
    }
	return error;
}

 //return url.match(/^(ht|f)tps?:\/\/[a-z0-9-\.]+\.[a-z]{2,4}\/?([^\s<>\#%"\,\{\}\\|\\\^\[\]`]+)?$/);
// validation for login END

// validation for Business User Registration START
function validateBusinessUser(theForm) {
var reason = "";

  reason += validateUsername(theForm.username);
  reason += validatePassword(theForm.password,theForm.password_confirm);
  reason += validateEmpty(theForm.personal_fullname,"Please enter contact person's full name");
  reason += validateEmpty(theForm.company_name,"Please enter company name");
  reason += validateEmpty(theForm.company_url,"Please enter company url");
  reason += validURL(theForm.company_url);

  if(theForm.company_logo.value)
  {
	  reason += validateImage(theForm.company_logo,"Please Select Image File For Company Logo");
  }
  reason += validateEmpty_textarea(theForm.personal_address,"Please enter personal address");
  reason += validateEmpty(theForm.personal_city,"Please enter city");
  reason += validateEmpty(theForm.personal_postcode,"Please enter personal post code");
 reason += validatePhone(theForm.personal_contact_no,"Please enter phone number","The phone number contains illegal characters","Please enter valid phone number e.g. 0800 108 8883");
 reason += validatePhone(theForm.personal_fax,"Please enter fax number","The fax number contains illegal characters","Please enter valid fax number e.g. 0800 108 8883");
  reason += validateEmail(theForm.personal_email);
  reason += validateEmpty(theForm.strap_line,"Please Enter Strap Line");
  reason += validateEmpty(theForm.receive_name,"Please enter receive name");
  reason += validateEmpty(theForm.receive_job_tiltle,"Please enter receive job title");
  reason += validatePhone(theForm.receive_contact_no,"Please enter receive contact number","The receive contact number contains illegal characters","Please enter valid receive contact number e.g. 0800 108 8883");
  reason += validatePhone(theForm.receive_mobile,"Please enter mobile number","The mobile number contains illegal characters","Please enter valid mobile number e.g. 0800 108 8883");
  reason += validateEmail(theForm.receive_email);
  //reason += validateEmpty(theForm.receive_address,"Please enter receive address");
  reason += validatePhone(theForm.receive_ddi_fax,"Please enter ddi fax number","The ddi fax number contains illegal characters","Please enter valid ddi fax number e.g. 0800 108 8883");
  reason += validatePhone(theForm.receive_phone_leads,"Please enter receive phone leads number","The receive phone leads number contains illegal characters","Please enter valid receive phone leads number e.g. 0800 108 8883");
  reason += validateEmail(theForm.receive_email_leads);
  reason += validateEmpty(theForm.account_name,"Please enter account name");
  reason += validateEmpty(theForm.account_job_title,"Please enter account job title");
  reason += validatePhone(theForm.account_contact_no,"Please enter account contact number","The account contact number contains illegal characters","Please enter valid account contact number e.g. 0800 108 8883");
  reason += validateEmail(theForm.account_email);
 // reason += validateRadioValue(theForm.account_business_type,"Please select business type");
  reason += validateEmpty(theForm.account_registration_no,"Please enter account registration no");
  reason += validateEmpty(theForm.account_vat,"Please enter VAT no");
  if (reason != "") {
    alert("Some fields need correction:\n\n" + reason);
    return false;
  }

  return true;
}

function validateBusinessUserEdit(theForm) {
var reason = "";

  reason += validateEmpty(theForm.personal_fullname,"Please enter contact person's full name");
  reason += validateEmpty(theForm.company_name,"Please enter company name");
  reason += validateEmpty(theForm.company_url,"Please enter company url");
  reason += validURL(theForm.company_url);

  if(theForm.company_logo.value)
  {
	  reason += validateImage(theForm.company_logo,"Please Select Image File For Company Logo");
  }

  reason += validateEmpty_textarea(theForm.personal_address,"Please enter personal Address");
  reason += validateEmpty(theForm.personal_city,"Please enter city");
  reason += validateEmpty(theForm.personal_postcode,"Please enter personal post code");
  reason += validatePhone(theForm.personal_contact_no,"Please enter phone number","The phone number contains illegal characters","Please enter valid phone number e.g. 0800 108 8883");
  reason += validatePhone(theForm.personal_fax,"Please enter fax number","The fax number contains illegal characters","Please enter valid fax number e.g. 0800 108 8883");
  reason += validateEmail(theForm.personal_email);
  reason += validateEmpty(theForm.strap_line,"Please Enter Strap Line");
  reason += validateEmpty(theForm.receive_name,"Please enter receive name");
  reason += validateEmpty(theForm.receive_job_tiltle,"Please enter receive job title");
  reason += validatePhone(theForm.receive_contact_no,"Please enter receive contact number","The receive contact number contains illegal characters","Please enter valid receive contact number e.g. 0800 108 8883");
  reason += validatePhone(theForm.receive_mobile,"Please enter mobile number","The mobile number contains illegal characters","Please enter valid mobile number e.g. 0800 108 8883");
  reason += validateEmail(theForm.receive_email);
  //reason += validateEmpty(theForm.receive_address,"Please enter receive address");
  reason += validatePhone(theForm.receive_ddi_fax,"Please enter ddi fax number","The ddi fax number contains illegal characters","Please enter valid ddi fax number e.g. 0800 108 8883");
  reason += validatePhone(theForm.receive_phone_leads,"Please enter receive phone leads number","The receive phone leads number contains illegal characters","Please enter valid receive phone leads number e.g. 0800 108 8883");
  reason += validateEmail(theForm.receive_email_leads);
  reason += validateEmpty(theForm.account_name,"Please enter account name");
  reason += validateEmpty(theForm.account_job_title,"Please enter account job title");
  reason += validatePhone(theForm.account_contact_no,"Please enter account contact number","The account contact number contains illegal characters","Please enter valid account contact number e.g. 0800 108 8883");
  reason += validateEmail(theForm.account_email);
 // reason += validateRadioValue(theForm.account_business_type,"Please select business type");
  reason += validateEmpty(theForm.account_registration_no,"Please enter account registration no");
  reason += validateEmpty(theForm.account_vat,"Please enter VAT no");

  if (reason != "") {
    alert("Some fields need correction:\n\n" + reason);
    return false;
  }

  return true;
}

//validate  forgot password
function validateForgot(theForm) {
var reason = "";
  reason += validateEmpty(theForm.username,"Please enter user name");
  /*reason += validateEmail(theForm.email); */

  if (reason != "") {
    alert("Some fields need correction:\n\n" + reason);
    return false;
  }

  return true;
}

//** validation for album addition**/
function validateAlbum(theForm){
  var reason = "";
  reason += validateEmpty(theForm.album_title,"Please enter Album Title");
  reason += validateImage(theForm.album_image,"Please Select Image File For Album Image");
  if (reason != "") {
    alert("Some fields need correction:\n\n" + reason);
    return false;
  }
  return true;
}


//** validation for album updation**/
function validateAlbumUpdate(theForm){
  var reason = "";
  reason += validateEmpty(theForm.album_title,"Please enter Album Title");
  if(theForm.album_image.value=='' && theForm.hidden_image.value==''){
 	 reason += validateImage(theForm.album_image,"Please Select Image File For Album Image");
  }
  if (reason != "") {
    alert("Some fields need correction:\n\n" + reason);
    return false;
  }
  return true;
}


//** validation for photo addition**/
function validatePhoto(theForm){
  var reason = "";
  reason += validateImage(theForm.photo,"Please Select Image File For Photo");
  if (reason != "") {
    alert("Some fields need correction:\n\n" + reason);
    return false;
  }
  return true;
}

//** validation for Property addition in message table**/
function validateProperty(theForm){
  var reason = "";

   reason += validateEmpty(theForm.property_name,"Please enter Property Name");
   reason += validateEmpty(theForm.property_address_1,"Please enter Property Address");
   reason += validateEmpty(theForm.property_city,"Please enter Property City");
   reason += validatePhone(theForm.contact_no,"Please enter contact number","The contact number contains illegal characters","Please enter valid contact number e.g. 0800 108 8883");
   reason += validateFloat(theForm.area,"Please enter area","The area contains illegal characters");
   reason += validateFloat(theForm.price,"Please enter price","The price contains illegal characters");
   reason += validateEmpty_FCKEditer(FCKeditorAPI.GetInstance('property_detail'),"Please enter Property Detail");

   var hasSelected = false;
	 var chklen = theForm.elements.length;
	 for( var n = 0; n < chklen; n++ )
	 {
		currobj = theForm.elements[n];
		if((currobj.type == "file") && (currobj.value!=''))
			hasSelected = true;
	}
	if(hasSelected)
	{}
	else
	{
	   reason += "Please select at least one image\n";
	}

  if (reason != ""){
    alert("Some fields need correction:\n\n" + reason);
    return false;
  }
  return true;
}


//** validation for Property edit in message table**/
function validatePropertyEdit(theForm){
  var reason = "";

   reason += validateEmpty(theForm.property_name,"Please enter Property Name");
   reason += validateEmpty(theForm.property_address_1,"Please enter Property Address");
   reason += validateEmpty(theForm.property_city,"Please enter Property City");
   reason += validatePhone(theForm.contact_no,"Please enter contact number","The contact number contains illegal characters","Please enter valid contact number e.g. 0800 108 8883");
   reason += validateFloat(theForm.area,"Please enter area","The area contains illegal characters");
   reason += validateFloat(theForm.price,"Please enter price","The price contains illegal characters");
   reason += validateEmpty_FCKEditer(FCKeditorAPI.GetInstance('property_detail'),"Please enter Property Detail");
   if(theForm.count_image.value==0)
   {
		var hasSelected = false;
		var chklen = theForm.elements.length;
		for( var n = 0; n < chklen; n++ )
		{
			currobj = theForm.elements[n];
			if((currobj.type == "file") && (currobj.value!=''))
				hasSelected = true;
		}
		if(hasSelected)
		{}
		else
		{
		   reason += "Please select at least one image\n";
		}
	}

  if (reason != "") {
    alert("Some fields need correction:\n\n" + reason);
    return false;
  }
  return true;
}

//** validation for message addition in message table**/
function validateMessage(theForm){
  var reason = "";


/*	var alle=theForm.elements['email[]'];
	var sel=0;
	for(var i=0;i<alle.length;i++)
	{
		if(alle[i].selected)
		{
			sel=1;
		}
	}
	if(sel==0)
	{
		 reason += 'Please Select E-mail.\n';
	}*/

  reason += validateEmpty(theForm.subject,"Please enter Subject");
  reason += validateEmpty_textarea(theForm.message,"Please enter Message");
  if (reason != "") {
    alert("Some fields need correction:\n\n" + reason);
    return false;
  }
  return true;
}

// validation for Business User Registration END

/*function validateEmpty(fld) {
    var error = "";

    if (fld.value.length == 0) {
        fld.style.background = 'Yellow';
        error = "The required field has not been filled in.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;
}
*/

//checkPhoto(http://www.hotscripts.com/forums/avatars/nevermind.gif);

//checkPhoto('http://www.hotscripts.com/forums/avatars/nevermind.png');

function checkPhoto(imagePath) {
   var pathLength = imagePath.length;
   var lastDot = imagePath.lastIndexOf(".");
   var fileType = imagePath.substring(lastDot,pathLength).toLowerCase();

   if((fileType == ".gif") || (fileType == ".jpg") || (fileType == ".jpeg") || (fileType == ".png") || (fileType == ".GIF") || (fileType == ".JPG") || (fileType == ".PNG"))
   {
       return true;
   }
   else
   {
       return false;
   }
}

function validateImage(fld,msg) {

	var error = "";

    if (!checkPhoto(fld.value))
	{
       // fld.parentNode.className = 'contact_input_err'
		//fld.className = 'inputbg_err';
        error = msg +"\n"
    } else {
        //fld.parentNode.className = 'contact_input'
		//fld.className = 'inputbg';
    }
    return error;
}

function validateEmpty(fld,msg) {
	var error = "";
    var texts = trim(fld.value);
    if (texts.length == 0) {
        fld.parentNode.className = 'contact_input_err'
		fld.className = 'inputbg_err';
        error = msg +"\n"
    } else {
        fld.parentNode.className = 'contact_input'
		fld.className = 'inputbg';
    }
    return error;
}
function validateEmpty_extra(fld,msg) {
    var error = "";
    var texts = trim(fld.value);
    if (texts.length == 0) {
        fld.style.background = 'Red';
        error = msg +"\n"
    } else {
        fld.style.background = '';
    }
    return error;
}
function validateEmpty_FCKEditer(fld,msg) {
    var error = "";
    var texts = trim(fld.GetXHTML());
    if (texts == ""){
        error = msg +"\n"
    }
    return error;
}

function validateEmpty_textarea(fld,msg) {
    var error = "";
    var textareas = trim(fld.value);
    if (textareas.length == 0) {
        fld.parentNode.className = 'contact_tarea_err'
		fld.className = 'big-textarea_err';
        error = msg +"\n"
    } else {
        fld.parentNode.className = 'contact_tarea'
		fld.className = 'big-textarea';
    }
    return error;
}

function validateUsername(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores

    if (fld.value == "") {
		//alert(fld.parentNode.className);
        //fld.style.background = 'Yellow';
		fld.parentNode.className = 'contact_input_err'
		fld.className = 'inputbg_err';
        error = "Please enter username.\n";
    } else if ((fld.value.length < 5) || (fld.value.length > 15)) {
        fld.parentNode.className = 'contact_input_err'
		fld.className = 'inputbg_err';
        error = "The username must be within 5 to 15 character.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.parentNode.className = 'contact_input_err'
		fld.className = 'inputbg_err';
        error = "The username must contain a-z, A-Z, 0-9 characters.\n";
    } else {
        fld.parentNode.className = 'contact_input'
		fld.className = 'inputbg';
    }
    return error;
}


/*function validatePassword(fld) {
    var error = "";
    var illegalChars = /[\W_]/; // allow only letters and numbers

    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "You didn't enter a password.\n";
    } else if ((fld.value.length < 7) || (fld.value.length > 15)) {
        error = "The password is the wrong length. \n";
        fld.style.background = 'Yellow';
    } else if (illegalChars.test(fld.value)) {
        error = "The password contains illegal characters.\n";
        fld.style.background = 'Yellow';
    } else if (!((fld.value.search(/(a-z)+/)) && (fld.value.search(/(0-9)+/)))) {
        error = "The password must contain at least one numeral.\n";
        fld.style.background = 'Yellow';
    } else {
        fld.style.background = 'White';
    }
   return error;
}*/

function validatePassword(fld,fld1) {
    var error = "";
    var illegalChars = /[\W_]/; // allow only letters and numbers

    if (fld.value == "") {
        fld.parentNode.className = 'contact_input_err'
		fld.className = 'inputbg_err';
        error = "Please enter password.\n";
    } else if ((fld.value.length < 7) || (fld.value.length > 15)) {
        error = "The password must be within 7 to 15 character.\n";
        fld.parentNode.className = 'contact_input_err'
		fld.className = 'inputbg_err';
    } else if (illegalChars.test(fld.value)) {
        error = "The password must contain a-z, A-Z, 0-9 characters.\n";
        fld.parentNode.className = 'contact_input_err'
		fld.className = 'inputbg_err';
    } else if (!((fld.value.search(/(a-z)+/)) && (fld.value.search(/(0-9)+/)))) {
        error = "The password must contain at least one numeral.\n";
        fld.parentNode.className = 'contact_input_err'
		fld.className = 'inputbg_err';
	} else if (fld.value != fld1.value) {
        fld.parentNode.className = 'contact_input_err'
		fld.className = 'inputbg_err';
		fld1.parentNode.className = 'contact_input_err'
		fld1.className = 'inputbg_err';
		error = "The password and confirm password must be same.\n";
    } else {
        fld.parentNode.className = 'contact_input'
		fld.className = 'inputbg';
		fld1.parentNode.className = 'contact_input'
		fld1.className = 'inputbg';
    }
   return error;
}

function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}

function validateEmail(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;

    if (fld.value == "") {
        fld.parentNode.className = 'contact_input_err'
		fld.className = 'inputbg_err';
        error = "Please enter email address.\n";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.parentNode.className = 'contact_input_err'
		fld.className = 'inputbg_err';
        error = "Please enter valid email address.\n";
    } else if (fld.value.match(illegalChars)) {
        fld.parentNode.className = 'contact_input_err'
		fld.className = 'inputbg_err';
        error = "The email address contains illegal characters.\n";
    } else {
        fld.parentNode.className = 'contact_input'
		fld.className = 'inputbg';
    }
    return error;
}

/*function validatePhone(fld) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');

   if (fld.value == "") {
        error = "You didn't enter a phone number.\n";
        fld.style.background = 'Yellow';
    } else if (isNaN(parseInt(stripped))) {
        error = "The phone number contains illegal characters.\n";
        fld.style.background = 'Yellow';
    } else if (!(stripped.length == 10)) {
        error = "The phone number is the wrong length. Make sure you included an area code.\n";
        fld.style.background = 'Yellow';
    }
    return error;
}*/

function validatePhone(fld,msg1,msg2,msg3) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');

   if (fld.value == "") {
        error = msg1 + "\n";
        fld.parentNode.className = 'contact_input_err'
		fld.className = 'inputbg_err';
    } else if (isNaN(parseInt(stripped))) {
        error = msg2 + "\n";
        fld.parentNode.className = 'contact_input_err'
		fld.className = 'inputbg_err';
    } else if (!(stripped.length == 11)) {
        error = msg3 + "\n";
        fld.parentNode.className = 'contact_input_err'
		fld.className = 'inputbg_err';
    } else {
        fld.parentNode.className = 'contact_input'
		fld.className = 'inputbg';
    }
    return error;
}

function validateFloat(fld,msg1,msg2) {
    var error = "";
   if (fld.value == "") {
        error = msg1 + "\n";
        fld.parentNode.className = 'contact_input_err'
		fld.className = 'inputbg_err';
    } else if (isNaN(fld.value)) {
        error = msg2 + "\n";
        fld.parentNode.className = 'contact_input_err'
		fld.className = 'inputbg_err';
    } else {
        fld.parentNode.className = 'contact_input'
		fld.className = 'inputbg';
    }
    return error;
}

function validateRadioValue(fld,msg)
{
  var error = "";
  var checked = false;
  var buttons = fld;
  for (var i=0; i<buttons.length; i++)
  {
    if (buttons[i].checked) {
      checked = true;
      break;
    }
   }
   if(!checked)
     error = msg + "\n";
   return error;
}

function IsWeb(urlStr) {
	urlStr = urlStr.value;
	var error = "";
	if (urlStr.indexOf(" ") != -1) {
	error = "Spaces are not allowed in a URL" + "\n";
	return error;
	}

	if (urlStr == "" || urlStr == null || urlStr == "http://") {
	return true;
	}

	urlStr=urlStr.toLowerCase();

	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var atom=validChars + '+';
	var urlPat=/^http:\/\/(\w*)\.([\-\+a-z0-9]*)\.(\w*)/;
	var matchArray=urlStr.match(urlPat);

	if (matchArray==null) {
	error = "The URL seems incorrect check it begins with http:// and it has 2 .'s \nFor Example ( http://www.example.com)" + "\n";
	return error;
	}

	var user=matchArray[2];
	var domain=matchArray[3];

	for (i=0; i<user.length; i++) {
	if (user.charCodeAt(i)>127) {
	error = "This domain contains invalid characters." + "\n";
	return error;
	}
	}

	for (i=0; i<domain.length; i++) {
	if (domain.charCodeAt(i) > 127) {
	error = "This domain name contains invalid characters." + "\n";
	return error;
	}
	}

	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;

	for (i=0;i<len;i++) {
	if (domArr[i].search(atomPat) == -1) {
	error = "The domain name does not seem to be valid." + "\n";
	return error;
	}
	}

return true;
}


{// JavaScript ajax showAjax('ajxregion.php?id='+objMe.value,'divregion');
var xmlHttp;
var urlName;
var div_id;

function showAjax(url,div)
{ 
		
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request");
 return;
 }
urlName = url;
div_id = div;
 
//var url="getuser.php";
//url=url+"?q="+str;
//url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged() 
{ 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	//alert(xmlHttp.responseText);
 	document.getElementById(div_id).innerHTML=xmlHttp.responseText;
 } 
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}
}









