function istcopy_locate_single_docstor_file(document_id)
	{			
		var document_id = document.all.locate_document_id.value
		var domain_path = js_http_mode+'://'+document.page_db.docstor_hostname.value+'.istdocstor.com'

		oTBody = new Object();
		oTBody = document.all.docstor_file_list
		var oItem = oTBody.getElementsByTagName("INPUT");

		if(oItem.length > 0)
		{	

			var sAction = domain_path+'/ist_docStor/view/docStor_filelist.cfm'
			var sTarget = 'single_file'
			var oNewForm = make_form('locate_file', sAction, sTarget)
			make_input(oNewForm, 'from_where_response_mode','find_multiple_files')
							
			for (i=0; i<oItem.length; i++)
				{
					if(oItem.item(i).name.substring(0,20) == 'multiple_document_id')
						{
							make_input(oNewForm, 'multiple_document_id', oItem.item(i).value)
						}
				}

			//make_input(oNewForm, 'multiple_document_id', 999)
			//make_input(oNewForm, 'multiple_document_id', 941129)
			
			oNewForm.submit()
		}
	}
	
function istcopy_locate_docstor_files(documentIds)
	{

			//var force_start_page = js_http_mode+'://'+document.page_db.docstor_hostname.value+'.istdocstor.com'

			var domain_path = js_http_mode+'://'+document.page_db.docstor_hostname.value+'.istdocstor.com'
			var sAction = domain_path+'/ist_docStor/view/docStor_filelist.cfm'
			var sTarget = 'single_file'
			var oNewForm = make_form('locate_file', sAction, sTarget)
			make_input(oNewForm, 'from_where_response_mode','find_multiple_files')
			make_input(oNewForm, 'multiple_document_id', documentIds)

			/* Added controls for forcing logon to land on the right page */
			make_input(oNewForm, 'force_start_page', sAction)
			make_input(oNewForm, 'force_start_page_form_variables', 'from_where_response_mode,multiple_document_id')
			oNewForm.submit()
	}
	
docStorOpened = false;	

function istcopy_select_docstor_file()
	{
		testWin = window.open('', 'docStor_treeview');
		if (testWin.location != 'about:blank' && testWin.opener.name != 'ISTcopy2')
		{
			testWin.window.AlertCloseWindow()
		}
		else
		{
			docStorOpened= true;
			var domain_path = js_http_mode+'://'+document.page_db.docstor_hostname.value+'.istdocstor.com'

			var sAction = domain_path+'/ist_docStor/view/docStor.cfm'
			var sTarget = 'docStor_treeview'
			var oNewForm = make_form('choose_file', sAction, sTarget)
			
			/* Added controls for forcing logon to land on the right page */
			make_input(oNewForm, 'force_start_page', sAction)
			make_input(oNewForm, 'force_start_page_form_variables', 'from_where_response_mode,multiple_document_id')
			oNewForm.submit()
		}
	}

function istcopy_tr_find_last(oTBody)
	{
		last_tr = oTBody.getElementsByTagName("TR").length-1
		
		if(last_tr > -1)
			{last_row = oTBody.getElementsByTagName("TR")[last_tr].row}
		else
			{last_row = 'row_0'}
	
		row_cnt = last_row.substring(4,last_row.length)
		return row_cnt
	}
	
function istcopy_td_find_duplicate_document_id(oTBody)
	{						
		duplicate = false
		var oItem = oTBody.getElementsByTagName("INPUT");

		for (i=0; i<oItem.length; i++) 
		{	//alert(oItem.item(i).id.substring(0,19))
			if(oItem.item(i).id.substring(0,19) == 'locate_document_id_')
				{
					if(document.all.locate_document_id.value == oItem.item(i).value)
						{								
							duplicate = true
							break
						}
				}
		}
		return duplicate			
	}
	
function istcopy_add_order_row()
	{
		var domain = window.location.href;
		oTBody = new Object();
		oTBody = document.all.docstor_file_list
		var oRow=document.createElement("TR");
		var oCell=document.createElement('TD');

		istcopy_td_find_duplicate_document_id(oTBody)
		
		if(duplicate == true)
			{alert('Duplicate File.\n\nThis file is already in your list.')}
		else
			{
				last = oTBody.getElementsByTagName("TD").length-1
				
				istcopy_tr_find_last(oTBody)

				if(last < 0)
					{cell_color = '#ffffff'}
				else
					{cell_color = oTBody.getElementsByTagName("TD")[last].bgColor}
	
				if(cell_color == '#cccccc')
					{cell_color = '#ffffff'}
				else
					{cell_color = '#cccccc'}			

				row_cnt++
				oRow[row_cnt] = oRow.cloneNode();
				oRow[row_cnt].row = 'row_'+row_cnt
				i = 0
				
				//Row 
				//cell_input = '<input type="button" class="buttonclass" value="Delete" title="Delete this file from your order." onMouseUp="istcopy_delete_file_from_order()"  onmouseover="classchange(\'buttonfocus\')" onMouseOut="classchange(\'buttonclass\')">'
				cell_input = '<span class="link" onclick="istcopy_delete_file_from_order()" title="Delete this file from your order."><img style="cursor:pointer" hspace="0" vspace="0" align="absmiddle" src="/ist_shared/ist_images/IST_icons/Modern/gif/16/normal/shoppingcart_remove_16.gif"></span>';

				oCell[i] = oCell.cloneNode();
				oCell[i].bgColor = cell_color;
				oCell[i].align = 'center';
				oCell[i].insertAdjacentHTML('beforeEnd', cell_input);
				oRow[row_cnt].appendChild(oCell[i]);

				//Document Name
				v_locate_document_name = document.all.locate_document_name.value
				cell_input = '<input type="hidden" id="locate_document_name_'+row_cnt+'" name="locate_document_name_'+row_cnt+'" size="10" value="'+v_locate_document_name+'">'

				oCell[i] = oCell.cloneNode();
				oCell[i].bgColor = cell_color;

				oCell[i].insertAdjacentText('beforeEnd', v_locate_document_name);

				oCell[i].insertAdjacentHTML('beforeEnd', cell_input);
				// Unremark this line and the next oCell.cloneNode(); to add a cell back for File ID display
				//oRow[row_cnt].appendChild(oCell[i]);

				//Document ID

				v_locate_document_id = document.all.locate_document_id.value
				cell_input = '<input type="hidden" id="locate_document_id_'+row_cnt+'" name="locate_document_id_'+row_cnt+'" size="10" value="'+v_locate_document_id+'">'
				cell_input = cell_input+' <input type="hidden" id="multiple_document_id_'+row_cnt+'" name="multiple_document_id_'+row_cnt+'" size="10" value="'+v_locate_document_id+'">'

				// Unremark this line and the previous oRow[row_cnt].appendChild(oCell[i]); to add a cell back for File ID display
				//oCell[i] = oCell.cloneNode();
				oCell[i].bgColor = cell_color;
				// Removed next line to hide the File ID
				//oCell[i].insertAdjacentText('beforeEnd', v_locate_document_id);

				oCell[i].insertAdjacentHTML('beforeEnd', cell_input);

				if ((domain.toLowerCase()).indexOf("state=2") != -1)
				{
									  cell_input='<input type="hidden" id="locate_document_template_id_'+row_cnt+'" name="locate_document_template_id_'+row_cnt+'" id="locate_document_template_id_'+row_cnt+'" size="10" value="">'
									  oCell[i].insertAdjacentHTML('beforeEnd', cell_input);
									}

				oRow[row_cnt].appendChild(oCell[i]);

				//Template Name

				//cell_input = '<input type="hidden" id="locate_document_template_name'+row_cnt+'" name="locate_document_template_name'+row_cnt+'" id="locate_document_template_name'+row_cnt+'" size="10" value="">'
									//cell_input = cell_input+' <input type="hidden" id="locate_document_template_id_'+row_cnt+'" name="locate_document_template_id_'+row_cnt+'" id="locate_document_template_id_'+row_cnt+'" size="10" value="">'
				//oCell[i] = oCell.cloneNode();

				//oCell[i].bgColor = cell_color;

				//oCell[i].onclick = getMenu;
				//oCell[i].onmouseover = MouseOverCell;
				//oCell[i].onmouseout = MouseOutCell;
				//oCell[i].setAttribute("title", "Template Configuration");
				//oCell[i].setAttribute("p0", v_locate_document_id);
				//oCell[i].setAttribute("p1", "0");

				//oCell[i].insertAdjacentText('beforeEnd', "");

				//oCell[i].insertAdjacentHTML('beforeEnd', cell_input);
				//oRow[row_cnt].appendChild(oCell[i]);

				//Document Quantity

				//if (!(domain.toLowerCase()).indexOf("state=0"))
				if (document.getElementById("iconIsWorkingB2"))
				{
					cell_input = '<input type="text" id="locate_document_quantity_'+row_cnt+'" name="locate_document_quantity_'+row_cnt+'" size="1" maxlength="5" value="1">';
					oCell[i] = oCell.cloneNode();
					oCell[i].bgColor = cell_color;
					oCell[i].insertAdjacentHTML('beforeEnd', cell_input);
					oRow[row_cnt].appendChild(oCell[i]);
				}
				 oTBody.appendChild(oRow[row_cnt]);

				//if (((domain.toLowerCase()).indexOf("state=2")))
							 //{
							 //  getTemplate(v_locate_document_id, row_cnt);
							 //}

			}

	}
	
function istcopy_send_copyticket_request()
	{		
		oTBody = new Object();
		oTBody = document.all.docstor_file_list
		var oItem = oTBody.getElementsByTagName("INPUT");

		if (oItem.length > 0) 
		{			
			var domain_path = js_http_mode+'://'+document.page_db.docstor_hostname.value+'.istdocstor.com'

			var sAction = ''
			var sTarget = 'xtest'
			var oNewForm = make_form('send_copyticket', sAction, sTarget)

			for (i=0; i<oItem.length; i++) 
				{
					make_input(oNewForm, oItem.item(i).name,oItem.item(i).value)
				}
			oNewForm.submit()	
		}

	}
	
function istcopy_delete_file_from_order()
	{			
		oTBody = new Object();
		oTBody = document.all.docstor_file_list
		var oItem = oTBody.getElementsByTagName("TR");
		obj = event.srcElement //.parentElement.parentElement

		for (i = 0; i < 6; i++)
			{				
				if(obj.tagName == 'TR')
					{break}
				else
					{obj = obj.parentElement}
			}

		for (i=0; i<oItem.length; i++) 
		{
			if(obj.row == oItem.item(i).row)
				{oTBody.removeChild(oItem.item(i))}
		}

	}

function getTemplate(documentID, rowNum)
		 {
		   frames['my_iframe'].document.forms['templateLookupForm'].elements['DocID'].value = documentID;
		   frames['my_iframe'].document.forms['templateLookupForm'].elements['rowNum'].value = rowNum;
		   frames['my_iframe'].document.forms['templateLookupForm'].elements['SiteID'].value = document.forms['form1'].elements['SiteID'].value
		   frames['my_iframe'].document.forms['templateLookupForm'].submit();
		 }

function setTemplate(rowNum)
		 {
		   //alert("setting");
		   parent.document.forms['form1'].elements['locate_document_template_id_' + rowNum].value = document.forms['templateData'].elements['templateID'].value;
		   //parent.document.forms['form1'].elements['locate_document_template_name' + rowNum].value = document.forms['templateData'].elements['templateName'].value;
		   //if (document.forms['templateData'].elements['templateName'].value != "")
		   //{
		   //  var templateName = document.forms['templateData'].elements['templateName'].value;
		   //}
		   //else
		   //{
		   //  var templateName = "[none defined]";
		   //}
		   //parent.document.forms['form1'].elements['locate_document_template_id_' + rowNum].insertAdjacentText('AfterEnd', templateName);
		   //tables = parent.document.getElementsByTagName('table');
		   //var cells = tables.docstor_selected_files.getElementsByTagName('td');
		   //cells[cells.length - 2].setAttribute("p1", document.forms['templateData'].elements['templateID'].value);
		 }

function getMenu()
		 {
		   get_context_menu('document_template')
		 }

var lastCellColor;

function MouseOverCell()
		 {
		   lastCellColor = this.bgColor
		   this.style.cursor='pointer';
		   this.style.background='inactivecaption';
		 }

function MouseOutCell()
		 {
		   this.style.background=lastCellColor;
		 }


