var uriWindow;
function windowURI(url, w, h,time,resizable)	// windowURI(link,width,height,time(close the new window after x seconds),resizable(1 -> true)
{
	if(time == undefined)
		time = 0;

	if(resizable == undefined)
		resizable = 1;
	uriWindow = window.open(url,"Window_print","menubar=no,scrollbars=1,left=10,top=0,width="+w +" ,height="+h +",resizable="+resizable);

	if(time != 0 && time != -1)
	{
		setTimeout('uriWindow.close();',time);
	}
}

function scrollToItemInfo()
{
	//window.scrollTo(0,0);
	
	if($('item_information'))
	{	
		var scroll = new Fx.Scroll(window, { 
			wait: false, 
			duration: 1200, 
			transition: Fx.Transitions.Quad.easeInOut
		});
		
		scroll.toElement('item_information');
	}
}


function windowPrint(url, w, h)
{
	//alert(url);
	printWindow=window.open(url,"Window_print","menubar=no,scrollbars=1,left=10,top=1,width="+w +" ,height="+h +",resizable=1")
}

var exampleWindow;
function windowExample(url, w, h)
{
	//alert(url);
	if(exampleWindow)
		exampleWindow.focus();
	exampleWindow=window.open(url,"Window_print","menubar=no,scrollbars=1,left=10,top=1,width="+w +" ,height="+h +",resizable=1")
}

function openWindow(text)
{
	while((text.indexOf("%BR%") != -1))
	{
		text = text.replace("%BR%","<BR>");
	}
	myWin = window.open("","nCt", "left=400, top=300,width=180,height=30,status=no,toolbar=no,menubar=no,scrollbars=auto,resizable=yes");
	myWin.document.write("<html><head><title>Note</title></head>");
	myWin.document.write ("<body><script>function closeWindow(){window.close()} \n\n setTimeout(\"closeWindow()\",1000);</script>"+text+"</body></html>");
	//setTimeout("myWin.close()",200);
	//myWin.document.write("<center><p><input type='button' value='Afsluiten' name='close' onClick='window.close()'></p><center>");
}

function CheckTab(el)
{
	if ((document.all) && (9==event.keyCode) && (event.ctrlKey))
	{
		el.selection=document.selection.createRange();
	    setTimeout("ProcessTab('" + el.id + "')",0);
	}
	if ((document.all) && (83==event.keyCode) && (event.ctrlKey))
	{
		document.forms[0].submit();
		openWindow('De pagina is opgeslagen');
	}
}

function ProcessTab(id)
{
	document.all[id].selection.text=String.fromCharCode(9);
	document.all[id].focus();
}

function changeColor(el, color1, color2)
{
	//alert(el);
	$(el).style.background = ($(el).style.background == color1) ? color2 : color1;
}

function test(cell,color1,color2)
{
	cell.style.background = (cell.style.background == color1) ? color2 : color1;
}

function checkUserForm()
{
	if(document.forms[0].username.value=="")
	{
		alert('U moet een gebruikersnaam opgeven!');
		return false;
	}

	/*if(document.forms[0].email.value=="")
	{
		alert('U moet email opgeven!');
		return false;
	}*/

	if(document.forms[0].password.value=="")
	{
		alert('U moet password opgeven!');
		return false;
	}

	var value = false;

	for(i=0;i<document.forms[0].elements.length;i++)
	{
		if(document.forms[0].elements[i].type=='checkbox')
		{
			if(document.forms[0].elements[i].checked==true)
			{
					value=true;
					break;
			}
		}
	}
	if(value==false)
	{
		alert('U dient minimaal 1 groep te selecteren!');
		return false;
	}
	return true;
}

function checkUpdateUserPropertiesForm()
{
	if(document.forms[0].username.value=="")
	{
		alert('U moet een gebruikersnaam opgeven!');
		return false;
	}

	/*if(document.forms[0].email.value=="")
	{
		alert('U moet email opgeven!');
		return false;
	}*/

	if(document.forms[0].password.value=="")
	{
		alert('U moet password opgeven!');
		return false;
	}

	return true;
}

function checkGroupForm()
{
	if(document.forms[0].name.value=="")
	{
		alert('U moet een naam voor de groep opgeven!');
		return false;
	}

	if(document.forms[0].profileId.value=="")
	{
		alert('U moet een profiel selecteren!');
		return false;
	}
}

function checkDescriptionAmount(maxAmount)
{
	if(document.descForm.personAmount.value<maxAmount)
	{
		return true;
	}
	else
	{
		alert("U kunt niet meer dan " + maxAmount + " personen inschrijven");
		return false;
	}
}

function TrackCount(fieldObj,countFieldName,maxChars)
{
	var countField = eval("fieldObj.form."+countFieldName);
	var diff = maxChars - fieldObj.value.length;

	// Need to check & enforce limit here also in case user pastes data
	if (diff < 0)
	{
		fieldObj.value = fieldObj.value.substring(0,maxChars);
		diff = maxChars - fieldObj.value.length;
	}
	countField.value = diff;
}

function LimitText(fieldObj,maxChars)
{
	var result = true;
	if (fieldObj.value.length >= maxChars)
		result = false;

	if (window.event)
		window.event.returnValue = result;
	return result;
}

function imgOn(menuObj)
{
	name = menuObj.name;
	leftImage = "img"+name+1;
	rightImage = "img"+name+2;
	document.images[leftImage].src="images/menu_low.gif";
	document.images[rightImage].src="images/menu2_low.gif";
}

function imgOut(menuObj)
{
	name = menuObj.name;
	leftImage = "img"+name+1;
	rightImage = "img"+name+2;
	document.images[leftImage].src="images/menu_hi.gif";
	document.images[rightImage].src="images/menu2_hi.gif";
}

function imgSubOn(menuObj)
{
	name = menuObj.name;
	leftImage = "subimg"+name+1;
	rightImage = "subimg"+name+2;
	document.images[leftImage].src="images/menu_sub_low.gif";
	document.images[rightImage].src="images/menu2_low.gif";
}

function imgSubOut(menuObj)
{
	name = menuObj.name;
	leftImage = "subimg"+name+1;
	rightImage = "subimg"+name+2;
	document.images[leftImage].src="images/menu_sub_hi.gif";
	document.images[rightImage].src="images/menu_sub2_hi.gif";
}

function checkAllFields(element)
{
	if(confirm("Hiermee gaat een eventuele selectie verloren"))
	{
		for(var i=0;i<document.forms[0].elements.length;i++)
		{
			document.forms[0].elements[i].checked=checkFields;
		}
		checkFields = !checkFields;
		if(checkFields)
			element.value = "alles aan";
		else
			element.value = "alles uit";
	}
}

function emptyForm()
{
	for(var i=0;i<document.forms[2].elements.length;i++)
	{
		if(document.forms[2].elements[i].type=="text")
			document.forms[2].elements[i].value="";
	}
}

function changeImage(img, newSrc)
{
	img.src = newSrc;
}

function open_new_window(location)
{
	new_window = window.open(location,"mailafriend","width=400,height=450,scrollbars=yes,left=10,top=10");
}

function checkAll(formName)
{
	for(var i=0;i<document.forms[formName].elements.length;i++)
	{
		if(document.forms[formName].elements[i].type=='checkbox' && document.forms[formName].elements[i].alt!='none')
			document.forms[formName].elements[i].checked = true;
	}
}

function unCheckAll(formName)
{
	for(var i=0;i<document.forms[formName].elements.length;i++)
	{
		if(document.forms[formName].elements[i].type=='checkbox' && document.forms[formName].elements[i].alt!='none')
			document.forms[formName].elements[i].checked = false;
	}
}

function checkElement(elementId)
{
	$(elementId).checked = true;
}

/*function checkForm(formName, userId)
{
	var found = false;
	for(var i=0;i<document.forms[formName].elements.length;i++)
	{
		if(document.forms[formName].elements[i].type=='checkbox')
		{
			if(document.forms[formName].elements[i].checked==true)
			{
				found = true;
				break;
			}
		}
	}
	if(!found)
	{
		alert('Gelieve minimaal 1 gebruiker aan te vinken');
		checkElement('author_'+userId);
	}
	return found;
}*/

dropDownEdited = false;

function setEndHour(beginDropDown)
{
	var endHouresDropDown = $('endhoures');
	var startMinutesDropDown = $('startminutes');
	if(endHouresDropDown.selectedIndex<beginDropDown.selectedIndex)
	{
		endHouresDropDown.options[beginDropDown.selectedIndex].selected = true;
	}
	setEndMinute(startMinutesDropDown);
}

function setEndMinute(beginDropDown)
{
	var startHouresDropDown = $('starthoures');
	var endHouresDropDown = $('endhoures');
	var endMinutesDropDown = $('endminutes');
	if(startHouresDropDown.selectedIndex==endHouresDropDown.selectedIndex)
	{
		if(endMinutesDropDown.selectedIndex<beginDropDown.selectedIndex)
		{
			endMinutesDropDown.options[beginDropDown.selectedIndex].selected = true;
		}
	}
}

function checkEmpty(elementNames)
{
	var errorElements = new Array();
	var j=0;
	for(var i=0;i<elementNames.length;i++)
	{
		if($(elementNames[i]).value=='')
		{
			errorElements[j] = elementNames[i];
			j++;
		}
	}
	return errorElements;
}

function checkAgenda()
{
	var elementArray = new Array("mainhead");
	var errorElements = checkEmpty(elementArray);
	var errorMessage = '';
	if(errorElements.length != 0)
	{
		for(var k=0;k < errorElements.length;k++)
		{
			if(errorElements[k]=='mainhead')
			{
				errorMessage += 'Gelieve een titel in te vullen';
			}
		}
		alert(errorMessage);
		return false;
	}
	return true;
}

var currentlySelected = -1;
function selectOne(dropDown,optionid)
{
	if(currentlySelected!=-1 || optionid)
	{
		for(var i=0;i<dropDown.options.length;i++)
		{
			if(optionid)
			{
				if(dropDown.options[i].id==optionid)
					dropDown.options[i].selected = true;
				else
					dropDown.options[i].selected = false;
			}
			else
			{
				if(i==currentlySelected)
					dropDown.options[i].selected = false;
				if(i==dropDown.selectedIndex)
					dropDown.options[i].selected = true;
			}
		}
	}
	currentlySelected = dropDown.selectedIndex;
}

function mouseOver(adminButton)
{
	var splittedSrc = adminButton.src.split("/");
	var restSrc = "";
	fileName = splittedSrc[splittedSrc.length-1];
	for(var i=0;i<splittedSrc.length-1;i++)
	{
		restSrc += splittedSrc[i] + "/";
	}
	var splittedFileName = fileName.split(".");
	adminButton.src =  restSrc + splittedFileName[0] + "_hov" + "." + splittedFileName[1];
}

function mouseOut(adminButton)
{
	var splittedSrc = adminButton.src.split("/");
	var restSrc = "";
	fileName = splittedSrc[splittedSrc.length-1];
	for(var i=0;i<splittedSrc.length-1;i++)
	{
		restSrc += splittedSrc[i] + "/";
	}
	var splittedFileName = fileName.split(".");
	var newFileName = splittedFileName[0].substring(0,splittedFileName[0].length-4);
	adminButton.src =  restSrc + newFileName + "." + splittedFileName[1];
}

function checkGroups()
{
	for(var i=0;i<document.forms.sendGroups.elements.length;i++)
	{
		if(document.forms.sendGroups.elements[i].type=="checkbox" && document.forms.sendGroups.elements[i].checked)
		{
			return true;
		}
	}
	alert('Gelieve een groep te kiezen.');
	return false;
}

function checkGroupAmount()
{
	var currentForm = document.forms[0];
	for(var i=0;i<currentForm.elements.length;i++)
	{
		if(currentForm.elements[i].type=="checkbox")
		{
			if(currentForm.elements[i].checked)
				return true;
		}
	}
	return confirm("Deze gebruiker is nu niet meer gekoppeld aan een groep. U vindt hem nu alleen nog terug in het overzicht van alle gebruikers.");
}

function displayFormat(dropDown)
{
	if(dropDown.options[dropDown.selectedIndex].value == 322)
		$("obl_format").style.display = "";
	else
		$("obl_format").style.display = "non";
}

function executeAction(action,actionObject)
{
	//alert(actionObject.id + ":" + action);
	switch(action)
	{
		case "display":
		{
			if(actionObject.style.display!="")
				actionObject.style.display = "";
			break;
		}
		case "hide":
		{
			if(actionObject.style.display!="none")
				actionObject.style.display = "none";
			break;
		}
	}
}

function getElementValue(elementName)
{
	return $(elementName).value;
}

function getElementLength(elementName)
{
	//alert($(elementName).value.length);
	return $(elementName).value.length;
}

function setVisibility(elementId,visible)
{
	if(visible)
		$(elementId).style.display = "";
	else
		$(elementId).style.display = "none";
}

function displayFormat(dropDown)
{
	if(dropDown.options[dropDown.selectedIndex].value == 1656)
		$("obl_format").style.display = "";
	else
		$("obl_format").style.display = "none";
}

function checkEmptyId(inputId)
{
	var translationArray = new Array(2);
	translationArray['content'] = '[[TRANSLATION.error_content]]';
	translationArray['mainhead'] = '[[TRANSLATION.error_mainhead]]';

	if($(inputId).value == '')
	{

		alert(translationArray[inputId]);
		return false;
	}
	return true;
}

function copyInputTo(copyFromElement,copyElementId) /* Copy the value from an element to another element onchange (e.g. menutitle to mainhead) */
{
	$(copyElementId).value = $(copyFromElement).value;
}

function createTarget(t)
{
    window.open("", t, "width=600,height=550,scrollbars=1");
    return true;
}

function getHTTPObject() {

  var xmlhttp;

  /*@cc_on

  @if (@_jscript_version >= 5)

    try {

      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

    } catch (e) {

      try {

        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

      } catch (E) {

        xmlhttp = false;

      }

    }

  @else

  xmlhttp = false;

  @end @*/

  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {

    try {

      xmlhttp = new XMLHttpRequest();

    } catch (e) {

      xmlhttp = false;

    }

  }

  return xmlhttp;

}

function popUp(URL, width, height)
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+width+",height="+height+",left = 320,top = 272');");
}

function checkNumeric(textfield,message)		// Checks whether the userinput is numeric or not
{
	inputstring = textfield.value;
	for (i = 0; i < inputstring.length; i++)
	{
		ch = inputstring.substring(i, i+1);
		if (ch < "0" || ch > "9")
		{
			if(message != '')
				alert(message);
			textfield.value = textfield.value.substring(0, i);
			textfield.focus();
			return false;
		}
	}
	return true;
}

function generateRandomString(length)
{

	var retVal = '';

	for (i=0; i < length; i++)
	{
		retVal += String.fromCharCode((parseInt(Math.random() * 1000) % 94) + 33);
	}

	return retVal;
}

var emptiedElements = new Array();
function js_in_array(the_needle, the_haystack)
{
	var the_hay = the_haystack.toString();
	if(the_hay == ''){
		return false;
	}
	var the_pattern = new RegExp(the_needle, 'g');
	var matched = the_pattern.test(the_haystack);
	return matched;
}

function emptyValue(element)
{
	if(!js_in_array(element.id,emptiedElements))
	{
		emptiedElements[emptiedElements.length] = element.id;
		element.value='';
	}
}

var fixedModuleWindows = new Array();

function showModuleInfoDiv(elmId)
{
	if (!js_in_array(elmId, fixedModuleWindows))
	{
		scrollTop = window.getScrollTop();
		topCoord = scrollTop+20;

		$(elmId).style.top = topCoord+'px';
		$(elmId).style.left = '20px';
		$(elmId).style.display = 'block';
	}
}

function clickModuleWindow(elmId)
{
	if (js_in_array(elmId, fixedModuleWindows))
	{
		// Remove this module window from the array
		tempArray = new Array();

		for (i=0; i<fixedModuleWindows.length; i++ )
		{
			if (fixedModuleWindows[i] != elmId)
			{
				tempArray[tempArray.length] = fixedModuleWindows[i];
			}
		}

		fixedModuleWindows = tempArray;
		delete tempArray;

		$(elmId).style.display = 'none'; // Hide the module window
	}
	else
	{
		fixedModuleWindows[fixedModuleWindows.length] = elmId; // Put this module window in the array
		new Drag.Move($(elmId), {'container': bodyC});
		$(elmId).style.cursor = 'move';
	}
}

function moduleWindowOut(elmId)
{
	if (!js_in_array(elmId, fixedModuleWindows))
	{
		$(elmId).style.display = 'none'; // Hide the module window
	}
}


function displayLayer( whichLayer)
{
	var showField = $(whichLayer);
	showField.style.display = 'block';
}

function hideLayer( whichLayer)
{
	var hideField = $(whichLayer);
	hideField.style.display = 'none';
}

function topSearchSubmit()
{
	o_topSearch = $('top_mySearch');
	o_search = $('mySearch');
	
	if(o_topSearch && o_search)
	{
		o_search.value = o_topSearch.value;
	}
	
	o_topAuthor = $('top_authorsearchfield');
	o_author = $('authorsearchfield');
	
	if(o_topAuthor && o_author)
	{
		o_author.value = o_topAuthor.value;
	}
	
	o_topCat = $('top_category');
	o_cat = $('category');
		
	if(o_topCat && o_cat)
	{
		o_cat.selectedIndex = o_topCat.selectedIndex;
	}
	
	if($('top_search_loader'))
	{
		$('top_search_loader').style.display = 'block';
	}
	
	var s_queryData = $('topSearch').toQueryString();
	new Ajax('/', {method:'get',data:s_queryData,update: $('content'),evalScripts:true, onComplete: function (){
		if($('top_search_loader'))
		{
			$('top_search_loader').style.display = 'none';
		}
	}}).request();
}

function selectVal(o_selectBox, s_selectVal)
{
	for(var i = 0; i < o_selectBox.options.length; i++)
	{
		if(o_selectBox.options[i].value == s_selectVal)
		{
			o_selectBox.options[i].selected = true;
			return;
		}
	}
}

function searchSubmit()
{
	if($('search_loader'))
	{
		$('search_loader').style.display = 'block';
	}
	var s_queryData = $('simpleSearch').toQueryString();
	new Ajax('/', {method:'get',data:s_queryData,update: $('content'),evalScripts:true, onComplete: function (){
		if($('search_loader'))
		{
			$('search_loader').style.display = 'none';
		}
	}}).request();
}

function advancedSearchSubmit()
{
	var s_queryData = $('advancedSearch').toQueryString();
	new Ajax('/', {method:'get',data:s_queryData,update: $('content'),evalScripts:true}).request();
}

function showUserLines(userId)
{
	var s_url = '/author/' + userId + '/1/-1/' + i_currentTimeline + '/' + i_currentTimelineItem;
	new Ajax(s_url, {update: $('contentContainer'),evalScripts:true}).request();
}

function swapResults(i_pageId)
{
	var s_url = '/?views=swapResults(' + i_pageId + ')&elementId=90';
	new Ajax(s_url, {update: $('searchResults'),evalScripts:true}).request();
}

function showCategoryLines(i_catId)
{
	var s_url = '/category/' + i_catId + '/1/-1/' + i_currentTimeline + '/' + i_currentTimelineItem;
	new Ajax(s_url, {method: 'get',update: $('contentContainer'),evalScripts:true}).request();
}

function userTimeList(o_href)
{
	var s_url = o_href.href + '&a=1';
	new Ajax(s_url, {update: $('content'),evalScripts:true}).request();
}

function castVote(i_timeLineId, i_vote)
{
	var s_url = '/?functions=insertVote('+i_timeLineId+')&vote=' + i_vote + '&elementId=90';
	new Ajax(s_url, {evalScripts:true}).request();
	$('voting'+i_timeLineId).style.display = 'none';
	$('voted'+i_timeLineId).style.display = 'block';
}

a_stars = new Array();
function voteHover(i_timeLineId, star)
{
	a_stars[i_timeLineId] = new Array();
	a_stars[i_timeLineId][1] = $('star_'+i_timeLineId+'_1').src;
	a_stars[i_timeLineId][2] = $('star_'+i_timeLineId+'_2').src;
	a_stars[i_timeLineId][3] = $('star_'+i_timeLineId+'_3').src;
	a_stars[i_timeLineId][4] = $('star_'+i_timeLineId+'_4').src;
	a_stars[i_timeLineId][5] = $('star_'+i_timeLineId+'_5').src;
	for(i=1; i<6; i++)
	{
		if(i <= star)
		{
			$('star_'+i_timeLineId+'_'+i).src = '/images/star_full.php';
		}
		else
		{
			$('star_'+i_timeLineId+'_'+i).src = '/images/star_empty.php';
		}
	}
}

/**
* resets the voting stars to their original setting..
*/
function voteOut(i_timeLineId)
{
	$('star_'+i_timeLineId+'_1').src = a_stars[i_timeLineId][1];
	$('star_'+i_timeLineId+'_2').src = a_stars[i_timeLineId][2];
	$('star_'+i_timeLineId+'_3').src = a_stars[i_timeLineId][3];
	$('star_'+i_timeLineId+'_4').src = a_stars[i_timeLineId][4];
	$('star_'+i_timeLineId+'_5').src = a_stars[i_timeLineId][5];
}

function formValueHints(id)
{
	form = $(id);
	
	form.submitHandle = true;
	form.a_hintElements = ['input', 'textarea'];
	
	form.addHintToInput = function (o_input, b_late) {
		if(o_input.title != "")
		{
			o_input.onfocus = function () {
				this_input = $(this);
				if(this_input.value == this_input.title)
				{
					this_input.removeClass("form_hint");
					this_input.value = "";
					
					
					if(this_input.prev_type == 'password')
					{
						this_input.onblur = function () {};
						newThis = changeInputType(this_input, 'password');
						
						form.addHintToInput(newThis, true);
						setTimeout(function() 
						{
							newThis.focus();
						}.bind(newThis), 1);
					}		
				}
			};
			o_input.onblur = function () {
				if(this.value == "" && this.title != "")
				{
					this.addClass("form_hint");
					this.value = this.title;
												
					if(this.type == 'password')
					{
						this.prev_type = 'password';
						newThis = changeInputType(this, 'text');
						form.addHintToInput(newThis);
					}						
				}
			};
			
			if(!b_late)
			{
				o_input.onblur();
			}
		}
	};
	
	form.addHints = function () {				
		this.a_hintElements.each(function(s_type)
		{	
			$(this).getElements(s_type).each(function(o_input) 
			{
				form.addHintToInput(o_input);
			});
		}.bind(this));
	};

	form.removeHints = function() {
		if(this.submitHandle)
		{
			this.a_hintElements.each(function(s_type)
			{	
				$(this).getElements(s_type).each(function(o_input) {
					if(o_input.title != "" && o_input.value == o_input.title)
					{
						o_input.value = "";
					}
				});
			}.bind(this));
		}
			
		form.submitHandle = false;
		setTimeout(function()
		{
			this.submitHandle = true;
		}.bind(form),100);
	};

	form.addHints();
	setTimeout(function()
	{
		this.addEvent("submit", this.removeHints);
	}.bind(form),100);
}

function photoGallery(i_itemId, i_index)
{
	if(i_index == undefined)
	{
		i_index = 0;
	}
	new Ajax('/?views=photoGallery(' + i_itemId + ',' + i_index + ')&elementId=90', {update: $('photoGallery')}).request();
}


function handleAjaxLink(o_elt)
{
	var s_url = o_elt.href + '?tabPage=1';
	new Ajax(s_url, {update: $('contentContainer'),evalScripts:true}).request();

}

function resizeImages()
{
	if($('contentContainer'))
	{
		$('contentContainer').getElements('img').each(function(o_img)
			{
				var i_width = o_img.width;
				var i_height = o_img.height;





				if(i_width > i_maxImageWidth)
				{
					var i_newHeight = ((i_maxImageWidth * i_height) / i_width).toInt();
					var i_newWidth = i_maxImageWidth;

					o_img.setStyle('width',i_newWidth + 'px');
					o_img.setStyle('height',i_newHeight + 'px');


				}
			});
	}
}

function changeInputType(elt, newType)
{
	var newElt = document.createElement('input');
	newElt.type = newType;
	if(elt.size)
	{
		newElt.size = elt.size;
	}

	if(elt.value)
	{
		newElt.value = elt.value;
	}
	if(elt.name)
	{
		newElt.name = elt.name;
	}
	if(elt.id)
	{
		newElt.id = elt.id;
	}
	if(elt.title)
	{
		newElt.title = elt.title;
	}
	if(elt.prev_type)
	{
		newElt.prev_type = elt.prev_type;
	}
	if(elt.className)
	{
		newElt.className = elt.className;
	}

	elt.parentNode.replaceChild(newElt,elt);
	return newElt;
}

function emptyAndMaskPasswordField(elt)
{
	newElt = changeInputType(elt,'password');
	newElt.value='';
	setTimeout("newElt.focus()",1);
}
