var ordernrText;
var ordernrCostText;
var timeCodeText;
var timeCodeCostText;

function BodyOnLoad(){
	var cell;
	var calendar;
	var input;
	var orderSeek;
	var timeCodeSeek;

	hideElement('KR5039'); //Selected cell info
	hideElement('KR27011');
	hideElement('KR27012');
	hideElement('KR27014');
	hideElement('KR27015');

	calendar = document.getElementById('KR5276');
	if(calendar != null){
		calendar.onclick = function(){show_office_calendar(null, null, null, null, 'YYMMDD')};
		calendar.style.cursor = 'pointer';
	}

	calendar = document.getElementById('KR5278');
	if(calendar != null){
		calendar.onclick=function(){show_office_calendar(null, null, null, null, 'YYMMDD')};
		calendar.style.cursor = 'pointer';
	}

	orderSeek = document.getElementById('I5165');
	if(orderSeek != null){
		orderSeek.onmousedown = function(){setOrdernrText()};
		orderSeek.onclick = function(){NewWindowHandler('arc30.d -x 1124 ' + ordernrText,'height=550, width=780, resizable=yes, menubar=no, toolbar=no, left=250, top=200')};
	}

	orderCostSeek = document.getElementById('I5234');
	if(orderCostSeek != null){
		orderCostSeek.onmousedown = function(){setOrdernrCostText()};
		orderCostSeek.onclick = function(){NewWindowHandler('arc30.d -x 1124 ' + ordernrCostText,'height=550, width=780, resizable=yes, menubar=no, toolbar=no, left=250, top=200')};
	}

	timeCodeSeek = document.getElementById('I5166');
	if(timeCodeSeek != null){
		timeCodeSeek.onmousedown = function(){setTimeCodeText()};
		timeCodeSeek.onclick = function(){NewWindowHandler('arc10.d -x 1125 ' + timeCodeText,'height=550, width=780, resizable=yes, menubar=no, toolbar=no, left=250, top=200')};
	}

	timeCodeCostSeek = document.getElementById('I5236');
	if(timeCodeCostSeek != null){
		timeCodeCostSeek.onmousedown = function(){setTimeCodeCostText()};
		timeCodeCostSeek.onclick = function(){NewWindowHandler('arc10.d -x 1125 ' + timeCodeCostText,'height=550, width=780, resizable=yes, menubar=no, toolbar=no, left=250, top=200')};
	}


	for(var i = 0, l = document.getElementsByTagName('input').length; i < l; i++) {
		input = document.getElementsByTagName('input').item(i);
		if(input.type == 'text') {
			//Tar bort autocomplete, vet inte om det funkar till 100%???
			input.autocomplete = 'off';
			//Ändrar till mörkare färg i disablade inputs. (INGET FUNKAR!!!)
//			if(input.disabled == true){
//				input.disabled = false;
//				input.style.className = 'testklass';
//				input.disabled = true;
//				input.color = '#456ABC';
//			}
		}
	}
}

function setOrdernrText(){
	var ordernr = document.getElementById('KR28');
	if(ordernr != null){
		ordernrText = ordernr.value;
	}
	else{
		ordernrText = "";
	}
}

function setOrdernrCostText(){
	var ordernrCost = document.getElementById('KR5233');
	if(ordernrCost != null){
		ordernrCostText = ordernrCost.value;
	}
	else{
		ordernrCostText = "";
	}
}

function setTimeCodeText(){
	var timeCode = document.getElementById('KR5134');
	if(timeCode != null){
		timeCodeText = timeCode.value;
	}
	else{
		timeCodeText = "";
	}
}

function setTimeCodeCostText(){
	var timeCodeCost = document.getElementById('KR5032');
	if(timeCodeCost != null){
		timeCodeCostText = timeCodeCost.value;
	}
	else{
		timeCodeCostText = "";
	}
}

function hideElement(elementId){
	element = document.getElementById(elementId);
	if(element != null){
		element.style.visibility = "hidden";
	}
}

function selectDay(cellInfo){
	var cell

	cell = document.getElementById('KR5039');
	if(cell != null){
		cell.value = cellInfo;
		__doPostBack('KR5038', '');
	}
}

function stopEnterKey(evt) {
  var evt = (evt) ? evt : ((event) ? event : null);
  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
  if ((evt.keyCode == 13) && (node.type=="text"))  {return false;}
}

document.onkeypress = stopEnterKey;
