/***********************************************
* Cool DHTML tooltip script II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="arrow2.gif">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thewidth, thecolor){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML="<font size=-1>" + thetext + "</font>"
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos && offsetfromcursorY > 0)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip


function showHelp(thisItem) {
	offsetfromcursorX=12; 
	offsetfromcursorY=10;
	if (document.getElementById("chkPopUpHelp").checked == true) {
		switch(thisItem) {
		case "setIntro":
			ddrivetip('Import HomeOwner Direct (Introducer) Policies into the system..', 250); 
			break;
		case "setTB":
			ddrivetip('Import HomePro Insurance (Trade Bonus) Policies into the system..', 250);
			break;
		case "setManual":
			ddrivetip('Input the new policies manually (ie one by one)..', 280);
			break;
		case "setFromFile":
			ddrivetip('Bulk Load the new policies from a comma delimited file..', 300);
			break;
		case "popUpHelp":
			ddrivetip('Turn Off PopUp Help..', 120);
			break;
		case "trainingMode":
			if (document.getElementById("chkTraining").checked == true) { 
				ddrivetip('Disable Training Mode, all Policy Changes WILL affect the live system..', 250);
			} else {
				ddrivetip('Enable Training Mode, Policy Changes WILL NOT effect the live system..', 250);
			}
			break;
		case "contactDetails_name":
			ddrivetip('Input the policy owner contact information here.  (full name)..', 250);
			break;
		case "contactDetails_address":
			ddrivetip('Input the policy owner contact information here.  (address including post code)..', 250);
			break;
		case "contactDetails_phone":
			ddrivetip('Input the policy owner contact information here.  (telephone number)..', 250);
			break;
		case "workContactDetails":
			ddrivetip('If required input the policy owner work contact information here (ie this is where the work is performed if the above address is used as a billing/postal address). Including full address and post code..', 250);
			break;		
		case "tradeType":			
			offsetfromcursorY = -70;
			ddrivetip('Select the appropriate trade associated with the work to be performed..', 250);
			break;
		case "coverLevel":			
			offsetfromcursorY = -70;
			ddrivetip('Select whether you want <b>value (</b>warranty cover only<b>)</b>, <b>value plus (</b>as per value but also covers deposits<b>)</b> or <b> commercial (</b>for non domestic work / non dwelling<b>)</b>..', 350);
			break;
		case "contractValue":
			ddrivetip('Input the total value of the works (inc VAT)..', 250);
			break;
		case "startDate":
			ddrivetip('Input the work start date..', 160);
			break;
		case "endDate":
			ddrivetip('Input the work completion date..', 220);
			break;
		case "addManual":
			ddrivetip('Add the above policy details into the Outstanding Pending table, see below..', 250);
			break;
		case "saveManual":
			ddrivetip('Save Changes to this Policy..', 170);
			break;
		case "cancelManual":
			ddrivetip('Cancel Edit of this Policy..', 170);
			break;
		case "importID":
			offsetfromcursorY = -70;
			ddrivetip('The ID of the Policy that is currently being edited..', 280);
			break;
		case "manualStatus":
			ddrivetip('Validation Errors from the input form below..', 250);
			break;		
		case "fileDetails":
			ddrivetip('Basic information from the file just uploaded..', 250);
			break;			
		case "whichFormat":
			offsetfromcursorY = -70;
			ddrivetip('Select a previously saved Import Format or use the columns from the Auto Detection..', 250);
			break;			
		case "actualData":
			ddrivetip('Actual data from the first line of the import file, select appropriate column name opposite..', 100);
			break;	
		case "saveFormat":
			ddrivetip('Select the Format Name to Save this column layout as..', 310);
			break;	
		case "newFormat":
			ddrivetip('Input a new format name to save this layout as..', 270);
			break;		
		case "back2FromFile":
			ddrivetip('Return to the previous screen..', 180);
			break;		
		case "deleteFormat":
			ddrivetip('Delete the currently selected format from the format list..', 250);
			break;
		case "OSSummary":
			offsetfromcursorY = -10;
			ddrivetip('Below is a summary of ALL the proposals waiting to be submitted, ie all policies below are waiting for the user to confirm that the details are correct (see tick box at the bottom of the screen)..', 550);
			break;
		case "FENSAOutBound":
			ddrivetip('Include this Policy in our Automatic FENSA Submission..', 250);
			break;
        case "SARNAFILAREA":
            ddrivetip('Sarnafil Roof Area..', 250);
            break;
        case "SARNAFILHEIGHT":
            ddrivetip('Sarnafil Roof Height..', 250);
            break;
		case "DOORS":
			ddrivetip('Number of Doors..', 250);
			break;
		case "WINDOWS":
			ddrivetip('Number of Windows..', 250);
			break;
		}
	}
}
