/* 
' +---------------------------------------------------+
' | eCommerce Gold -- ASI Computer Systems            |
' +---------------------------------------------------+
' | NOTICE:                                           |
' | EDITING CODE ON THIS PAGE IS STRICTLY PROHIBITED  |
' | UNLESS THIS PAGE IS SPECIFICALLY LISTED UNDER THE |
' | eBUILDER - CUSTOM USER PAGES SECTION.             |
' |                                                   |
' | IF THIS PAGE IS NOT LISTED UNDER THE CUSTOM PAGES |
' | SECTION, IT MAY BE OVERWRITTEN BY AN              |
' | ENHANCEMENT/FIX UPDATE.                           |
' |                                                   |
' | ASICS shall not be held responsible for any files |
' | overwritten in the event this notice is ignored.  |
' +---------------------------------------------------+
*/

/// POPS up a calendar -- USE ONLY WITH writeFormInputDate() ASPX function...
function popCalendar(formElements, dotdot) {
	// SET default_date...
	var default_date = document.frm.elements[formElements + "_month"].value + "/" + document.frm.elements[formElements + "_day"].value + "/" + document.frm.elements[formElements + "_year"].value;
	
	// POP and focus the window...
	var popWin = window.open(dotdot + "pop_calendar.aspx?formElements=" + formElements + "&defaultDate=" + default_date, "POPCAL", "width=100,height=100,resizable=no,scrollbars=no,menubar=no,status=no");
	popWin.focus();
}

function ChangeELStatus() {
	var fso = document.getElementById("el");
	var el_status = fso.style.display;
	
	if (el_status == "none") {
		fso.style.display = "inline";
	} else {
		fso.style.display = "none";
	}
}

// open new window
function openWindow(url, name, attrs) {
	popWin = window.open(url, name, attrs); 
	popWin.focus();
}


//function limit(what,chars,counter) {

//if (what.value.length > chars) {
//what.value=what.value.substr(0,chars);
//alert('The maximum number of characters that can be entered here is ' +chars+ '.' );
//}

//var myPostition = what.toString

//counting = (chars - what.value.length);
//c = document.getElementById(counter);
//c.innerHTML = counting;
//}

 var m_strLastValue="";
   
   function StoreLastValue(objTextArea)
   {
    m_strLastValue = objTextArea.value;
   }
   
   function ValidateTextArea(objTextArea, iMaxLines, iMaxCharsInLine, iMaxTotalChars)
   {
    //get all the text:
    var strAllText=objTextArea.value;
    
    //get lines:
    //var arrLines=strAllText.split("\r\n");
    var arrLines=strAllText.split(/\n/);
    
    //get amount of lines:
    var iLinesCount=(strAllText == "")?0:arrLines.length;
    
    //check if maximum lines count exceeded:
    if (iLinesCount > iMaxLines)
    {
 	  alert("Maximum of " + iMaxLines + " lines reached"  );
 	  objTextArea.value = m_strLastValue;
 	  return false;
    }
    
    if (objTextArea.value.length > iMaxTotalChars) {
		alert("Maximum of " + iMaxTotalChars + " characters reached");
		objTextArea.value = m_strLastValue;
		return false;
	}

    
    //check if maximum characters in line has been exceeded:
    for (var i=0; i<arrLines.length; i++)
    {
 	  if (arrLines[i].length > iMaxCharsInLine)
 	  {
 		 alert("Maximum of " + iMaxCharsInLine + " characters in line number "+(i+1)+" reached");
 		 objTextArea.value = m_strLastValue;
 		 return false;
 	  }
    }
    
    return true;
   }


