function TelenorChangeBG (elem, bg) {
	elem.tempBG = elem.style.backgroundImage;
	elem.style.backgroundImage = 'url('+bg+')';
}

function TelenorRevertBG (elem) {
	elem.style.backgroundImage = elem.tempBG;
}
/**
 * The Sonofon object 
 * Objects: upper camel case
 * Methods & properties: lower camel case
*/
var Sonofon = {
	
	/**
	 * This method returns a reference to an HTML element
	 * @param	{String} sId The id-attribute of the HTML element you want to find
	 * @returns 	A reference to the node
	*/
	$:function (sId){
		return document.getElementById(sId)!=null?document.getElementById(sId):false;
	},
	
	/**
	 * A method to easily create new DOM objects and populate them with attributes
	 * @param	{String} sType The type of HTML element to create
	 * @param	{Object} oConfig An object with attributes to attach to the created element
	 * @returns 	The newly created element
	*/
	createElement:function (sType,oConfig){
		var elm = document.createElement(sType);
		for(p in oConfig){
			if(p == "CSSClass"){
				elm.className = oConfig[p];
			} else if(p == "content"){
				try {
					elm.innerHTML = oConfig[p];
				} catch(e){}
			} else {
				elm.setAttribute(p,oConfig[p]);
			}
		}
		document.body.appendChild(elm);
		return elm;
	},
	/**
	 * This method will return a absolute pixel value of an element left edge to the edge of the browserwindow
	 * @param	{Node} o The HTML element which offset you want to find
	 * @returns 	A number
	*/
	getAbsLeft:function (o){
		var iY = 0;
		while(o.offsetParent){
			iY += o.offsetLeft;
			o = o.offsetParent;
		}
		return iY;
	},

	/**
	 * This method will return a absolute pixel value of an element top edge to the edge of the browserwindow
	 * @param	{Node} o The HTML element which offset you want to find
	 * @returns 	A number
	*/
	getAbsTop:function (o){
		var iX = 0;
		while(o.offsetParent){
			iX += o.offsetTop;
			o = o.offsetParent;
		}
		return iX;
	},
	disableFirebugConsoleInIE:function (){
		try {
			if(!window.console){
				window.console = {}
				var m = ["debug","info","warn","error","assert","dir","dirxml","trace","group","groupEnd","time","timeEnd","profile","profileEnd","count"];
				for(var i=0; i<m.length; i++){
					window.console[m[i]] = function(){return false;};
				}
			}
		} catch(e){}
	},
	disableIEBackgroundFlicker:function (){
		try { document.execCommand('BackgroundImageCache', false, true); } catch(e){}
	},
	
	/**
	 * 
	*/
	Page: {
		Tables:{		
			zebratize:function (){
				var oTables = $(".stripes");
				for(var i=0; i<oTables.length; i++){
					var oTbodys = oTables[i].getElementsByTagName("TBODY");
					for(var j=0; j<oTbodys.length; j++){
						for(var k=0; tr=oTbodys[j].getElementsByTagName("TR")[k]; k++){
							tr.className = k%2==0?"odd":"even";
						}
					}
				}
			}
		}, // @Sonofon.Page.Tables.zebratize
					
		Flow:{
			initialize:function (){
				$(".options").addClass("hidden");
				
				var curtains = {open:""};
				
				$("#choice01-radio").click(function (){
					if(curtains.open != this.id){
						$("#choice01-options").removeClass("hidden");
						$("#choice01-options").slideDown("slow");
						$("#choice01").removeClass("dimmed");
						if(curtains.open != ""){
							$("#choice02-options").slideUp("slow");
						}
						$("#choice02").addClass("dimmed");
						curtains.open = this.id;
					}
				});
				$("#choice02-radio").click(function (){
					if(curtains.open != this.id){
						if(curtains.open != ""){
							$("#choice01-options").slideUp("slow");
						}
						$("#choice01").addClass("dimmed");
						$("#choice02-options").removeClass("hidden");
						$("#choice02-options").slideDown("slow");
						$("#choice02").removeClass("dimmed");
						curtains.open = this.id;
					}
				});
			}
		},
		
		FAQ:{
			initialize:function (){
				$("ul#faq.expandable-link-list div.answer").hide();
				$("ul#faq.expandable-link-list div.hr-dotted").hide();
				$("ul#faq.expandable-link-list a.open").each(function (){ this.setAttribute("status","collapsed") }); // set inital attr of the link to collapsed

				$("ul#faq.expandable-link-list a.open").click(function (){
					if(this.getAttribute("status") == "collapsed"){			// check custom attr status to enable expand and collapse on the same link
						this.setAttribute("status","expanded");
						$(".answer",this.parentNode).slideDown("slow",function() {
						//$(".hr-dotted",this.parentNode).show();
							
						var s=s_gi('sonofontelenorprod');
						s.linkTrackVars='prop5';
						s.linkTrackEvents='None';
						s.prop5='Kundeservice - '+$(".open",this.parentNode).attr('innerHTML');
						s.tl(this,'o','FAQ');
});
			// toogle status attr
					} else {
						$(".answer",this.parentNode).slideUp("slow");
						//$(".hr-dotted",this.parentNode).hide();
						this.setAttribute("status","collapsed");
					}
					return false;
				});
				$("ul#faq.expandable-link-list a.close").click(function (){
					$(this.parentNode).slideUp("slow");
					$(".hr-dotted",this.parentNode.parentNode).hide();
					$(".open",this.parentNode.parentNode).attr("status","collapsed");
					Sonofon.Page.Layout.resizeRightCol();
					return false;
				});
			}
		},
		
		GenericExpandList:{
			initialize:function (){
				$("ul.list-element-expand div.answer").hide();
				$("ul.list-element-expand div.hr-dotted").hide();
				$("ul.list-element-expand a.open").each(function (){ this.setAttribute("status","collapsed") }); // set inital attr of the link to collapsed

				$("ul.list-element-expand a.open").click(function (){
					if(this.getAttribute("status") == "collapsed"){			// check custom attr status to enable expand and collapse on the same link
						$(".answer",this.parentNode).slideDown("slow");
						$(".hr-dotted",this.parentNode).show();
						this.setAttribute("status","expanded");				// toogle status attr
					} else {
						$(".answer",this.parentNode).slideUp("slow");
						$(".hr-dotted",this.parentNode).hide();
						this.setAttribute("status","collapsed");
					}
					return false;
				});
				$("ul.list-element-expand a.close").click(function (){
					$(this.parentNode).slideUp("slow");
					$(".hr-dotted",this.parentNode.parentNode).hide();
					$(".open",this.parentNode.parentNode).attr("status","collapsed");
					return false;
				});
			}
		},
		
		Tabs:{
			imgStdPath: new Array(),
			imgSelPath: new Array(),
			tempStdPath: new Array(),
			tempSelPath: new Array(),
			deepLinkHashCollectionPrefix:"tab-coll-",
			initialize:function (){
				$(".tabs").each(function (collCount){
					var sId = Sonofon.Page.Tabs.deepLinkHashCollectionPrefix+collCount;
					$(this).attr('id',sId);
					if (typeof($(this).attr("openTab"))=='undefined') $(this).attr("openTab",1);
					$(".tab-btn",$(this)).each(function (counter){							$(this).attr("container",collCount);
						$(this).attr("imageon",Sonofon.Page.Tabs.imgSelPath[counter]);
						$(this).attr("imageoff",Sonofon.Page.Tabs.imgStdPath[counter]);
						$(this).click(function (){
							Sonofon.Page.Tabs.gotoTab($(this).attr("container"),counter+1);
						});
					});
					Sonofon.Page.Tabs.hideAllContent(sId);
					Sonofon.Page.Tabs.gotoTab(collCount,$(this).attr("openTab"));
				});
			},
			reInitTabCollection:function (o){
				$(".tabs",o).each(function (collCount){
					var sId = Sonofon.Page.Tabs.deepLinkHashCollectionPrefix+1000;
					$(this).attr('id',sId);
					if (typeof($(this).attr("openTab"))=='undefined') $(this).attr("openTab",1);										//$(this).attr("imgPath",Sonofon.Page.Tabs.imgPath);					
					$(".tab-btn",$(this)).each(function (counter){
						$(this).attr("imageon",Sonofon.Page.Tabs.imgSelPath[counter]);
						$(this).attr("imageoff",Sonofon.Page.Tabs.imgStdPath[counter]);
						$(this).attr("container",1000);
						$(this).click(function (){
							Sonofon.Page.Tabs.gotoTab($(this).attr("container"),counter+1);
						});
					});
					Sonofon.Page.Tabs.hideAllContent(sId);
					Sonofon.Page.Tabs.gotoTab(1000,$(this).attr("openTab"));
				});
                                                //CHANGES DONE BY TCS FOR CHG0017592
		                //if($.browser.msie){
                			var sc = document.getElementById(o.attr('id')).getElementsByTagName("SCRIPT");
                    			for(var i=0; i<sc.length; i++){
                        	  	  eval(sc[i].innerHTML)
                    			}
                    			this.resetImgSrc(o.attr('id'));
                    			this.gotoTab(1000,1);
		                //}
                                                //END CHANGES
   			},
			gotoTab:function (iCollection,iStep){
				var container = this.deepLinkHashCollectionPrefix+iCollection;
				this.resetImgSrc(container);
				this.hideAllContent(container);
				this.resetZIndices(container);
				this.setTopZIndex($(".tab-btn",$("#"+container)).eq(iStep-1));
				this.setImgSrc(container,iStep-1);
				$(".tab-content",$("#"+container)).eq(iStep-1).show();
				$("#"+container).attr("openTab",iStep);
				Sonofon.Page.FloatingLayer.resizeIframe();
				return false; 
			},
			resetZIndices:function (container){
				$(".tab-btn",$("#"+container)).each(function (counter){
					$(this).css({zIndex:(100-counter)});
				});
			},
			resetImgSrc:function (container){
				$(".tab-btn img",$("#"+container)).each(function (counter){
					$(this).attr('src',$("#"+container+" .tab-btn").eq(counter).attr("imageoff"));
				});
			},
			setImgSrc:function (container, i){
				$("img",$("#"+container+" .tab-btn").eq(i)).attr('src',$("#"+container+" .tab-btn").eq(i).attr("imageon"));
			},
			setTopZIndex:function (o){
				$(o).css({zIndex:101});
			},
			hideAllContent:function (sId){
				$(".tab-content",$("#"+sId)).hide();
			},
			//CHANGES DONE BY TCS FOR CHG0017592
			saveTabs:function(){
    			this.tempStdPath = (new Array()).concat(this.imgStdPath);
	    		this.tempSelPath = (new Array()).concat(this.imgSelPath);
			},
			restoreTabs:function(){
    			this.imgStdPath = this.tempStdPath;
	    		this.imgSelPath = this.tempSelPath;
			}
			//END CHANGES

		}, // @Sonofon.Page.Tabs
		
		Tooltips:{
			initialize:function (){
				
				$(".tooltip-text").hide();
				$(".tooltip-text").css({visibility:"hidden"});

				$(".tooltip").each(function (){
					$(this).click(function (e){
						$(".tooltip-text").hide();
						$(".tooltip-text",this).show();
						$(".tooltip-text",this).css({visibility:"visible"});
						var i = $(".tooltip-text",this).get(0);
						$(".tooltip-text",this).top("-"+(i.offsetHeight-5)+"px");
						if(!e) var e = window.event;
						if(e.stopPropagation){
							e.stopPropagation();
						} else {
							e.cancelBubble = true;
						}
					});
					$(this).mouseover(function (e){
						$(".tooltip-text").hide();
					});
				});
				
			}
		}, // @Sonofon.Page.Tooltips
		
		FloatingLayer:{
			initialize:function (){
				$(".xp-layer-close").each(function (){
					$(this).click(function (e){
						$(this).parent().parent().parent().parent().parent().parent().removeClass("shown");
						$(".layer-body",document.getElementById("xp-layer-2")).html("");
						if(document.getElementById("progressbar")!=null){ // only hide milkmask if we're in a flow
							Sonofon.Page.FloatingLayer.MilkMask.destroy();
						}
//CHANGES DONE BY TCS FOR CHG0017592
    					Sonofon.Page.Tabs.restoreTabs();
    					//END CHANGES
						return false;
					});
				});
			},
			show:function (oConfig){

				// ie 6 iframe/select fix
				try {
					if(1==2 && document.getElementById("ie6fix") == null){ // only create once
						var appendTo = document.getElementById(oConfig.id);
						var oIframe = Sonofon.createElement("IFRAME",{id:"ie6fix",CSSClass:"ie6fix",src:"/blank.html"});
						oIframe.style.width = appendTo.offsetWidth + "px";
						oIframe.style.height = appendTo.offsetHeight + "px";
						appendTo.appendChild(oIframe);
					}
				} catch(e){}

				$("#"+oConfig.id).addClass("shown");

				// set html of xp-layer
				if(oConfig.html != "undefined"){
				    //CHANGES DONE BY TCS FOR CHG0017592
					Sonofon.Page.Tabs.saveTabs();
					//END CHANGES
					Sonofon.Page.FloatingLayer.content({id:oConfig.id,html:oConfig.html});
					Sonofon.Page.Tabs.reInitTabCollection($("#"+oConfig.id));
				}

				// calc x pos
				var sLeft = "";
				if(typeof oConfig.left == "number"){
					sLeft = oConfig.left+"px";
				} else if(typeof oConfig.left == "string"){
					if(oConfig.left == "center"){
						var w = parseInt($("#"+oConfig.id).width());
						sLeft = (Math.round(($(window).width()/2)) - (Math.round(w/2)) ) + $(document).scrollLeft() + "px";
					}
				}

				// calc y pos
				var sTop = "";
				if(typeof oConfig.top == "number"){
					sTop = oConfig.top+"px";
				} else if(typeof oConfig.top == "string"){
					if(oConfig.top == "center"){
						var h = document.getElementById(oConfig.id).offsetHeight;
						sTop = ( Math.round(($(window).height()/2)) - (Math.round(h/2)) ) + $(document).scrollTop() + "px";
					}
				}
				//alert(sLeft + ", "+ sTop)
				if(parseInt(sLeft) < 0){ sLeft = "0px"; }
				if(parseInt(sTop) < 0){ sTop = "0px"; }
				$("#"+oConfig.id).css({left:sLeft,top:sTop});

				if(document.getElementById("progressbar")!=null){ // only show milkmask if we're in a flow
					Sonofon.Page.FloatingLayer.MilkMask.create();
				}

			},
			hide:function (oConfig){
				$("#"+oConfig.id).removeClass("shown");
				$("#"+oConfig.id).addClass("xp-offscreen");
			},
			spawn:function (oConfig){
				
			},
			clone:function (oConfig){

			},
			content:function(oConfig){
				if(typeof oConfig.html == "string"){
					$("#"+oConfig.id + " .layer-body").eq(0).html(oConfig.html);
				} else if(typeof oConfig.html == "object"){
					var devnull = document.getElementById("devnull");
					if(devnull==null){  devnull = Sonofon.createElement("DIV",{id:"devnull"}); }
					$("#"+oConfig.id + " .layer-body").html("");
					$("#"+oConfig.id + " .layer-body").eq(0).append(oConfig.html.html());
					$(devnull).append(oConfig.html);
				}
			},
			resizeIframe:function (){
				if (document.getElementById("xp-layer-2")) {
					var oXP = document.getElementById("xp-layer-2");
					var iframe = oXP.getElementsByTagName("IFRAME");
					if(iframe[0]) iframe[0].style.height = oXP.offsetHeight + "px";
				}
			},
			MilkMask:{
				ieImgUrl:"",
				create:function(){
					if (document.getElementById("col-middle")) {
						var col = document.getElementById("col-middle");
						var oDiv = Sonofon.createElement("DIV",{id:"milkmask",content:"<img src='"+this.ieImgUrl+"' />"});
						oDiv.style.height = col.offsetHeight + "px";
						oDiv.style.width = col.offsetWidth + "px";
						col.appendChild(oDiv);
						var i,j;
						for(i=0; j = col.getElementsByTagName("SELECT")[i]; i++){
							j.style.visibility = "hidden";
						}
					}
				},
				destroy:function (){
					if (document.getElementById("col-middle")) {
						var col = document.getElementById("col-middle");
						var o = document.getElementById("milkmask");
						if(o) try { col.removeChild(o); } catch(e){}
						var i,j;
						for(i=0; j = col.getElementsByTagName("SELECT")[i]; i++){
							j.style.visibility = "visible";
						}
					}
				}
			}

		}, // @Sonofon.Page.FloatingLayer
				
		Switcher:{
			show:function (oConfig){
				// flip elements in oConfig.mother
				$("#"+oConfig.mother+" .hidden").removeClass("hidden");
				return false;
			},
			hide:function (oConfig){
				// flip elements in oConfig.mother
				$("#"+oConfig.mother+" .toggle-target").addClass("hidden");
				return false;
			},
			toggleCheckBox:function (oConfig){
			                var o = oConfig.thisRef;
				if(o.getAttribute("state") != "expanded"){
				    $("#"+oConfig.mother).removeClass("hidden");
				    o.setAttribute("state", "expanded");
				} else
				{
				    $("#"+oConfig.mother).addClass("hidden");
				    o.setAttribute("state", "");
				}
				return false;
			},
			/**
			 *  @param Object - example: { mother: String [required] - the HTML-elements' id attribute, thisRef: Object [required] - reference the the calling object, swapText: String [optional] - the text to replace with, addClass: String [optional] - add this classname to the calling object, deep: Boolean [optional] - Whether or not to only toggle direct children of the calling object }
			*/
			toggle:function (oConfig){
				// flip all elements in oConfig.mother with classnames = .toggle-target.hidden
				if(typeof oConfig.mother == "string"){
					if(oConfig.deep === false){ // only direct children
						$("#"+oConfig.mother+" > .toggle-target.hidden").removeClass("hidden");
					} else { 					// all children below mother
						$("#"+oConfig.mother+" .toggle-target.hidden").removeClass("hidden");
					}
					var o = oConfig.thisRef;
					if(o.getAttribute("state") != "expanded"){
						if(oConfig.swapText != undefined){
							// save the original nodeValue in custom attribute
							o.origText = o.firstChild.nodeValue;
							o.firstChild.nodeValue = oConfig.swapText;
						}
						if(oConfig.addClass != undefined){
							$(o).addClass(oConfig.addClass);
						}
						o.setAttribute("state","expanded");
					} else {
						if(oConfig.swapText != undefined){
							o.firstChild.nodeValue = o.origText;
						}
						if(oConfig.addClass != undefined){
							$(o).removeClass(oConfig.addClass);
						}
						o.setAttribute("state","");
						
						if(oConfig.deep === false){
							$("#"+oConfig.mother+" > .toggle-target").addClass("hidden");
						} else {
							$("#"+oConfig.mother+" .toggle-target").addClass("hidden");
						}
					}
				} else {
					for(var i=0; i<oConfig.mother.length; i++){
						var elm = oConfig.mother[i];
						window.console.log(elm)
						$("#"+elm+" .toggle-target.hidden").removeClass("hidden");
						var o = oConfig.thisRef;
						if(o.getAttribute("state") != "expanded"){
							if(oConfig.swapText != undefined){
								// save the original nodeValue in custom attribute
								o.origText = o.firstChild.nodeValue;
								o.firstChild.nodeValue = oConfig.swapText;
							}
							if(oConfig.addClass != undefined){
								$(o).addClass(oConfig.addClass);
							}
							o.setAttribute("state","expanded");
						} else {
							if(oConfig.swapText != undefined){
								o.firstChild.nodeValue = o.origText;
							}
							if(oConfig.addClass != undefined){
								$(o).removeClass(oConfig.addClass);
							}
							o.setAttribute("state","");
							$("#"+elm+" .toggle-target").addClass("hidden");
						}
					} // for()
				}
				try { Sonofon.Page.Layout.resizeRightCol(); } catch(e){ }
				return false;
			}
		}, // @Sonofon.Page.Switcher
		
		Cookie:{
			create:function(name,value,days){
				if(days){
					var date = new Date();
					date.setTime(date.getTime()+(days*24*60*60*1000));
					var expires = "; expires="+date.toGMTString();
				} else {
					expires = "";
				}
				document.cookie = name+"="+value+expires+"; path=/";
			},
			read:function(name){
				var nameEQ = name + "=";
				var ca = document.cookie.split(';');
				for(var i=0; i<ca.length; i++){
					var c = ca[i];
					while (c.charAt(0)==' ') c = c.substring(1,c.length);
					if(c.indexOf(nameEQ)==0) return c.substring(nameEQ.length,c.length);
				}
				return null;
			}
		}, // @Sonofon.Page.Cookie
		
		Popup:function (thisRef){
			var win = window.open(thisRef.href);
			return false;
		}, // @Sonofon.Page.Popup

		print:function (){
			try {
				window.print(); 
			} catch(e){}
			return false;
		}, // @Sonofon.Page.Print
		
		Forms:{
			emptyOnFocus:function (oThis){
        	                                try {
		                   oThis.value = "";
		                   if(oThis.className.indexOf("input-em") != -1){
			       oThis.setAttribute("special-class",true);
			       oThis.className = oThis.className.replace("input-em","");
		                   }
		            
		                   if(oThis.onblur != undefined){
			     oThis.onblur = function (){
			       if(this.value == ""){
			         this.value = this.defaultValue;
			         if(this.getAttribute("special-class")){
			           this.className += " input-em";
			         }
			       }
			     }
    		                   }
 	                                 } catch(e){}
                                          }

		}, // @Sonofon.Page.Forms
		
		Layout:{
			resizeRightCol:function (){
				if($("#col-right-inner").attr('id') && ($("#basket").attr('id') || $("#ucLogin_ucLogin_Panel1").attr('id'))){
					$("#col-right-inner").css("height","auto");
					if ($("#basket").attr('id'))
						var rightColOffsetTop = document.getElementById("basket").offsetHeight;
					else
						var rightColOffsetTop = document.getElementById("ucLogin_ucLogin_Panel1").offsetHeight;
					var rightColheight = document.getElementById("col-right-inner").offsetHeight;
					var contentHeight = document.getElementById("meat").offsetHeight;
					var lessIsMore = (document.body.className.indexOf("front") != -1 ? 20 : 0);
					if (contentHeight>(rightColOffsetTop+rightColheight)) $("#col-right-inner").css("height",contentHeight-rightColOffsetTop-lessIsMore+"px");
				}
			},
			hideRightColShadowIfInFlow:function (){
				if(document.getElementById("progressbar")!=null){
					if(document.getElementById("col-right-inner")!=null)
						document.getElementById("col-right-inner").style.display = "none";
				}
			}
		}, // @Sonofon.Page.Layout
		
		start:function (){
									
			/**
			 * 
			*/
			Sonofon.Page.Flow.initialize();

			/**
			 * Creates all handlers for buttons and show/hide of content within a div with class="tabs".
			 * The internal structure of the HTML is extremely important to make it work. CSS classes must
			 * be typed exactly as in the prototype.
			*/
			Sonofon.Page.Tabs.initialize();

			/**
			 * Converts an ul with id="faq" and class="expandable-link-list" to an 
			 * expand/collapse list with a different appearance than the GenericExpandList.
			*/
			Sonofon.Page.FAQ.initialize();

			/**
			 * Every ul on the page with class="list-element-expand" will be converted to an expand/collapse list
			 * Appearance can be customized in the stylesheet (search for ".list-element-expand").
			 * The internal structure of the HTML is extremely important to make it work. CSS classes must
			 * be typed exactly as in the prototype.
			*/
			Sonofon.Page.GenericExpandList.initialize();

			/**
			 * Initializes all elements with class="tooltip" to show and hide an element inside the first
			 * element onclick. Appearance can be customized in the stylesheet.
			*/
			// pt. deaktiveret da den ødelægger link popup i nyt vindue
			Sonofon.Page.Tooltips.initialize();

			/**
			 * 
			*/
			Sonofon.Page.FloatingLayer.initialize();
						/**
			 * Resizes the background-image in the right column to expand all the way down to the footer.
			*/

			
		} // @Sonofon.Page.start
		
	} // @Sonofon.Page
} // @Sonofon



$(function (){
	Sonofon.Page.start();
});
Sonofon.Page.FloatingLayer.MilkMask.ieImgUrl = "/Images/milkmask_tcm52-26946.gif";

function tabInit() {

}

function DomWindowInit() {
	Sonofon.Page.Tabs.saveTabs();
	Sonofon.Page.Tabs.reInitTabCollection($('#DOMWindow'));
	Cufon.refresh('#DOMWindow');
}

function flashClick(element) {
	$(element).click();
}
$(document).ready(function (){
	$('.roundcorners').each(function (){ $(this).corner("cc:#fff") });
});

    function ChangeLabelColorForValidator(val){
        var lbl = document.getElementById(val.controltovalidate + '_lbl');
        if(lbl!= null ){
            // Find label through naming rule
            var k, value;

            // Find out all validators associated
            var vals = new Array();
            for(k=0; k < Page_Validators.length; k++){
                if(Page_Validators[k].controltovalidate == val.controltovalidate)
                    vals.push(Page_Validators[k]);
            }

            //Determine if some validator fails
            value = true;
            for(k=0; k < vals.length;k++)
                value = (value && vals[k].isvalid);
            
            ChangeLabelColor(lbl, value);
            var req = document.getElementById(val.controltovalidate + '_req');
            if (req!=null) {
                ChangeLabelColor(req, value);
            }
        }        
    }
    
    function SetErrorLabelColor(labelName) {
        var lbl = document.getElementById(labelName + '_lbl');
        if (lbl!=null) {
            ChangeLabelColor(lbl, false);
        }
        var req = document.getElementById(labelName + '_req');
        if (req!=null) {
            ChangeLabelColor(req, false);
        }
    }

    function ChangeLabelColor(lbl, valid){
            // Change label text color
            if (valid) {
                lbl.style.color = ''; // no style on label...
                lbl.style.fontWeight = '';
            }else{
                lbl.style.color = 'red'; // error color, red
                //lbl.style.fontWeight = 'bold';
            }    
    }


