// Validate the first step of the new product creation process
function validateProductInfo() 
{
//    alert('hi');
	var msg = "Please fill in the following fields:\n";
	var blnAlert = false;
	var objTmp = null;
	var strLabel = new String();
	var label = "";
	
//	alert("value"+LTrim(document.getElementById("name").value));
	
	if (trim(document.getElementById("name").value) == "") 
	{
 
		blnAlert = true;
		msg += "\n  - Product name";
	}
	if (trim(document.getElementById("version").value) == "")
	 {
		blnAlert = true;
		msg += "\n  - Product version";
	}
	if (trim(document.getElementById("detail1").value) == "") 
	{
		blnAlert = true;
		msg += "\n  - Product description";
	}
	if (objTmp = document.getElementById("detail2"))
	 {
		if (trim(objTmp.value) == "") 
		{
			blnAlert = true;
			strLabel = trim(document.getElementById("detail2label").firstChild.nodeValue);
			label = strLabel.substr(0, strLabel.length-1);
			msg += "\n  - " + label;
		}
	}
	if (objTmp = document.getElementById("detail3"))
	 {
		if (trim(objTmp.value) == "") 
		{
			blnAlert = true;
			strLabel = trim(document.getElementById("detail3label").firstChild.nodeValue);
			label = strLabel.substr(0, strLabel.length-1);
			msg += "\n  - " + label;
		}
	}
	if (objTmp = document.getElementById("detail4"))
	 {
		if (trim(objTmp.value) == "") 
		{
			blnAlert = true;
			strLabel = trim(document.getElementById("detail4label").firstChild.nodeValue);
			label = strLabel.substr(0, strLabel.length-1);
			msg += "\n  - " + label;
		}
	}
	if (objTmp = document.getElementById("detail5"))
	 {
		if (trim(objTmp.value) == "") 
		{
			blnAlert = true;
			strLabel = trim(document.getElementById("detail5label").firstChild.nodeValue);
			label = strLabel.substr(0, strLabel.length-1);
			msg += "\n  - " + label;
		}
	}
	if (blnAlert)
	 {
		window.alert(msg);
		return false;
	} 
	else 
	{	
		return true;
	}
	
   }
   
    function LTrim( value )
	   {
        
        var re = /\s*((\S+\s*)*)/;
        return value.replace(re, "$1");
 
       }
 
     // Removes ending whitespaces
     function RTrim( value ) 
     {
     var re = /((\s*\S+)*)\s*/;
     return value.replace(re, "$1");
 
      }
 
     // Removes leading and ending whitespaces
     function trim( value ) 
     {
       return LTrim(RTrim(value));
 
     } 
// inkoo added 20060515 to limit max characters in textarea
function textareaCheck(textareaId, textareaCounterId, maxlimit) {
    var textareaObj = document.getElementById(textareaId);
    if (textareaObj && textareaObj.type == 'textarea') {
        if (textareaObj.value.length > maxlimit) {
            textareaObj.value = textareaObj.value.substring(0, maxlimit);
        } else {
            var textareaCounterObj = document.getElementById(textareaCounterId);
            textareaCounterObj.innerHTML = maxlimit - textareaObj.value.length;
        }
    }
}
