//Detects browser type 
function makeObject(){
    var x; 
    var browser = navigator.appName; 
    if(browser == "Microsoft Internet Explorer"){
        x = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else{
        x = new XMLHttpRequest();
    }
    return x;
}
function isNumeric(str) 
{
 var checkOK = "0123456789";
 var checkStr = str;
 var allValid = true;
	for (index = 0;  index < checkStr.length;  index++)
	{
		ch = checkStr.charAt(index);
		for (sub_index = 0;  sub_index  < checkOK.length;  sub_index ++)
		if (ch == checkOK.charAt(sub_index )) {
			break;
		}
		if (sub_index  == checkOK.length){
	 		allValid = false;
			break;
		}
	}
 return allValid;	
}


function isAlphaNumeric(str) 
{
 var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
 var checkStr = str;
 var allValid = true;
	for (index = 0;  index < checkStr.length;  index++)
	{
		ch = checkStr.charAt(index);
		for (sub_index = 0;  sub_index  < checkOK.length;  sub_index ++)
		if (ch == checkOK.charAt(sub_index )) {
			break;
		}
		if (sub_index  == checkOK.length){
	 		allValid = false;
			break;
		}
	}
 return allValid;	
}

function isAlphabet(str) 
{
 var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
 var checkStr = str;
 var allValid = true;
	for (index = 0;  index < checkStr.length;  index++)
	{
		ch = checkStr.charAt(index);
		for (sub_index = 0;  sub_index  < checkOK.length;  sub_index ++)
		if (ch == checkOK.charAt(sub_index )) {
			break;
		}
		if (sub_index  == checkOK.length){
	 		allValid = false;
			break;
		}
	}
 return allValid;	
}

function isValidString(str) 
{
 var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";
 var checkStr = str;
 var allValid = true;
	for (index = 0;  index < checkStr.length;  index++)
	{
		ch = checkStr.charAt(index);
		for (sub_index = 0;  sub_index  < checkOK.length;  sub_index ++)
		if (ch == checkOK.charAt(sub_index )) {
			break;
		}
		if (sub_index  == checkOK.length){
	 		allValid = false;
			break;
		}
	}
 return allValid;	
}


function isValidEmail(emailStr)
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(emailStr)){
		return (true)
	}
	return (false)
}
function trim(sString) {
  while (sString.substring(0,1) == ' '){
        sString = sString.substring(1, sString.length);
   }
   while (sString.substring(sString.length-1, sString.length) == ' '){
        sString = sString.substring(0,sString.length-1);
   }
return sString;
}