function isNum (str) 
{
	var ret = 0;
	var i, ch;
	for (i = 0; i < str.length; ++i) 
	{
		ch = str.charAt(i);
		if (ch < "0" || ch > "9")
			ret = 1;
	}
	return ret;
}

/**********************************************************
/ is_email : check if the string passed has an email format
/ args : email - the email string
/ Noam E. - 09/12/2004
/*********************************************************/
function is_email(email)
{
	var reg = /^[a-z0-9\._-]+@(:?[a-z0-9][a-z0-9-]+\.){1,6}[a-z]{2,6}$/i
	return ((reg.exec(email)!=null))
}

/**********************************************************
	/ is_url : check if the string passed has an url format
	/ args : url - the email string
	/ Noam E. - 09/12/2004
	/*********************************************************/
function is_url(url)
{
	var reg_http= /^http:\/\/[\w.]+\.\w{1,4}/
	var reg2 = /[.]{2,}/
	
	return ( (reg_http.exec(url)!=null) && (reg2.exec(url)==null) )
}

/**
function is_a_space(value)
@description - check if the given value is a space only 
@author Yuval Dayan
@param value - the value to check
@return true or false
**/
function is_a_space(value)
{
	var ret = false;

	value = value.replace(/ /g,'');
	if(value.length == 0)
	{
		ret = true;
	}
	return ret;
}

/**
function loadXMLDoc(url,func,async)
@description - load an xml document using httprequest 
@author Yuval Dayan
@param url - the url , func - the callback function,async - if it will be async or sync
@return true or false
**/
var gl_xmlhttp;
function loadXMLDoc(url,func,async)
{
	var ret = true;
// code for Mozilla, etc.
	try
	{
		if(window.XMLHttpRequest)
	  {
		  gl_xmlhttp=new XMLHttpRequest();
		  gl_xmlhttp.onload = func ;
		  gl_xmlhttp.open("GET",url,async);
		  gl_xmlhttp.send(null);
	  }
		else // code for IE
	  {
	  	if (window.ActiveXObject)
	  	{
		  	gl_xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		    if (gl_xmlhttp)
		    { 
			    gl_xmlhttp.onreadystatechange=func;
			    gl_xmlhttp.open("GET",url,async);
			    gl_xmlhttp.send();
		    }
		   }
	  }
	}
	catch(ex){ret = false;}

	return ret;
}

/**
function is_a_compad_id(compad_id)
@description - check if the compad id is valid (3-16 characters with only numbers or english letter)
@author Yuval Dayan
@param url - compad_id - the comapd id
@return true or false
**/
function is_a_compad_id(compad_id)
{
	var ret = false;
	
	//check that it is has numbers or english letters only
	var req_exp= /^([a-zA-Z]){1}([0-9a-zA-Z]){2,15}$/;
	if(req_exp.exec(compad_id)!=null)
	{
		ret = true;
	}

	return ret;
}

//this was taken from David frankel XMLUTILS lib
function makeDocument(async) 
{
	if(undefined == async)
		async = false;
	var doc = null;
	
	var t = typeof(ActiveXObject);
	if (t != 'undefined') 
	{
		var ids = [ 'msxml2.DOMDocument.5.0', 'msxml2.DOMDocument.4.0', 
								'msxml2.DOMDocument', 'Msxml.DOMDocument', 'Microsoft.DOMDocument' 
							];
		var len = ids.length;
		var id;
		for (var i = 0; (i < len) && ! doc; i++) 
		{
			id = ids[i];
			try 
			{
				doc = new ActiveXObject(id);
			}
			catch (e) {}
		}
	}
	if (!doc) {
		try 
		{
			doc = document.implementation.createDocument("", "", null);
		}
		catch (er) {}
	}
	
	if (doc) 
	{
		doc.async = async;
		// Load an XML file into the DOM instance.
		// Display the content of the object.
	}
	return doc;
}

//this was taken from David frankel XMLUTILS lib
//attach an event to the object
function addEventListener(obj, evt, fnc, useCapture){
	if (arguments.length < 4) 
		useCapture=false;
	if (obj.addEventListener)
	{
		obj.addEventListener(evt, fnc, useCapture);
	} 
	else if (obj.attachEvent) 
	{
		obj.attachEvent("on"+evt,fnc);
	}
	return true;
}

