 function ValidEmail(EmailAddress)
 {
  if ((EmailAddress.indexOf(' ') >= 0) || (EmailAddress.indexOf(';') >= 0) || (EmailAddress.indexOf(',') >= 0) || (EmailAddress.indexOf('@') < 1)) return false;
  if (EmailAddress.substr(EmailAddress.indexOf('@')).indexOf('.') < 2) return false;
  if (EmailAddress.substr(EmailAddress.indexOf('.',EmailAddress.indexOf('@'))).length < 3) return false;
  return true 
 }  
function trim(s) {
	return s.replace(/^\s*(.*?)\s*$/, "$1");
}
function isFloat(s){
	var i;
    s = trim(s);
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if ((c != '.') && ((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
function isInteger(s){
	var i;
    s = trim(s);
    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 in_array(needle, haystack, strict) {    // Checks if a value exists in an array
    // 
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
 
    var found = false, key, strict = !!strict;
 
    for (key in haystack) {
        if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
            found = true;
            break;
        }
    }
 
    return found;
}
function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   myfield.form.submit();
   return false;
   }
else
   return true;
}

function functionenter(function_name,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;
if (keycode == 13)
   {
   eval(function_name);
   return false;
   }
else
   return true;
}

function ValidateCatField(val) {
	if (trim(val) == '') {
		return false;
	}
	return true;
}
function submitCatValue() {
	if (ValidateCatField(document.getElementById('cat_add_fld').value)) {
		xajax_ajaxCatAdd(document.getElementById('cat_add_fld').value);
		cClick();
	} else {
		alert('Please specify *Category*!');
	}
}
function ValidateTaglineField(val) {
	if (trim(val) == '') {
		return false;
	}
	return true;
}
function submitTaglineValue() {
	if (ValidateTaglineField(document.getElementById('tagline_add_fld').value)) {
		xajax_ajaxTaglineAdd(document.getElementById('tagline_add_fld').value);
		cClick();
	} else {
		alert('Please specify *Tag Line*!');
	}
}

	function detectBrowserClass(modern){
		var nBrowser = navigator.appName;
		var nVersion = navigator.appVersion;
		var nAgent = navigator.userAgent;
		this.version;
		this.browser;
		this.os;
		this.modern = (typeof modern == 'object') == true ? modern:0;
		if(nVersion.indexOf('Windows') !=-1){
		     this.os = 'win';
		}else{
		    this.os = (nVersion.indexOf('Macintosh') !=-1) == true ? 'mac':'other';
		}
		if (nAgent.indexOf('Opera') !=-1){
		    var strIndex = nAgent.indexOf('Opera');
		    this.version = nAgent.substring((strIndex + 6), (strIndex + 9));
		    this.browser = 'opera';
		}
		else if (nAgent.indexOf('Firefox') !=-1){
		    var strIndex = nAgent.indexOf('Firefox');
		    this.version = nAgent.substring((strIndex + 8), (strIndex + 11));
		    this.browser = 'firefox';
		}
		else if(nAgent.indexOf('MSIE') !=-1){
		    var strIndex = nAgent.indexOf('MSIE');
		    this.version = nAgent.substring((strIndex + 5), (strIndex + 8));
		    this.browser = 'ie';
		}
		else if (nAgent.indexOf('Safari') !=-1){
		     if (nAgent.indexOf('Version') !=-1){
		          var strIndex = nAgent.indexOf('Version')
		          this.version = nAgent.substring((strIndex + 8), (strIndex + 11))
		     }else{
		          this.version = 2;
		     }
		this.browser = 'safari';
		}
		else if (nAgent.indexOf('Netscape') !=-1){
		     var strIndex = nAgent.indexOf('Netscape');
		     this.version = nAgent.substring((strIndex + 9), (strIndex + 12));
		     this.browser = 'netscape';
		}else{
		     this.browser = nBrowser.toLowerCase();
		     this.version = null;
		}
		this.whichBrowser = function (){ return this.browser; }
		this.whichVersion = function (){ return this.version; }
		this.whichOS = function (){	return this.os; }
		this.getInfo = function (){
		     var info = "Browser name: " + nBrowser + "<br />" +
		     "Browser version: "+ nVersion + "<br />" +
		     "User Agent: " + nAgent;
		      return info;
		}
		this.modernBrowser = function (){
		     var isModern = false;
		     if(typeof(this.modern[this.browser])=='number' || this.version === null){
		     isModern = ( this.modern[this.browser] <= this.version || this.version === null ) == true ? true :0;
		}
		return isModern;
		}
	}
