var Hoffset=70 //Enter buttons' offset from right edge of window (adjust depending on images width)
var Voffset=80 //Enter buttons' offset from bottom edge of window (adjust depending on images height)
var leftspeed=3 //Enter scroll speed in integer (Advised: 1-3)
var mainspeed=3 //Enter scroll speed in integer (Advised: 1-3)
var rightspeed=3 //Enter scroll speed in integer (Advised: 1-3)

var ieNOTopera=document.all&&navigator.userAgent.indexOf("Opera")==-1
var myleftspeed=0
var mymainspeed=0
var myrightspeed=0
var myleftdowncount=0
var myrightdowncount=0
var mymaindowncount=0
var myleftupcount=0
var myrightupcount=0
var mymainupcount=0
var ieHoffset_extra=document.all? 15 : 0


function ScrollUp(theObject, whichFrame) {
   if (whichFrame == "Left") {
      myleftupcount+=1
	    // increase speed
	    if (myleftupcount == 1) {
	       myleftspeed = myleftspeed - 8
				 theObject.title = "Click again to go to the top of the screen"
			}	 
			// go to the top of the screen
	    if (myleftupcount == 2)	{	
	        myleftspeed = myleftspeed - 3
				 myleftupcount = 0  
				 theObject.title = "Scroll Up. Click once to increase the speed. Click twice to get to the top"
				 if (window.frames["sideIframe"].frames["ExtraInfoIframe"])
    				 window.frames["sideIframe"].frames["ExtraInfoIframe"].scrollTo(0,0)
			}	 
	 }
   if (whichFrame == "Main") {
      mymainupcount+=1
	    // increase speed
	    if (mymainupcount == 1) {
	       mymainspeed = mymainspeed - 8
				 theObject.title = "Click again to go to the top of the screen"
			}	 
			// go to the end of the screen
	    if (mymainupcount == 2)	{	
	       mymainspeed = mymainspeed - 3
				 mymainupcount = 0  
				 theObject.title = "Scroll Up. Click once to increase the speed. Click twice to get to the top"
         if (window.frames["mainIframe"].frames["PickupDestinationFrame"])
				    window.frames["mainIframe"].frames["PickupDestinationFrame"].scrollTo(0,0)
      	 else
            window.frames["mainIframe"].scrollTo(0,0)
			}	 	 
	 }
   if (whichFrame == "Right") {
   	  myrightupcount += 1
	    // increase speed
	    if (myrightupcount == 1) {
	       myrightspeed = myrightspeed - 8
				 theObject.title = "Click again to go to the top of the screen"
			}	 
			// go to the end of the screen
	    if (myrightupcount == 2)	{	
	       myrightspeed = myrightspeed - 3
				 myrightupcount = 0  
				 window.frames["rightIframe"].scrollTo(0,0)
			}	 
   }	 
}
function ScrollDown(theObject, whichFrame) {
   if (whichFrame == "Left") {
      myleftdowncount+=1
	    // increase speed
	    if (myleftdowncount == 1) {
	       myleftspeed += 8
				 theObject.title = "Click again to go to the end of the screen"
			}	 
			// go to the end of the screen
	    if (myleftdowncount == 2)	{	
	       myleftspeed = 3
				 myleftdowncount = 0  
				 theObject.title = "Scroll Down. Click once to increase the speed. Click twice to get to the bottom"
				 if (window.frames["sideIframe"].frames["ExtraInfoIframe"])
   				 window.frames["sideIframe"].frames["ExtraInfoIframe"].scrollTo(0,window.frames["sideIframe"].frames["ExtraInfoIframe"].document.body.scrollHeight)
				 else 		 
  				 window.frames["sideIframe"].scrollTo(0,window.frames["sideIframe"].frames["ExtraInfoIframe"].document.body.scrollHeight)
			}	 
	 }
   if (whichFrame == "Main") {
      mymaindowncount+=1
	    // increase speed
	    if (mymaindowncount == 1) {
	       mymainspeed += 8
				 theObject.title = "Click again to go to the end of the screen"
			}	 
			// go to the end of the screen
	    if (mymaindowncount == 2)	{	
	       mymainspeed = 3
				 mymaindowncount = 0  
				 theObject.title = "Scroll Down. Click once to increase the speed. Click twice to get to the bottom"
         if (window.frames["mainIframe"].frames["PickupDestinationFrame"])
				    window.frames["mainIframe"].frames["PickupDestinationFrame"].scrollTo(0,window.frames["mainIframe"].frames["PickupDestinationFrame"].document.body.scrollHeight)
      	 else
            window.frames["mainIframe"].scrollTo(0,window.frames["mainIframe"].document.body.scrollHeight)
			}	 
	 }	 
   if (whichFrame == "Right") {
   	  myrightdowncount += 1
	    // increase speed
	    if (myrightdowncount == 1) {
	       myrightspeed += 8
				 theObject.title = "Click again to go to the end of the screen"
			}	 
			// go to the end of the screen
	    if (myrightdowncount == 2)	{	
	       myrightspeed = 3
				 myrightdowncount = 0  
				 window.frames["rightIframe"].scrollTo(0,window.frames["rightIframe"].document.body.scrollHeight)
			}	 
	 }
}

function scrollLeftFrame(){
   if (window.frames["sideIframe"].frames["ExtraInfoIframe"])
      window.frames["sideIframe"].frames["ExtraInfoIframe"].scrollBy(0,myleftspeed)
	 else		 
	    window.frames["sideIframe"].scrollBy(0,myleftspeed)
}

function scrollMainFrame(){
   if (window.frames["mainIframe"].frames["PickupDestinationFrame"])
      window.frames["mainIframe"].frames["PickupDestinationFrame"].scrollBy(0,mymainspeed)
	 else
      window.frames["mainIframe"].scrollBy(0,mymainspeed)
}

function scrollRightFrame(){
   window.frames["rightIframe"].scrollBy(0,myrightspeed)
}

function initializeIT(){
   if (myleftspeed!=0)
      scrollLeftFrame()
   if (mymainspeed!=0)
      scrollMainFrame()
   if (myrightspeed!=0)
      scrollRightFrame()
}

if (document.all||document.getElementById||document.layers)
   setInterval("initializeIT()",20)

function toPrint(selectedFrame) {
   if (selectedFrame == "sideIframe") {
	   if (window.frames[selectedFrame].frames["ExtraInfoIframe"].document.getElementById("temp")) {
       window.frames[selectedFrame].frames["ExtraInfoIframe"].document.getElementById("temp").value="Print"
       window.frames[selectedFrame].frames["ExtraInfoIframe"].document.getElementById("View").onclick()
		 }	 
	   window.frames[selectedFrame].frames["ExtraInfoIframe"].focus();
     window.frames[selectedFrame].frames["ExtraInfoIframe"].print();			
	 }		
   else {	 
	    if (window.frames[selectedFrame].frames["clientFrame"]) {
			   window.frames[selectedFrame].frames["clientFrame"].focus();
			   window.frames[selectedFrame].frames["clientFrame"].print();
			 }  
	    else {
			  window.frames[selectedFrame].focus();
				// enable options for printing
				if (window.frames[selectedFrame].document.getElementById("CallerNameText")) {
				   var AddressObject = window.frames[selectedFrame].window.frames["PickupDestinationFrame"];
					 window.frames[selectedFrame].document.getElementById("CallerNameText").disabled = false
					 window.frames[selectedFrame].document.getElementById("CallerNumber").disabled = false
					 if (window.frames[selectedFrame].document.getElementById("Reference1"))
     			    window.frames[selectedFrame].document.getElementById("Reference1").disabled = false
					 if (window.frames[selectedFrame].document.getElementById("Reference2"))
   	 			 		window.frames[selectedFrame].document.getElementById("Reference2").disabled = false
					 if (window.frames[selectedFrame].document.getElementById("Tolls"))
  	 			    window.frames[selectedFrame].document.getElementById("Tolls").disabled = false  
  				 window.frames[selectedFrame].document.getElementById("Goods").disabled = false  
  				 window.frames[selectedFrame].document.getElementById("Vehicle").disabled = false
           window.frames[selectedFrame].document.getElementById("DeliveryTime").disabled = false  
  				 window.frames[selectedFrame].document.getElementById("PickupTime").disabled = false  
  				 window.frames[selectedFrame].document.getElementById("Delivery").disabled = false
  				 window.frames[selectedFrame].document.getElementById("GoodsClass").disabled = false
  				 AddressObject.document.getElementById("PickupSite").disabled = false  
					 AddressObject.document.getElementById("PickupAddress").disabled = false   
  				 AddressObject.document.getElementById("PickupSuburb").disabled = false  
  				 AddressObject.document.getElementById("PickupInstruction").disabled = false

  				 for(i=1; i<=window.frames[selectedFrame].document.getElementById("TotalDestination").value; i++) {
	     		    if (AddressObject.document.getElementById("Destination"+i+"Site")) {
  		 		 			 AddressObject.document.getElementById("Destination"+i+"Site").disabled = false
  		 		 			 AddressObject.document.getElementById("Destination"+i+"Address").disabled = false
  		 		 			 AddressObject.document.getElementById("Destination"+i+"Suburb").disabled = false
  		 		 			 AddressObject.document.getElementById("Destination"+i+"Instruction").disabled = false
	            }
           }		
				}	 
		    window.frames[selectedFrame].print();

				// after printing, disable options again
				if (window.frames[selectedFrame].document.getElementById("CallerNameText")) {
				   var AddressObject = window.frames[selectedFrame].window.frames["PickupDestinationFrame"];
					 window.frames[selectedFrame].document.getElementById("CallerNameText").disabled = true
					 window.frames[selectedFrame].document.getElementById("CallerNumber").disabled = true
					 if (window.frames[selectedFrame].document.getElementById("Reference1"))
     			    window.frames[selectedFrame].document.getElementById("Reference1").disabled = true
					 if (window.frames[selectedFrame].document.getElementById("Reference2"))
   	 			 		window.frames[selectedFrame].document.getElementById("Reference2").disabled = true
					 if (window.frames[selectedFrame].document.getElementById("Tolls"))
  	 			    window.frames[selectedFrame].document.getElementById("Tolls").disabled = true  
  				 window.frames[selectedFrame].document.getElementById("Goods").disabled = true  
  				 window.frames[selectedFrame].document.getElementById("Vehicle").disabled = true
           window.frames[selectedFrame].document.getElementById("DeliveryTime").disabled = true  
  				 window.frames[selectedFrame].document.getElementById("PickupTime").disabled = true  
  				 window.frames[selectedFrame].document.getElementById("Delivery").disabled = true
  				 window.frames[selectedFrame].document.getElementById("GoodsClass").disabled = true
  				 AddressObject.document.getElementById("PickupSite").disabled = true  
					 AddressObject.document.getElementById("PickupAddress").disabled = true   
  				 AddressObject.document.getElementById("PickupSuburb").disabled = true  
  				 AddressObject.document.getElementById("PickupInstruction").disabled = true

  				 for(i=1; i<=window.frames[selectedFrame].document.getElementById("TotalDestination").value; i++) {
	     		    if (AddressObject.document.getElementById("Destination"+i+"Site")) {
  		 		 			 AddressObject.document.getElementById("Destination"+i+"Site").disabled = true
  		 		 			 AddressObject.document.getElementById("Destination"+i+"Address").disabled = true
  		 		 			 AddressObject.document.getElementById("Destination"+i+"Suburb").disabled = true
  		 		 			 AddressObject.document.getElementById("Destination"+i+"Instruction").disabled = true
	            }
           }		
				}	 
			 }    
	 }

  
	 
}
function toCopy(selectedFrame) {
   if (selectedFrame == "sideIframe") {
	   window.frames[selectedFrame].frames["ExtraInfoIframe"].focus();
	  	var range = window.frames[selectedFrame].frames["ExtraInfoIframe"].document.body.createTextRange();
   		range.execCommand('Copy');
	 } else {
	   if (window.frames[selectedFrame].frames["clientFrame"]) {
			   window.frames[selectedFrame].frames["clientFrame"].focus();
			   var range = window.frames[selectedFrame].frames["clientFrame"].document.body.createTextRange(); 
			} else {   
	      window.frames[selectedFrame].focus();
			   var range = window.frames[selectedFrame].document.body.createTextRange(); 
			}   
	  	range.execCommand('Copy');
	 }		
}



