/*
Written by Nicholas P Lawrence, <nicl@perlguy.org.uk>.
Copyright (C) 2003 Nicholas P Lawrence.

This program is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later
version.

This program is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more
details.

You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/

function selectViewEditListing(authorised, edit_button) {
  if (authorised == 1) {
    edit_button.style.color  = '#999999';
    edit_button.style.border = 'solid 1px #999999';
  } else {
    edit_button.style.color  = '#000000';
    edit_button.style.border = 'solid 1px #000000';
  }
}

function viewGuide() {
  document.viewedit.action = 'viewlisting.html';
  document.viewedit.submit();
}

function GuideAdminWindow(url,width,height) { GuideAdminWin=window.open(url,"GuideAdminWindow","resizable=no,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,copyhistory=0,width="+width+",height="+height);
        GuideAdminWin.location = url;
	GuideAdminWin.focus();
}

function HelpWindow(url,width,height) { HelpWin=window.open(url,"GuideHelpWindow","resizable=no,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,copyhistory=0,width="+width+",height="+height);
        HelpWin.location = url;
	HelpWin.focus();
}

//      function isEmail(string) {
//        if (!string) return false;
//          var iChars = "*|,\"<:>[]{}`\';()&$#%";
//          for (var i = 0; i < string.length; i++) {
//            if (iChars.indexOf(string.charAt(i)) != -1)
//              return false;
//          }
//          return true;
//      }
//      function isProper(string) {
//        if (!string) return false;
//          var iChars = "*|,\"<:>[]{}`\';()@&$#%";
//          for (var i = 0; i < string.length; i++) {
//            if (iChars.indexOf(string.charAt(i)) != -1)
//              return false;
//          }
//          return true;
//      }

function isEmail(string) {
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) {
		return true;
	} else {
		return false;
	}
}

function isProper(string) {
	if (string.search(/^\w+( \w+)?$/) != -1) {
		return true;
	} else {
		return false;
	}
}

function isInteger(sText) {
	var ValidChars = "0123456789";
	var isInteger = true;
	var Char;
	for (i = 0; i < sText.length && isInteger == true; i++)  { 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) {
			isInteger = false;
		}
	}
	return isInteger;
}



