function CheckAll()
{
   count = document.resultform.elements.length;
   for (i=0; i < count; i++) {
      if(document.resultform.elements[i].checked == 1) {
         document.resultform.elements[i].checked = 1; 
      } else {
         document.resultform.elements[i].checked = 1;
      }
   }
}

function UncheckAll(){
   count = document.resultform.elements.length;
   for (i=0; i < count; i++) {
      if(document.resultform.elements[i].checked == 1) {
         document.resultform.elements[i].checked = 0;
      } else {
         document.resultform.elements[i].checked = 0;
      }
   }
}

function SelUnSelAll()
{
   if (document.resultform.elements["chkbox_header"].checked) {
      CheckAll();
   } else {
      UncheckAll();
   }
}

function doSelectedAction(action)
{
   items = "";
   document.resultform.checkeditems.value = "";
   count = document.resultform.elements.length;
   for(i=1; i < count; i++) {
      if(document.resultform.elements[i].checked == 1) {
         items += document.resultform.elements[i].value + "*";
      }
   }

   if(items != "") {
      document.resultform.checkeditems.value = items;
      //document.resultform.action += action;
      document.resultform.submit();
   } else {
      alert("No Images Selected");
   }
}

function doc_picker(docname)
{
   var url = "viewdoc.php?docnum=" + docname;
   var width = screen.width;
   var height = screen.height;
   var width=width-10;
   var height=height-85;
   win = window.open(url, "","height="+height+",width="+width+",screenX=0,screenY=0,left=0,top=0,status=1,scrollbars=yes");
}

 function doc_picker_shippers_assist(docname,type)
	{
	   var url = "http://customer.tigercourier.com/Login/inc/centerline.php?filetype=" + type + "&probill=" + docname + "&company=021";
	   var width = screen.width;
	   var height = screen.height;
	   var width=width-10;
	   var height=height-85;
	   win = window.open(url, "","height="+height+",width="+width+",screenX=0,screenY=0,left=0,top=0,status=1,scrollbars=yes");
	}

function sig_picker(docname)
{
   var url = "viewsig.php?docnum=" + docname;
   var width=350;
   var height=545;
   win = window.open(url, "","height="+height+",width="+width+",screenX=0,screenY=0,left=0,top=0,status=1,scrollbars=yes,menubar=yes");
}

function sendpro(){
   var params = Form.serialize($('frmProbillQuery'));
   var pleasewait="<img src='js/loading.gif' /> Retrieving Data..."
   $(proresults).innerHTML=pleasewait
   new Ajax.Updater('proresults', 'probill.php', {asynchronous:true, parameters:params});
}

function tracepro(){
   var params = Form.serialize($('frmTraceQuery'));
   var pleasewait="<img src='/js/loading.gif' /> Retrieving Data..."
   $(proresults).innerHTML=pleasewait
   new Ajax.Updater('proresults', 'trace-submit.php', {asynchronous:true, parameters:params});
}

function inputSubmitEvent(form, input)
{
  input.onkeydown = function(e)
  {
    e = e || window.event;
    if(e.keyCode == 13)
    {
      tracepro();
      return false; 
    }
  };
}

/*
* Function: showLayer()
* Purpose:  This function will show a specific layer based on there id
*/
function showHide()
{ 
	
	//var selectInd = document.getElementById('account').selectedIndex.value;
	var selectVal = document.getElementById('account').value;
	if (selectVal == 'MIDLAND') 
	{
		document.getElementById('midLand').style.visibility="visible";
		document.getElementById('midLand').style.display="block";
	}
	else if(selectVal == 'DICOM')
	{
		 document.getElementById('midLand').style.visibility="hidden"; 	
		 document.getElementById('midLand').style.display="none";
	}
} 

/*
*	Function:	displayWindow
*	Purpose:	This function opens a new window with defined specifications.
*	Params:		title - The title of the window 
*			    sMessage - the message to be displayed within the window
*/
function displayWindow(sMessage, title, target)
{
	//checks to see if a title was entered for the new window. If not just enters Error for the msg
	if (title == "")
	{
		title = "ERROR";
	}
	var win = window.open("", "", "toolbar='no',scrollbars='no',location='no'" +
						  "left=700,top=300,statusbar='no',menubar='no',resizable='no'," +
                              "width=250,height=65");
	
	var content="<html><head><title>";
	content += title;
	content += "</title>";
	content += "</head><body bgcolor='#000000' style='color: white' onblur='self.focus()'>";
	content += "<form name='fItems' action='"
	content += target;
	content += "'  method='POST'>";
	content += "<div align='center'><h4>";
	content += sMessage;
	content += "</h4>";
	if(title != "Error")
	{
		content += "<input type='button' value=' Yes ' onclick='self.close()' />";
		content += "<input type='button' value=' No ' onclick='return false' />";
	}
	else
	{
		content += "<input type='button' value=' Exit ' onclick='self.close()' />";
	}
	content += "</div";
	content += "</body></html>";
	
	win.document.write(content);
	win.document.close();
}

/*
* Function: checkDigit()
* Purpose:  This function will check if the user selected an activity
*/
function checkVals()
{
	if(document.AcctFlat.manifestNum.value == "")
	{
			displayWindow("You must enter a Manifest Number", "Error", "accountFlatFile.php");
			return false;
	}	
	else
	{
		return confirm('Are You Sure You Want to FTP the Flat File for Manifest # '+document.AcctFlat.manifestNum.value);
	}
}



