﻿function ResizeTextArea(TextAreaId, p) {
    
    e = window.document.getElementById(TextAreaId);
    

    if (e.rows + p < 1) 
    {
        e.rows = 1;
    }
    else 
    {
        e.rows += p;
    }
}

function onSilverlightError(sender, args) {
var appSource = "";
if (sender != null && sender != 0) {
    appSource = sender.getHost().Source;
}

var errorType = args.ErrorType;
var iErrorCode = args.ErrorCode;

if (errorType == "ImageError" || errorType == "MediaError") {
    return;
}

var errMsg = "Unhandled Error in Silverlight Application " + appSource + "\n";

errMsg += "Code: " + iErrorCode + "    \n";
errMsg += "Category: " + errorType + "       \n";
errMsg += "Message: " + args.ErrorMessage + "     \n";

if (errorType == "ParserError") {
    errMsg += "File: " + args.xamlFile + "     \n";
    errMsg += "Line: " + args.lineNumber + "     \n";
    errMsg += "Position: " + args.charPosition + "     \n";
}
else if (errorType == "RuntimeError") {
    if (args.lineNumber != 0) {
    errMsg += "Line: " + args.lineNumber + "     \n";
    errMsg += "Position: " + args.charPosition + "     \n";
    }
    errMsg += "MethodName: " + args.methodName + "     \n";
}

throw new Error(errMsg);

}

function ListBox_SelectAll(controlName, value) {
	
	//get control
	var control = null;
	if (typeof controlName == "string") {
		control = document.getElementById(controlName);
	}

	//select all
	if (control != null) {
		if (control.type == "select-multiple") {
			for (var i = 0; i < control.options.length; i++) {
				control.options[i].selected = value;
			}
		}
	}

}

function TextBox_Clear(controlName) {
	
	//get control
	var control = null;
	if (typeof controlName == "string") {
		control = document.getElementById(controlName);
	}

	//clear	
	if (control != null) {		
		if (control.type == "text") {
			control.value = "";
		}
	}

}
