/* Class Document (ver 1.0.1 - July 16 2008)  */
if (typeof Base == 'undefined') var Base = {};

var ReqNormalColor = '#fff';
var ReqValueColor = '#F3D528';
var NumericValues = "0123456789.";
var TextValues = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_.,#'";
var TextNumericValues = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_.,#'0123456789";

// http://pietschsoft.com/post/2007/07/Creating-Namespaces-in-JavaScript-is-actually-rather-simple.aspx
// http://www.javascriptkit.com/jsref/navigator.shtml
if (!Base.Browser) Base.Browser = {};
/*
Base.Browser = {
	Name : 'Browser',
	Msgbox : function(msg){alert(msg);},
	Confirm : function(msg){return confirm(msg);},
	Confirm2 : function(msg){return confirm(msg);},
	Return : {
		Test1 : 'Allo',
		Test2 : function(){
			alert(Test1);		
		}
	}
}
*/
/* BROWSER CLASS  */
function Browser(){
    this.IE = false;
    this.FF = false;
    this.OP = false;
    this.SA = false;
    this.KR = false;
    this.NA = false;
    this.Name = '';
	this.Version = 0;
	this.MinorVersion = 0;
	this.Platform = '';
	this.userAgent = '';
	this.Language = '';
	this.Parse();
	//alert('Fureteur:' + this.Name + ' ,Version: ' + this.Version);
}
Browser.prototype.Parse = function Parse(){
	try{
		var i;
		var props;
		var prop;

		this.GetBrowser() 
		
		switch(this.Name){
			case "IE":
				props = navigator.userAgent.split(';');
				if(props[1] != '' || props[1] != 'undefined' || props[1] != null ){this.Version = this.ParseVersion(props[1],6);}				
				break;
			case "FF":
				props = navigator.userAgent.split('/');
				if(props[3] != '' || props[3] != 'undefined' || props[3] != null ){this.Version = this.ParseVersion(props[3],2);}				break;			
			case "OP":
			
				break;
			case "SA":
			
				break;
			case "NS":
			
				break;
			case "KR":
			
				break;								
			default:												
				break;
		}
		this.GetPlatform();
		this.GetLanguage();
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return;
	} 
}
Browser.prototype.ParseVersion = function ParseVersion(prop,def){
	try{
		if (prop.indexOf("1.") != -1){this.Version=1; return 1;}
		else if(prop.indexOf("2.") != -1){this.Version = 2; return 2;}
		else if(prop.indexOf("3.") != -1){this.Version = 3; return 3;}
		else if(prop.indexOf("4.") != -1){this.Version = 4; return 4;}
		else if(prop.indexOf("5.") != -1){this.Version = 5; return 5;}
		else if(prop.indexOf("6.") != -1){this.Version = 6; return 6;}
		else if(prop.indexOf("7.") != -1){this.Version = 7; return 7;}
		else if(prop.indexOf("8.") != -1){this.Version = 8; return 8;}
		else if(prop.indexOf("9.") != -1){this.Version = 9; return 9;}
		else if(prop.indexOf("10.") != -1){this.Version = 10; return 10;}	
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		if(def == '' || def == '' || def == ''){return def;}
		else{return 0;}
	}
};
Browser.prototype.Version = function Version(){
    return this.Version;
};
Browser.prototype.Name = function Name(){
    return this.Name;
};
Browser.prototype.Platform = function Platform(){
    return this.Platform;
};
Browser.prototype.GetPlatform = function GetPlatform(){
  var OS = navigator.platform.toLowerCase();
  if (OS.indexOf("win") != -1){this.Platform='Windows';}
  else if (OS.indexOf("mac") != -1){this.Platform='Mac';}
  else if (OS.indexOf("unix") != -1){this.Platform='Unix';}
  else if (OS.indexOf("linux") != -1){this.Platform='Linux';}
  else {this.Platform='Unknown';}
};
Browser.prototype.GetBrowser = function GetBrowser(){
    if (navigator.userAgent.indexOf("MSIE")!=-1){this.IE=true;this.Name="IE";}
    else if (navigator.userAgent.indexOf("Firefox") != -1){this.FF=true;this.Name = "FF";}
    else if (navigator.userAgent.indexOf("Navigator") != -1 || navigator.userAgent.indexOf("Netscape") != -1){this.NS=true;this.Name = "NS";}
    else if (navigator.userAgent.indexOf("Opera") != -1) {this.OP=true;this.Name = "OP";}
    else if (navigator.userAgent.indexOf("Safari") != -1) {this.SA=true;this.Name = "SA";}
    else if (navigator.userAgent.indexOf("Konqueror") != -1) {this.KR=true;this.Name = "KR";}
    else {this.NA=true;this.Name = "NA";}
    this.userAgent = navigator.userAgent;
};
/*
Browser.prototype.GetBrowserVersion = function(){
    if (navigator.userAgent.indexOf("1.") != -1){this.Version=1;}
    else if(navigator.userAgent.indexOf("2.") != -1){this.Version = 2;}
    else if(navigator.userAgent.indexOf("3.") != -1){this.Version = 3;}
    else if(navigator.userAgent.indexOf("4.") != -1){this.Version = 4;}
    else if(navigator.userAgent.indexOf("5.") != -1){this.Version = 5;}
    else if(navigator.userAgent.indexOf("6.") != -1){this.Version = 6;}
    else if(navigator.userAgent.indexOf("7.") != -1){this.Version = 7;}
    else if(navigator.userAgent.indexOf("8.") != -1){this.Version = 8;}
    else if(navigator.userAgent.indexOf("9.") != -1){this.Version = 9;}
    else if(navigator.userAgent.indexOf("10.") != -1){this.Version = 10;}
    
    //navigator.appVersion
    
    
};
*/
Browser.prototype.Close = function Close(){
	try{
		// <a href="javascript:window.opener='x';window.close();">Close</a>
		window.opener = 'x';
		window.close();
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return;
	}
};
Browser.prototype.PageName = function PageName(){
	try{
		var sPath = window.location.pathname;
		var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
		return sPage;
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return '';
	}
};
Browser.prototype.GetLanguage =function Language(){
	try{
        var langCode = navigator.language || navigator.systemLanguage;
        var lang = langCode.toLowerCase(); 
        lang = lang.substr(0,2); 
        //var dest = window.location.href; 
        
//        for (i=langcodes.length-1;i >= 0; i--){
//            if (lang==langcodes[i]){
//                dest = dest.substr(0,dest.lastIndexOf('.')) + '-' + lang.substr(0,2) + dest.substr(dest.lastIndexOf('.')); 
//                window.location.replace ?window.location.replace(dest) :window.location=dest;
//            }
//        }	
	
	    this.Language = lang;
	
	    
//		// IE.
//		try{return navigator.userLanguage;}
//		catch(err){}

//		// FF.
//		try{return navigator.language;}
//		catch(err){}
			
		return("NA");	
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return "NA";
	}
};

/* DOCUMENT CLASS  */
function Document(){}
Document.prototype.GetMouseX = function GetMouseX(obj){
    try{
        var X = 0;
        if(obj != '' && obj != 'undefined' & obj != null){X = event.x - obj.offsetLeft;}
        else{X = event.x;}
        return X;
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return 0;
	}
};
Document.prototype.GetMouseY = function GetMouseY(obj){
    try{
        var Y = 0;
        if(obj != '' && obj != 'undefined' & obj != null){Y = event.y - obj.offsetTop;}
        else{Y = event.y;}
        return Y;       
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return 0;
	}    
};
Document.prototype.GetCursorPosition = function GetCursorPosition(obj){
    var curleft = 0;
    var curtop = 0;        
    try{
    if (obj.offsetParent) {
        do{
            curleft += obj.offsetLeft;
		    curtop += obj.offsetTop;
        } while (obj = obj.offsetParent);
        return [curleft,curtop];
    }        
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return 0;
	}        
};
Document.prototype.GetElementPosition = function GetElementPosition(parentContainer,elementID){
    var eID=this.GetElementValueById(elementID);
    try{
        items = parentContainer.getElementsByTagName(eID.tagName);
        found = 0;
        for (p = 0; p < items.length; p++){
            if(items[p] == eID){found = 1; break;}
        }
        if(found){return p;}
        else{return -1;}        
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return 0;
	}        
};
Document.prototype.GetElementPositionEx = function GetElementPositionEx(element){
    var result = new Object();
    result.x = 0;
    result.y = 0;
    result.width = 0;
    result.height = 0;
    if(element.offsetParent){
        result.x = element.offsetLeft;
        result.y = element.offsetTop;
        var parent = element.offsetParent;
        while(parent){
            result.x += parent.offsetLeft;
            result.y += parent.offsetTop;
            var parentTagName = parent.tagName.toLowerCase();
            if (parentTagName != "table" &&
                parentTagName != "body" && 
                parentTagName != "html" && 
                parentTagName != "div" && 
                parent.clientTop && 
                parent.clientLeft) {
                result.x += parent.clientLeft;
                result.y += parent.clientTop;
            }
            parent = parent.offsetParent;
        }
    }
    else if (element.left && element.top) {
        result.x = element.left;
        result.y = element.top;
    }
    else {
        if(element.x){result.x = element.x;}
        if (element.y){result.y = element.y;}
    }
    if (element.offsetWidth && element.offsetHeight) {
        result.width = element.offsetWidth;
        result.height = element.offsetHeight;
    }
    else if (element.style && element.style.pixelWidth && element.style.pixelHeight) {
        result.width = element.style.pixelWidth;
        result.height = element.style.pixelHeight;
    }
    return result;
};
Document.prototype.GetPosition = function GetPosition(element){
  var positionX = 0;
  var positionY = 0;
  while (element != null)
  {
    positionX += element.offsetLeft;
    positionY += element.offsetTop;
    element = element.offsetParent;
  }
  return [positionX, positionY];
};
Document.prototype.IsElementExisting = function IsElementExisting(elementName){
    var obj=null;
    try{
        if (document.getElementById){
            obj = document.getElementById(elementName);
        }else if(document.layers){
            obj = document.layers[elementName];
        }else if(document.all){
            obj = document.all[elementName];
        }else{return false;}
        if(obj != null && obj != 'undefined' & obj != ''){
            return true;	        
        }else{
            return false;
        }
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return false;
	}
};
Document.prototype.GetElementsByTagName = function GetElementsByTagName(tag,id){
    var elements;
    var eles;
    try{
        if(tag == ''){return null;}
        if(id != ''){
	        eles = document.getElementsByTagName(tag);
	        if(eles != 'undefined' && eles != '' && eles.length>0){
		        for(i = 0;i < eles.length;i++){
			        if(eles[i].id == id){ 
				        elements.push(eles[i]);
			        }
		        }
	        }else{return null;}
        }else{elements = document.getElementsByTagName(tag);}
        return elements;        
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return 0;
	}
};
Document.prototype.GetElements = function GetElements(parentName,tag){
    try{
	    var elements;
	    var eles;
	    var parent = this.GetElementById(parentName);
	    if(parent == null || parent == 'undefined' || parent == ''){return null;}
	    if(parent.hasChildNodes()){
		    if(tag != '' && tag != 'undefined' && tag != null){
			    eles=parent.getElementsByTagName(tag);
			    if(eles != 'undefined' && eles != '' && eles.length>0){
				    return eles;
			    }else{return null;}
		    }else{
			    eles=parent.getElementsByTagName("*");
			    for(i=0;i<eles.length;i++){
				    if(eles[i].nodeValue != 'empty'){
					    elements.push(eles[i]);
				    }
			    }
			    return elements;			
		    }
	    }else{
		    return null;
	    }
    }catch(err){
	    if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
	    return 'undefined';
    }	
};
Document.prototype.GetNodeTextType = function GetNodeTextType(node){
    if(node == '' || node == 'undefined'){return 0;}
    switch(node.nodeType){
	    case 1:return 'ELEMENT_NODE';
	    case 2:return 'ATTRIBUTE_NODE';
	    case 3:return 'TEXT_NODE';
	    case 4:return 'CDATA_SECTION_NODE';
	    case 5:return 'ENTITY_REFERENCE_NODE';
	    case 6:return 'ENTITY_NODE';
	    case 7:return 'PROCESSING_INSTRUCTION_NODE';
	    case 8:return 'COMMENT_NODE';
	    case 9:return 'DOCUMENT_NODE';
	    case 10:return 'DOCUMENT_TYPE_NODE';
	    case 11:return 'DOCUMENT_FRAGMENT_NODE';
	    case 12:return 'NOTATION_NODE';
    }
};
Document.prototype.GetElementById = function GetElementById(elementId){
    try{
		if(elementId == '' || elementId == null || elementId == 'undefined'){return '';}
        if(document.getElementById){return document.getElementById(elementId);}
        else if(document.all){return document.all[elementId];}
        else{return null;}        
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return null;
    }    
};
Document.prototype.GetElementClassNameById = function GetElementClassNameById(elementId){
    var e;
    try{
	    if(elementId == '' || elementId == null || elementId == 'undefined'){return '';}
        if(document.getElementById){e=document.getElementById(elementId);}
        else if(document.all){e=document.all[elementId];}
        else{return '';}
        return e.className;
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return '';
	}
};
Document.prototype.GetParentElementClassNameById = function GetParentElementClassNameById(elementId,parentTagName){
    var p,o;
    try{
        if(elementId == '' || elementId == null || elementId == 'undefined'){return '';}
        o=this.GetElementById(elementId);
        p=this.FindParentWithTagFromElement(o,parentTagName);
        return p.className;
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return '';
	}
};
Document.prototype.GetParentElementByTagName = function GetParentElementByTagName(elementId,parentTagName){
    var p,o;
    try{
        if(elementId == '' || elementId == null || elementId == 'undefined'){return '';}
        o=this.GetElementById(elementId);
        p=this.FindParentWithTagFromElement(o,parentTagName);
        return p;
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return '';
	}
};
Document.prototype.GetElementTagName = function GetElementTagName(elementId){
    try{
		if(elementId == '' || elementId == null || elementId == 'undefined'){return '';}
        return this.GetElementById(elementId).tagName;
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return '';
	}    
};
Document.prototype.GetElementsByClassName = function GetElementsByClassName(className, tag, elm){
    var testClass;
    var elements;
    var returnElements = [];
    var current;
    var length;    
    try{
        testClass = new RegExp("(^|\\\\s)" + className + "(\\\\s|$)");
        tag = tag || "*";
        elm = elm || document;
        elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
        length = elements.length;        
    
        for(var i=0; i<length; i++){
	        current = elements[i];
	        if(testClass.test(current.className)){returnElements.push(current);}
        }
        return returnElements;	    
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return 0;
	}
};
Document.prototype.GetElementByClassName = function GetElementByClassName(className, tag, elm){
    var testClass;
    var elements; 
    var current;
    var length;	    
    try{
        testClass = new RegExp("(^|\\\\s)" + className + "(\\\\s|$)");
        tag = tag || "*";
        elm = elm || document;
        elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);        
        length = elements.length;
                
        for(var i=0; i<length; i++){
	        current = elements[i];
	        if(testClass.test(current.className)){
		        return current;
	        }
        }
        return null;	        
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return null;
	}
};
Document.prototype.FindParentWithTagFromName = function FindParentWithTagFromName(elementName, parentTagName){
    try{
	    var el=this.GetElementById(elementName);
	    if(el == null || el == 'undefined' || el == ''){return 'undefined';}
	    var parent = el.parentNode;
	    if(parent == null || parent == 'undefined' || parent == ''){return 'undefined';}
	    if(parent){
		    if (parent.tagName == parentTagName){
			    return parent;
		    }else{
			    return this.FindParentWithTagFromName(parent.id, parentTagName);  
		    }
	    }else{
		    return null;
	    }
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
	    return 'undefined';
    }	
};
Document.prototype.FindParentWithTagFromElement = function FindParentWithTagFromElement(element, parentTagName){
    try{
	    if(element == null || element == 'undefined' || element == ''){return 'undefined';}
	    var parent = element.parentNode;
	    if(parent == null || parent == 'undefined' || parent == ''){return 'undefined';}
	    if(parent){
		    if (parent.tagName == parentTagName){
			    return parent;
		    }else{
			    return this.FindParentWithTagFromElement(parent, parentTagName);  
		    }
	    }else{
		    return null;
	    }
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
	    return 'undefined';
    }	
};
Document.prototype.SetElementValueById = function SetElementValueById(elementId, value) {
    var oString;
    try {
        var obj = this.GetElementById(elementId);
        if (obj != 'undefined' && obj != '' && obj != null) {
            var tagName = this.GetElementTagName(elementId);
            tagName = tagName.toUpperCase();
            switch (tagName) {
                case 'LABEL':
                    if (value == 'undefined' || value == null) { return; }
                    //obj.innerText=value;
                    obj.innerHTML = value;
                    break;
                case 'INPUT':
                    var attr = obj.getAttribute("type").toUpperCase();
                    switch (attr) {
                        case 'TEXT':
                            if (value == 'undefined' || value == null) { value = ''; }
                            obj.value = value;
                            break;
                        case 'CHECKBOX':
                            if (value == '' || value == 'undefined' || value == null) { obj.checked = false; }
                            if (value == true || value == 'true' || value == 'checked') { obj.checked = true; }
                            else if (value == false || value == 'false' || value == 'unchecked') { obj.checked = false; }
                            else { obj.checked = false; }
                            break;
                        case 'HIDDEN':
                            if (value == 'undefined' || value == null) { value = ''; }
                            obj.value = value;
                            break;                            
                        default:
                            obj.value = value;
                            break;
                    }
                    break;
                case 'SELECT':
                    var list = this.GetElementById(elementId);
                    oString = new Strings;
                    var index;
                    if (oString.IsNumericKey(value)) {
                        list.selectedIndex = value;
                    } else {
                        for (index = 0; index < list.options.length; index++) {
                            if (list.options[index].text.toLowerCase() == value.toLowerCase()) {
                                list.selectedIndex = index;
                                break;
                            }
                        }
                    }
                    break;
                default:
                    obj.value = value;
                    break;
            }
        }
    } catch (err) {
        if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); }
        return;
    } finally { delete oString; }
};
/*
Document.prototype.GetElementValueById = function GetElementValueById(elementId){
    try{
	    if(document.getElementById){return document.getElementById(elementId).value;}
	    else if(document.all){return document.all[elementId].value;}
	    else{return '';}
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return '';
	}
};*/
Document.prototype.GetElementValueById = function GetElementValueById(elementId) {
    var element = null;
    try {
        var obj = this.GetElementById(elementId);
        if (obj != 'undefined' && obj != '' && obj != null) {
            var tagName = this.GetElementTagName(elementId);
            tagName = tagName.toUpperCase();
            switch (tagName) {
                case 'LABEL': return obj.innerHTML; break;
                case 'INPUT':
                    var attr = obj.getAttribute("type").toUpperCase();
                    switch (attr) {
                        case 'TEXT': return obj.value; break;
                        case 'CHECKBOX': return obj.checked; break;
                        case 'HIDDEN': return obj.value; break;
                        case 'RADIO': return obj.checked; break;
                        default: return obj.value; break;
                    }
                    break;
                case 'SELECT':
                    var value = '';
                    if (-1 < obj.selectedIndex) {
                        var opt = obj.options[obj.selectedIndex];
                        value = opt.value;
                        if (!value && !('value' in opt))
                            value = opt.text;
                    }
                    return value;

                    return obj.value; break;
                default: obj.value = value; break;
            }
        }
    } catch (err) {
        if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); }
        return '';
    }
};
Document.prototype.IsObject = function IsObject(obj){ 
    if(obj != '' && obj != 'undefined' && obj != null){
        if(typeof(obj) == 'undefined'){return false;}
        else if(typeof(obj) == 'object'){return true;}
        else if(typeof(obj) == 'string'){return false;}
        else{return false;}
    }else{return false;}
};
Document.prototype.GetTargetElementByEvent = function GetTargetElementByEvent(evt){
    var elem = null;
    try{
		if (evt.target) {
			elem = (evt.target.nodeType == 3) ? evt.target.parentNode : evt.target
		} else {
			elem = evt.srcElement
		}
		return elem    
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return null;
	}
};
Document.prototype.CreateElementByTagName = function CreateElementByTagName(tag, id, runat, cssclass, height ,width, top, left, href, target, src, alt) {
    var elem = null;
    try {
        if (tag == undefined) { return null; }
        if (id == 'undefined' || id == undefined || id == '' || id == null) { id = DynamicID(); }
        elem = document.createElement(tag);
        if (elem == 'undefined' || elem == undefined || elem == '' || elem == null) { return null; }
        if ((runat != 'undefined' || runat != undefined || runat != '' || runat != null) && runat == true) { elem.setAttribute("runat", "server"); }
        if (cssclass != 'undefined' || cssclass != undefined || cssclass != '' || cssclass != null) {
            if ((runat != 'undefined' || runat != undefined || runat != '' || runat != null) && runat == true) { elem.setAttribute("cssclass", cssclass); }
            else { elem.setAttribute("class", cssclass); }
        }

        if (height == 'undefined' || height == undefined || height == '' || height == null) { elem.style.height = height; }
        if (width == 'undefined' || width == undefined || width == '' || width == null) { elem.style.width = width; }
        if (top == 'undefined' || top == undefined || top == '' || top == null) { elem.style.top = top; }
        if (left == 'undefined' || left == undefined || left == '' || href == null) { elem.style.left = left; }
        
        if (href == 'undefined' || href == undefined || href == '' || href == null) { elem.setAttribute("href", href); }
        if (target == 'undefined' || target == undefined || target == '' || target == null) { elem.setAttribute("target", target); }
        if (src == 'undefined' || src == undefined || src == '' || src == null) { elem.setAttribute("src", src); }
        if (alt == 'undefined' || alt == undefined || alt == '' || alt == null) { elem.setAttribute("alt", alt); }

        if (href == 'undefined' || href == undefined || href == '' || href == null) { elem.setAttribute("href", href); }
        if (href == 'undefined' || href == undefined || href == '' || href == null) { elem.setAttribute("href", href); }
        if (href == 'undefined' || href == undefined || href == '' || href == null) { elem.setAttribute("href", href); }
        if (href == 'undefined' || href == undefined || href == '' || href == null) { elem.setAttribute("href", href); }


        return elem
    } catch (err) {
        if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); }
        return null;
    }
};
Document.prototype.AddElement = function AddElement(parentID, type, ID, props) {
    var elem = null;
    try {
        if (parentID == undefined) { parentID = document.body; }
        if (ID == undefined) { ID = DynamicID(); }
        switch (type.toUpperCase) {
            case 'DIV':

                break;
            case 'IFRAME':

                break;
            case 'LINK':
                var link = document.createElement("img");
                linkPDF.setAttribute("href", path);
                linkPDF.setAttribute("target", "_blank");
                linkPDF.appendChild(document.createTextNode(text));
            

                break;
            case 'TABLE':

                break;
            case 'TBODY':

                break;
            case 'TR':

                break;
            case 'TD':

                break;
            case 'LABEL':

                break;
            case 'TEXT':

                break;
            case 'P':

                break;
            case 'UL':

                break;
            case 'LI':

                break;
            case 'LIST':

                break;
            case 'HIDDEN':

                break;
            case 'SELECT':

                break;
            case 'OPTION':

                break;
            case 'IMG':
                elem.style.backgroundImage = "url(" + DOC_PIC + ")";
                break;
            default:
                return null;
        }
        return elem
    } catch (err) {
        if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); }
        return null;
    }
};
Document.prototype.DynamicID = function DynamicID() {

    try {




    } catch (err) {
        if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); }


    }




};
/* COOKIES CLASS  */       
function Cookies(){}
/*
Cookies.prototype.SetCookie = function(name,value){
	try{
         var argv = this.SetCookie.arguments;
         var argc = this.SetCookie.arguments.length;
         var path = (argc > 2) ? argv[2] : null;
         var expires = (argc > 3) ? argv[3] : null;
         var domain = (argc > 4) ? argv[4] : null;
         var secure = (argc > 5) ? argv[5] : false;
         document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +  ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");	
		return true;
	}catch(err){
		return false;
	}
};
Cookies.prototype.SetCookie = function(name,value,path,expireDays,domain,secure){
	try{
		if(name=='' || name == 'undefined' || name == null){return false;}
		var exp = new Date();
		var _value = (value == '' || value == 'undefined' || value == null) ? '' : value;
        var _path = (path != '' && path != 'undefined' && path != null) ? path : null;
        var _expires = (expireDays != '' && expireDays != 'undefined' && expireDays != null) ? exp.setTime(exp.getTime() + (expireDays*24*60*60*1000)) : null;
        var _domain = (domain != '' && domain != 'undefined' && domain != null) ? domain : null;
        var _secure = ((secure != '' && secure != 'undefined' && secure != null) && secure == true) ? true : false;
        document.cookie = name + "=" + escape (_value) + ((_expires  ==  null) ? "" : ("; expires=" + _expires)) +  ((_path == null) ? "" : ("; path=" + path)) + ((_domain == null) ? "" : ("; domain=" + domain)) + ((_secure == true) ? "; secure" : "");	
		return true;
	}catch(err){
		return false;
	}
};
Cookies.prototype.GetCookie = function(name,section){
	try{
		var i;
		var sections = document.cookie.split(';');
		for(i=0;i < sections.length;i++){
				var c = sections[i];
				while (c.charAt(0) == ' ') c = c.substring(1,c.length);
				if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
		}
		return "";
	}catch(err){
		return "";
	}   
};
Cookies.prototype.GetCookieVal = function(offset){
	try{
		var endstr = document.cookie.indexOf (";", offset);
		if (endstr == -1) endstr = document.cookie.length;
		return unescape (document.cookie.substring(offset, endstr));
	}catch(err){
		return "";
	}   
}; */
Cookies.prototype.DelCookie = function DelCookie(sName){
    
	try{
		document.cookie = sName + "=" + getCookie(sName) + "; expires=" + (new Date()).toGMTString() + ";";
		return true;
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return false;
	}    
};
Cookies.prototype.SetCookie = function SetCookie(name,value){
	if(document.cookie != document.cookie){index = document.cookie.indexOf(name);}
	else{index = -1;}

	if(index == -1){
		var _value = (value == '' || value == 'undefined' || value == null) ? '' : value;
		document.cookie=name+"="+_value+"; expires=Monday, 04-Apr-2010 05:00:00 GMT";
	}
};
Cookies.prototype.GetCookie = function GetCookie(name){
	var i,index;
	var value='';
	try{
		if(document.cookie){
			index = document.cookie.indexOf(name);
			if(index != -1){
				var sections = document.cookie.split(';');
				for(i=0;i < sections.length;i++){
					var section = sections[i].split('=');
					if(section[0].replace(" ","") == name.replace(" ","")){
						value=section[1];
						if(value != '' && value != 'undefined' && value != null){return value;}
					}
				}		
			}	
		}
		return '';
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return '';
	}
};

/* STRING CLASS  */
function Strings(){
	this._Document = new Document();
}
Strings.prototype.SubString = function SubString(value,start,length){
	return String(value).substring(start, length);
};
Strings.prototype.Left = function Left(value,length){
    if (length <= 0){
            return "";
    }else if(length > String(value).length){
            return str;
    }else{
		return String(value).substring(0,length);
	}
};
Strings.prototype.Right = function Right(value,length){
    if (length <= 0){
        return "";
    }else if(length > String(value).length){
        return str;
    }else{
        var iLen = String(value).length;
        return String(value).substring(iLen, iLen - length);
    }
};
Strings.prototype.Trim = function Trim(value){
	try{
		return RTrim(LTrim(value));
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return value.replace(/^\s+|\s+$/g, '');
	}
};
Strings.prototype.LTrim = function LTrim(value){
    var whitespace = new String(" \t\n\r");
    var s = new String(value);

    if(whitespace.indexOf(s.charAt(0)) != -1){
        var j=0, i = s.length;
        while(j < i && whitespace.indexOf(s.charAt(j)) != -1){
            j++;
			s = s.substring(j, i);
		}
    }
    return s;
};
Strings.prototype.RTrim = function RTrim(value){
    var whitespace = new String(" \t\n\r");
    var s = new String(value);

    if(whitespace.indexOf(s.charAt(s.length-1)) != -1){
        var i = s.length - 1;

        while(i >= 0 && whitespace.indexOf(s.charAt(i)) != -1){
            i--;
			s = s.substring(0, i+1);
        }
    }
    return s;
};
Strings.prototype.InStr = function InStr(strSearch, SearchFor){
	for (i=0; i < Len(strSearch); i++){
	    if (SearchFor == Mid(strSearch, i, 1)){
			return i;
	    }
	}
	return -1;
};
Strings.prototype.IsEmpty = function IsEmpty(elementID){
	var obj=this._Document.GetElementById(elementID);
	var value='';
	
	try{
		if(obj != '' && obj != 'undefined' && obj != null){
			return true;	
		}else{
			value=obj.value; 
			
		}
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		if(this.Trim(elementID)=''){return true;}
		else{return false;}
	}
};
//Strings.prototype.IsNumeric = function IsNumeric(n){if(n*1==NaN)return false;else return true;};
Strings.prototype.IsNumeric = function isNumeric(x) {
var RegExp = /^(-)?(\d*)(\.?)(\d*)$/; // Note: this WILL allow a number that ends in a decimal: -452. 
var result = x.match(RegExp);
if(result == null){result=false;}
return result;
};

/* CONVERT CLASS  */
function Convert(obj){}
Convert.prototype.Dec2Hex = function Dec2Hex(s){return (s <15.5 ? '0' : '') + Math.round(s).toString(16);};
Convert.prototype.Hex2Dec = function Hex2Dec(s){return parseInt(s,16);};
Convert.prototype.Val2Hex = function Val2Hex(s){return s.value.toLowerCase().replace( /[^\da-f]/g,'').replace( /^(\w)(\w)(\w)$/,'$1$1$2$2$3$3');};

/* GUI CLASS  */
function GUI(obj){
    /* Inherits Document Class.*/
    /* GUI.prototype = new Document; */
    var _Document = new Document();
    this._Document = new Document();
    this._Timer=0;
    this._element=null;
    var hideMilliseconds;
    /* this.ClassName=cname; */
    
    if(obj != '' && obj != 'undefined' && obj != null){
        if(typeof(obj) == 'undefined'){
            this._element=null;
            return;
        }else if(typeof(obj) == 'object'){
            this._element = obj;
            this.Name=obj.id;
        }else if(typeof(obj) == 'string'){
            this._element=_Document.GetElementById(obj);
            //this._element=this.GetElementById(obj);
            this.Name=obj;
        }else{
            this._element=null;
            return;    
        }
    }
}
// correct the constructor pointer because it points to GUI
//GUI.prototype.constructor = GUI;
GUI.prototype.ClearTimer = function ClearTimer(){
    try{
        clearTimeout(this._Timer);
        this._Timer=null;         
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return;
	}
};
GUI.prototype.Show = function Show(opacity){
    try{
        if(this._element == '' || this._element == 'undefined' || this._element == null){return;}
        this.ChangeVisibility(true);
        if(opacity > 0){
            if(opacity != '' && opacity != 'undefined' && opacity != null){this.ChangeOpacity(opacity);}
        }
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return;
	}
};
GUI.prototype.Hide = function Hide(){
    try{
        if(this._element == '' || this._element == 'undefined' || this._element == null){return;}
        this.ChangeVisibility(false);
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return;
	}
};
GUI.prototype.ShowDelay = function ShowDelay(value){
    try{
        if(this._element == '' || this._element == 'undefined' || this._element == null){return;}
        //this.ChangeVisibility(true);
        //this.SetOpacityEx(
        
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return;
	}
};
GUI.prototype.HideDelay = function HideDelay(milliseconds){
    var thisObj;
    try{
        if(this._element == '' || this._element == 'undefined' || this._element == null){return;}
        thisObj=this;
        this._Timer=setTimeout(function(){thisObj.Hide();}, milliseconds);
        //_Timer=setTimeout(function(){thisObj.SetOpacityEx(85,0,1000);}, milliseconds);
        //_Timer=setTimeout("GUI.prototype.Hide()",milliseconds);
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return;
	}
};    
GUI.prototype.SetOpacity = function SetOpacity(value){
    try{
        if(this._element == '' || this._element == 'undefined' || this._element == null){return;}
        if(value>10){value=10;}
        this._element.style.opacity = value/10;
        this._element.style.filter = 'alpha(opacity=' + value*10 + ')';        
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return;
	}
};
GUI.prototype.SetOpacityEx = function SetOpacityEx(opacityStart,opacityEnd,milliseconds){
    var speed;
    var opacityTimer=0;
    var i;
    var thisObj;        
    try{
        if(this._element == '' || this._element == 'undefined' || this._element == null){return;}
        speed=Math.round(milliseconds / 100);
        thisObj = this;
    
        if(opacityStart > opacityEnd){
            if(!thisObj.IsVisible()){
                thisObj.ChangeOpacity(0);
                thisObj.ChangeVisibility(true);
                }
            for(i = opacityStart; i >= opacityEnd ; i--){
                //setTimeout("this.ChangeOpacity(" + i + "," + this._element.id + ")",(opacityTimer * speed));
                setTimeout(function(){thisObj.ChangeOpacity(i,thisObj._element.id);},(opacityTimer * speed));
                opacityTimer++;
                this._Document.SetElementValueById("Y",i);
            }
        }else if(opacityStart < opacityEnd){
            if(!thisObj.IsVisible()){
                thisObj.ChangeVisibility(true);
                if(opacityStart<=0){thisObj.ChangeOpacity(0);}
            }            
            for(i = opacityStart ; i <= opacityEnd ; i++){
                //setTimeout("this.ChangeOpacity(" + i + "," + this._element.id + ")",(opacityTimer * speed));
                setTimeout(function(){thisObj.ChangeOpacity(i,thisObj._element.id);},(opacityTimer * speed));                
                opacityTimer++;
                this._Document.SetElementValueById("Y",i);
            }    
        }        
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return 0;
	}
};
GUI.prototype.ChangeOpacity = function ChangeOpacity(opacity,elementID,displayStyle){
    var obj;
    try{
        if(this._element == '' || this._element == 'undefined' || this._element == null){obj=elementID;}
        if(this._element == '' || this._element == 'undefined' || this._element == null){if(obj == '' || obj == 'undefined' || obj == null){return;}}
        else{obj=this._element;}            
        
        if(opacity > 0){if(!this.IsVisible()){this.ChangeVisibility(true);}}
        else if(opacity <= 0){if(this.IsVisible()){this.ChangeVisibility(false);}}

        obj.style.opacity=(opacity / 100);
        obj.style.MozOpacity=(opacity / 100);
        obj.style.KhtmlOpacity=(opacity / 100);
        obj.style.filter="alpha(opacity=" + opacity + ")";
        
        this._Document.SetElementValueById("X",opacity)
        
        if(opacity > 0 ){
            if(displayStyle != '' && displayStyle != 'undefined' & displayStyle != null){
                obj.style.display=displayStyle;
            }else{
                obj.style.display='block';
            }
        }else{obj.style.display='none';}
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return 0;
	}
};
GUI.prototype.ChangeVisibility = function ChangeVisibility(visible){
    try{
        if(this._Document.IsElementExisting(this._element.id)){
            if(this._element == '' || this._element == 'undefined' || this._element == null){return;}
            if (document.getElementById){
                if(visible == true){this._element.style.visibility = "visible";}
                else{this._element.style.visibility = "hidden";}
            }else if(document.layers){
                if(visible == true){document.layers[this._element.id].visibility = "show";}
                else{document.layers[this._element.id].visibility = "hide";}
            }else if(document.all){
                if(visible == true){document.all[this._element.id].style.visibility = "visible";}
                else{document.all[this._element.id].style.visibility = "hidden";}
            }else{return;}
        }else{return;}
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return;
	}
}; 
GUI.prototype.IsVisible = function IsVisible(){
    try{
        if(this._Document.IsElementExisting(this._element.id)){
            if(this._element == '' || this._element == 'undefined' || this._element == null){return;}
            if(document.getElementById){
                if(this._element.style.visibility == "visible"){return true;}
                else if(this._element.style.visibility == "hidden"){return false;}
                else{return false;}
            }else if(document.layers){
                if(document.layers[this._element.id].visibility == "show"){return true;}
                else if(document.layers[this._element.id].visibility == "hide"){return false}
                else{return false;}
            }else if(document.all){
                if(document.all[this._element.id].style.visibility == "visible"){return true;}
                else if(document.all[this._element.id].style.visibility == "hidden"){return false}
                else{return false;}
            }else{return;}
        }else{return;}
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return;
	}
};
GUI.prototype.SetElementBGcolor = function SetElementBGcolor(elementId,color){
    var obj;
    try{
        if(document.getElementById){obj=document.getElementById(elementId);}
        else if(document.all){obj=document.all[elementId];}
        else{return false;}
        
        if(obj != '' && obj != 'undefined' && obj != null){
			if(color == '' || color == 'undefined' || color == null){return false;}
			else{obj.style.backgroundColor=color;}
        }        
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return null;
	}    
};
GUI.prototype.RGBToHex = function RGBToHex(rgb){
	try{
		var char = "0123456789ABCDEF"
		return String(char.charAt(Math.floor(rgb / 16))) + String(char.charAt(rgb - (Math.floor(rgb / 16) * 16)));  
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return '';
	}
};

/*  VALIDATION CLASS  */      
function Validation(){
	this._Document = new Document();
	this._GUI = new GUI();
	this._String = new Strings();
}
Validation.prototype.IsEmpty = function IsEmpty(objName,highlightBG){
	try{
		var obj=this._Document.GetElementById(objName);
		if(obj == '' || obj == 'undefined' || obj == null){return false;}
		var Value=this._Document.GetElementValueById(objName);
	     
		if(Value != ''){
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqNormalColor);}
			return false;
		}else{
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqValueColor);}
			return true;
		}	
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}
};
Validation.prototype.IsNumericValue = function( IsNumericValueobjName,highlightBG){
     try{
		var obj=this._Document.GetElementById(objName);
		var n=this._Document.GetElementValueById(objName);
	     
		if(n == ''){return false;}
		if(this.TestRegex(obj,"10")){
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqNormalColor);}
			return true;
		}else{
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqValueColor);}
			return false;
		}     
    }catch(err){
		if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqNormalColor);};
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}
};
/*
Validation.prototype.IsTextValue = function(objName,highlightBG){
	try{
		var obj=this._Document.GetElementById(objName);
		var v=obj.value;
		var IsText=true;
		var c,i;
		
		while(i < v.length){
    		c=v.charAt(i);
    		if(TextValues.indexOf(c) == -1){IsText=false;break;}
    		i++;
		}
		if(IsText){
			if(highlightBG==true){this._GUI.SetElementBGcolor(objName,ReqNormalColor);}
			return true;
		}else{
			if(highlightBG == true){this._GUI.SetElementBGcolor(objName,ReqValueColor);}
			return false;
		}
	}catch(err){return true;}
};*/
Validation.prototype.IsTextMatch = function IsTextMatch(sourceElementID,compareElementID){
	try{
		var source=this._Document.GetElementById(sourceElementID);
		var compare=this._Document.GetElementById(compareElementID);
	
		if(this._Document.IsObject(source) && this._Document.IsObject(compare)){
			if(this._Document.GetElementValueById(sourceElementID) == this._Document.GetElementValueById(compareElementID)){return true;}
			else{return false;}		
		}else{return true;}
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}
};
Validation.prototype.IsNumericKey = function IsNumericKey(){
	try{
		if(window.event.keyCode < 48 || window.event.keyCode > 57) {window.event.keyCode = 0;}
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return;
	}
};
Validation.prototype.IsTextKey = function IsTextKey(){
	try{
		if((window.event.keyCode < 65 || window.event.keyCode > 90) && (window.event.keyCode < 97 || window.event.keyCode > 122)){window.event.keyCode = 0;}
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return;
	}
};
Validation.prototype.IsNumericOrTextKey = function IsNumericOrTextKey(){
	try{
		if((window.event.keyCode < 65 || window.event.keyCode > 90) && (window.event.keyCode < 97 || window.event.keyCode > 122) && (window.event.keyCode < 48 || window.event.keyCode > 57)){window.event.keyCode = 0;}
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return;
	}
};
Validation.prototype.IsValidIP = function IsValidIP(objName,highlightBG){
     try{
		var obj=this._Document.GetElementById(objName);
		var email=this._Document.GetElementValueById(objName);
	     
		if(email == ''){return false;}
		if(TestRegex(obj,"1")){
			obj.value = email.toLowerCase();
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqNormalColor);}
			return true;
		}else{
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqValueColor);}
			return false;
		}     
     }catch(err){
		if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqNormalColor);}
		return true;
	}
};
/*
Validation.prototype.isValidEmail = function isValidEmail(objName,highlightBG){
    try{
		var obj=this._Document.GetElementById(objName);
		var email=this._Document.GetElementValueById(objName);
	     
		if(email == ''){
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqValueColor);}
			return false;
		}
		if(this.TestRegex(obj,"4")){
			obj.value = email.toLowerCase();
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqNormalColor);}
			return true;
		}else{
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqValueColor);}
			return false;
		}      
    }catch(err){
		if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqNormalColor);}
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}
};
*/
Validation.prototype.isValidEmail = function isValidEmail(objName,highlightBG){
    try{
		var obj=this._Document.GetElementById(objName);
		var emails=this._Document.GetElementValueById(objName);
		var email;
		var i = 0;
		var regmask = /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
		var regex = new RegExp(regmask);
		
		if(emails == ''){
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqValueColor);}
			return false;
		}
		email = emails.split(";");
		if(email.length > 0){
            for(i = 0;i < email.length;i++){
                if(regex.test(email[i]) == false){
                    if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqValueColor);}		           
		            return false;
	            }
            }
            if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqNormalColor);}		
		    return true;
		}else{
		    if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqValueColor);}
		    return false;
		}		
    }catch(err){
		if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqNormalColor);}
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}finally{delete regex; delete obj;}
};
Validation.prototype.isValidEmailCount = function isValidEmailCount(objName,maxCount,highlightBG){
    try{
		var obj=this._Document.GetElementById(objName);
		var emails=this._Document.GetElementValueById(objName);
		var email;
		var i = 0;

	     
		if(emails == ''){
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqValueColor);}
			return false;
		}
		
		email = emails.split(";");
		if(email.length <= maxCount){
		    if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqNormalColor);}
		    return true;
		}else{
		    if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqValueColor);}
		    return false;
		}
    }catch(err){
		if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqNormalColor);}
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}
};
Validation.prototype.isValidPhone = function isValidPhone(objName,highlightBG){
	try{
		var obj=this._Document.GetElementById(objName);
		var phone=this._Document.GetElementValueById(objName);
	     
		if(phone == ''){return false;}
		if(this.TestRegex(obj,"2")){
			obj.value = phone.toLowerCase();
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqNormalColor);}
			return true;
		}else{
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqValueColor);}
			return false;
		} 	
	}catch(err){
		if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqNormalColor);}
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}
};
Validation.prototype.isValidPostalCode = function isValidPostalCode(objName, highlightBG, format) {
    try {
        var obj = this._Document.GetElementById(objName);
        var pc = this._Document.GetElementValueById(objName);

        if (pc == '') { return false; }
        if (this.TestRegex(obj, "5")) {
            obj.value = pc.toUpperCase();
            if (format == true || format == "true") {
                if (obj.value.length == 6) {
                    obj.value = this._String.Left(obj.value, 3) + " " + this._String.Right(obj.value, 3)
                }
            }
            if (highlightBG == true) { _GUI.SetElementBGcolor(objName, ReqNormalColor); }
            return true;
        } else {
            if (highlightBG == true) { _GUI.SetElementBGcolor(objName, ReqValueColor); }
            return false;
        }
    } catch (err) {
        if (highlightBG == true) { _GUI.SetElementBGcolor(objName, ReqNormalColor); }
        if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); }
        return true;
    }
};
Validation.prototype.isValidDoc = function isValidDoc(objName,highlightBG){
	try{
		//var obj = this._Document.GetElementById(objName);
		var value = this._Document.GetElementValueById(objName);
		var ext = this._String.Right(value,4);
	     
		if(ext == '' || ext == 'undefined' || ext == null){return false;}
		if(ext == '.doc' || ext == '.rtf' || ext == '.pdf' || ext == '.txt' || ext == 'docx'){
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqNormalColor);}
			return true;
		}else{
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqValueColor);}
			return false;
		} 	
	}catch(err){
	    if(objName == '' || objName == 'undefined' || objName == null){alert('Element name missing or not specified!');}
		_GUI.SetElementBGcolor(objName,'#ffffff');
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}
};
Validation.prototype.isValidSelection = function isValidSelection(objName,highlightBG){
	try{
		var value=this._Document.GetElementValueById(objName);
	     
		if(value == '' || value == 'undefined' || value == null){return false;}
		if(value == '' || value == '0' || value == 0){
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqValueColor);}
			return false;
		}else{
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqNormalColor);}
			return true;
		} 	
	}catch(err){
		_GUI.SetElementBGcolor(objName,'#ffffff');
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}
};
Validation.prototype.isChecked = function isChecked(objName,highlightBG){
	try{
		var checkBox=this._Document.GetElementById(objName);
	     
		if(checkBox == '' || checkBox == 'undefined' || checkBox == null){return false;}
		if(checkBox.checked){
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqNormalColor);}
			return true;
		}else{
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqValueColor);}
			return false;
		} 	
	}catch(err){
		_GUI.SetElementBGcolor(objName,'#ffffff');
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}
};
Validation.prototype.isListChecked = function isListChecked(objName,highlightBG){
	try{
		var obj=this._Document.GetElementById(objName);
	    var checkBox;
	    var i=0;
	    var isChecked=false
	     
		if(obj == '' || obj == 'undefined' || obj == null){return false;}
		for(i=0;i<30;i++){
			checkBox=this._Document.GetElementById(objName+'_'+i);   
			if(checkBox != '' && checkBox != 'undefined' & checkBox != null){
				if(checkBox.checked){isChecked=true;}
			}else{break;}
		}
		if(isChecked){
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqNormalColor);}
			return true;
		}else{
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqValueColor);}
			return false;
		} 	
	}catch(err){
		_GUI.SetElementBGcolor(objName,'#ffffff');
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}
};
Validation.prototype.isRadioListSel = function isRadioListSel(objName,highlightBG){
	try{
		var obj=this._Document.GetElementById(objName);
	    var radioButton;
	    var i=0;
	    var isSel=false
	     
		if(obj == '' || obj == 'undefined' || obj == null){return false;}
		for(i=0;i<30;i++){
			radioButton=this._Document.GetElementById(objName+'_'+i);   
			if(radioButton != '' && radioButton != 'undefined' & radioButton != null){
				if(radioButton.checked){isSel=true;}
			}else{break;}
		}
		if(isSel){
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqNormalColor);}
			return false;
		}else{
			if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqValueColor);}
			return true;
		} 	
	}catch(err){
		_GUI.SetElementBGcolor(objName,'#ffffff');
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}
};
Validation.prototype.TestRegex = function TestRegex(obj,regmaskid){
    // Test Regular expressions: http://www.roblocher.com/technotes/regexp.aspx
    var regmask = "";
    
	try{
		switch(regmaskid.toString()){
			case "1":    // IP Address.
				regmask = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/; 
				break;    
			case "2":    // Phone No.
				regmask = /^\d\d\d-\d\d\d-\d\d\d\d$/;  
				break;    
			case "4":    // Email. "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$"
				//regmask = "/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/";
				regmask = /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
				break;
			case "5":    // Postal Code.   /^\D{1}\d{1}\D{1}\-?\d{1}\D{1}\d{1}$/;       /^[a-ceghj-npr-tvxyA-CEGHJ-NPR-TVXY]\d[a-zA-Z](\s)?\d[a-zA-Z]\d\s*/;
			    regmask = /^\s*[a-ceghj-npr-tvxy]\d[a-z](\s)?\d[a-z]\d\s*$/i
				break;
			case "9":    // Alpha.
				regmask = /^([a-zA-Z])+$/;
				break;
			case "10":    // Numeric.
				regmask = /^([0-9_\.\-])+$/;
				break;								
			default :
				break;
		}
	     
		if(regmask == null){
			return true;
		}else{
			var regex = new RegExp(regmask);
			var incomming = obj.value;

			if(regex.test(incomming)){
				return true;
			}else{
				return false;
			}       
		}	
	}catch(err){
		if(highlightBG == true){_GUI.SetElementBGcolor(objName,ReqNormalColor);}
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}
};
Validation.prototype.IsMaxLength = function IsMaxLength(objID,len,highlightBG,trim){
	var mlength=0;
	var obj;
		
	try{
		if(objID == '' || objID == 'undefined' || objID == null){return true;}
		obj = _DOC.GetElementById(objID);
		if(len == '' || len == 'undefined' || len == null || len == 0  || isNaN(len)){
			mlength = obj.getAttribute ? parseInt(obj.getAttribute("maxlength")) : ""
		}else{
			mlength = len;
		}
		if((mlength != '' && mlength != 'undefined' && mlength != null) && mlength > 0){
			if(obj.getAttribute && obj.value.length > mlength){
				if(highlightBG == true){_GUI.SetElementBGcolor(objID,ReqValueColor); return true;}
			}else{if(highlightBG == true){_GUI.SetElementBGcolor(objID,ReqNormalColor); return false;}}
		}
	}catch(err){
		if(highlightBG == true){_GUI.SetElementBGcolor(objID,ReqNormalColor);}
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}
}
Validation.prototype.IsMinLength = function IsMinLength(objID,len,highlightBG){
	var mlength=0;
	var obj;
		
	try{
		if(objID == '' || objID == 'undefined' || objID == null){return true;}
		obj = _DOC.GetElementById(objID);
		if(len == '' || len == 'undefined' || len == null || len == 0  || isNaN(len)){
			mlength = obj.getAttribute ? parseInt(obj.getAttribute("maxlength")) : ""
		}else{
			mlength = len;
		}
		if((mlength != '' && mlength != 'undefined' && mlength != null) && mlength > 0){
			if(obj.getAttribute && obj.value.length < mlength){
				if(highlightBG == true){
					_GUI.SetElementBGcolor(objID,ReqValueColor);
					return false;
				}
			}
			else{
				if(highlightBG == true){
					_GUI.SetElementBGcolor(objID,ReqNormalColor);
					return true;	
				}
			}
		}
	}catch(err){
		if(highlightBG == true){_GUI.SetElementBGcolor(objID,ReqNormalColor);}
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return true;
	}
}

/*  CLIENT CLASS  */
function Client(){
	this._Document = new Document();
	this._Browser = new Browser();
}
Client.prototype.Prompt = function Prompt(msg){
	try{
		var input = prompt(msg, "");
		return input;
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return '';
	}
};
Client.prototype.Highlight = function Highlight(id){
	try{
		var text=this._Document.GetElementById(id);
		text.style.color='#ff0000';
		text.style.fontWeight='bold';	
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return;
	}
};
Client.prototype.SetFocus = function SetFocus(id){
	try{
		var obj=this._Document.GetElementById(id);
		obj.focus();
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return;
	}
};
Client.prototype.Restore = function Restore(id){
	try{
		var text=this._Document.GetElementById(id);
		text.style.color='#909090';
		text.style.fontWeight='normal';	
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return;
	}
};
Client.prototype.Maximize = function Maximize(){
	try{
		top.window.moveTo(-4,-4);
		if (document.all){top.window.resizeTo(screen.availWidth + 8,screen.availHeight + 8);}
		else if(document.layers || document.getElementById){
			if (top.window.outerHeight<screen.availHeight || top.window.outerWidth<screen.availWidth){
				top.window.outerHeight = screen.availHeight + 8;
				top.window.outerWidth = screen.availWidth + 8;
			}
		}	
	
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return;
	}
};
Client.prototype.ResizeWindow = function ResizeWindow(h,w,t,l){
	try{
		top.window.moveTo(t,l);
		if(document.all){top.window.resizeTo(w,h);}
		return true;
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return false;
	}
};
Client.prototype.AssignCSSfiles = function AssignCSSfiles(){
	try{
		this._Browser.GetBrowser();
		//this._Browser.GetBrowserVersion();
		if(this._Browser.IE){
			if(this._Browser.Version == 6){this.AddStylesheet("text/css","stylesheet","../css/ie/style-ie6.css","screen");}
			else if(this._Browser.Version == 7){this.AddStylesheet("text/css","stylesheet","../css/ie/style-ie7.css","screen");}
			else if(this._Browser.Version == 8){this.AddStylesheet("text/css","stylesheet","../css/ie/style-ie8.css","screen");}
			else{this.AddStylesheet("text/css","stylesheet","../css/ie/style-ie6.css","screen");}
		}
		else if(this._Browser.FF){this.AddStylesheet("text/css","stylesheet","../css/ff/style-ff.css","screen");}
		else if(this._Browser.NS){this.AddStylesheet("text/css","stylesheet","../css/ns/style-ns.css","screen");}
		else if(this._Browser.OP){this.AddStylesheet("text/css","stylesheet","../css/op/style-op.css","screen");}
		else if(this._Browser.KR){this.AddStylesheet("text/css","stylesheet","../css/kr/style-kr.css","screen");}
		else if(this._Browser.SA){this.AddStylesheet("text/css","stylesheet","../css/kr/style-kr.css","screen");}
		else{this.AddStylesheet("text/css","stylesheet","../css/ie/style-ie6.css","screen");}	
		return true;
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return false;
	}
};
Client.prototype.AddStylesheet = function AddStylesheet(type,rel,href,media){
	try{
		var headID = document.getElementsByTagName("head")[0];
		var cssNode = document.createElement('link');
		cssNode.type=type;
		cssNode.rel=rel;
		cssNode.href=href;
		cssNode.media=media;
		headID.appendChild(cssNode);
		return true;	
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return false;
	}
};
Client.prototype.MsgBox = function MsgBox(msg){
	try{
		alert(msg);
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return;
	}
};
Client.prototype.DisableAutoComplete = function DisableAutoComplete(id) {
    var obj = null;
    try {
        if (id == undefined || id == "undefined" || id == null) { id = ''; }
        if (id == '') {
            for (var i = 0, l = document.getElementsByTagName('input').length; i < l; i++) {
                if (document.getElementsByTagName('input').item(i).type == 'text') {
                    document.getElementsByTagName('input').item(i).setAttribute('autocomplete', 'off');
                }
            }
            return true;
        } else {
            obj = this._Document.GetElementById(id);
            if (obj.type == 'text') {
                obj.setAttribute('autocomplete', 'off');
                return true;
            }
        }
        return false;
    } catch (Error) {
        if (isDebug) { alert(err + '\n\n(' + GetmethodName() + ')'); }
        return false;
    } finally {
        delete obj;
    }
};

/*
Client.prototype.Confirm = function Confirm(msg){
	try{
		var anwser = confirm(msg);
		if(anwser){return true;}else{return false;}
	}catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return false;
	}
};
Client.prototype.PopUp = function PopUp(url,name,height,width,top,left,location,menubar,resizable,scrollbars,status,toolbar,center){
    var _Window;     
    var params = '';
    try{
        if(url == "" || url == "undefined" || url == null){return;}
    //    var left   = (screen.width  - width)/2;
    //    var top    = (screen.height - height)/2;

        if(name == undefined){name = 'Adecco';}
        if(center == undefined){center = true;}
        if(height == undefined){height = 200;}
        if(width == undefined){width = 300;}
        if(top == undefined){top = 100;}
        if(left == undefined){height = 100;}
        if(location == undefined){location = 'no';}
        if(menubar == undefined){menubar = 'no';}
        if(resizable == undefined){resizable = 'no';}
        if(scrollbars == undefined){scrollbars = 'no';}
        if(status == undefined){status = 'no';}
        if(toolbar == undefined){toolbar = 'no';}
        
        params += 'width='+ height +', height='+ height;
        params += ', top=' + top + ', left=' + left;
        params += ', directories=no';
        params += ', location=' + location;
        params += ', menubar=' + menubar;
        params += ', resizable=' + resizable;
        params += ', scrollbars=' + scrollbars;
        params += ', status=' + status;
        params += ', toolbar=' +toolbar;
        
        _Window = window.open(url,name, params);
        if (_Window.focus){_Window.focus()}
        return _Window;    
    }catch(err){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return;    
    }finally{delete _Window;}
};
Client.prototype.Prompt = function Prompt(msg,validate){
    try{
        if(msg == "" || msg == "undefined" || msg == null){return '';}
        if(validate == undefined){validate = false;}
        var input = prompt(msg, '');
        if(validate && (input == "" || input == "undefined" || input == null)){
            if(this.Confirm('Une valeur est requise pour continuer, désirez vous continuer?')){
                input = prompt(msg, '');
                return input;
            }else{
                return '';
            }
        }else{
            return input;
        }
    }catch(Error){
		if(isDebug){alert(err + '\n\n(' + GetmethodName() + ')');}
		return '';    
	}
};
*/
function GetmethodName() {
	var ownName;
	try{
		// When Method is in Class, must double naming Method Name else this method will not work!!
		//ownName = arguments.callee.toString();         // Current Method Name.
		ownName = arguments.callee.caller.toString()   // Calling Method Name.
		ownName = ownName.substr('function '.length);      // trim off "function "
		ownName = ownName.substr(0, ownName.indexOf('(')); // trim off everything after the function name
		return ownName;
	}catch(ex){if(isDebug){alert(ex.message + '\n(GetmethodName)'); return 'N/A';}}
}

/*
var Clients = {
	name : "Clients";,
	version : 1.0.0;
	initialise : function(){
		// do some stuff on load.
		alert('Initialize');
	}
	msgbox : function(msg){
		alert(msg);
	}
	return{
		method1 : function() {}
	}	
	window.onload = initialise;
};
var Thing = {
initialise : function(){
	alert('initializing');
};

return {
my_method : function() {}
};

window.onload = initialise;
}
*/