
function initfields()
{
	//set tabindexes and focus
	var i,j;
	var rowcount;
	setFocus('Contents_txtArtikel');
	
	i=1;
	//i will automaticaly raised in function if object exists
	i=setTabIndex('Contents_txtArtikel',i);
	i=setTabIndex('lstArticles',i);
	i=setTabIndex('txtAantal',i);
	
	for (j=1;j<=7;j++)
	{
		i=setTabIndex('drpKenmerk' + j,i)
	}
	
	i=setTabIndex('txtBestelRegelOpmerking',i);
	i=setTabIndex('btnBestel2',i);
	
	rowcount=document.getElementById('Contents_tblBestelRegels').rows.length;
	if (rowcount>1)
	{
		//start with 2. row 1 = header
		for (j=2;j<=rowcount;j++)
		{
			i=setTabIndex('Contents_btnEdit_' + j,i);
			i=setTabIndex('Contents_btnRemove_' + j,i);
		}
	}
	i=setTabIndex('Contents_btnOrder',i);

}

function AddRowShoppingCart(func,e)
{
	//Contents_btnBestel
	var btnname;
	
	if (func=='add') {btnname='Contents_btnBestel';}
	if (func=='edit') {btnname='Contents_btnEditBestel';}
	if (e==null) { 
			
		if (CheckNumeric('txtAantal',CAP_ErrorNumeriek_aantal,false)==true)
		//if (CheckNumeric('txtAantal','Het veld aantal moet een numerieke waarde bevatten.',false)==true)
		{
			if ( CheckBestelHoeveelheid('txtAantal','hidMinimaleBestelHoeveelheid',CAP_ErrorMinimumBestelHoeveelheid) == true)
			{
				if ( CheckPakketSize('txtAantal','hidPakketGrootte',CAP_ErrorPakketGrootte) == true )
				{
					document.getElementById(btnname).click();
				} else {
					return;
				}
			} else {
				return;
			}
		} else {
			return;		
		}
	}
	
	if (e.keyCode==13){
		if (CheckNumeric('txtAantal',CAP_ErrorNumeriek_aantal,false)==true)
		{
			if ( CheckBestelHoeveelheid('txtAantal','hidMinimaleBestelHoeveelheid',CAP_ErrorMinimumBestelHoeveelheid) == true)
			{
				if ( CheckPakketSize('txtAantal','hidPakketGrootte',CAP_ErrorPakketGrootte) == true )
				{
					e.returnValue=false;
					e.cancel = true;
					document.getElementById(btnname).click();
				} else {
					return;
				}
			} else {
				return;
			}
		} else {
			return;
		}
		
		
		
	}
}

function CaptureEnter(e)
{
	// CAPTURE ENTER KEY ON ON KEYPRESS EVENT
	
	if (e.keyCode==13)
	{
		SearchArticlesQuickOrder(e)
		e.returnValue=false;
		e.cancel = true;
	}
}

function SearchArticlesQuickOrder(e)
{	
	//FILLS LIST BOX WITH ARTICLES
	
	var searchstring=document.getElementById('Contents_txtArtikel').value;
	
	
	if (e.keyCode==13){
				
		e.returnValue=false;
		e.cancel = true;
		document.frames('frasubfunction').location='quickorder.aspx?func=1&searchstring=' + searchstring + '&enter=true';
		//document.getElementById('frasubfunction').src = 'quickorder.aspx?func=1&searchstring=' + searchstring + '&enter=true&csid='+csid;
	} else 
	{
		document.frames('frasubfunction').location='quickorder.aspx?func=1&searchstring=' + searchstring + '&enter=false';
		//document.getElementById('frasubfunction').src = 'quickorder.aspx?func=1&searchstring=' + searchstring + '&enter=false&csid='+csid;
	}
	
	
	//fires also on mouseclick
	/*if (e==null) { 
		
		document.frames('frasubfunction').location='quickorder.aspx?func=1&searchstring=' + searchstring + '';
		return;
	}*/
	
	//keycode 13=enter
	/*if (e.keyCode==13){
		
		e.returnValue=false;
		e.cancel = true;
		document.frames('frasubfunction').location='quickorder.aspx?func=1&searchstring=' + searchstring + '';
	}*/
}


function EditBestelRegel(regelid)
{
	//show the edit header and the edit line rows
	var row = document.getElementById('Contents_QuickOrderRow1');
	row.style.display = '';
	row = document.getElementById('Contents_QuickOrderRow2');
	row.style.display = '';
	
	document.frames('frasubfunction').location='quickorder.aspx?func=3&regelid=' + regelid + '';
	//document.getElementById('frasubfunction').src = 'quickorder.aspx?func=3&regelid=' + regelid + '&csid=' + csid;
	//prevent submit
	return false;
}

function RemoveBestelRegel(regelid)
{
	if (confirm(CAP_VerwijderBestelRegel)==true)
	{
		document.frames('frasubfunction').location='quickorder.aspx?func=4&regelid=' + regelid + '';
		//document.getElementById('frasubfunction').src = 'quickorder.aspx?func=4&regelid=' + regelid + '&csid=' + csid;
	}
	return false;
}

function SelectArticleQuickOrder(e)
{
	//SELECT ARTICLE FROM LISTBOX AND COPY IT IN TEXBOX
	//HIDE SELECTBOX
	
	if ((e != null) && (e.keyCode==13)) {
		
		e.returnValue=false;
		e.cancel = true;
	}
	
	
	var selIndex=document.getElementById('lstArticles').selectedIndex;
	
	var articleid=document.getElementById('lstArticles').options[selIndex].value;
	var description=document.getElementById('lstArticles').options[selIndex].text;
	var articleid,artcode;
	

	document.getElementById('lstArticles').style.display='none';
	
	document.frames('frasubfunction').location='quickorder.aspx?func=2&artikelid=' + articleid + '';
	//document.getElementById('frasubfunction').src = 'quickorder.aspx?func=2&artikelid=' + articleid + '&csid=' + csid;
}

function AutoSelect (textbox) {
    if (textbox.createTextRange) {
        var oRange = textbox.createTextRange(); 
        oRange.moveStart("character", 0); 
        oRange.moveEnd("character", textbox.value.length); 
        oRange.select();
    } else if (textbox.setSelectionRange) {
        textbox.setSelectionRange(0, textbox.value.length);
    } 
}

