// UN COMMENT THIS CODE TO STOP RIGHT CLICKING ON THE DUET DESIGN!!!var stripe0 = '#FEFEFE'			// FOR ZEBRA STRIPED TABLES FURTHER DOWN - HARD CODED COLOURS, I KNOW ... THE SHAME!var stripe1 = '#ECF0F8'stripe1 = '#EFEFEF'var hidetimer   // used so that if the user flips on and off a lot of helppopups they tidy up after themselvesvar message="";var form="";function clickIE() {	if (document.all) {(message);return false;}}function clickNS(e) {	if  (document.layers||(document.getElementById&&!document.all)) {		if (e.which==2||e.which==3) {(message);return false;}	}	if (document.layers) {		document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;	} else {		document.onmouseup=clickNS;document.oncontextmenu=clickIE;	}}//if (window.location.href.indexOf("duetdev") == -1) { document.oncontextmenu=new Function("return false") }function TabOver(obj){var name = obj.id.split("_").pop();$("dtabs_left_"+name).className = "tabOverLeft";$("dtabs_back_"+name).className = "tabOverBack";$("dtabs_right_"+name).className = "tabOverRight";}function TabOut(obj){var name = obj.id.split("_").pop();$("dtabs_left_"+name).className = "tabNormalLeft";$("dtabs_back_"+name).className = "tabNormalBack";$("dtabs_right_"+name).className = "tabNormalRight";}function loadURL(url){location.href = url;}//execute a script when the user presses the ENTER keyfunction doOnEnter(script) { 		var code = 0	if (event.which) {	code = event.which	} else {code = window.event.keyCode}	if (code==13) eval(script);}function submitme() {	var needToConfirm = false;	document.forms[0].submit();}function submitmeredirect() {	var needToConfirm = false;	var realret = document.forms[0].RealRedirectTo.value;	var webdbname = document.forms[0].webdbname.value;	var realretshort = realret.replace( webdbname.substring( 0 , webdbname.length - 1  ) ,"")	if (realret != webdbname) {	document.forms[0].redirectto.value = realretshort ; 	}	document.forms[0].submit();}function submitmeanon() {	var needToConfirm = false;	document.forms[0].Save.click();}function openview(theview, product, code, count) {	if (product == "cargo" && (theview == "quotesadmin" || theview=="quotes")) {		window.location.href = "/myquotes?openform";	}else if (product == "cargo" && (theview == "policiesadmin" || theview=="policies")) {		window.location.href = "/mypolicies?openform";	}else if (product == undefined) {		RenewalOffersAdminCargo			window.location.href = "/" + theview + "?openview&count=22";					} else if (code != undefined) {		window.location.href = "/" + theview + "?searchview&Query=" + code.split(":: ")[1] + "&restricttocategory=" + product + "&count=22";	} else 	{		window.location.href = "/" + theview + "?openview&restricttocategory=" + product + "&count=22";	}}/* Updated from Duet Freight, 17-Dec-2008 BP */function openviewcount(theview, product, count) {	if (product == undefined) {//@		RenewalOffersAdminCargo;		window.location.href = "/" + theview + "?openview&count=" + count;	} else {		window.location.href = "/" + theview + "?openview&restricttocategory=" + product + "&count=" + count;	}}function openviewscroll(theview, product, code) {	if (product == "cargo" && (theview == "quotesadmin" || theview=="quotes")) {		window.location.href = "/myquotes?openform";	}else if (product == undefined) {		window.location.href = "/" + theview + "?openview&count=9999"	} else if (code != undefined) {		window.location.href = "/" + theview + "?searchview&Query=" + code.split(":: ")[1] + "&restricttocategory=" + product + "&count=100"	} else 	{		window.location.href = "/" + theview + "?openview&restricttocategory=" + product + "&count=100"	}}function openviewscrolltitle(theview, product, title) {	 if (product == undefined) {		window.location.href = "/" + theview + "?openview&count=100"	} else if (title != undefined) {		window.location.href = "/" + theview + "?openview&restricttocategory=" + product + "&norestricttocategory=" + title + "&count=100"	} else 	{		window.location.href = "/" + theview + "?openview&restricttocategory=" + product + "&count=100"	}}function showdebug() {	showit = document.getElementById('showdebug')	showit.style.display = ((showit.style.display =='block') ? 'none' : 'block')}function logoff() {	window.location.href = "/logout"	//window.location.href = "/brokerhome?openform&logout"}function feedback(menu, form) {	menu = (menu=="") ? '' : "&menu=" + menu	form = (form=="") ? '' : "&form=" + form	newwindow = window.open('/feedback?openform&sys=' + window.location.host + menu + form,'feedback','menubar=no, titlebar=no, toolbar=no, status=yes,width=590,height=390,top=200,left=300', true);	if (window.focus) {newwindow.focus()}}//function checkDUET() {//	if (pageWidth() != 950) {//		if (pageHeight() != 675) {	//			window.location.href = "/WebDirectLogonError"//		}//	}//}function checkDUET() {	var sURL = window.document.URL.toString();	var arrParams = sURL.split("/");	if (pageWidth() != 950) {		if (pageHeight() != 675) {						var i = 0;			var z = 0;			for (i=0; i < arrParams.length ;i++)			{				if (arrParams[i] == "Direct") {z = 1;}			}			if (z == 0) 	{window.location.href = "/WebDirectLogonError";}		}	}}function subpop(url, width, height) {	newwindow = window.open(url,'printpreview','menubar=no, titlebar=no, toolbar=no, status=yes,width=' + width + ',height=' + height + ',top=20,left=50', true);	if (window.focus) {newwindow.focus()}}function replaceSubstring(inputString, fromString, toString) {   // Goes through the inputString and replaces every occurrence of fromString with toString   var temp = inputString;   if (fromString == "") {      return inputString;   }   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)      while (temp.indexOf(fromString) != -1) {         var toTheLeft = temp.substring(0, temp.indexOf(fromString));         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);         temp = toTheLeft + toString + toTheRight;      }   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop      var midStrings = new Array("~", "`", "_", "^", "#");      var midStringLen = 1;      var midString = "";      // Find a string that doesn't exist in the inputString to be used      // as an "inbetween" string      while (midString == "") {         for (var i=0; i < midStrings.length; i++) {            var tempMidString = "";            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }            if (fromString.indexOf(tempMidString) == -1) {               midString = tempMidString;               i = midStrings.length + 1;            }         }      } // Keep on going until we build an "inbetween" string that doesn't exist      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string      while (temp.indexOf(fromString) != -1) {         var toTheLeft = temp.substring(0, temp.indexOf(fromString));         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);         temp = toTheLeft + midString + toTheRight;      }      // Next, replace the "inbetween" string with the "toString"      while (temp.indexOf(midString) != -1) {         var toTheLeft = temp.substring(0, temp.indexOf(midString));         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);         temp = toTheLeft + toString + toTheRight;      }   } // Ends the check to see if the string being replaced is part of the replacement string or not   return temp; // Send the updated string back to the user} // Ends the "replaceSubstring" function/* ------------------------------------------------------------------------------     ZEBRA STRIPED TABLE/* ------------------------------------------------------------------------------*/function tableruler() { if (document.getElementById && document.createTextNode) {  var tables=document.getElementsByTagName('table');  for (var i=0;i<tables.length;i++) {   if(tables[i].className=='ruler' || tables[i].className=='sortable') {    var trs=tables[i].getElementsByTagName('tr');    for(var j=0;j<trs.length;j++) {     if(trs[j].parentNode.nodeName=='TBODY'  && trs[j].className != 'header' && trs[j].className != 'header1' && trs[j].className != 'colheader' && trs[j].className != 'subheadernoclick') {      if (trs[j].className=='subheader') {       trs[j].onmouseover=function(){this.className='subheader_dn';return false}       trs[j].onmouseout=function(){this.className='subheader';return false}      } else {       trs[j].onmouseover=function(){this.className='ruled';return false}       trs[j].onmouseout=function(){this.className='';return false}       if (j % 2 == 0) {trs[j].bgColor = stripe0} else {trs[j].bgColor = stripe1}       }     }    }   }  } }}function OpenDoc(unid) {window.location.href = "/0/" + unid}function EditDoc(unid) {window.location.href = "/0/" + unid + "?EditDocument"}function EditDocTop(unid) {parent.location.href = "/0/" + unid + "?EditDocument"}function OpenDocTop(unid) {parent.location.href = "/0/" + unid}// Browser Window Size and Positionfunction pageWidth() {return window.innerWidth != null? window.innerWidth: document.body != null? document.body.clientWidth:null;}function pageHeight() {return window.innerHeight != null? window.innerHeight: document.body != null? document.body.clientHeight:null;}function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset:document.documentElement.scrollLeft? document.documentElement.scrollLeft:document.body.scrollLeft? document.body.scrollLeft:0;}function posTop() {return typeof window.pageYOffset != 'undefined' ? window.pageYOffset:document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop?document.body.scrollTop:0;}function posRight() {return posLeft()+pageWidth();}function posBottom() {return posTop()+pageHeight();}function showhide(whichelement, showtrue) {	try {		trxxx = document.getElementById(whichelement);		if (showtrue ==undefined) 			trxxx.style.display = (trxxx.style.display =="none" ? "block" : "none")		else			trxxx.style.display = (showtrue ? "block" : "none")	} catch (e) {		}}/* Switches a tabbed folder design.  If required, set var currenttab=number in the JS Header of the form.  number is active tab on open.naming of tabs must follow the constructs below ----<div id="tabs">	<ul>		<li><a href="javascript:switchtab(1)" id="tab1" class="active">FIRST TAB</a></li>		<li><a href="javascript:switchtab(2)" id="tab2">SECOND TAB</a></li>	</ul></div><div class="tabbedpage active" id="tabbedpage1">	Tab page one text</div><div class="tabbedpage" id="tabbedpage2">	Tab page two text</div>*/function switchtab(newtab) {	try { 	   if(currenttab > 0) {throw true} else {throw false}	}		catch(hastab) {		if(hastab==true) {			document.getElementById("tab" + currenttab).className = ""			document.getElementById("tabbedpage" + currenttab).className = "tabbedpage"		}		else		{			try { totaltabs > 0 } catch (e) { totaltabs = 5 }			for (tab=1; tab <= totaltabs; tab++)  {			_tabbedpage = document.getElementById("tabbedpage" + tab)			if (_tabbedpage !=null) _tabbedpage.className = "tabbedpage"						_tab = document.getElementById("tab" + tab)			if (_tab !=null) document.getElementById("tab" + tab).className = ""			}		}	} 	_tab = document.getElementById("tabbedpage" + newtab)	_currclass = _tab.className	if (_currclass.indexOf('active') == -1) _tab.className += " active"	document.getElementById("tab" + newtab).className = "active"		currenttab = newtab}// USED TO RESIZE THE HEIGHT OF THE CONTENT DIV ON ANY PAGE RELEVANT TO THE HEADER HEIGHT AND VALIDATION HEIGHT (IF SHOWN)function resizewindow() {	divmain = document.getElementById("main")	divhead = document.getElementById("header")	divcontent = document.getElementById("content")		divmainsize = (divmain != null ? divmain.offsetHeight : 0)	divheadsize = (divhead != null ? divhead.offsetHeight : 0)//	validsize = (divvalid != null ? divvalid.offsetHeight : 0)	if (divcontent !=null) {divcontent.style.height = divmainsize - divheadsize - 12}	if (document.getElementById("action") != null ) document.getElementById("action").style.height = divmainsize - divheadsize - 16;	if (document.getElementById("main_narrow") != null ) document.getElementById("main_narrow").style.height = divmainsize - divheadsize - 16;}function conv2simple(unclean) { unclean = unclean.replace("&nbsp;", " ");unclean = unclean.replace("&amp;", "&");unclean = unclean.replace(/&gt;/gi, ">");unclean = unclean.replace(/&lt;/gi, "<");unclean = unclean.replace(/\r\n/g, "");unclean = unclean.replace(/\t/g, " ");unclean = unclean.replace(/<\/?\w+:[^>]*>/gi, "");unclean = unclean.replace(/<\\?\??xml[^>]>/gi, "");// unclean = unclean.replace(/<p>&nbsp;<\/p>/gi, "<BR><BR>");// unclean = unclean.replace(/&nbsp;/gi, " ");unclean = unclean.replace(/[ ]+/g, " ");unclean = unclean.replace(/<(\/)?strong>/ig, '<$1B> '); //replaces <STRONG> with <B>unclean = unclean.replace(/<(\/)?em>/ig, '<$1I> '); //replaces <EM> with <I>unclean = unclean.replace(/<\/P>/gi, '');unclean = unclean.replace(/<P/gi, "\n<P");unclean = unclean.replace(/<H/gi, "\n<H");unclean = unclean.replace(/<BR[^>]*>/gi, "\n<BR>");unclean = unclean.replace(/<TABLE/gi, '\n<TABLE');unclean = unclean.replace(/<\/TABLE>/gi, '\n<\/TABLE>');unclean = unclean.replace(/<TBODY/gi, '\n<TBODY');unclean = unclean.replace(/<\/TBODY>/gi, '\n<\/TBODY>');unclean = unclean.replace(/<TD>\n/gi, '\n<TD>');//unclean = unclean.replace(/<\/TD>/gi, '\n<\/TD>');//unclean = unclean.replace(/<TR/gi, '\n<TR');unclean = unclean.replace(/<UL/gi, '\n<UL');unclean = unclean.replace(/<\/UL>/gi, '\n<\/UL>');unclean = unclean.replace(/<OL/gi, '\n<OL');unclean = unclean.replace(/<\/OL>/gi, '\n<\/OL>');unclean = unclean.replace(/<LI/gi, '\n<LI');unclean = unclean.replace(/<DL/gi, '\n<DL');unclean = unclean.replace(/<\/DL>/gi, '<\/DL>\n');unclean = unclean.replace(/<DD/gi, '\n<DD');unclean = unclean.replace(/<FORM/gi, '\n<FORM');unclean = unclean.replace(/<\/FORM/gi, '\n<\/FORM');unclean = unclean.replace(/<SELECT/gi, '\n<SELECT');unclean = unclean.replace(/<OPTION/gi, '\n<OPTION');unclean = unclean.replace(/<INPUT/gi, '\n<INPUT');unclean = unclean.replace(/<!--/gi, '\n<!--');unclean = unclean.replace(/-->/gi, '-->\n');unclean = unclean.replace(/^\s/i, ''); //Removes Spaces on the beginning unclean = unclean.replace(/\s$/i, ''); //Removes Spaces on the end unclean = unclean.replace(/\]<\/A>/gi, '\]<\/A> ');return unclean}var xmlhttp=false;/*@cc_on @*//*@if (@_jscript_version >= 5)try {xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {try {xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");} catch (E) {xmlhttp = false;}}@end @*/if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {	xmlhttp = new XMLHttpRequest();	}function inithelp(formname) { if (document.getElementById && document.createTextNode) {  var imgs=document.getElementsByTagName('img');  for (var i=0;i<imgs.length;i++) {  	if (imgs[i].className=="help") {  	  imgs[i].onmouseover=function(){help(this.id);return false}       imgs[i].onmouseout=function(){hidehelp();return false}      }   } } form = formname}var currenthelpkey = ""var currenthelphtml = ""// AN IDEA FOR LATER!  WE CAN CHANGE THIS TO CACHE EACH LOOKED UP ENTRY INTO MEMORY, THEN IF THE USER GOES BACK TO A HELP FIELD IN THE SAME DOC/SESSION// IT'LL GET FROM CACHE AND NOT FROM AN XML LOOKUP!function help(field) {	field = field.split("h_")[1]	key = form + field		if (key != currenthelpkey) {		surl = "/help?readviewentries&restricttocategory=" + key		xmlhttp.open("GET", surl);		xmlhttp.onreadystatechange = function() {		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { showhelp(field) } }		xmlhttp.send(null);	} else 	{		showhelp(field)	}}function showhelp(field) {	var obj = document.getElementById("h_" + field);		var thediv = MM_findObj("helpdiv")	thediv.innerHTML=(xmlhttp.responseText.indexOf("<text>")==-1) ? "Sorry ... help for " + field + " not found" : conv2simple(xmlhttp.responseText)	currenthelpkey = key	currenthelphtml = thediv.innerHTML		setpos(obj, "helpdiv")	if (navigator.appName == "Microsoft Internet Explorer") {		setpos(obj, "helpiframe")		thehelpiframe = document.getElementById("helpiframe")		thehelpiframe.style.height = 100		thehelpiframe.style.visibility="visible"	}	thediv.style.visibility="visible";//	clearTimeout(hidetimer);//	hidetimer = setTimeout("hidehelp();", 25 * thediv.innerHTML.length);}function hidehelp() {	var thediv = MM_findObj("helpdiv")	thediv.style.visibility="hidden"	if (navigator.appName == "Microsoft Internet Explorer") {		thehelpiframe = document.getElementById("helpiframe")		thehelpiframe.style.visibility="hidden"	}}function setpos(obj,lyr){	var newX = findPosX(obj) + 24 - 166 - 6;					// arbitrary offsets for the position of #MAIN	var thediv = MM_findObj("header")	headerheight = parseInt(thediv.offsetHeight)		var newY = findPosY(obj) + 18 - 120 - headerheight - 16; 	var x = new getObj(lyr);	x.style.top = newY + 'px';	x.style.left = newX + 'px';}function findPosX(obj){	var curleft = 0;	if (obj.offsetParent)	{		while (obj.offsetParent)		{			curleft += obj.offsetLeft			obj = obj.offsetParent;		}	}	else if (obj.x)		curleft += obj.x;	return curleft;}function findPosY(obj){	var curtop = 0;	if (obj.offsetParent)	{		while (obj.offsetParent)		{			curtop += obj.offsetTop			obj = obj.offsetParent;		}	}	else if (obj.y)		curtop += obj.y;	return curtop;}function getObj(name){ if (document.getElementById) {	   this.obj = document.getElementById(name);	   this.style = document.getElementById(name).style; } else if (document.all) {	   this.obj = document.all[name];	   this.style = document.all[name].style; } else if (document.layers) {	   if (document.layers[name])	   {	   	this.obj = document.layers[name];	   	this.style = document.layers[name];	   }	   else	   {	    this.obj = document.layers.testP.layers[name];	    this.style = document.layers.testP.layers[name];	   } }}function MM_findObj(n, d) { //v4.01  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);  if(!x && d.getElementById) x=d.getElementById(n); return x;}<!-- From website:  http://www7.ewebcity.com/cyanide7 -->function formatCurrency(num) {	num = num.toString().replace(/\\u00A3|\,/g,'');	if(isNaN(num))	num = "0";	sign = (num == (num = Math.abs(num)));	num = Math.floor(num*100+0.50000000001);	pence = num%100;	num = Math.floor(num/100).toString();	if(pence<10)	pence = "0" + pence;	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)	num = num.substring(0,num.length-(4*i+3))+','+	num.substring(num.length-(4*i+3));	return (((sign)?'':'-') + '\u00A3' + num + '.' + pence);}// example - <input type="text" name="serialnumber" id="serialnumber" size="10" maxlength="10" onkeypress="return isNumberInput(this, event);" title="Serial number contains only digits" />function isNumberInput(field, event){	var key, keyChar;	if (window.event)		key = window.event.keyCode;	else if (event)		key = event.which;	else	return true;	// Check for special characters like backspace	if (key==null || key==0 || key==8 || key==13 || key==27 || key==16 || key==37 || key==39 || key==36 || key==46 || key==9 || (key > 95 & key < 106) || key==110 || key==190 ) return true;	// Check to see if it's a number	keyChar = String.fromCharCode(key);		if (/\d/.test(keyChar)) {		window.status = "";		return true;	}	else {		window.status = "Field accepts numbers only.";		return false;	}}function greeting() {	now = new Date();	t = now.getHours();	if (t<5) document.write("Good [very early!] morning");	else if (t<12) document.write("Good morning");	else if (t<18) document.write("Good afternoon");	else document.write("Good evening");}var win = null;function winpopup(url, w, h, scroll, status){	w = (w) ? w : 750;	h = (h) ? h : 550;	scroll = (scroll) ? scroll : 'yes';	status = (status) ? status : 'yes';		LeftPosition = (screen.width) ? (screen.width-w)/2 : 50;	TopPosition = (screen.height) ? (screen.height-h)/2 : 20;			settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+ scroll +', resizable=no, menubar=no, titlebar=no, toolbar=no, status=' + status		var now = new Date();	var hms = now.getHours() + "_" + now.getMinutes() + "_" + now.getSeconds();		newwindow = window.open(url, hms, settings)		if (window.focus) newwindow.focus()}function countLines(textareaname, charsperline){var textareaworking = document.getElementById(textareaname);var textareaarray = textareaworking.value.split(/\n/);var currentlines = 0for (var loop=0; loop < textareaarray.length; loop++){    var lengthofline = Math.ceil(textareaarray[loop].length / charsperline) ;	currentlines = currentlines + lengthofline;	}return currentlines}