function GetElementById(ename){
	var obj;

	if (document.all)
	{
	eval("obj = document.all[\"" + ename + "\"]");
	}
	else if (document.layers)
	{		
		eval("obj = document.layers[\"" + ename + "\"]");
	}
	else if (document.getElementById)
	{	
		eval ("obj = document.getElementById (\"" + ename + "\")");		
	}
	else	
		obj =  undefined;

	return obj;
}

function showHideTab(idTab){
	var obj = GetElementById(idTab);
	
	if (obj){
		if (obj.style.display == ""){
			obj.style.display = "none";
		}
		else if (obj.style.display == "none"){
			obj.style.display = "";
		}
	}
}

function formCheck(formobj,fieldRequired,fieldDescription,alertMsg){
	var l_Msg = alertMsg.length;
    for (var i = 0; i < fieldRequired.length; i++){
        var obj = formobj.elements[fieldRequired[i]];
        if (obj){
            if (obj.type == null){
                var blnchecked = false;
                for (var j = 0; j < obj.length; j++){
                    if (obj[j].checked){
                        blnchecked = true;
                    }
                }
                if (!blnchecked){
                    alertMsg += " - " + fieldDescription[i] + "\n";
                }
                continue;
            }

            switch(obj.type){
	            case "select-one":
	                if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].value == ""){
	                    alertMsg += " - " + fieldDescription[i] + "\n";
	                }
	                break;
	            case "select-multiple":
	                if (obj.selectedIndex == -1){
	                    alertMsg += " - " + fieldDescription[i] + "\n";
	                }
	                break;
	            case "text":
	            case "password":
	            case "textarea":
	                if (obj.value == "" || obj.value == null){
	                    alertMsg += " - " + fieldDescription[i] + "\n";
	                }
	                break;
	            default:
            }
        }
    }

    if (alertMsg.length == l_Msg){
        return true;
    }else{
        alert(alertMsg);
        return false;
    }
}

function showTab(id){
	var obj = GetElementById(id);
	if (obj) {
		obj.style.display = "";
	}
}

function hideTab(id){
	var obj = GetElementById(id);
	if (obj) {
		obj.style.display = "none";
	}
}


function makeQueryStringFromArray(objArray){
	var str = "";
	var obj = null;
		
	for (i=0; i<objArray.length; i++){
		obj = GetElementById(objArray[i]);
		if (obj){
			str += obj.id + '=' + encodeURIComponent(obj.value) + '&';
		}
	}
	return str;
}

function goToPage(pageURL){
	document.location.href = pageURL;
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}

String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

