/**
 * @fileoverview
 * API functions
 * @version $Revision: 58410 $ 
 * Copyright (C) 2004-2008 United Planet GmbH, Freiburg
*/

/**
* Creates an JavaScript date object from a html control.
* <p>
* Example usage:
* <p>
* <code>HelperMainGetDateObject(getElement("A84E5E7F9EA9ED1A829DB98DBF5459F59961FA3B"));</code>
* @param {object} oHtml Reference to a html input control of types "date", "time" or "date & time".
* @return JavaScript date object.
*/  
function getDateObject(oHtml){ return Helper.getDateObject(oHtml); }

/**
* Creates an JavaScript number object from a html control.
* <p>
* Example usage:
* <p>
* <code>getNumberObject(getElement("5F7S5E7F9EA9ED1A829DB98DBF5459F59961FA3B"));</code>
* @param {object} oHtml Reference to a html input control of types "integer", "float" or "currency".
* @return {object} JavaScript number object.
*/  
function getNumberObject(oHtml){ return Helper.getNumberObject(oHtml);}

/**
* Parses a local formatted string.
* (for example 3.215,20 -> 3215.20)
* <p>
* Example usage:
* <p>
* <code>getIntegerStringByLocal("1.234");</code>
* @param {string} strValue Local formatted string.
* @return {string} Integer or float formatted string.
*/    
function getIntegerStringByLocal(strValue){ return Helper.getIntegerStringByLocal(strValue); }
function getFloatStringByLocal(strValue){ return Helper.getFloatStringByLocal(strValue); }
function getCurrencyStringByLocal(strValue){ return Helper.getCurrencyStringByLocal(strValue); }

/**
 * Parses a local formatted string.
 * (for example 3.215,20 -> 3215.20)
* <p>
* Example usage:
* <p>
* <code>getIntegerByLocalString("1.234");</code>
* @param {string} strValue Local formatted string.
* @return Integer or float. 
*/    
function getIntegerByLocalString(strValue){ return Helper.getIntegerByLocalString(strValue); }
function getFloatByLocalString(strValue){ return Helper.getFloatByLocalString(strValue); }
function getCurrencyByLocalString(strValue){ return Helper.getCurrencyByLocalString(strValue); }

/**
 * Creates a local formatted string from an number string or jsDate.
 * <p>
 * Example usage:
 * <p>
 * <code>toLocalString(getElement("DDB279D4974A17DB27A89F58DB36F7BF4E10DA13"),"123.45");</code>
 * @param oHtml Reference to a html input control of types "integer", "float", "currency" (format settings can be appended here, too).
 * @param Value Number string or JavaScript date object.
 * @return {String} Local formatted number as string 
 */    
function toLocalString(oHtml, Value){ return Helper.toLocalString(oHtml, Value); }

/**
 * Creates a local formatted string from an date object or number object 
 * and writes it as value into a html control.
 * <p>
 * Example usage:
 * <p>
 * <code>writeLocalString(getElement("DDB279D4974A17DB27A89F58DB36F7BF4E10DA13"),new Date());</code>
 * @param oHtml Reference to a html input control of types "date", "time", "date & time",
 * 				"integer", "float", "currency" (format settings can be appended here, too).
 * @param Value Value to localize.
 * @return <code>True</code> or <code>false</code>.  
 */    
function writeLocalString(oHtml, value){ return Helper.writeLocalString(oHtml, value); }

/**
 * Checks a html control, as if "entry required" has been set OR checks all controls of a form, where "entry required" was set.
 * <p>
 * Example usage:
 * <p>
 * <code>checkRequired(getElement("E94A9FBDADD46039BB62F76870E1EC57C226C6DC"), "An alternative text!");</code>
 * @param oHtml Reference to a html input control or to a form control ("FormGroup")
 * @param strMessage (OPTIONAL) Text to show, if checkRequired returns <code>false</code>. If not set, value of FORM_CONSTR_REQUIRED
 * 					 from "preset texts" will be displayed.  
 * @return <code>True</code> or <code>false</code>.
 */
function checkRequired(oHtml, strMessage){ return Helper.checkRequired(oHtml, strMessage); }

/**
 * Calculates the difference of values from two html controls of type "date & time" and returns it as string
 * formatted as "2 days 3 minutes"
 * <p>
 * Example usage:
 * <p>
 * <code>getLocalDurationString(getElement("4E48F310711C446B4B04752A6B3239900D49F3A0"),getElement("E13A41C114E8754574DEA9767F505DDE3491C89A"));</code>
 * @param oHtmlDateFrom Reference to a html control of type "date & time"
 * @param oHtmlDateTo Reference to a html control of type "date & time"
 * @return {string} string formatted as "2 days 3 minutes".
 */   
function getLocalDurationString(oHtmlDateFrom, oHtmlDateTo){ return Helper.getLocalDurationString(oHtmlDateFrom, oHtmlDateTo); }

/**
 * Calculates a result of values from two html controls with an operator an writes it in html control.
 * <p>
 * Example usage:
 * <p>
 * <code>calculate(getElement("F28BA7351E3C8F5123880548CFA72B64566A1421"), getElement("80467069EA61BD786CFFEB508786723D6451F2F5"), "+", getElement("B52A9E9FC555A820984E63DECF13BCAA33E308CD"));</code>
 * @param oHtml1 Reference to a html control of type "integer", "float", "currency"
 * @param oHtml2 Reference to a html control of type "integer", "float", "currency"
 * @param strOp Operator
 * @param oHtmlResult Result; Reference to a html control of type "integer", "float", "currency"
 * @return <code>True</code> or <code>false</code>.
 */
function calculate(oHtml1, oHtml2, strOp, oHtmlResult){ return Helper.calculate(oHtml1, oHtml2, strOp, oHtmlResult); }

/**
 * Writes a value in a viewfield or static text field.
 * <p>
 * Example usage:
 * <p>
 * <code>setTextValueById("ID_labelcontrol900CB1AB", "blabla");</code>
 * @param id DOM id of the element; equivalent to the id-attibute value of the html element.
 * @param strValue Value to write.
 * @return <code>True</code> or <code>false</code>.
 */    
function setTextValueById(id, strValue){ return Browser.setValueByElementId(id, strValue); }

/**
 * Writes a value in a viewfield or static text field.
 * <p>
 * Example usage:
 * <p>
 * <code>setTextValue(getElement("F28BA7351E3C8F5123880548CFA72B64566A1433"), "blabla");</code>
 * @param oHtml Reference to a html input control. 
 * @param strValue Value to write.
 * @return <code>True</code> or <code>false</code>.
 */
function setTextValue(oHtml, strValue){ return Browser.setValue(oHtml, strValue); }

/**
 * Reads a value from a viewfield or static text field.
 * <p>
 * Example usage:
 * <p>
 * <code>getTextValueById("ID_labelcontrol900CB1AB");</code>
 * @param id DOM id of the element; equivalent to the id-attibute value of the html element.
 * @return Value from viewfield or static text field.
 */    
function getTextValueById(id){ return Browser.getValueByElementId(id); }

/**
 * Reads a text node from a view field or static text field.
 * <p>
 * Example usage:
 * <p>
 * <code>getTextValue(getElement("F28BA7351E3C8F5123880548CFA72B64566A1433"));</code>
 * @param oHtml Reference to a html input control.
 * @return Value from viewfield or static text field.
 */
function getTextValue(oHtml){ return Browser.getValue(oHtml); }

/**
 * Sets two datafields on a duration of a whole day: dateFrom 00:00 a.m., dateTo 00:00 a.m. next day.
 * <p>
 * Example usage (executable on an checkbox onclick() event):
 * <p>
 * <code>setFullDays(getElement("123401F1E55C9A193BE6EC4091B45C6A5A6C8154"), getElement("DD2E01F1E55C9A193BE6EC4091B45C6A5A6C8154"), getElement("4D0708BDECC7D088613F818CE1B09B8D812F5750") );</code>
 * @param oHtmlCheck Checkbox
 * @param oHtmlFrom dateFrom
 * @param oHtmlTo dateTo
 */
function setFullDays(oHtmlCheck, oHtmlFrom, oHtmlTo){ return Helper.setFullDays(oHtmlCheck, oHtmlFrom, oHtmlTo); }

/**
 * Inks rows and columns in a view table depending on a number value.
 * <p>
 * Example usage:
 * <p>
 * <code>inking("viewcontrolD54BA2DD", ">", 10, "#008000", "row");</code>
 * @param control Name of control, whose value should be to checked (name from expert page of the column).
 * @param op Operator
 * @param comp Value to compare with.
 * @param color Value of color (hexadecimal or name)
 * @param colored Possible values: "row" = whole row (tr), "cell" = whole cell (td), "span" = text of cell (span).
 */    
function inking(control, op, comp, color, colored){ return Helper.inking(control, op, comp, color, colored); }

/**
 * Inks date or datetime values in a view table depending on a number value.
 * @see #inking
 * @param type Possible values: "date" = date, "datetime" = date & time.
 */
function inkingDate(control, op, type, color, colored){ return Helper.inkingDate(control, op, type, color, colored); }

/**
 * Inks strings in a view table depending on a number value.
 * @see #inking
 */
function inkingString(control, op, comp, color, colored){ return Helper.inkingString(control, op, comp, color, colored); }

function getRow(no){ return Helper.getRow(no); }
function getCol(no){ return Helper.getCol(no); }

/**
 * Compares a value of a date control with the current date.
 * <br>
 * Imperative for input and view controls (for view controls the expert attribute <code>jsobject = true (Boolean)</code> has to be set.)
 * <p>
 * Example usage:
 * <p>
 * <code>dateComparedToNow(getElement("5F7S5E7F9EA9ED1A829DB98DBF5459F59961FA3B"));</code>
 * @param p_oDate Reference to an html input control of type "date", "time" or "datetime"
 * @return a JavaScript number object. <br>
 * 			<UL>
 *				<LI>-1 if an error occurred or input field is empty. 
 *				<LI>0 if value is less than current date.
 *				<LI>1 if value equals current date.
 *				<LI>2 if value is greater than current date.
 *		   	</UL>
 * 
 */
function dateComparedToNow(p_oDate){ return Helper.dateComparedToNow(p_oDate); }

/**
 * Adds or subtracts a intervall to/from a given JavaScript date object.
 * <p>
 * Example usage:
 * <p>
 * <code>
 * var dtNow = new Date();
 * <br>
 * var dtAdd1 = dateAdd("d", 1,  dtNow); // adds 1 day to current date.
 * <br>
 * var dtAdd2 = dateAdd("h", -2, dtNow); // subtracts 2 hours from current date.
 * </code>
 * @param {String} p_strInterval Possible values: "ms" - for milliseconds; "s" - for seconds; "mi" - for minutes; "h" - for hours; "d" - for days; "mo" - for months; "y" - for years;
 * @param {Integer} Number value for given interval, that should be added to date. Negative values are also possible.
 * @param {Date} JavaScript date object.
 * @return {object} JavaScript date object.
 */
function dateAdd(p_strInterval, p_iNum, p_oDate){return Helper.dateAdd(p_strInterval, p_iNum, p_oDate); }

/**
 * Executes an application-request.
 * <p>
 * Example usage:
 * <p>
 * <code>makeAppRequest("1002", "1000", false, false, true); // opens page 1000 of application 1002 in an new window</code>
 * @param {string}  p_strApp Application id
 * @param {string}  p_strTarget Page id
 * @param {boolean} p_bClosePopup Close popup (if current page in popup).
 * @param {boolean} p_bChangeParent Set request into main window (if current page in popup). 
 * @param {boolean} p_bNewWindow Set request into a new popup window.
 */ 
function makeAppRequest(p_strApp, p_strTarget, p_bClosePopup, p_bChangeParent, p_bNewWindow){ return Helper.makeAppRequest(p_strApp, p_strTarget, null, p_bNewWindow, p_bClosePopup, p_bChangeParent); }

