/////////misc///////////////
function GetRootUrl() {
    var elt=document.getElementById("hiddenRootUrl");
    return elt.value;
}
function IsHidden(ctl) {
	var c = ctl;
	while (c) {
		if (c.hidden || c.style.display == 'none') {
			return true;
		}
		c = c.parentElement;
	}
}
function IsRadComboBox(ctrl)
{
    if((ctrl!=null)  && (ctrl.className.indexOf("rcbInput") >= 0)) {return true;}   
    return false;
}
function SetRadComBoxText(combo, newtext) {combo.SetText(newtext);}
function ClearRadComBox(combo) {SetRadComBoxText(combo, "");}
function ClearTextBox(textboxid) {document.getElementById(textboxid).value = "";}
///////////////////////
//text area length check
///////////////////////
 function maxLength(field,maxChars)
 {
      
       if(field.value.length >= maxChars) {
          event.returnValue=false;
          return false;
       }
 }  

 function maxLengthPaste(field,maxChars)
 {
       event.returnValue=false;
       if((field.value.length +  window.clipboardData.getData("Text").length) > maxChars) {
         return false;
       }
       event.returnValue=true;
 }

//radgrid scripts
function RequestError(sender, e)    
{
    var showMessage = "<table><tr><td align='left'><font size=2>Dear Customer,<br><br>\n";

    showMessage += "Thank you for your request. The request is temporarily unavailable, whilst we are developing it.<br>\n";
    showMessage += "The developing will ensure you continue to enjoy all the current features of Service, plus new features that will be introduced in coming days.<br>\n";
    showMessage += "We expect the request to be available soon.<br>\n";
    showMessage += "We apologise for any inconvenience and thank you for your patience.<br><br>\n";
    showMessage += "<b>The PicNet Software Development.</b>\n</font></td></tr></table>";
    radalert(showMessage, 330, 180, "Temporarily Unavailable");
    
    //e.Status
    //e.ResponseText
    //e.ResponseHeaders
    
    return false;
}
function printpr()
{
var OLECMDID = 7;
/* OLECMDID values:
* 6 - print
* 7 - print preview
* 1 - open window
* 4 - Save As
*/
var PROMPT = 1; // 2 DONTPROMPTUSER 
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser); 
WebBrowser1.ExecWB(OLECMDID, PROMPT);
WebBrowser1.outerHTML = "";
}

function byId(id) {
    return document.getElementById(id);
}

function byPartialId(partialid) {
    var re = new RegExp(partialid, 'g');
    var elems = document.getElementsByTagName('*'), i = 0, el;
    while (el = elems[i++]) {
        if (el.id.match(re)) {
            return byId(el.id);
        }
    }
    return null;
}

Function.prototype.chain = function(args) {
    args.push(this);
    return function() {
        for (var i = 0; i < args.length; i++) {
            args[i]();
        }
    }
};
