function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}


var cal1;
function showKalender(naam_object,aanroep_obj)
{
	var datum = new Date();
	
	if(document.getElementById('y_' + naam_object).value == '' ||	
		document.getElementById('m_' + naam_object).value == '' ||
		document.getElementById('d_' + naam_object).value == '' 
		)
		{
			datum = new Date();
		}
		else
			datum.setFullYear( document.getElementById('y_' + naam_object).value, document.getElementById('m_' + naam_object).value - 1, document.getElementById('d_' + naam_object).value)
	
	cal1 = new Calendar ("cal1", naam_object, datum);
	cal1.fallback = cal1.fallback_multi;
	renderCalendar (cal1);
	
	//positioneren van kalender naast het object wat het heeft aangeroepen.
	 document.getElementById('cal_kalender_display').style.top = DL_GetElementTop(aanroep_obj) 
	 document.getElementById('cal_kalender_display').style.left = DL_GetElementLeft(aanroep_obj) + aanroep_obj.offsetWidth;
	
}

// DHTML Calendar
// $Author: Karl Agius $
// $Date: 2005/02/15 21:54:32 $
// $Revision: 1.1 $

function Calendar (cname, id, date)
{

	// Used to notify the calendar that it is attached to a single html field.
	this.fallback_single = 0;
	
	// Used to notify the claendar that it is attached to 3 html fields.
	this.fallback_multi = 1;
	
	// Used to notify the calendar that it is attached to both field sets.
	this.fallback_both = 2;
	
	
	//callback functie
	this.do_callback = '';
	
	// Read-only calendar
	this.viewOnly = false;
	
	// Allows the user to select weekends
	this.allowWeekends = true;
	
	// Allows the user to select weekdays
	this.allowWeekdays = true;
	
	// The minimum date that the user can select (inclusive)
	this.minDate = "--";
	
	// The maximum date that the user can select (exclusive)
	this.maxDate = "--";
	
	// Allow the user to scroll dates
	this.scrolling = true;
	
	// The id of this calendar
	this.name = cname;
	
	// The first day of the week in the calendar (0-Sunday, 6-Saturday)
	this.firstDayOfWeek = 1;
	
	// Fallback method
	this.fallback = this.fallback_both;
	
	// Sets the date and strips out time information
	this.calendarDate = date;
	this.calendarDate.setUTCHours(0);
	this.calendarDate.setUTCMinutes(0);
	this.calendarDate.setUTCSeconds(0);
	this.calendarDate.setUTCMilliseconds(0);
	
	// The field id that the calendar is attached to.
	// For single input, this is used "as is". for the
	// Multi-input, it is given a suffix for _day, _month
	// and _year inputs.
	this.attachedId = id;
	
	// The left and right month control icons
	this.controlLeft = "&#171;";
	this.controlRight = "&#187;";
		
	// The left and right month control icons (when disabled)
	this.controlLeftDisabled = "";
	this.controlRightDisabled = "";
	
	// The css classes for the calendar and header
	this.calendarStyle = "cal_calendar";
	this.headerStyle = "cal_header";
	this.headerCellStyle = "cal_cell";
	this.headerCellStyleLabel = "cal_labelcell";
	
	// The css classes for the rows
	this.weekStyle = "cal_week";
	this.evenWeekStyle = "cal_evenweek";
	this.oddWeekStyle = "cal_oddweek";
	
	// The css classes for the day elements
	this.dayStyle = "cal_day";
	this.disabledDayStyle = "cal_disabled";
	this.commonDayStyle = "cal_common";
	this.holidayDayStyle = "cal_holiday";
	this.eventDayStyle = "cal_event";
	this.todayDayStyle = "cal_today";
	
	// specifies the labels for this calendar
	this.dayLabels = new Array("Zo", "Ma", "Di", "Wo", "Do", "Vr", "Za");
	this.monthLabels = new Array(
		"Jan", "Feb", "Mrt", "Apr"
		, "Mei", "Jun", "Jul", "Aug"
		, "Sep", "Okt", "Nov", "Dec");
	
	// Specifies the dates of any event. The events are to be defined as arrays,
	// with element 0 being the date and element 1 being an id.
	this.eventDates = new Array();
	
	// Attach event handlers to any fallback fields.
	if (this.viewOnly == false) {
		
		setFieldValue(this.attachedId, this.calendarDate);
		
		if ((this.fallback = this.fallback_both) || (this.fallback = this.fallback_single)) {
			eval("document.getElementById(\"" + this.attachedId + "\").onchange = function () {updateFromSingle("+this.name+", this);}");
		}

		if ((this.fallback = this.fallback_both) || (this.fallback = this.fallback_multi)) {

			eval("document.getElementById(\"d_" + this.attachedId + "\").onchange = function () {updateFromMultiDay("+this.name+", this);}");
			eval("document.getElementById(\"m_" + this.attachedId + "\").onchange = function () {updateFromMultiMonth("+this.name+", this);}");
			eval("document.getElementById(\"y_" + this.attachedId + "\").onchange = function () {updateFromMultiYear("+this.name+", this);}");
			
		}
	} 
	
	document.getElementById('cal_kalender_display').style.display = '';
	
	selectEvent = new Function();
}

function updateFromSingle (sender, helper) {
	newDate = new Date (helper.value);
	newDate.setUTCDate(newDate.getUTCDate()+1);
	sender.calendarDate = newDate;

	renderCalendar (sender);
	setFieldValue(sender.attachedId, sender.calendarDate);
}

function updateFromMultiDay (sender, helper) {

	if (isNaN(helper.value)) {
		helper.value = sender.calendarDate.getUTCDate();
		return false;
	}

	sender.calendarDate.setUTCDate(helper.value);
	renderCalendar (sender);
	setFieldValue(sender.attachedId, sender.calendarDate);
}

function updateFromMultiMonth (sender, helper) {

	if (isNaN(helper.value)) {
		helper.value = sender.calendarDate.getUTCMonths() -1;
		return false;
	}
	
	sender.calendarDate.setUTCMonth(helper.value-1);
	renderCalendar (sender);
	setFieldValue(sender.attachedId, sender.calendarDate);
}

function updateFromMultiYear (sender, helper) {

	if (isNaN(helper.value)) {
		helper.value = sender.calendarDate.getUTCFullYear();
		return false;
	}
	
	sender.calendarDate.setUTCFullYear(helper.value);
	renderCalendar (sender);
	setFieldValue(sender.attachedId, sender.calendarDate);
}

function getFirstCalendarDate (calendar)
{
	return new Date (
		calendar.calendarDate.getUTCFullYear()
		, calendar.calendarDate.getUTCMonth()
		, 1
	);
}

function renderCalendar (calendar)
{
	calHtml1 =  ("<table id=\"cal_" + calendar.attachedId + "\" class=\"" + calendar.calendarStyle +"\">");
	calHtml1 += ((calendar.scrolling)?buildHeader(calendar):buildStaticHeader(calendar));
	calHtml1 += buildCalendarTable (calendar);
	calHtml1 += ("</table>");
	
	//alert("cal_kalender_display")
	document.getElementById("cal_kalender_display").innerHTML = calHtml1;
}

function scrollMonthBack (calendar)
{
	calendar.calendarDate.setUTCMonth(calendar.calendarDate.getUTCMonth() - 1);
	setFieldValue(calendar.attachedId, calendar.calendarDate);
	renderCalendar (calendar);
}

function selectDate (calendar, day)
{
	if (!calendar.viewOnly) {
		calendar.calendarDate.setUTCDate(day);
		setFieldValue(calendar.attachedId, calendar.calendarDate);
		renderCalendar (calendar);
		
		if(calendar.do_callback.length > 0 )
			eval(calendar.do_callback)
		
	}
}

function scrollMonthForward (calendar)
{
	calendar.calendarDate.setUTCMonth(calendar.calendarDate.getUTCMonth() + 1);
	setFieldValue(calendar.attachedId, calendar.calendarDate);
	renderCalendar (calendar);
}

function setFieldValue(fieldId, date) {
	document.getElementById(fieldId).value = date.getUTCFullYear() + "/" + (date.getUTCMonth()+1) + "/" + date.getUTCDate();
	document.getElementById("y_" + fieldId).value = date.getUTCFullYear();
	document.getElementById("m_" + fieldId).value = date.getUTCMonth() + 1;
	document.getElementById("d_" + fieldId).value = date.getUTCDate();
}

function buildHeader (calendar)
{
	
	enableLeft = true;
	enableRight = true;
	
	if (calendar.minDate != "--") 
	{
		if (calendar.calendarDate.getUTCFullYear() <= calendar.minDate.getUTCFullYear())
		{
			if (calendar.calendarDate.getUTCMonth() <= calendar.minDate.getUTCMonth())
			{
				enableLeft = false;
			}
		}
	}

	if (calendar.maxDate != "--") 
	{
		if (calendar.calendarDate.getUTCFullYear() >= calendar.maxDate.getUTCFullYear())
		{
			if (calendar.calendarDate.getUTCMonth() >= calendar.maxDate.getUTCMonth())
			{
				enableRight = false;
			}
		}
	}

	calHtml2 = "";
	
	calHtml2 +=  (
		"<tr class=\""
		+ calendar.headerStyle
		+ "\">");
	calHtml2 +=  (
		"<td class=\""
		+ calendar.headerCellStyle
		+ ((enableLeft)?("\" onclick=\"scrollMonthBack(" + calendar.name + ")"):"")
		+ "\">"
		+ ((enableLeft)?calendar.controlLeft:calendar.controlLeftDisabled)
		+ "</td>");
	calHtml2 +=  (
		"<td colspan=\"4\" class=\""
		+ calendar.headerCellStyleLabel
		+ "\">"
		+ calendar.monthLabels[calendar.calendarDate.getUTCMonth()] 
		+ ", " + calendar.calendarDate.getUTCFullYear()
		+ "</td>");
		
	calHtml2 +=  (
		"<td class=\""
		+ calendar.headerCellStyle
		+ ((enableRight)?("\" onclick=\"scrollMonthForward(" + calendar.name + ")"):"")
		+ "\">"
		+ ((enableRight)?calendar.controlRight:calendar.controlRightDisabled)
		+ "</td>");
	
	calHtml2 += "<td align=\"center\" onmouseover=\"this.style.cursor='pointer';\" onclick=\"hideCalendar('" + calendar.attachedId + "')\" ><img src=\"../../images/icons/error16.png\"></td> "	
	
	calHtml2 += ("</tr>");
	
	calHtml2 +=  (
		"<tr class=\""
		+ calendar.headerStyle
		+ "\">")

	for (i = 0; i < 7; i++) {
		showDay = i + calendar.firstDayOfWeek;
		if (showDay > 6) showDay = showDay - 7;
		calHtml2 +=  (
			"<td class=\""
			+ calendar.headerCellStyle
			+ "\">"
			+ calendar.dayLabels[showDay]
			+ "</td>");
	}

	calHtml2 += ("</tr>");
	return calHtml2
}

function buildStaticHeader (calendar)
{
	calHtml2 = "";
	
	calHtml2 +=  (
		"<tr class=\""
		+ calendar.headerStyle
		+ "\">");
	calHtml2 +=  (
		"<td colspan=\"7\" class=\""
		+ calendar.headerCellStyleLabel
		+ "\">"
		+ calendar.monthLabels[calendar.calendarDate.getUTCMonth()] 
		+ ", " + calendar.calendarDate.getUTCFullYear()
		+ "</td>");	
	calHtml2 += ("</tr>");
	
	calHtml2 +=  (
		"<tr class=\""
		+ calendar.headerStyle
		+ "\">")

	for (i = 0; i < 7; i++) {
		showDay = i + calendar.firstDayOfWeek;
		if (showDay > 6) showDay = showDay - 7;
		calHtml2 +=  (
			"<td class=\""
			+ calendar.headerCellStyle
			+ "\">"
			+ calendar.dayLabels[showDay]
			+ "</td>");
	}

	calHtml2 += ("</tr>");
	return calHtml2
}




function RenderDayDisabled (calendar, currentDate)
{
	calHtml += ('<td class="day">');
	calHtml += ("<span class=\"" + calendar.disabledDayStyle + "\">");
	calHtml += (currentDate.getUTCDate());
	calHtml += ("</span>");
	calHtml += ("</td>");
}

function RenderDayEnabled (calendar, currentDate, dayStyle)
{
	currentDayStyle = dayStyle;
	calHtml += ('<td class="day">');
	calHtml += ("<span class=\"" + dayStyle + "\" onclick=\"selectDate(" + calendar.name + ", " + currentDate.getUTCDate() + ");hideCalendar('" + calendar.attachedId + "') \">");
	calHtml += (currentDate.getUTCDate());
	calHtml += ("</span>");
	calHtml += ("</td>");
}

function hideCalendar(id)
{
	document.getElementById('cal_kalender_display').style.display = 'none';
}


function RenderDayEvent (calendar, currentDate, dayStyle, eventId)
{
	currentDayStyle = dayStyle;
	calHtml += ('<td class="day">');
	calHtml += ("<span class=\"" + dayStyle + "\" onclick=\"selectDate(" + calendar.name + ", " + currentDate.getUTCDate() + "); " + calendar.name + ".selectEvent('" + eventId + "')\">");
	calHtml += (currentDate.getUTCDate());
	calHtml += ("</span>");
	calHtml += ("</td>");
}

function buildCalendarTable (calendar)
{
	currentDate = getFirstCalendarDate(calendar);
	odd = 0;
	while (currentDate.getUTCDay() != calendar.firstDayOfWeek)
	{
		currentDate.setUTCDate(currentDate.getUTCDate() - 1);
	}

	calHtml = "";
	do
	{
		odd += 1;

		calHtml +=  (
			"<tr class=\"" + (((odd%2)==0) ? calendar.evenWeekStyle : calendar.oddWeekStyle) + "\">")

		for (i = 0;i < 7;i++)
		{
			currentDayStyle = calendar.dayStyle;
			currentEventStyle = calendar.commonDayStyle;
			currentDateString = currentDate.getUTCFullYear() + "/" + (currentDate.getUTCMonth()+1) + "/" + currentDate.getUTCDate();

			if (currentDate < calendar.minDate) 
			{
				RenderDayDisabled (calendar, currentDate);
			} 
			else if (currentDate > calendar.maxDate) 
			{
				RenderDayDisabled (calendar, currentDate);
			} 
			else if (currentDate.getUTCMonth() != calendar.calendarDate.getUTCMonth())
			{
				RenderDayDisabled (calendar, currentDate);
			}
			else if (currentDate.getUTCDate() == calendar.calendarDate.getUTCDate())
			{
				if ((currentDate.getUTCDay() == 0) || (currentDate.getUTCDay() == 6))
				{
					if (calendar.allowWeekends == true)
					{
						RenderDayEnabled (calendar, currentDate, calendar.todayDayStyle);
					} 
					else 
					{
						RenderDayDisabled (calendar, currentDate);	
						month = calendar.calendarDate.getUTCMonth();
						calendar.calendarDate.setUTCDate(calendar.calendarDate.getUTCDate()+1);
						if (month != calendar.calendarDate.getUTCMonth())
						{
							renderCalendar(calendar);
						}
						setFieldValue(calendar.attachedId, calendar.calendarDate);
					}
				} else {
					if (calendar.allowWeekdays == true)
					{
						RenderDayEnabled (calendar, currentDate, calendar.todayDayStyle);
					} 
					else 
					{
						RenderDayDisabled (calendar, currentDate);	
						month = calendar.calendarDate.getUTCMonth();
						calendar.calendarDate.setUTCDate(calendar.calendarDate.getUTCDate()+1);
						if (month != calendar.calendarDate.getUTCMonth())
						{
							renderCalendar(calendar);
						}
						setFieldValue(calendar.attachedId, calendar.calendarDate);
					}
				}
			}
			else if ((currentDate.getUTCDay() == 0) || (currentDate.getUTCDay() == 6))
			{
				if (calendar.allowWeekends == true)
				{
				
					style = calendar.holidayDayStyle
					
					for (j=0; j < calendar.eventDates.length; j++)
					{
						if (calendar.eventDates[j][0] == currentDateString) 
						{
							style = calendar.eventDayStyle;
							RenderDayEvent (calendar, currentDate, style, calendar.eventDates[j][0]);
						}
					}
					
					if (style == calendar.holidayDayStyle)
					{
						RenderDayEnabled (calendar, currentDate, style);
					}
				} 
				else 
				{
					RenderDayDisabled (calendar, currentDate);	
				}
			} else {
				if (calendar.allowWeekdays == true)
				{
					style = calendar.commonDayStyle

					for (j=0; j < calendar.eventDates.length; j++)
					{
						if (calendar.eventDates[j][0] == currentDateString) 
						{
							style = calendar.eventDayStyle;
							RenderDayEvent (calendar, currentDate, style, calendar.eventDates[j][0]);
						}
					}

					if (style == calendar.commonDayStyle)
					{
						RenderDayEnabled (calendar, currentDate, style);
					}
				} 
				else 
				{
					RenderDayDisabled (calendar, currentDate);	
				}
			}

			currentDate.setUTCDate(currentDate.getUTCDate() + 1);	
		}
		
		calHtml += ("</tr>");
		

	} while (currentDate.getUTCMonth() == calendar.calendarDate.getUTCMonth());
	return calHtml;
}

// $Log: calendar.js,v $
// Revision 1.1  2005/02/15 21:54:32  Karl Agius
// Initial release
//

function del(omsch,targetUrl ,id)
{
	var agree = confirm('Wilt u \'' + omsch + '\' verwijderen?');
	
	if(agree)
	{
			
		AjaxRequest.get(
		{
		'url': targetUrl
		,'id':id
		,'method':'POST'
		,'onSuccess': function(req){process_Delete(req); }
		,'timeout':2000
		,'onTimeout':function(req){ alert('Timed Out!'); }
		,'onError':function(req){ alert(req.responseText);}
		}
		);
	
	}
}


function position_validation_div()
	{
		
		var overzicht = document.getElementById('tabmenu')
		
		var validatie = document.getElementById('validatie')
		
		var login = document.getElementById('login')
		
		
		if(validatie && overzicht)
		{
			validatie.style.left = DL_GetElementLeft(overzicht) + 560;
			validatie.style.top = DL_GetElementTop(overzicht) + 25;
			validatie.style.visibility = 'visible';
		
		
			if(validatie.className == 'ok_melding') 
			{
				opacity('validatie',100,0,3000);
			}
		}
		else if(login)
		{
			login.style.left = DL_GetElementLeft(document.getElementById('login')) ;
			login.style.top = DL_GetElementTop(document.getElementById('login')) + 50;
			login.style.visibility = 'visible';
		}
		
	}


var ie4 = ((navigator.appVersion.indexOf("MSIE")>0) && (parseInt(navigator.appVersion) >= 4));
var count = 0, count2 = 0, add1 = 3, add2 = 10, timerID;

var fadeObj;


function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 



function xreplace(checkMe,toberep,repwith){

	var temp = checkMe;

	var i = temp.indexOf(toberep);

	while(i > -1)

	{

	temp = temp.replace(toberep, repwith);

	i = temp.indexOf(toberep, i + repwith.length + 1);

}

return temp;

}
function form_submit()
{
	var formOpd = document.getElementById('formOpd');
	formOpd.submit();

}
function pagingIndex_submit(pageIndex)
{
	var formOpd = document.getElementById('formOpd');
	var page = document.getElementById('pagingIndex');
	page.value = pageIndex;
	formOpd.submit();

}
function form_input_changed()
{
	var frm_form_change = document.getElementById('form_is_changed');

	frm_form_change.value = 1;
}
function doNavigate(url)
{

	var frm_form_change = document.getElementById('form_is_changed');

	if(frm_form_change.value == 1)
	{
		var agree = confirm('U heeft een wijziging gedaan, maar deze is nog niet opgeslagen. \nU gaat verder zonder op te slaan.');

		if(agree)
		{
			document.location = url;
		}
	}
	else
		document.location = url;
}

function DL_GetElementTop(eElement)
	{
	    var nTopPos = eElement.offsetTop;            // initialize var to store calculations
	    var eParElement = eElement.offsetParent;     // identify first offset parent element  
	    while (eParElement != null)
	    {                                            // move up through element hierarchy
	        nTopPos += eParElement.offsetTop;        // appending top offset of each parent
	        eParElement = eParElement.offsetParent;  // until no more offset parents exist
	    }
	    return nTopPos;                              // return the number calculated
	}
function DL_GetElementLeft(eElement)
{
    var nLeftPos = eElement.offsetLeft;          // initialize var to store calculations
    var eParElement = eElement.offsetParent;     // identify first offset parent element  
    while (eParElement != null)
    {                                            // move up through element hierarchy
        nLeftPos += eParElement.offsetLeft;      // appending left offset of each parent
        eParElement = eParElement.offsetParent;  // until no more offset parents exist
    }
    return nLeftPos;                             // return the number calculated
}

var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
	var keyCode = (isNN) ? e.which : e.keyCode; 
	
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if(input.value.length >= len && !containsElement(filter,keyCode))
	{
		input.value = input.value.slice(0, len);
		input.form[(getIndex(input)+1) % input.form.length].focus();
	}
	function containsElement(arr, ele) {
		var	found = false, index = 0;
		while(!found && index < arr.length)
		if(arr[index] == ele)
			found = true;
		else
			index++;
		return found;
	}
	function getIndex(input) {
		var index = -1, i = 0, found = false;
		while (i < input.form.length && index == -1)
		if (input.form[i] == input)index = i;
		else i++;
			return index;
	}
	return true;
}
var popup_countid = 0;

function createPopup(left, top, w, h,  titel, html)
{
	//alert(navigator.appName)

	//alert(navigator.appVersion)
	
	//alert(navigator.appVersion.indexOf('MSIE 6.0'))
	
	var isDraggable = (( !(navigator.appName == 'Microsoft Internet Explorer') && (navigator.appVersion.indexOf('MSIE 6.0') > -1)  ))

	//alert (isDraggable)

	popup_countid = popup_countid+1;
	//alert("Div" + popup_countid)
	new popUp(left, top, w, h, "FPPP" + popup_countid, html, "white", "lightgrey", "9pt sans-serif", titel, "orange", "black", "white", "gray", "black", false, isDraggable, true, true, false, false,'../images/min.gif','../images/max.gif','../images/close.gif','../images/resize.gif');
	showbox("FPPP" + popup_countid)

	
}

var		redColored = false;
function checkRenteValue( obj, orgValue ) {
var	inhoud = replace(obj.value,',','.');
	//if (orgValue == "-") return;
	obj.style.color = "";
	//First check if a . is part of inhoud
	if ( inhoud.indexOf(".", 0) != -1 || inhoud.length == 1 )
	{
		if (Math.abs( parseFloat(inhoud) - parseFloat(orgValue) ) > 0.5 )
		{
			redColored = true;
			obj.style.color = "red";
		}
		return;
	}		
	//	Decimal sep. not found, place one after the first digit.
	var	tmp = "";
	var	j = 0;
	for ( i = 0; i < inhoud.length; i++)
	{
			
		tmp = tmp + inhoud.charAt(i);
		if ((( i == 0) && (inhoud.charAt(0) != "-")) || ((i == 1) && (inhoud.charAt(0) == "-")))
			tmp += ".";
	}
	if (Math.abs( parseFloat(tmp) - parseFloat(orgValue) ) > 0.5 )
	{
		obj.style.color = "red";
		redColored = true;
	}
	obj.value = replace(tmp,'.',',');
} 

	function replace(string,text,by) {
	    var strLength = string.length, txtLength = text.length;
	    if ((strLength == 0) || (txtLength == 0)) return string;

	    //var i = string.toString().toLowerCase().indexOf(text.toString().toLowerCase());
	    var i = string.indexOf(text);
	    if ((!i) && (text != string.substring(0,txtLength))) return string;
	    if (i == -1) return string;

	    var newstr = string.substring(0,i) + by;

	    if (i+txtLength < strLength)
	        newstr += replace(string.substring(i+txtLength,strLength),text,by);

	    return newstr;
	}

function CheckAll( recCount )
{
	CheckUncheckAll( true, recCount );
}

function UnCheckAll( recCount )
{
	CheckUncheckAll( false, recCount );
}

function CheckUncheckAll( blCheckIt, recCount )
{
	var objCheckboxen;
	var i;
	var intChk;

	for (intChk = 1; intChk <= recCount; intChk++)
	{
		objCheckboxen = document.getElementsByName("chk"+intChk);

		for (i = 0; i < objCheckboxen.length; i++ ) 
		{
			if (blCheckIt)
			{
				if(objCheckboxen[i].checked == false)
				{
					objCheckboxen[i].checked = true;
				}
			}
			else
			{
				if(objCheckboxen[i].checked == true)
				{
					objCheckboxen[i].checked = false;
				}
			}
		}
	}
}

