﻿if(!window.c1_webutil_loaded)
{
    window.c1_browser_userAgent=(navigator==null||navigator.userAgent==null)?'':navigator.userAgent.toLowerCase();
	window.c1_browser_appVersion=(navigator==null||navigator.appVersion==null)?'':navigator.appVersion;
	window.c1_browser_major=parseInt(c1_browser_appVersion);
	window.c1_browser_opera=c1_browser_userAgent.indexOf('opera')!=-1;
	window.c1_browser_ie=!c1_browser_opera&&(c1_browser_userAgent.indexOf('msie')!=-1);
	window.c1_browser_iemac=c1_browser_ie&&(c1_browser_userAgent.indexOf('mac')!=-1);
	window.c1_browser_safari=c1_browser_userAgent.indexOf('safari')!=-1;
	window.c1_browser_konqueror=c1_browser_userAgent.indexOf('konqueror')!=-1;
	window.c1_browser_mozilla=!c1_browser_ie&&!c1_browser_opera&&((c1_browser_userAgent.indexOf('netscape')!=-1)||(c1_browser_userAgent.indexOf('mozilla')!=-1))&&(c1_browser_major>=5);
	window.c1_browser_ie3=c1_browser_ie&&(c1_browser_major<4);
	window.c1_browser_ie4=c1_browser_ie&&(c1_browser_major==4)&&(c1_browser_userAgent.indexOf("msie 4")!=-1);
	window.c1_browser_ie5point5=c1_browser_ie&&(c1_browser_major==4)&&(c1_browser_userAgent.indexOf("msie 5.5")!=-1);
	window.c1_browser_ie5=c1_browser_ie&&(c1_browser_major==4)&&(c1_browser_userAgent.indexOf("msie 5")!=-1)&&!c1_browser_ie5point5;
	window.c1_browser_ie5point5plus=c1_browser_ie&&!c1_browser_ie3&&!c1_browser_ie4&&!c1_browser_ie5;
	window.c1_browser_transitions=c1_browser_ie5point5plus&&(c1_browser_userAgent.indexOf('nt 4')==-1);
	window.c1_browser_ie6plus=c1_browser_ie&&!c1_browser_ie3&&!c1_browser_ie4&&!c1_browser_ie5&&!c1_browser_ie5point5;
	window.c1_browser_ie7=c1_browser_ie&&(c1_browser_major==4)&&(c1_browser_userAgent.indexOf("msie 7")!=-1);
	window.c1_browser_shadows=c1_browser_ie6plus;
	window.c1_browser_n6=(c1_browser_userAgent.indexOf('netscape6')!=-1);
	window.c1_browser_overlays=c1_browser_ie5point5plus;
	window.c1_browser_addeventhandlers=!c1_browser_iemac;
	window.c1_browser_backcompatie=c1_browser_ie&&(!c1_browser_ie6plus||document.compatMode=="BackCompat");
	window.c1_browser_backcompatopera=c1_browser_opera&&document.compatMode=="QuirksMode";
	window.c1_browser_backcompat=c1_browser_backcompatie||c1_browser_backcompatopera;
	window.c1_browser_css1compat=document.compatMode=="CSS1Compat";
	window.c1_browser_filters=null;
	
	window.DetectFilters=function()
	{
		try{document.body.filters; return true;}
		catch(e){return false;};
	};
	
	if (c1_browser_shadows||c1_browser_transitions)
	{
	    if(c1_browser_filters==null)
		{
			c1_browser_filters=DetectFilters();
		};
	}
	
	//==Constants============================
    var c1_slidetype_none = 0;
    var c1_slidetype_constant = 1;
	var c1_slidetype_expaccelerate = 2;
	var c1_slidetype_expdecelerate = 3;
	var c1_slidetype_quadaccelerate = 4;
	var c1_slidetype_quaddecelerate = 5;	
	
    var c1_transtype_none = 0;
    var c1_transtype_custom = 1;
    var c1_transtype_dissolve = 2;
    var c1_transtype_fade = 3;
    var c1_transtype_iriscircle = 4;
    var c1_transtype_iriscirclein = 5;
    var c1_transtype_iriscross = 6;
    var c1_transtype_iriscrossin = 7;
    var c1_transtype_irisdiamond = 8;
    var c1_transtype_irisdiamondin = 9;
    var c1_transtype_irisplus = 10;
    var c1_transtype_irisplusin = 11;
    var c1_transtype_irissquare = 12;
    var c1_transtype_irissquarein = 13;
    var c1_transtype_irisstar = 14;
    var c1_transtype_irisstarin = 15;
    var c1_transtype_pixelate = 16;
    var c1_transtype_wheel2 = 17;
    var c1_transtype_wheel8 = 18;
    var c1_transtype_wipedown = 19;
    var c1_transtype_wipeleft = 20;
    var c1_transtype_wiperight = 21;
    var c1_transtype_wipeup = 22;
    
    

	function C1_GetElementBounds(element)
	{
	    var bdrTop = 0;
	    var bdrRight = 0;
	    var bdrBottom = 0;
	    var bdrLeft = 0;
	    var padTop = 0;
	    var padRight = 0;
	    var padBottom = 0;
	    var padLeft = 0;
	    
	    if(element.currentStyle)
		{
			var style = element.currentStyle;
			bdrTop = parseInt(style.borderTopWidth);
			bdrTop = isNaN(bdrTop)?0:bdrTop;
			bdrRight = parseInt(style.borderRightWidth);
			bdrRight = isNaN(bdrRight)?0:bdrRight;
			bdrBottom = parseInt(style.borderBottomWidth);
			bdrBottom = isNaN(bdrBottom)?0:bdrBottom;
			bdrLeft = parseInt(style.borderLeftWidth);
			bdrLeft = isNaN(bdrLeft)?0:bdrLeft;
			padTop = parseInt(style.paddingTop);
			padTop = isNaN(padTop)?0:padTop;
			padRight = parseInt(style.paddingRight);
			padRight = isNaN(padRight)?0:padRight;
			padBottom = parseInt(style.paddingBottom);
			padBottom = isNaN(padBottom)?0:padBottom;
			padLeft = parseInt(style.paddingLeft);
			padLeft = isNaN(padLeft)?0:padLeft;
		}else if(document.defaultView&&document.defaultView.getComputedStyle)
		{
			var style = document.defaultView.getComputedStyle(element,'');
			bdrTop = parseInt(style.getPropertyValue("border-top-width"));
			bdrTop = isNaN(bdrTop)?0:bdrTop;
			bdrRight = parseInt(style.getPropertyValue("border-right-width"));
			bdrRight = isNaN(bdrRight)?0:bdrRight;
			bdrBottom = parseInt(style.getPropertyValue("border-bottom-width"));
			bdrBottom = isNaN(bdrBottom)?0:bdrBottom;
			bdrLeft = parseInt(style.getPropertyValue("border-left-width"));
			bdrLeft = isNaN(bdrLeft)?0:bdrLeft;
			padTop = parseInt(style.getPropertyValue("padding-top"));
			padTop = isNaN(padTop)?0:padTop;
			padRight = parseInt(style.getPropertyValue("padding-right"));
			padRight = isNaN(padRight)?0:padRight;
			padBottom = parseInt(style.getPropertyValue("padding-bottom"));
			padBottom = isNaN(padBottom)?0:padBottom;
			padLeft = parseInt(style.getPropertyValue("padding-left"));
			padLeft = isNaN(padLeft)?0:padLeft;
		}
		
		return [bdrLeft + padLeft, bdrTop + padTop, bdrRight + padRight, bdrBottom + padBottom];
	}

    window.C1_GetTransitionString=function(trans, custom)
    {
        var prefix = 'progid:DXImageTransform.Microsoft.';
	    switch(trans)
	    {
		    case c1_transtype_none:return null;
		    case c1_transtype_custom:return custom;
		    case c1_transtype_dissolve:return prefix + 'RandomDissolve()';
		    case c1_transtype_fade:return prefix + 'Fade()';
		    case c1_transtype_iriscircle:return prefix + 'Iris(irisStyle=CIRCLE)';
		    case c1_transtype_iriscirclein:return prefix + 'Iris(irisStyle=CIRCLE,motion=in)';
		    case c1_transtype_iriscross:return prefix + 'Iris(irisStyle=CROSS)';
		    case c1_transtype_iriscrossin:return prefix + 'Iris(irisStyle=CROSS,motion=in)';
		    case c1_transtype_irisdiamond:return prefix + 'Iris(irisStyle=DIAMOND)';
		    case c1_transtype_irisdiamondin:return prefix + 'Iris(irisStyle=DIAMOND,motion=in)';
		    case c1_transtype_irisplus:return prefix + 'Iris(irisStyle=PLUS)';
		    case c1_transtype_irisplusin:return prefix + 'Iris(irisStyle=PLUS,motion=in)';
		    case c1_transtype_irissquare:return prefix + 'Iris(irisStyle=SQUARE)';
		    case c1_transtype_irissquarein:return prefix + 'Iris(irisStyle=SQUARE,motion=in)';
		    case c1_transtype_irisstar:return prefix + 'Iris(irisStyle=STAR)';
		    case c1_transtype_irisstarin:return prefix + 'Iris(irisStyle=STAR,motion=in)';
		    case c1_transtype_pixelate:return prefix + 'Pixelate(MaxSquare=20)';
		    case c1_transtype_wheel2:return prefix + 'Wheel(spokes=2)';
		    case c1_transtype_wheel8:return prefix + 'Wheel(spokes=8)';
		    case c1_transtype_wipedown:return prefix + 'Wipe(GradientSize=1.0,wipeStyle=1)';
		    case c1_transtype_wipeleft:return prefix + 'Wipe(GradientSize=1.0,wipeStyle=0,motion=reverse)';
		    case c1_transtype_wiperight:return prefix + 'Wipe(GradientSize=1.0,wipeStyle=0)';
		    case c1_transtype_wipeup:return prefix + 'Wipe(GradientSize=1.0,wipeStyle=1,motion=reverse)';
	    };
    	
	    return null;
    };
    
    window.C1_ElementContains=function(element1, element2)
    {
	    if(element2==null||element1==null){return false;};
	    if(c1_browser_ie){return element1.contains(element2);};
	    if(element2==element1){return true;}
    	
	    while(element2.parentNode)
	    {
		    element2=element2.parentNode;
		    if(element2==element1){return true;};
	    };
	    return false;
    };
    
    window.C1_AddEventHandler=function(element,eventName,handler)
    {
	    if(!window.c1_browser_addeventhandlers){return false;};
	    if(element.attachEvent)
	    {
		    return element.attachEvent("on"+eventName,handler);
	    }else if(element.addEventListener)
	    {
		    element.addEventListener(eventName,handler,false);
		    return true;
	    };
	    return false;
    };
		
    window.C1_RemoveEventHandler=function(element,eventName,handler)
    {
	    if(!window.c1_browser_addeventhandlers){return false;};
	    if(element.detachEvent)
	    {
		    return element.detachEvent("on"+eventName,handler);
	    }else if(element.removeEventListener)
	    {
		    element.removeEventListener(eventName,handler,false);
		    return true;
	    };
    	
	    return false;
    };
	
	window.C1_GetPageOffsetLeft=function(element)
	{
		return c1_browser_ie?C1_GetPageOffsetLeft_IE(element):C1_GetPageOffsetLeft_Mozila(element);
	};
	
	window.C1_GetPageOffsetTop=function(element)
	{
		return c1_browser_ie?C1_GetPageOffsetTop_IE(element):C1_GetPageOffsetTop_Mozila(element);
	};
	
	window.C1_GetPageOffsetLeft_IE=function(element)
	{
		return(c1_browser_iemac?C1_GetPageOffsetLeft_IEMac(element):c1_browser_ie4?C1_GetPageOffsetLeft_IE4(element):C1_GetPageOffsetLeft_IE4Plus(element));
	};
	
	window.C1_GetPageOffsetTop_IE=function(element)
	{
		return(c1_browser_iemac?C1_GetPageOffsetTop_IEMac(element):c1_browser_ie4?C1_GetPageOffsetTop_IE4(element):C1_GetPageOffsetTop_IE4Plus(element));
	};

	window.C1_GetPageOffsetLeft_IE4Plus = function(element) 
	{
	    var x = 0;
	    while (element.offsetParent != null) 
	    {
	        x += element.offsetLeft;

	        if (element.offsetParent.tagName != "TABLE"
				&& element.offsetParent.tagName != "TD"
				&& element.offsetParent.tagName != "TR"
				&& element.offsetParent.currentStyle != null) {
	            var bdrLeft = parseInt(element.offsetParent.currentStyle.borderLeftWidth);
	            if (!isNaN(bdrLeft)) { x += bdrLeft; };
	        };

	        if (element.offsetParent.tagName == "TABLE"
				&& element.offsetParent.border > 0) {
	            x += 1;
	        };

	        element = element.offsetParent;
	    };

	    if (element != null && element.offsetParent == null && element != document.body)
	        x += element.offsetLeft;

	    if (c1_browser_css1compat && element == document.body) {
	        var marginLeft = parseInt(element.currentStyle.marginLeft);
	        if (!isNaN(marginLeft))
	        { x += marginLeft; };
	    };


	    return x;
	};

	window.C1_GetPageOffsetTop_IE4Plus = function(element) 
	{
	    var y = 0;
	    while (element.offsetParent != null) 
	    {
	        y += element.offsetTop;

	        if (element.offsetParent.tagName != "TABLE"
				&& element.offsetParent.tagName != "TD"
				&& element.offsetParent.tagName != "TR"
				&& element.offsetParent.currentStyle != null) {
	            var bdrTop = parseInt(element.offsetParent.currentStyle.borderTopWidth);
	            if (!isNaN(bdrTop)) { y += bdrTop; };
	        };

	        if (element.offsetParent.tagName == "TABLE"
				&& element.offsetParent.border > 0)
	        { y += 1; };

	        element = element.offsetParent;
	    };

	    if (element != null && element.offsetParent == null && element != document.body)
	        y += element.offsetTop;

	    if (c1_browser_css1compat && element == document.body) {
	        var marginTop = parseInt(element.currentStyle.marginTop);
	        if (!isNaN(marginTop)) { y += marginTop; };
	    };
	    return y;
	};
	
	window.C1_GetPageOffsetLeft_IE4=function(element)
	{
		var x=0;
		while(element!=document.body)
		{
			x+=element.offsetLeft;
			element=element.offsetParent;
		};
		return x;
	};
	
	window.C1_GetPageOffsetTop_IE4=function(element)
	{
		var y=0;
		while(element!=document.body)
		{
			y+=element.offsetTop;
			element=element.offsetParent;
		};
		return y;
	};
	
	window.C1_GetPageOffsetLeft_IEMac=function(element)
	{
		var x=0;
		while(element.offsetParent!=document.body)
		{
			x+=element.offsetLeft;
			element=element.offsetParent;
		};
		
		x+=(element.offsetLeft+C1_GetBodyOffsetX());
		return x;
	};
	
	window.C1_GetPageOffsetTop_IEMac=function(element)
	{
		var y=0;
		while(element.offsetParent!=document.body)
		{
			y+=element.offsetTop;
			element=element.offsetParent;
		};
		
		y+=(element.offsetTop+C1_GetBodyOffsetY());
		return y;
	};
	
	window.C1_GetBodyOffsetX=function()
	{
		if(c1_bodymarginleft==null)
		{
			if(!document.all["c1_trick"])
				{C1_AddTrickElement();};
			
			c1_bodymarginleft=-document.all["c1_trick"].offsetLeft;
		};
		
		return c1_bodymarginleft;
	};
	
	window.C1_GetBodyOffsetY=function()
	{
		if(c1_bodymargintop==null)
		{
			if(!document.all["c1_trick"])
				{C1_AddTrickElement();};
		
		c1_bodymargintop=-document.all["c1_trick"].offsetTop;
		};
	
		return c1_bodymargintop;
	};

	window.C1_AddTrickElement=function()
	{
		document.body.insertAdjacentHTML('beforeEnd','<div id="c1_trick" style="position:absolute;left:0;top:0;z-index:-1000;visibility:hidden">*</div>');
	};
	
	window.C1_GetPageOffsetLeft_Mozila=function(element)
	{
		var x=0;
		do
		{
			if(element.style.position=='absolute')
				{return x+element.offsetLeft;}
			else
			{
				x+=element.offsetLeft;
				if(element.offsetParent)
				{
					if(element.offsetParent.tagName=='TABLE'
						&&!c1_browser_safari
						&&!c1_browser_konqueror)
					{
						if(parseInt(element.offsetParent.border)>0){x+=1;};
					};
				};
			};
		}while((element=element.offsetParent));
		
		return(c1_browser_konqueror?x+C1_BodyMarginLeft():x);
	};
	
	window.C1_GetPageOffsetTop_Mozila=function(element)
	{
		var y=0;
		do
		{
			if(element.style.position=='absolute')
			{
				return y+element.offsetTop;
			}
			else
			{
				y+=element.offsetTop;
				if(element.offsetParent)
				{
					if(element.offsetParent.tagName=='TABLE'
						&&!c1_browser_safari
						&&!c1_browser_konqueror)
					{
						if(parseInt(element.offsetParent.border)>0)
							{y+=1;};
					};
				};
			};
		}while((element=element.offsetParent));
		
		return(c1_browser_konqueror?y+C1_BodyMarginTop():y);
	};
	
	window.C1_BodyMarginLeft=function()
	{
		if(c1_bodymarginleft==null)
		{
			c1_bodymarginleft=C1_GetBodyMarginLeft();
		};
		
		return c1_bodymarginleft;
	};
	
	window.C1_BodyMarginTop=function()
	{
		if(c1_bodymargintop==null)
		{
			c1_bodymargintop=C1_GetBodyMarginTop();
		};
		return c1_bodymargintop;
	};
	
	window.C1_GetBodyMarginLeft=function()
	{
		if(!isNaN(parseInt(document.body.style.marginLeft)))
		{
			return parseInt(document.body.style.marginLeft);
		};
		if(!isNaN(parseInt(document.body.style.margin)))
		{
			return parseInt(document.body.style.margin);
		};
		if(!isNaN(parseInt(document.body.leftMargin)))
		{
			return parseInt(document.body.leftMargin);
		};
		return 10;
	};
	
	window.C1_GetBodyMarginTop=function()
	{
		if(!isNaN(parseInt(document.body.style.marginTop)))
		{
			return parseInt(document.body.style.marginTop);
		};
		if(!isNaN(parseInt(document.body.style.margin)))
		{
			return parseInt(document.body.style.margin);
		};
		if(!isNaN(parseInt(document.body.topMargin)))
		{
			return parseInt(document.body.topMargin);
		};
		return 10;
	};
	

	function C1_IsStringNullOrEmpty(str)
	{
	    if (!str) return true;
	    
	    if (str == null) return true;
	    if (str == "") return true;
	    
	    return false;
	};
	
	window.C1_CalcVisibleRatio=function(passed, duration, slidetype)
	{
		if(slidetype==c1_slidetype_none||passed>=duration)
		{
			return 1;
		};
		
		var percentage=passed/duration;
		var ret;
		
		switch(slidetype)
		{
			case c1_slidetype_constant:
				ret=percentage;
				break;
				
			case c1_slidetype_expdecelerate:
			case c1_slidetype_expaccelerate:
				ret=1 - Math.pow(1/300,percentage);
				break;
				
			case c1_slidetype_quaddecelerate:
			case c1_slidetype_quadaccelerate:
				ret=1 - Math.pow(percentage,2);
				break;
		};
		
		return Math.min(Math.max(0,ret),1);
	};
	
	window.C1_GetParentTableElement = function(element)
	{
	    var parent;
	    if (c1_browser_ie)
	        parent = element.parentElement;
	    else
	        parent = element.parentNode;
	        
	    while (parent)
	    {
	        if (parent.tagName.toLowerCase() == "table")
	            return parent;
	    
	        if (c1_browser_ie)
	           parent = parent.parentElement;
	        else
	           parent = parent.parentNode;
	    }
	    
	    return parent
	};
	
	
	//===HtmlTextWriter=========================
 	function HtmlTextWriter()
	{
	    this.html=[];
	}

    HtmlTextWriter.prototype.WriteTagLeftChar = function()
	{
	    this.html[this.html.length] = "<";
	}

	HtmlTextWriter.prototype.WriteTagRightChar = function()
	{
	    this.html[this.html.length] = ">";
	}
	
	HtmlTextWriter.prototype.Write = function(str)
	{
	    this.html[this.html.length] = " " + str + " ";
	}
	
	HtmlTextWriter.prototype.WriteBeginTag = function(tagName)
	{
	    this.html[this.html.length] = "<" + tagName;
	}
	
	HtmlTextWriter.prototype.WriteEndTag = function(tagName)
	{
	    this.html[this.html.length] = "</" + tagName + ">";
	}
	
	HtmlTextWriter.prototype.WriteFullBeginTag = function(tagName)
	{
	    this.html[this.html.length] = "<" + tagName + ">";
	}
	
	HtmlTextWriter.prototype.WriteSelfClosingTagEnd = function()
	{
	    this.html[this.html.length] = "/>";
	}
	
	HtmlTextWriter.prototype.WriteAttribute = function(name, value)
	{
	     if (value != undefined && value != null)
        {
            this.html[this.html.length] = " " + name + '="';
            this.html[this.html.length] = value;
            this.html[this.html.length] = '"';
        }
	}
	
	HtmlTextWriter.prototype.Clean = function()
	{
	    this.html = [];
	}
	
	HtmlTextWriter.prototype.ToString = function()
	{
	    return this.html.join('');	    
	}
	
    function C1_Split__String(aString, aDelim, aCount) 
    {
		if(aCount == undefined)
			return aString.split(aDelim);
		var aResultArray = new Array();
		var arr = aString.split(aDelim);
		for(var i=0; i<arr.length; i++) {
			if(i >= aCount) {
				aResultArray[aCount-1] = aResultArray[aCount-1] + aDelim + arr[i];
			} else {
				aResultArray.push(arr[i]);
			}
		}
		return aResultArray;
    }
	
    String.c1format=function()
    {
	    return String._c1toFormattedString(true, arguments)
    };

    String.c1_LocalFormat=function()
    {
	    return String._c1toFormattedString(true, arguments)
    };

    String._c1toFormattedString=function(local,args)
    {
	    var result="";
	    var format=args[0];
	    for(var pos=0;true;)
	    {
		    var start=format.indexOf("{",pos);
		    var end=format.indexOf("}",pos);

		    if(start<0&&end<0)
		    {
			    result+=format.slice(pos);
			    break
		    }
    		
		    if(end>0&&(end<start||start<0))
		    {
			    result+=format.slice(pos,end+1);
			    pos=end+2;
			    continue
		    }
    		
		    result+=format.slice(pos,start);
		    pos=start+1;
		    if(format.charAt(pos)==="{")
		    {
			    result+="{";
			    pos++;
			    continue
		    }
    		
		    if(end<0)break;
		    var f=C1_Split__String(format.slice(pos,end), ":", 2);
		    var i=parseInt(f[0])+1;
		    var arg=args[i];
		    if(typeof arg==="undefined"||arg===null)
			    arg="";

		    if(arg.toFormattedString)
			    result+=arg.toFormattedString(f[1]?f[1]:"");
		    else if(local&&arg.c1_LocalFormat)
			    result+=arg.c1_LocalFormat(f[1]?f[1]:"");
		    else if(arg.format) 
			    result+=arg.format(f[1]?f[1]:"");
		    else result+=arg.toString();
    		
		    pos=end+1
	    }
    	
	    return result
    };
	
    String.prototype.zf = function(l) 
    {
        if (l <= this.length) return this;
        var pad = new Array(l-this.length);
        for(var i = 0; i < pad.length; i++)
            pad[i] = 0;
            
        pad = pad.join('');
        return pad + this; 
    };

    Number.prototype.zf = function(l) { return this.toString().zf(l); }
	
	//===Date==============================
	Date.prototype.c1_GetDateOnly=function()
    {
	    return new Date(this.getFullYear(),this.getMonth(),this.getDate());
    }
    
    Date.prototype.c1_AddDays=function(days)
    {
	    return new Date(this.getFullYear(),this.getMonth(),this.getDate() + days);
    }
    
    Date.prototype.c1_AddMonths=function(months)
    {
	    return new Date(this.getFullYear(),this.getMonth() + months, 1);
    }
    
    Date.prototype.c1_AddYears=function(years)
    {
	    return this.c1_AddMonths(years*12);
    }
    
    Date.prototype.c1_IsSameDate=function(date)
    {
        return (this.getFullYear() == date.getFullYear() && this.getMonth() == date.getMonth() && this.getDate() == date.getDate());
    }
    
    Date.prototype.c1_GetDayOfYear=function()
    {
        var start = new Date(this.getFullYear(), 0, 1)
        var distance = this.valueOf() - start.valueOf();
        var days = distance / (24 * 60 * 60 * 1000);
        return Math.floor(days) + 1;
    }
    
    Date.prototype.c1_GetWeekOfYear=function(firstDayOfWeek)
    {
        if (!firstDayOfWeek) firstDayOfWeek = 0;

        var days = this.c1_GetDayOfYear() - 1;
        var offset = this.getDay() - (days % 7);
        offset = ((offset - firstDayOfWeek) + 14) % 7;
        
        var weeks = ((days + offset) / 7);
        return Math.floor(weeks) + 1;
    }
    
    Date.prototype.c1_GetWeekStartDate=function(firstDayOfWeek)
    {
        return new Date(this.getFullYear(),this.getMonth(),this.getDate()-((this.getDay()-firstDayOfWeek+7)%7));
    }
    
    Date.prototype.c1_GetDaysInMonth = function()
    {
        return new Date(this.getFullYear(),this.getMonth() + 1, 0).getDate();
    }
    
     Date.prototype.toString = function()
    {
        return this.getFullYear() + '/' + (this.getMonth() + 1) + '/' + this.getDate();
    }
    
	Date.prototype.format = function(f)
	{
	    return Date.c1_LocalFormat(f);
	}
	
    Date.prototype.c1_LocalFormat = function(f)
    {
        if (!this.valueOf())
            return '&nbsp;';

        var d = this;
        return f.replace(/(yyyy|yy|y|MMMM|MMM|MM|M|dddd|ddd|dd|d|HH|H|hh|h|mm|m|ss|s|t)/gi,
		  	    function($1)
		  	    {
			          switch ($1)
			          {
			          case 'yyyy': return d.getFullYear();
			          case 'yy':   return (d.getFullYear()%100).zf(2);
			          case 'y':    return (d.getFullYear()%100);
			          case 'MMMM': return c1_monthnames[d.getMonth()];
			          case 'MMM':  return c1_monthnames[d.getMonth()].substr(0, 3);
			          case 'MM':   return (d.getMonth() + 1).zf(2);
			          case 'M':    return (d.getMonth() + 1);
			          case 'dddd': return c1_daynames[d.getDay()];
			          case 'ddd':  return c1_abbdaynames[d.getDay()];
			          case 'dd':   return d.getDate().zf(2);
			          case 'd':	   return d.getDate();
			          case 'HH':   return d.getHours().zf(2);
			          case 'H':    return d.getHours();
			          case 'hh':   return ((h = d.getHours() % 12) ? h : 12).zf(2);
			          case 'h':    return ((h = d.getHours() % 12) ? h : 12);
			          case 'mm':   return d.getMinutes().zf(2);
			          case 'm':    return d.getMinutes();
			          case 'ss':   return d.getSeconds().zf(2);
			          case 's':    return d.getSeconds();
			          case 't':	 return d.getHours() < 12 ? 'A.M.' : 'P.M.';
			          }
		  	    }
		    );
    }

	function C1_Calendar_FindDate(date,dates)
    {
	    var index=null;
	    var lowerBound=0;
	    var upperBound=dates.length;
	    
	    while(lowerBound<upperBound)
	    {
		    index=(lowerBound+upperBound)>>1;
		    if(date.valueOf()==dates[index].valueOf()){return[index,true];};
    		
		    if(date<dates[index])
		    {
			    upperBound=index;
		    }else
		    {
			    lowerBound=index+1;
		    };
	    };
    	
	    return[lowerBound,false];
    };
	
	//===C1_Hashtable========================================
    function C1_Hashtable()
    {
        this.hashtable 	= new Array();
    }

    C1_Hashtable.prototype.clear = function()
    {
        this.hashtable = new Array();
    }

    C1_Hashtable.prototype.containsKey = function (key)
    {
        var exists = false;

        for (var i in this.hashtable)
        {
            if (i == key && this.hashtable[i] != null)
            {
                exists = true;
                break;
            }
        }
        return exists;
    }

    C1_Hashtable.prototype.containsValue = function(value)
    {
        var contains = false;

        if (value != null)
        {
            for (var i in this.hashtable)
            {
                if (this.hashtable[i] == value)
                {
                    contains = true;
                    break;
                }
            }
        }

        return contains;
    }


    C1_Hashtable.prototype.get = function(key)
    {
        return this.hashtable[key];
    }

    C1_Hashtable.prototype.isEmpty = function()
    {
        return (this.size == 0) ? true : false;
    }

    C1_Hashtable.prototype.keys = function()
    {
        var keys = new Array();

        for (var i in this.hashtable)
        {
            if (this.hashtable[i] != null)
                keys.push(i);
        }
        return keys;
    }

    C1_Hashtable.prototype.put = function(key, value)
    {
        if (key == null || value == null)
        {
            throw "NullPointerException {" + key + "},{" + value + "}";
        }
        else
        {
            this.hashtable[key] = value;
        }
    }

    C1_Hashtable.prototype.remove = function(key)
    {
        var rtn = this.hashtable[key];

        this.hashtable[key] = null;

        return rtn;
    }

    C1_Hashtable.prototype.size = function()
    {
        var size = 0;

        for (var i in this.hashtable)
        {
            if (this.hashtable[i] != null)
                size ++;
        }

        return size;
    }

    C1_Hashtable.prototype.values = function()
    {
        return this.hashtable;
    }

    C1_Hashtable.prototype.toArray = function()
    {
	    var array = new Array();

	    for (var i in this.hashtable )
		    array[array.length] = this.hashtable[i];

	    return array;
    }
}

window.c1_webutil_loaded=true;


if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();