/*

	VERSION=[00.20]                                                                       

	Releases jump because the file changes every build

	02.02 - Specific changes to writelabel to account for new prom column 12.12.02

	02.07 - Added items gp to query string of show_prom function to help Karen 07.01.03

	02.0A - FD702 - removed erroneous reference to nfretry - replaced with promretry

					changed id of popup window (windowID) in show_prom and prom retry

					to promwindowID and renamed variable "path" in promretry to promretrypath

					to avoid confusion with function nf() and nfretry() variables

	02.0B - FD707 - some sites rename the window "main" AOL and bbc.co.uk being notable

					examples. Change the name of the frames adding decconet to the names

					and update any references in script of from submit targets.

	02.0C - ID0307 - Make promotions window wide enough to fit 33 character descriptions

	20.15 - New version number format [buildnumber].[version]

	30.02 - ID0335 - make pop up windows work with AOL console

	31.10 - CD330 - new orderOptions() function for setting and
					displaying delivery addess etc.
	31.03 - ID0389 - invoie spilling over to next line
	31.08 - ID0408 - ../ paths in decconet cause security alerts in norton personal firewall
	31.11 - CD382 - Adapt DeccoNet To Interface With Internet Explorer 5.0
	31.13 - ID0440 - qty ordered not being updated with Update Order
	32.02 - FD738 - Blue Background Around 'Update Basket' Intermittently Disappears
	32.02 - FD742 - No shop manager warning when changes made
	32.03 - FD738 - Set timeout values to 100
	32.04 - ID0454 - Popup box when adding items from addByItemNo
	32.11 - CD380 - ShowTopic function registered as a global function for searchhelp link
	32.12 - ID0474 - fails on set_message() in branch home page
	33.01 - CD408 - showStats(); function added for 24months sales stats
	33.02 - CD408 - change size of 24 months sales window
	33.16 - FD772 - Shopping Basket Order Quantities Doubling Up
	33.25 - FD*** - Decconet.js file rejected by Handyman diy's win2K machine
	33.25 - ID0565 - Fix made again and added to sourcesafe
	35.01 - ID0595 - Add screen= to doprompt string to stop errors in errlog
	35.02 - FD772 - Shopping Basket Order Quantities Doubling Up second attempt
	35.06 - FD785 - Prompt user on exiting reapid code entry
	42.00 - CE480 - Change write label to check the presence of the stock column
	42.12 - ID0888 - Item number changing when clicking qty box
	71.01 - CD556 - Allow Dcode item entry in Deccolink and DeccoNet.
	00.01 - ID1098 - Reset version number of decconet.js because was going to run out of numbers in 2010.
	00.02 - FD955 - Change "updatepc" to exit with an error on corrupt DBZ files
	00.03 - CD766 - Adjustment to small_firewall DNSTANDBY DNS servers.
	      - CD743 - Added eventlogging to delsales, topsales and budisk.
	00.04 - CD782 - Adjustment to small_firewall for DECCO SYSTEMS @ HOME
	00.05 - CD786 - Alert email when ack contains zero invoice.
	00.06 - CD795 - ediorders multiply scotts price by uos
	00.07 - ID1103 - change to dnfserv to only return non deleted items by dcode
	00.08 - CD807 - ediorders scotts future dated orders
	00.09 - CD809 - ediorders multiply qty by uop when uos 1 on scotts orders
	00.10 - CD808 - logrotate config modifications
	00.11 - CD806 - Morrisons letsgrow year 2
	00.12 - ID1104 - Debug version of basket to trace null cust order number
	00.13 - ID1118 - deccoups
	00.14 - ID1119 - Remove ln commands from instruct
		ID1120 - DECCONET UPGRADE change rsync scripts
		ID1121 - DECCONET UPGRADE correct installation of cron
		ID1123 - DECCONET UPGARDE add dialafile startup script to release and instruct
		ID1124 - DECCONET UPGRADE remove mrtg from crontab
		ID1125 - DECCONET UPGRADE Locking function incompatible
		ID1126 - DECCONET UPGRADE cleardb script creates profit centre withoput full permissions
	00.15 - CD787 - Increase number of connectons between Decconet and B2BE
		ID1128 - DECCONET UPGRADE - Heartbeat program
		ID1129 - DECCONET UPGRADE - Relink programs to b9503 dialafile libaries
		ID1130 - DECCONET UPGRADE - change apache restart command in instruct
		ID1131 - DECCONET UPGRADE - the mysqlSync line in crontab  has a CR in it
		ID1132 - DECCONET UPGRADE - budisk does not correctly identify when backup is completed
		ID1133 - DECCONET UPGRADE - chamge all dnfserv script to remove sleep
		ID1134 - Checkorders not working
		ID1135 - DECCONET UPGRADE - BUTAPE not working
		ID1136 - DECCCOET UPGRADE - change log-level in small_firewall from 5 to debug 			
		ID1137 - DECCONET UPGRADE - Remove signal trap from heartbeat program
		ID1138 - DECCONET UPGRADE - Remove /p from heartbeat program
		ID1139 - DECCONET UPGRADE - Remove signal call from dnfserv
		ID1140 - DECCONET UPGRADE - Compatilibility mods to decconet startup / shutdown
		ID1141 - DECCONET UPGRADE - check_df_connection does no call close_mail
		ID1142 - DECCONET UPGRADE - amend startdnf logging
	00.16   FD961 - Barcode corruption in ediorders
		FD962 - Htmlstore not deleting records correctly
	00.17   ID1147 - Change banners on Decconet
	00.18   ID1143 - DECCONET UPGRADE - remove lockmgr from system
		ID1144 - DECCONET UPGRADE - use unzip instead of pkzip
		ID1145 - DECCONET UPGRADE - remove fserv logging from dnfserv
		ID1146 - DECCONET UPGRADE - change cwd to / for edge 02.03
		ID1148 - DECCONET UPGRADE - deccoups gets out of sync with messages from ups
		ID1149 - DECCONET UPGRADE - sequential running of dbcheck and htmlstore
		ID1150 - DECCONET UPGRADE - fix lo_rotate on ups_log
		ID1151 - DECCONET UPGRADE - mysqlSync script in dos format
		ID1152 - DECCONET UPGRADE - add df logrotate to release
		ID1153 - DECCONET UPGRADE - remove signals and alarms from ups_start
		ID1154 - DECCONET UPGRADE - remove O-NONBLOCK from ups_start open()
		ID1155 - DECCONET UPGRADE - reordering of startup scripts for upgrade
	00.19   CD831 - Synchronise Deccodata across all Decconet servers
		CD832 - Modify small_firewall script
		FD960 - Null character preventing processing of Decconet ordetr
		ID1156 - ftp_cron - increase number of passes from 2 to 10
		ID1157 - ftp_cron_autofax - file untransmitted for 5 mins befoer error
	00.20	ID1158 - DECCONET UPGRADE - ftp_put_check_autofax incompatible with CentOS

*/

var additm_submitted = false;

var DNVersion = "D10.40 build 2";

var resizeflag = 0;

var nfpath;

var prpath;

var setflag;


	function dohelp()

	{//function to open the help screen when the user clicks "help"

	 //from the browser menu, or function key f1

	 helpscreen="/decconet/helpfiles/helpdlg.html"

	 features="dialogHeight:400px;dialogWidth:800px;center:yes;help:no;resizable:yes;scroll:no;status:no;";

	 showModelessDialog(helpscreen,"",features)

	 return false;

	}



	//This statement attaches the above dohelp() function to the onhelp event

	//document.attachEvent("onhelp",dohelp);

	//function currently diasabled awaiting CD



	function getCookie(NameOfCookie)

		// Function used to get the value of a cookie by passing the name, e.g. getCookie('glyn')

		/*used by:

			top.html in root

			index.html in search

		  Written by Glyn.

		*/

	{

		if (document.cookie.length > 0) //If the cookie exists

		{

			begin = document.cookie.indexOf(NameOfCookie+"="); //Start at the "="

			if (begin != -1) 		//Error check

			{	begin += NameOfCookie.length+1; //get the legnth of the string

				end = document.cookie.indexOf(";", begin); //mark end as before th colon

				if (end == -1) end = document.cookie.length;	//error check

				return unescape(document.cookie.substring(begin, end));	//parse the value and return it

			}

		}

		return null; //if cookie non-existant return null

	}



		function setCookie (name, value, expires, path, domain, secure)

{

      document.cookie = name + "=" + escape(value) +

        ((expires) ? "; expires=" + expires : "") +

        ((path) ? "; path=" + path : "") +

        ((domain) ? "; domain=" + domain : "") +

        ((secure) ? "; secure" : "");

}







	function updateFrame()

	// Used to call update the bottom.html screen

	{	/*used by:

			top.html in root

			index.html in search

			char.html

			basket.html

		  Written by Ron.

		*/



		updatescreen="/u/decconet/htdocs/decconet/search/bottom.html"

		custno = top.getCookie('custno');

		username = top.getCookie('username');

		if(top.decconetside.document.readyState=="complete" && parent.decconetside.bottom.document.readyState=="complete")

		{//if the container is loaded set the screen

		top.decconetside.bottom.location.replace("/cgi-bin/decco/basket?screen="+updatescreen+"&custno="+custno+"&username="+username+"&Routine=03");

		}

		else{

		//otherwise try again

		setTimeout("updateFrame();",100);}





	}





	function goToBasket()

	// Submits necessary details to show the basket

	{	/*used by:

			top.html in root

		  Written by Ron.

		*/

		point=top.frames[0]; //pointer to an object

		point.goToBasketForm.custno.value = top.getCookie('custno');//fill the form

		point.goToBasketForm.username.value = top.getCookie('username');

		point.goToBasketForm.submit();//submit form

	}



	//takes the user to the checkout screen

	function goToCheckout()

	{

		point=top.frames[0]; //pointer to an object

		point.goToCheckoutForm.custno.value=top.getCookie('custno');//fill the form

		point.goToCheckoutForm.username.value = top.getCookie('username');

		point.goToCheckoutForm.submit();

	}



		function favourites()

	{	//goes to shop manager

		/*used by:

			top.html in search

		  Written by Ron.

		*/

		//take focus out of the qty box to fire change event in IE5.0
		top.decconetmain.focus();

		ofavForm = parent.decconetside.favForm

		ofavForm.username.value=top.getCookie('username');

		ofavForm.custno.value=top.getCookie('custno');

		ofavForm.submit();

	}



	function allsup()

	{	//returns a list of all suppliers

		/*used by:

			side.html in search

		*/

		//simple http cgi routine call

		parent.decconetmain.location = "/cgi-bin/decco/basket?screen=/u/decconet/htdocs/decconet/search/char.html&custno="+top.getCookie('custno')+"&username="+top.getCookie("username")+"&Routine=12";

	}



	function doTabs(number)



	{

		// Set tab in top.html for branch screens, if number = 1, the prod sel highlighted, 2 then shop bskt

		top.frames[0].cellClicked = number;

		//check if the top frame is ready

		if(top.frames[0].document.readyState=="complete") top.frames[0].setTabs();

		else {//if not wait and try again

		mycall="doTabs("+number+")";

		setTimeout(mycall,100);

		}

	}



	function doSetupTabs(cell)

	{

		//This function sets the tabs in the setup section

		//of decconet.

	 if(top.frames[0].document.readyState=="complete")



	 {//if the menu is loaded

	 top.frames[0].cellClicked=cell;//set the current page

	 top.frames[0].setTabs();//and call the local setTabs function

	 }



	 else{//or wait and try again

	 setTimeout("doSetupTabs("+cell+")",100);

	 }



	}



	function updatebasket()

	{

		form=parent.decconetmain.document.basketform;	//pointer to the main frame

		myarray=parent.decconetmain.basketarray;//pounter to the array

		form.custno.value = top.getCookie('custno');//load the form

		form.username.value = top.getCookie('username');

		//we need to take focus off the qty box to force it to fire it's onchange event
		top.decconetmain.focus();

		if(myarray.length==0) myarray[0]=" ";//if the user has not initialised the array by

		//selecting a value, initialise it for him with a blank value



		form.array.value = myarray;

		parent.decconetmain.doprompt = 0;//stop the save prompt appearing

		form.submit();

	}



	function promptupdatebasket(bIsBasket)

{	//sends the user input into the shopping basket

	/*

		used by:

		char.html

		basket.html

	*/
//fire the change event for IE5.0
top.decconetmain.focus();

myarray=parent.decconetmain.basketarray;

if(bIsBasket)//Update absket from the shopping basket screen replaces values rather than adding

//more so we use a different routine if it's from the basket screen (ID0192)

{
parent.decconetmaintop.location.replace("/cgi-bin/decco/basket?screen=/u/decconet/htdocs/decconet/search/basket.html&custno="+top.getCookie('custno')+"&username="+top.getCookie('username')+"&array="+myarray+"&todo=amend&Routine=04");
}

else{

parent.decconetmaintop.location.replace("/cgi-bin/decco/basket?screen=/u/decconet/htdocs/decconet/search/basket.html&custno="+top.getCookie('custno')+"&username="+top.getCookie('username')+"&array="+myarray+"&Routine=01");

}

}



function ld()	//load array

{	//stores the users order in an array for sending to the basket later

	/*

		used by:

		char.html

		basket.html

		favourites.html

	*/

packsizecell = 4;
 //set a pointer to the form
 formname=event.srcElement.parentElement.parentElement;



 //set the quantity field to black text because user has acknowledged any duplicate items

 event.srcElement.className="qty";

 //pointer to the line number

 var currentline = formname.ln.value;

 //get the users qty

 var myqty = parseInt(formname.qty.value);



 //parseint returns NaN if user changes the value to blank so we need to

 //clear that item from the array

 if(isNaN(myqty)) basketarray[currentline] = "";

 else  //write the new (valid numeric) value to the array

 basketarray[currentline] = formname.itm.value +","+myqty;



 //and set a flag to remind the user to update changes

 doprompt = 1;

 //set a pointer to the table "rows" collection

 var myline = formname.parentElement;

 //and get the packsize as a number

 var mypacksize= parseInt(myline.cells[packsizecell].innerText);

 //check to see if the user has violated the packsize check

 if (mypacksize > 1 && myqty >= mypacksize)

 { //if so set packsize text color to magenta
 	myline.cells[packsizecell].innerHTML='<font color="magenta">'+mypacksize+'</font>';

 }

 else

 {		//The user may have corrected a packsize violation so set the color empty so teh ckass takes precedence
 		myline.cells[packsizecell].innerHTML='<font color="">'+mypacksize+'</font>';

 }
}



function nf(path){	//displays the popup window

	/*used by:

		char.html

		basket.html

		favourites.html

	*/

	nfpath="/decconet/info/"+path

	decconetInfoWindow=open("/decconet/search/nfframe.html","info",'location=no,menubar=no,resizable=yes,width=100,height=300');

	decconetInfoWindow.blur()

}

function showStock(path){	//displays the popup window

	/*used by:

		char.html

		basket.html

		favourites.html

	*/

	nfpath=path;

	decconetInfoWindow=open("/decconet/search/nfframe.html","info",'location=no,menubar=no,resizable=yes,width=100,height=300');

	decconetInfoWindow.blur()

}

function checkprompt(bIsBasket)

//checks if the user submited his basket before quitting the screen

	/*used by:

		char.html

		basket.html

		favourites.html

	*/

{

//if the user made changes and tries to leave other than by clicking update basket

if(doprompt==1){

//ask if he wants to save. Call updatebasket() if he does

if(confirm("You have made changes to this order, which have not been updated.\nThe system will now update your order. If you wish to discard the changes, click cancel,\notherwise click ok to confirm the changes."))

{

 //update using a different target to the main

 if(bIsBasket==true){
  promptupdatebasket(true);
 }
 //I know is basket it no longer boolean. Check for the keydirect pages
 if(bIsBasket=="rapid")
 {
	 top.decconetmain.dobasket(true);
	 //we can't let the user go where
	 //he wanted because of the checks
	 //made on the rapid code entry screen
	 //so just let the dobasket function handle redirection
	 return;
 }

 else{promptupdatebasket();}

return;

}//or proceed as normal if he doesn't

else return;

  }

  //and if the user hadn't made changes do nothing

  return;

}



function val()	//validate key strokes and accept numerics or special keys

	/*used by:

		char.html

		basket.html

		favourites.html

	*/

{var mykey = event.keyCode   //get the key pressed
    if((mykey > 47) && (mykey < 58)){//if a number

if(event.shiftKey) event.returnValue=false;//did he have shift pressed? - so it's a char - refuse it



if(event.srcElement.id=="qty")	//if it's a qty field

{

	if(event.srcElement.value.length==4)event.returnValue=false;//and they are trying to overrun the length don't accept

}

	//setprompt for IE5.0
	if(event.srcElement.parentElement.parentElement.name!="addByItemNoForm") doprompt=1;
    return; //other wise numbers are ok

    }



    else if((mykey > 95) && (mykey < 106)){//if a numpad number



	/*if(event.srcElement.id=="qty")	//if it's a qty field

{

	if(event.srcElement.value.length==4)event.returnValue=false;//and they are trying to overrun the length don't accept

}*/

	//setprompt for IE5.0
	if(event.srcElement.parentElement.parentElement.name!="addByItemNoForm") doprompt=1;
    return;	//otherwise numpad numbers are ok

     }



	 //various othe rkeys like backspace enter delete etc

else if((mykey == 9)){return;}

else if((mykey == 13)){
	// we don't want to cancel a enter press in the add by item no "itecm code" field or
	//the form doesn't autosubmit
	if(event.srcElement.parentElement.parentElement.name!="addByItemNoForm"||event.srcElement.id=="qty")event.keyCode = 9; return;
	}

else if((mykey == 33)){parent.decconetmain.focus(); return;}//pgup

else if((mykey == 34)){parent.decconetmain.focus(); return;}//pgdn

else if((mykey == 35)){parent.decconetmain.focus(); return;}//end

else if((mykey == 36)){parent.decconetmain.focus(); return;}//end

else if((mykey == 37)){return;}

else if((mykey == 39)){return;}

else if((mykey == 38)){//If its an up arrow

myvar=event.srcElement;

if(myvar.tabIndex==1){event.returnValue=false;}

else if(myvar.id!="qty"){event.returnValue=false;}

else{

	myobject=document.all.qty[myvar.tabIndex-2];

	myobject.focus();

	return;

	}

}

else if((mykey == 40)){event.keyCode = 9; return;}

    else if((mykey != 8 && mykey != 46)){//cant remember what these are...

    event.returnValue=false;}  //but refuse anything not defined above

}


//
// validate key strokes and accept numerics or special keys or d-z as first char
//

function dcode_val()
{
   //get the key pressed
   var mykey = event.keyCode

   // number (not numpad)
   if((mykey >= 48) && (mykey <= 57))
   {
      // did he have shift pressed? - so it's a char - refuse it
      if(event.shiftKey)
      {
         event.returnValue = false;
      }

      // setprompt for IE5.0
   	if(event.srcElement.parentElement.parentElement.name != "addByItemNoForm")
   	{
   	   doprompt = 1;
   	}

      var value_text = event.srcElement.value;
      var value_char = event.srcElement.value.charAt(0);
      var sel_range = document.selection.createRange();

      // if first character in field is not numeric
      if(value_char != '' && value_char != '0' && value_char != '1' && value_char != '2' && value_char != '3' && value_char != '4' && value_char != '5' && value_char != '6' && value_char != '7' && value_char != '8' && value_char != '9')
      {
         var sel_text = sel_range.text;
         // if the cursor is positioned at first character and no text is selected
         if(sel_range.moveStart("character", 100) == value_text.length && sel_text.length == 0)
         {
            event.returnValue = false;
         }
      }

   	return; //other wise numbers are ok
   }
   else

   // number (numpad)
	if((mykey >= 96) && (mykey <= 105))
	{
      // setprompt for IE5.0
   	if(event.srcElement.parentElement.parentElement.name != "addByItemNoForm")
   	{
   	   doprompt = 1;
   	}

      var value_text = event.srcElement.value;
      var value_char = event.srcElement.value.charAt(0);
      var sel_range = document.selection.createRange();

      // if first character in field is not numeric
      if(value_char != '' && value_char != '0' && value_char != '1' && value_char != '2' && value_char != '3' && value_char != '4' && value_char != '5' && value_char != '6' && value_char != '7' && value_char != '8' && value_char != '9')
      {
         var sel_text = sel_range.text;
         // if the cursor is positioned at first character and no text is selected
         if(sel_range.moveStart("character", 100) == value_text.length && sel_text.length == 0)
         {
            event.returnValue = false;
         }
      }

   	return; //other wise numbers are ok
   }
   else

   // d - z char
   if((mykey >= 68) && (mykey <= 90))
   {
      // if it's not been pressed in a qty field
   	if(event.srcElement.id != "qty")
   	{
         var value_text = event.srcElement.value;
         var value_char = event.srcElement.value.charAt(0);
         var sel_range = document.selection.createRange();

         if(sel_range.moveEnd("character", 1) != 0)
         {
            var sel_text = sel_range.text;
            var sel_char = sel_text.charAt(0);
            if(sel_char != '0' && sel_char != '1' && sel_char != '2' && sel_char != '3' && sel_char != '4' && sel_char != '5' && sel_char != '6' && sel_char != '7' && sel_char != '8' && sel_char != '9')
            {
               if(sel_text.length == 1)
               {
                  event.returnValue=false;
               }
            }
         }

         if(sel_range.moveStart("character", 100) != value_text.length)
         {
            event.returnValue = false;
         }

  	      return;
   	}

   	event.returnValue=false;
   }

   // tab
   if((mykey == 9))
   {
      return;
   }

   // enter
   if((mykey == 13))
   {
	   // we don't want to cancel an enter press in the add by item no
	   // "item code" field or the form doesn't autosubmit
   	if(event.srcElement.parentElement.parentElement.name != "addByItemNoForm"
   	   || event.srcElement.id == "qty")
   	{
   	   event.keyCode = 9;
   	}

   	return;
	}
   else

   // page up
   if((mykey == 33))
   {
      parent.decconetmain.focus();
      return;
   }
   else

   // page down
   if((mykey == 34))
   {
      parent.decconetmain.focus();
      return;
   }
   else

   // end
   if((mykey == 35))
   {
      parent.decconetmain.focus();
      return;
   }
   else

   // home
   if((mykey == 36))
   {
      parent.decconetmain.focus();
      return;
   }
   else

   // left arrow
   if((mykey == 37))
   {
      return;
   }
   else

   // right arrow
   if((mykey == 39))
   {
      return;
   }
   else

   // up arrow
   if((mykey == 38))
   {
      myvar = event.srcElement;

      if(myvar.tabIndex == 1)
      {
         event.returnValue = false;
      }
      else if(myvar.id != "qty")
      {
         event.returnValue = false;
      }
      else
      {
         myobject=document.all.qty[myvar.tabIndex - 2];
         myobject.focus();

      	return;
      }
   }
   else

   // down arrow
   if((mykey == 40))
   {
      event.keyCode = 9;
      return;
   }
   else

   // backspace and delete
   if((mykey != 8 && mykey != 46))
   {
      // refuse anything not defined above
      event.returnValue = false;
   }
}



function qty_plus()//increments the qty ordered by one on click

{	/*used by:

		char.html

		favourites.html

	*/

myvar=event.srcElement;//pointer to input box

myfrm=event.srcElement.parentElement.parentElement.itm.value;//waste of code?

myfrm='document.af'+myfrm;//?

if(myvar.value==9999){myvar.select(); return;}//if already maximum value of 9999 do nothing

if(myvar.value=="")myvar.value=1;//if the field was blank to begin with insert 1

else myvar.value=parseInt(myvar.value)+1;//otherwise get the number and increase it by 1

myvar.select();
ld();//and then update the bakset array
}



function scrolltop()	//scrolls the decconetmaintop frame when the main frame scrolls horizontally

	/*used by:

		char.html

	*/

{

myvar = document.body.scrollLeft; //get the offset of the main page

parent.decconetmaintop.document.body.scrollLeft = myvar; //and adjust the header to match

}



function formsubmit(form) //called by the supplier number link on search results

	/*used by:

		char.html

		basket.html

	*/

{

form.custno.value = top.getCookie('custno'); //store the customer number

form.username.value=top.getCookie('username');

form.submit()

}


function additm() //adds an item by item number to the basket

	/*used by:

		basket.html

	*/

	{



	 if(event.srcElement.name="itm"&&event.keyCode==13) {event.returnValue=false; return;}
	mystring = addByItemNoForm.itm.value	//get the item number

	 if(mystring.length==6 && additm_submitted == false){	//if the user has input 6 digits
	additm_submitted = true;
	 if(document.addByItemNoForm.qty.value.length<1||document.addByItemNoForm.qty.value==0){alert("You have not entered a qty for this item"); return false;}//check the user has already defined a qty if not warn them
	 deladd(document.addByItemNoForm, 'newItem');	 //then call the add to basket function
	}
	}



function deladd(form,action) //dynamic function that handles the new item and delete item functions in basket

	{   /*used by:

			basket.html

		*/

		var currentline = form.ln.value;



		switch(action){

		case "del": deladdarray[currentline] = form.itm.value +","+form.qty.value;



					document.adddelform.custno.value = top.getCookie('custno');

					document.adddelform.username.value=top.getCookie('username');

					document.adddelform.array.value = deladdarray;

					document.adddelform.todo.value = "del";

					document.adddelform.submit();





		break;



		case "newItem": //alert("we are adding from line" + currentline);

						deladdarray[currentline] = form.itm.value +","+form.qty.value;

						//alert(deladdarray);

						document.adddelform.custno.value = top.getCookie('custno');

						document.adddelform.username.value=top.getCookie('username');

						document.adddelform.array.value = deladdarray;

						document.adddelform.todo.value = "newItem";

						document.adddelform.submit();

		break;



		default:  alert("An unexpected error occured");

		}

	}



	function order(formname)



	{	//submits the order

		/*used by:

			checkout.html

		*/



		formname.username.value = top.getCookie('username');

		formname.custno.value = top.getCookie('custno');

		formname.submit()

	}



	function set_message()

		//writes the column headings function

		/*used by:

			most screens with anything in the header

		*/

	{

		    mainpoint=parent.decconetmain.msg;
			if(typeof(mainpoint)=="object"){

				mycheck=top.decconetmaintop.document.all["msgbox"];

				if(typeof(mycheck)=="object")
				{
				mycheck.innerHTML=mainpoint.innerHTML;
				return;
				}
				else
				{
				setTimeout("set_message()",100);
				}
			}
			else
			{
				setTimeout("set_message()",100);
			}
	}



	function doupdate()

		//returns to shelf setupmode

		/*used by:

			itemsetup.html

		*/

	{

	 parent.decconetmain.location='/cgi-bin/decco/basket?error=/u/decconet/htdocs/decconet/search/error.html&screen=/u/decconet/htdocs/decconet/search/shelfsetup.html&custno='+top.getCookie('custno')+'&Routine=13';

	}



	function newbasket()

	{	//creates an empty shopping basket file

		parent.decconetmain.location='/cgi-bin/decco/basket?screen=/u/decconet/htdocs/decconet/search/basket.html&custno='+top.getCookie('custno')+'&username='+top.getCookie('username')+'&Routine=31';

	}



	function writelabel()

{

	//checks the price option and writes column headings accordingly

	//new check that displayStock has been set to something
	//if not default it to OFF
if(typeof(displayStock)=='undefined') displayStock="OFF";

	//point to the option

	mypoint=parent.decconetmain.document.all.mypriceoption;

	//error check

	if(mypoint!=null)

	{

		mycheck=mypoint.innerText;//get the value

		myrow=label.rows[2];//point to the labels row



		switch(mycheck)	//actgion according to value

		{

			case "S":

			myrow.cells[11].innerText="SRP";	//srp only

			//the next line is commented out because we are not setting a label for the button anymore

			//priceoptions.innerText="Hide all prices";

			priceoptions.innerText="          ";	//the button should have had this value set anyway but the html needs changing

			priceoptions.style.visibility="visible"; //make the button visible (it should be anyway, but teh html needs changing)

			break;

			case "Y":

			gp = parent.decconetmain.mygp.innerText;	//check what gp option they are on

			mylabels = new Array(mytrade.innerHTML,"Disc %","Your Price","P<br>R","SRP",gp); // create an array of column headers

			startcell = (displayStock=="ON") ? 7 : 6;

				for(i=startcell;i<mylabels.length+startcell;i++)

				{	//cycle through each one writing it in as we go

					//gp is soft coded depending on their option

					myrow.cells[i].innerHTML=mylabels[i-startcell];

				}

			//priceoptions.innerText="Hide non retail prices";

			priceoptions.innerText="          ";

			priceoptions.style.visibility="visible"; //see above - the html needs changing

			break;



			default:

			//priceoptions.innerText="Show all prices";

			priceoptions.innerText="          ";

			priceoptions.style.visibility="visible";	//no labels need writing

			}

	}



	else {

		//if not ready try again

		setTimeout("writelabel();",100);

	}



}



function checklength()

{

//checks teh field length. should really be using a maxlength property in the form fields.

//but we alse refuse certain characters

point = event.srcElement;

myvalue = point.value;

if(myvalue.length==12)

{

	mykey = event.keyCode;

	if(event.keyCode==8||event.keyCode==46||event.keyCode==37||event.keyCode==39||event.keyCode==35)return;

	else{ event.returnValue=false;

	 return;}

}



if(event.keyCode==55&&event.shiftKey==true)

 {//refuse "&"

 	event.returnValue=false;

  	return;

 }



 if(event.keyCode==220&&event.shiftKey==false)

 {//refuse "\"

 	event.returnValue=false;

  	return;

 }



}



function show_prom(srcElement,gp)

{

	//karen has a mare with blank values in query string so replace it with a null to help her out

	if(gp=="")gp=null;

	top.decconetside.focus();//because p is a hyperlink it holds focus even though the

						// cursor is in a search field. We change focus to the side frame

						// to prevent confusion when hitting enter in a search field

	windowlocation = "/decconet/search/promframe2.html"

	//FD*** (handyman253) caused me to escape (\) the forward slash characters of the query string.
	//only on this line and I don't know why.
	prpath = "/cgi-bin/decco/show_prom?oldscreen=\/u\/decconet\/htdocs\/decconet\/promotions\/oldprom.html&newscreen=\/u\/decconet\/htdocs\/decconet\/promotions\/newprom.html&gp="+gp+"&item="+srcElement.id+"&custno="+top.getCookie('custno')+"username="+top.getCookie('username')+"&Routine=01";



	promwindowID = open(windowlocation, "Promotions", 'location=no,menubar=no,scrollbars=yes,resizable=yes,width=375,height=300');

	promwindowID.blur();

}

function orderOptions(readonly,file)
{
	if(readonly){
	myscreen="/u/decconet/htdocs/decconet/search/readonlyorderoptions.html";
	}
	else {
	myscreen="/u/decconet/htdocs/decconet/search/orderoptions.html";
	file="null"
	}
	windowlocation = "/cgi-bin/decco/basket?screen="+myscreen+"&custno="+top.getCookie('custno')+"&username="+top.getCookie('username')+"&file="+file+"&Routine=35";
	optionswindowID = open(windowlocation, "Promotions", 'location=no,menubar=no,scrollbars=yes,resizable=yes,width=420,height=320');
	if(optionswindowID.blur)optionswindowID.focus();
}

function showtopic(topic)
{
	//new feature in decconet means the "helpdata frame" is
	//not necessary present so point it to the main frame if that is the case
	helpdata = top.decconetmain.helpdata;
	if(typeof(helpdata)!="object")helpdata=top.decconetmain;

	switch(topic)
	{	case "logon": helpdata.location="/decconet/helpfiles/logonhelp.html";
		break;
		case "setup": helpdata.location="/decconet/helpfiles/setuphelp.html";
		break;
		case "shopman": helpdata.location="/decconet/helpfiles/shopmanhelp.html";
		break;
		case "search": helpdata.location="/decconet/helpfiles/searchhelp.html";
		break;
		case "addorder": helpdata.location="/decconet/helpfiles/addorderhelp2.html";
		break;
		case "basket": helpdata.location="/decconet/helpfiles/baskethelp.html";
		break;
		case "checkout": helpdata.location="/decconet/helpfiles/checkouthelp.html";
		break;
		case "rapidcode": helpdata.location="/decconet/helpfiles/rapidcodehelp.html";
		break;
		case "orderhist": helpdata.location="/decconet/helpfiles/orderhisthelp.html";
		break;
		case "support": helpdata.location="/decconet/helpfiles/support2.html";
		break;
		default: helpdata.location="/decconet/helpfiles/index2.html";
	}
}

function showStats(itm)
{
	decconetInfoWindow=open("/cgi-bin/decco/basket?item="+itm+"&custno="+top.getCookie("custno")+"&username="+top.getCookie("username")+"&screen=/u/decconet/htdocs/decconet/search/24months.html&Routine=37","info",'location=no,menubar=no,resizable=yes,width=600,height=140');
	//decconetInfoWindow.focus();
	//decconetInfoWindow.document.title="24 Months Sales Statistics for item "+itm;
}
