

function checkUser(logged) {
  if (logged) {
    document.uploadForm.submit();
  } else {
    if (customerType == 'login') {
      document.loginForm.submit();
    } else {
      document.userForm.submit();
    }
  }
}

function userCheck(returnValue) {
  if (returnValue == "ok") {
    parent.document.uploadForm.submit();
  } else {
    alert("Your customer id could not be found or created.");
  }
}


function closeFlash() {
  document.getElementById("appObject").style.visibility = "hidden";
}
function openFlash() {
  document.getElementById("appObject").style.visibility = "visible";
}



var customerType = 'login';
function showFlap(flap) {
  customerType = flap;
  if (flap == 'login') {
    getId("flap_1").style.backgroundColor = "#ffffff";
    getId("flap_2").style.backgroundColor = "#aaaaaa";
    getId('loginBlock').style.display = "block";
    getId('newCustomerBlock').style.display = "none";
  } else {
    getId("flap_1").style.backgroundColor = "#aaaaaa";
    getId("flap_2").style.backgroundColor = "#ffffff";
    getId('loginBlock').style.display = "none";
    getId('newCustomerBlock').style.display = "block";
  }  
}

function showFlap2(flap) {
  customerType = flap;
  if (flap == 'custInfo') {
    getId("flap_1").style.backgroundColor = "#ffffff";
    getId("flap_2").style.backgroundColor = "#aaaaaa";
    getId('infoBlock').style.display = "block";
    getId('changeBlock').style.display = "none";
  } else {
    getId("flap_1").style.backgroundColor = "#aaaaaa";
    getId("flap_2").style.backgroundColor = "#ffffff";
    getId('infoBlock').style.display = "none";
    getId('changeBlock').style.display = "block";
  }  
}


function stageGo(view) {
  document.stageForm.view.value = view;
  document.stageForm.submit();
}

function removeTemplate(id, active) {
  if (active) {
    document.removeTemplateForm.view.value = "";
  }
  document.removeTemplateForm.removeTemplate_arg_1.value = id;
  document.removeTemplateForm.submit();
}

function activateTemplate(id) {
  document.activateTemplateForm.activateTemplate_arg_1.value = id;
  document.activateTemplateForm.submit();
}


var fileCounter = 1;

function makeNewFileInputField() {
	fieldUsed = true;
	var brElement = document.createElement("br");
	var theNewField = document.createElement("input");
	theNewField.type = "file";
	theNewField.size = "35";
	theNewField.name = "fileFld" + fileCounter++;
	divObj = getId("divBlock");
	divObj.appendChild(theNewField);
	theNewField.onchange = new Function("makeNewFileInputField();");	
	divObj.appendChild(brElement);
}



function displayBlock(ev, id) {
	var scrollComp = document.getElementsByTagName("html").item(0).scrollTop;
  ev = ev || window.event;
  getId(id).style.top   = ev.clientY + scrollComp + 10 + "px";
  getId(id).style.left  = ev.clientX + 10 + "px";
  getId(id).style.display = "block";
}

function moveBlock(ev, id) {
	var scrollComp = document.getElementsByTagName("html").item(0).scrollTop;
  ev = ev || window.event;
  getId(id).style.top   = ev.clientY + scrollComp + 10 + "px";
  getId(id).style.left  = ev.clientX + 10 + "px";
}
  
function hideBlock(id) {
  getId(id).style.display = "none";
}






function showPageDimmer() {
	var scrollComp = document.getElementsByTagName("html").item(0).scrollTop;
	var dimBlock = getId("pageDimmer");
	dimBlock.style.visibility = "visible";
	dimBlock.style.height = (1024 + scrollComp) + "px";
}

function quantityChange(q, str) {  
  q = (isNaN(parseInt(q))) ? 0 : parseInt(q);
  inputs = document.getElementsByTagName("input");
  i=0;
  while (inputs.item(i)) {
    input = inputs.item(i);
    if (input.type == 'text' && input.name.indexOf(str) != -1) {
      input.value = q;
    }
    i++;
  }
}

function checkInt(inputObj) {
  inputObj.value = (isNaN(parseInt(inputObj.value))) ? 0 : parseInt(inputObj.value);
}


