
function checkTrans(theForm)
{
	if (theForm.sStatus.value == "")
  {
    alert("Please enter a Status.");
    theForm.sStatus.focus();
    return (false);
  }
  	if (theForm.sType.value == "")
  {
    alert("Please enter a Type.");
    theForm.sType.focus();
    return (false);
  }
  
if (theForm.sStatus.value != "ACTV")
{
  	if (theForm.sAgentName.value == "")
  {
    alert("Please enter an Agent Name.");
    theForm.sAgentName.focus();
    return (false);
  }
	if (theForm.sAgentId.value == "")
  {
    alert("Please enter an Agent ID.");
    theForm.sAgentId.focus();
    return (false);
  }
  }
     if (theForm.sMls.value == "")
  {
    alert("Please enter in a valid MLS number.");
    theForm.sMls.focus();
    return (false);
  }
   return (true);
}



function toggleCheck(sFormName, sFieldName, sControlName)
{
    var selectall = eval( 'document.' + sFormName + '.' + sControlName )
    var selectallvalue = selectall.checked
    var checkVal = eval( 'document.' + sFormName + '.' + sFieldName )

    if( selectallvalue == false )
    {
		for (i = 0; i < checkVal.length; i++)
		{
			checkVal[i].checked = false;
		}
    }
    else
    {
		for (i = 0; i < checkVal.length; i++)
		{
			checkVal[i].checked = true;
		}
    }
}


function hkOpener(hkCommand) {
		hkID = "child" + hkCommand;
		hkObject = document.getElementById(hkID);
		hkExID = "parent" + hkCommand;
		
		if(hkObject.style.display == "none") {
			hkObject.style.display = "block";
			document.thisInputForm.searchType.value = 'advance'
			document.getElementById("textButton").innerHTML = "Hide Advance Search"
		}
		else {
			hkObject.style.display = "none";
			document.thisInputForm.searchType.value = 'simple'
			document.getElementById("textButton").innerHTML = "Show Advance Search"
		}
	}



function checkLandings(theForm)
{
 if (theForm.title.value == "")
  {
    alert("Please enter either a Title");
    theForm.title.focus();
    return (false);
  }
 if (theForm.landingurl.value == "")
  {
    alert("Please enter either a Page Url");
    theForm.title.focus();
    return (false);
  }
  return (true);
}

function mlsSearch(theForm)
{
 if (theForm.ZP.value == "" && theForm.CNY.value == "" && theForm.LN.value == "")
  {
    alert("Please enter a value for either \"MLS Number\",  \"Zip Code\" or \"County\" before beginning your search.");
    theForm.LN.focus();
    return (false);
  }
selectOption = 0;
for (i=0; i < theForm.CIT.length; i++) {
if (theForm.CIT[i].selected) {
selectOption = selectOption + 1;
}
}
if (selectOption > 20) {
alert("We are sorry but you may only select 20 options.  You have selected " + selectOption);
return false;
}

if (!hkNumOnly(theForm.LN.value)) {
		valid = 0
		alert("Please Enter in Numbers Only")
		theForm.LN.focus();
    	return (false);
	}

// search NWES
if (theForm.CNY.value == "Cook-Chicago")
{
if ((theForm.nsLow.value == '') && (theForm.nsHigh.value =='') && (theForm.ewLow.value == '') &&  (theForm.ewHigh.value == '')){

}else{

if ((theForm.nsLow.value != '') && (theForm.nsHigh.value !='') && (theForm.ewLow.value != '') &&  (theForm.ewHigh.value != '')){
}else{
	alert("All Quandrants must be filled")
		theForm.nsLow.focus();
    	return (false);
}
}
	if (!hkNumOnly(theForm.nsLow.value)) {
		valid = 0
		alert("Please Enter in Numbers Only")
		theForm.nsLow.focus();
    	return (false);
	}
	if (!hkNumOnly(theForm.nsHigh.value)) {
		valid = 0
		alert("Please Enter in Numbers Only")
		theForm.nsHigh.focus();
    	return (false);
	}
	if (!hkNumOnly(theForm.ewLow.value)) {
		valid = 0
		alert("Please Enter in Numbers Only")
		theForm.ewLow.focus();
    	return (false);
	}
	if (!hkNumOnly(theForm.ewHigh.value)) {
		valid = 0
		alert("Please Enter in Numbers Only")
		theForm.ewHigh.focus();
    	return (false);
	}
}
//

  return (true);
}

function checkFolder(theForm)
{
   if (theForm.folderName.value == "")
  {
    alert("Please enter a name for the folder you wish to add!");
    theForm.folderName.focus();
    return (false);
  }
	if (!hkFolder(theForm.folderName.value)) {
		valid = 0
		alert("You have some invalid charachters")
		theForm.folderName.focus();
    	return (false);
	}
   return (true);
}





function checkCalendar(theForm)
{
   if (theForm.dateRemind.value == "")
  {
    alert("Please enter a date");
    theForm.dateRemind.focus();
    return (false);
  }
       if (theForm.title.value == "")
  {
    alert("Please a value for the Subject");
    theForm.title.focus();
    return (false);
  }
 if (theForm.dateStart.value == "")
  {
    alert("Please enter a date");
    theForm.dateStart.focus();
    return (false);
  }
   if (theForm.dateEnd.value == "")
  {
    alert("Please enter a date");
    theForm.dateEnd.focus();
    return (false);
  }


  return (true);
}


function mlsSampleSearch(theForm)
{
 if (theForm.cityZip.value == "")
  {
    alert("Please enter either a City Name or a Zip Code.");
    theForm.cityZip.focus();
    return (false);
  }
  return (true);
}


function adminSearch(theForm)
{
 if (theForm.title.value == "")
  {
    alert("Please enter a value for the \"Title\" field.");
    theForm.title.focus();
    return (false);
  }
  return (true);
}

function editMember(theForm)
{

if (theForm.username.value == "")
  {
    alert("Please enter a value for the \"Email Address (username)\" field.");
    theForm.username.focus();
    return (false);
  }
	var ValidEmail=IsValidEmail (theForm.username.value);
	if ((ValidEmail==false) && (theForm.username.value != "")){
	alert("You have entered in a invalid email address");
	theForm.username.focus();
	return (false);
	}
if (!checkDate(theForm.contactDate, "no"))	{
	return false;
}
 if (theForm.type.value == "")
  {
    alert("Please enter a value for the \"Buyer/Seller\" field.");
    theForm.type.focus();
    return (false);
  }
	if (theForm.password.value == "")
  {
    alert("Please enter a value for the \"Password\" field.");
    theForm.password.focus();
    return (false);
  }
 if (theForm.firstName.value == "")
  {
    alert("Please enter a value for the \"First Name\" field.");
    theForm.firstName.focus();
    return (false);
  }
 
  return (true);
}
//

function myAccountCheck(theForm)
{

if (theForm.username.value == "")
  {
    alert("Please enter a value for the \"Email Address (username)\" field.");
    theForm.username.focus();
    return (false);
  }
	var ValidEmail=IsValidEmail (theForm.username.value);
	if ((ValidEmail==false) && (theForm.username.value != "")){
	alert("You have entered in a invalid email address");
	theForm.username.focus();
	return (false);
	}
 if (theForm.type.value == "")
  {
    alert("Please enter a value for the \"Buyer/Seller\" field.");
    theForm.type.focus();
    return (false);
  }
 if (theForm.firstName.value == "")
  {
    alert("Please enter a value for the \"First Name\" field.");
    theForm.firstName.focus();
    return (false);
  }

  return (true);
}
//
// Change password
function myPassword(theForm)
{

if (theForm.username.value == "")
  {
    alert("Please enter a value for the \"Username\" field.");
    theForm.username.focus();
    return (false);
  }
	var ValidEmail=IsValidEmail (theForm.username.value);
	if ((ValidEmail==false) && (theForm.username.value != "")){
	alert("You have entered in a invalid username (email address)");
	theForm.username.focus();
	return (false);
	}
	if (theForm.currentpassword.value == "")
  {
    alert("Please enter a value for the \"Current Password\" field.");
    theForm.currentpassword.focus();
    return (false);
  }
	if (theForm.password1.value == "")
  {
    alert("Please enter a value for the \"Password\" field.");
    theForm.password1.focus();
    return (false);
  }
   if (theForm.password2.value == "")
  {
    alert("Please enter a value for the \"Confirm Password\" field.");
    theForm.password2.focus();
    return (false);
  }
    if (theForm.password1.value != theForm.password2.value)
  {
    alert("Your passwords do not match.  Please re-confirm your password.");
    theForm.password2.focus();
    return (false);
  } 
  return (true);
}
//
// register script
function registerCheck(theForm)
{

if (theForm.username.value == "")
  {
    alert("Please enter a value for the \"Email Address (username)\" field.");
    theForm.username.focus();
    return (false);
  }
	var ValidEmail=IsValidEmail (theForm.username.value);
	if ((ValidEmail==false) && (theForm.username.value != "")){
	alert("You have entered in a invalid email address");
	theForm.username.focus();
	return (false);
	}
			
	if (theForm.password1.value == "")
  {
    alert("Please enter a value for the \"Password\" field.");
    theForm.password1.focus();
    return (false);
  }
   if (theForm.password2.value == "")
  {
    alert("Please enter a value for the \"Confirm Password\" field.");
    theForm.password2.focus();
    return (false);
  }
    if (theForm.password1.value != theForm.password2.value)
  {
    alert("Your passwords do not match.  Please re-confirm your password.");
    theForm.password2.focus();
    return (false);
  }
   if (theForm.type.value == "")
  {
    alert("Please enter a value for the \"Buyer/Seller\" field.");
    theForm.type.focus();
    return (false);
  }
       if (theForm.workingWith.value == "")
  {
    alert("Please enter a value for the \"Are you working with an agent?\" field.");
    theForm.workingWith.focus();
    return (false);
  }
     if (theForm.refered.value == "")
  {
    alert("Please enter a value for the \"How did you find our web site?\" field.");
    theForm.refered.focus();
    return (false);
  }
	if (theForm.firstName.value == "")
  {
    alert("Please enter a value for the \"First Name\" field.");
    theForm.firstName.focus();
    return (false);
  }
 if (theForm.termsOfUse.checked==false)
  {
    alert("You must agree to the Terms of Use before proceeding!");
    theForm.termsOfUse.focus();
    return (false);
  }
 
  return (true);
}
//

// Checks box before Delete
function deleteCheck(theForm)
{
if (theForm.deleteLock.checked == false)
  {
    alert("If you are sure you want to delete this item and all items associated with it.\nCheck the \"Delete Lock\" box and hit the delete button again.");
    return (false);
  }
  return (true);
}
//

// Checks to see if Email is formatted correctly
function IsValidEmail (strEmail){
		var bIsValid=true;
		var Space1=" ";
		var At1="@";
		var Dot1=".";
		var strTemp=new String(strEmail);
		if (strTemp.length < 5) 
				bIsValid = false;
		
		if (strTemp.indexOf(Space1)>0)
				bIsValid = false;
		
		if (strTemp.indexOf(At1)<2)
				bIsValid = false;
		
		if (strTemp.lastIndexOf(Dot1) < strTemp.indexOf(At1, 1) + 1)
				bIsValid = false;
		return bIsValid; 
}
//
// Checks to see if Date is formatted correctly
function checkdate(theDate)
{
var valid = 1
value = theDate
	var dateregex=/^[ ]*[0]?(\d{1,2})\/(\d{1,2})\/(\d{4,})[ ]*$/;
		var match=value.match(dateregex);
			if (match) 
				{
				var tmpdate=new Date(match[3],parseInt(match[1])-1,match[2]);
				if (tmpdate.getDate()==parseInt(match[2]) && tmpdate.getFullYear()==parseInt(match[3]) && (tmpdate.getMonth()+1)==parseInt(match[1]))
				{ 
			return valid
			}
		}
	}
//
// Contact Form Validation
function contactCheck(theForm)
{
 if (theForm.name.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.name.focus();
    return (false);
  }
 	if (theForm.email.value == "")
  	{
    alert("Please enter a value for the \"Email\" field.");
    theForm.email.focus();
    return (false);
  	}
	var ValidEmail=IsValidEmail (theForm.email.value);
	if ((ValidEmail==false) && (theForm.email.value != "")){
	alert("You have entered in a invalid email address");
	theForm.email.focus();
	return (false);
	}
  if (theForm.reason.value == "")
  {
    alert("Please enter a value for the \"Why are you contacting Endeavor Realty?\" field.");
    theForm.reason.focus();
    return (false);
  }
  return (true);
}
//

// Numbers Only
function hkNumOnly(TheNumber) {
var valid = 1
var hkGoodNumbers = "0123456789.,"
var i = 0
if (TheNumber=="") {
valid = 1
	}
for (i =0; i <= TheNumber.length -1; i++) {
if (hkGoodNumbers.indexOf(TheNumber.charAt(i)) == -1) {
valid = 0
}
	}
return valid
}
////

// Numbers Only
function hkFolder(TheNumber) {
var valid = 1
var hkGoodNumbers = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_- "
var i = 0
if (TheNumber=="") {
valid = 1
	}
for (i =0; i <= TheNumber.length -1; i++) {
if (hkGoodNumbers.indexOf(TheNumber.charAt(i)) == -1) {
valid = 0
}
	}
return valid
}
////


// Open New Window
function hurriKane(winurl,winname,winfeatures)
{
	hK = window.open(winurl,winname,winfeatures);
 	setTimeout('hK.focus();',250);
}
//

// Mortgage Calculator
var isIE4 = false;
	var cache;
	
	if(navigator.appName.indexOf("Microsoft") != -1  &&  parseInt(navigator.appVersion) >= 4)
	 isIE4 = true;
	
	function ReadDollarDecision(whichVal) {
		dwnPayFld 	= document.frmCalc.downpay;
		price 	= document.frmCalc.price;
	
		if(whichVal < ReadDollarField(dwnPayFld)) { 
			dwnPayFld.value = price.value; 
		}
	}
	
	function CheckFloatField(field) {
	   var val = field.value;
	
	   // lop off trailing "0"s after a decimal point first
	   if(val.indexOf(".") != -1) {
	      while(val.charAt(val.length-1) == "0")
	         val = val.substring(0,val.length-1);
	      if(val.charAt(val.length-1) == ".")
	         val = val.substring(0,val.length-1);
	   }
	
	   if("" + parseFloat(val) != val)
	      field.value = field.defaultValue;
	}
	
	
	function CheckIntField(field) {
	   var val = field.value;
	   if("" + parseInt(val) != val)
	      field.value = field.defaultValue;
	}
	
	
	function CheckDollarField(field) {
	   var flt = ReadDollarField(field);
	   if(isNaN(flt))
	      field.value = cache;
	   else {
	      str = FloatToDollarString(flt);
	      field.value = str;
	   }
	}
	
	
	function ReadDollarField(field) {
	   var str = field.value;
	   if(str.charAt(0) == "$")
	      str = str.substring(1, str.length);
	
	   var pos = str.lastIndexOf(",");
	   while(pos != -1) {
	      str = str.substring(0,pos) + str.substring(pos+1, str.length);
	      pos = str.lastIndexOf(",", pos);
	   }
	
	   return parseFloat(str);
	}
	
	
	function FloatToDollarString(flt) {
	   // round off to nearest dollar
	   var str = "" + Math.round(flt)
	
	   // add commas
	   pos = str.length;  // str.indexOf(".");
	   pos -= 4;
	   while(pos >= 0) {
	      str = str.substring(0,pos+1) + "," + str.substring(pos+1, str.length);
	      pos -= 3;
	   }
	
	   return str;
	}
	
	
	function recalcTermMonths(frm) {
	   var tYr = parseFloat(frm.termYears.value);
	   var tMon = Math.round(tYr * 12.0);
	   tYr = parseFloat(tMon) / 12.0;
	   frm.termYears.value = "" + tYr;
	   frm.termMonths.value = "" + tMon;
	}
	
	
	function recalcTermYears(frm) {
	   var tMon = parseInt(frm.termMonths.value);
	   var tYr = parseFloat(tMon) / 12.0;
	   frm.termYears.value = "" + tYr;
	   frm.termMonths.value = "" + tMon;
	}
	
	
	function RecalcMonthlyPay(frm) {
	   var Principle  = ReadDollarField(frm.price) - ReadDollarField(frm.downpay);
	   var AnnualInt  = parseFloat(frm.intYear.value);
	   var MonthlyInt = AnnualInt / (12.0 * 100.0);
	   var LenMonths  = parseInt(frm.termMonths.value);
	
	   if(MonthlyInt == 0)
	      var MonthlyPay = Principle / LenMonths;
	   else
	      var MonthlyPay = Principle * ( MonthlyInt / ( 1 - Math.pow((1 + MonthlyInt), -LenMonths) ) );
	   MonthlyPay = Math.round(MonthlyPay * 100) / 100;
	
	   frm.payMonth.value = FloatToDollarString(MonthlyPay);
	}
	
	
	function RecalcDownPay(frm) {
	   var AnnualInt  = parseFloat(frm.intYear.value);
	   var MonthlyInt = AnnualInt / (12.0 * 100.0);
	   var LenMonths  = parseInt(frm.termMonths.value);
	   var MonthlyPay = ReadDollarField(frm.payMonth);
	   var Principle  = ReadDollarField(frm.price) - ReadDollarField(frm.downpay);
	   var OldDownPay = ReadDollarField(frm.downpay);
	   var EffPrinciple
	
	   if(MonthlyInt == 0)
	      EffPrinciple = MonthlyPay * LenMonths;
	   else
	      EffPrinciple = MonthlyPay * ((1 - Math.pow((1 + MonthlyInt), -LenMonths)) / MonthlyInt);
	
	   var NewDownPay = OldDownPay + (Principle - EffPrinciple);
	   frm.downpay.value = "" + NewDownPay;
	   CheckDollarField(frm.downpay);
	
	   RecalcDownPayPerc(frm);
	   RecalcMonthlyPay(frm);
	}
	
	
	function RecalcDownPayPerc(frm) {
	   var HomePrice  = ReadDollarField(frm.price);
	   var DownPay = ReadDollarField(frm.downpay);
	   var DownPayPerc = 100 * DownPay / HomePrice;
	
	   if(DownPayPerc >= 0  &&  DownPayPerc <= 100) {
	      var DownPayPercStr = "" + DownPayPerc;
	
	      var pos = DownPayPercStr.indexOf(".");
	      if(DownPayPercStr.length > pos + 4)
	         DownPayPercStr = DownPayPercStr.substring(0,pos+4);
	
	      frm.downpayperc.value = DownPayPercStr;
	   }
	   else if(DownPayPerc < 0) {
	      frm.downpayperc.value = "0";
	      RecalcDownPayAmount(frm);
	   }
	   else {
	      frm.downpayperc.value = "100";
	      RecalcDownPayAmount(frm);
	   }
	}
	
	
	function RecalcDownPayAmount(frm) {
	   var HomePrice  = ReadDollarField(frm.price);
	   var DownPayPerc = parseFloat(frm.downpayperc.value);
	   if(DownPayPerc < 0) {
	      frm.downpayperc.value = "0";
	      RecalcDownPayAmount(frm)
	   }
	   else if(DownPayPerc > 100) {
	      frm.downpayperc.value = "100";
	      RecalcDownPayAmount(frm)
	   }
	   else {
	      var DownPay = HomePrice * DownPayPerc / 100;
	      DownPay = FloatToDollarString(DownPay);
	      frm.downpay.value = "" + DownPay;
	   }
	}
function clearFields(form) {
  var formNum = form.elements.length // Number of form elements

  for (i = 0; i < formNum; i++) {
    var shortForm = form.elements[i] // Shortcut Reference for Form Elements
    if (shortForm.type == "text"){
      shortForm.value = "";
    } else if (shortForm.name == "CNY"){
    } else if (shortForm.type == "checkbox"){
      shortForm.checked = false;
    } else if (shortForm.type == "radio"){
      shortForm.checked = false;
    } else if (shortForm.type == "textarea"){ // Only Clears Textareas in MSIE
      shortForm.value = "";
    } else if (shortForm.type == "hidden"){
    } else if (shortForm.type == "password"){
    } else if (shortForm.type == "image"){
    } else if (shortForm.type == "button"){
    } else if (shortForm.type == "reset"){
    } else if (shortForm.type == "submit"){
    } else{
      shortForm.selectedIndex = false;
      shortForm.options[0].selected = true;
    }
  }
}	
function printThisPage() {
  if (confirm("Ok To Print Page?") == true )  {
  window.print();
  history.back(1);
}
}
function clearText(query){
if (query.defaultValue==query.value)
query.value = ""
}



/*************************************************************************
  dw_banners.js   version date: Feb 2004

  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  Copyright 2001-4 by Sharon Paine 
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

bannerObjects = {};
function bannerObj(id, delay, bMouse) {
  this.id = id; this.delay = delay; this.items = []; this.timer = null;
  bannerObjects[this.id] = this;
  this.animString = "bannerObjects." + this.id;
  if (bMouse) { // set up pause/resume onmouseover/out
    var el = document.getElementById(this.id);
    if (el) {
      el.onmouseover = bannerObj.clearTimer;
      el.onmouseout = bannerObj.restartTimer;
    }
  }
}

bannerObj.prototype.ctr = 0;
bannerObj.prototype.addItem = function(sHtml) {
 	this.items[this.items.length] = sHtml;
}

bannerObj.prototype.rotate = function() {
  var el = document.getElementById(this.id);
  if ( el && typeof el.innerHTML != "undefined" ) {
    el.innerHTML = this.items[this.ctr];
    if (this.ctr < this.items.length-1) this.ctr++;
    else this.ctr = 0;
    this.timer = setTimeout(this.animString + ".rotate()", this.delay);
  }
}

// these 2 functions called onmouseover/out of banner el
bannerObj.clearTimer = function() { clearTimeout(bannerObjects[this.id].timer); }
 
bannerObj.restartTimer = function(e) {
  e = e? e: window.event;
  var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
  if ( this != toEl && !contained(toEl, this) ) {
    var animStr = bannerObjects[this.id].animString;
    bannerObjects[this.id].timer = setTimeout(animStr + ".rotate()",500);
  }
}  

// returns true of oNode is contained by oCont (container)
function contained(oNode, oCont) {
  if (!oNode) return; // in case alt-tab away while hovering (prevent error)
  while ( oNode = oNode.parentNode ) if ( oNode == oCont ) return true;
  return false;
}

// adapted from act_api.js by Dan Pupius of www.13thparallel.org
var imageHandler = {
  imgs: [],
  path: "",
  preload: function() {
    var i, img;
    for (i=0; arguments[i]; i++) {
      img = new Image();
      img.src = this.path + arguments[i];
      this.imgs[this.imgs.length] = img;
    }
  }
}


	// 
	// These functions check to see if the text field 
	// contains a valid date
	// If not, they display an error message,
	// focus the control and return false.
	// 
	// Declaring valid date character, minimum year and maximum year
	var dtCh= "/";
	var minYear=1900;
	var maxYear=2100;

	function isInteger(s){
		var i;
    	for (i = 0; i < s.length; i++){   
        	// Check that current character is number.
        	var c = s.charAt(i);
        	if (((c < "0") || (c > "9"))) return false;
    	}
    	// All characters are numbers.
    	return true;
	}

	function stripCharsInBag(s, bag){
		var i;
    	var returnString = "";
    	// Search through string's characters one by one.
    	// If character is not in bag, append to returnString.
    	for (i = 0; i < s.length; i++){   
     	   var c = s.charAt(i);
     	   if (bag.indexOf(c) == -1) returnString += c;
    	}
    	return returnString;
	}

	function daysInFebruary (year){
		// February has 29 days in any year evenly divisible by four,
  	  // EXCEPT for centurial years which are not also divisible by 400.
	    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
	}
	
	function DaysArray(n) {
		for (var i = 1; i <= n; i++) {
			this[i] = 31
			if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
			if (i==2) {this[i] = 29}
   		} 
   		return this
	}

	function checkDate(obj,req){
	
	if (req == "yes" || obj.value != "") {
		sDateString = obj.value
		var daysInMonth = DaysArray(12)
		var pos1=sDateString.indexOf(dtCh)
		var pos2=sDateString.indexOf(dtCh,pos1+1)
		/// Use This for the States
		var strMonth=sDateString.substring(0,pos1)
		var strDay=sDateString.substring(pos1+1,pos2)
		/// Use This for Europe
		//var strMonth=sDateString.substring(pos1+1,pos2)
		//var strDay=sDateString.substring(0,pos1)
		
		var strYear=sDateString.substring(pos2+1)
		strYr=strYear
		if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
		if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
		for (var i = 1; i <= 3; i++) {
			if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
		}
		month=parseInt(strMonth)
		day=parseInt(strDay)
		year=parseInt(strYr)
		if (pos1==-1 || pos2==-1){
			alert("The date format should be : dd/mm/yyyy")
			obj.focus()
			return false
		}
		if (strMonth.length<1 || month<1 || month>12){
			alert("Please enter a valid month")
			obj.focus()
			return false
		}
		if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
			alert("Please enter a valid day")
			obj.focus()
			return false
		}
		if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
			alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
			obj.focus()
			return false
		}
		if (sDateString.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(sDateString, dtCh))==false){
			alert("Please enter a valid date")
			obj.focus()
			return false
		}
		}
	return true
	}
	
	function isWhite(ch) {
		if (ch==' ' || ch=='	' || ch=="\n" || ch=="\r") return true;
		return false;
	};


function remove_XS_whitespace(obj)
{
  var tmpStr = "";
  var obj_length = obj.value.length;
  var obj_length_minus_1 = obj.value.length - 1;
  for (i = 0; i < obj_length; i++)
  {
    if (obj.value.charAt(i) != ' ')
    {
      tmpStr += obj.value.charAt(i);
    }
    else
    {
      if (tmpStr.length > 0)
      {
        if (obj.value.charAt(i+1) != ' ' && i != obj_length_minus_1)
        {
          tmpStr += obj.value.charAt(i);
        }
      }
    }
  }
  obj.value = tmpStr;
};

