function mailto(user, domain) { window.location = "mailto:" + user + "@" + domain; }

function doFooter (loggedin) {
	document.writeln ('<table width="980" border="0" cellspacing="0" cellpadding="0" class="footer">');
		document.writeln ('<tr><td colspan="2" align="center"><img src="images/shim.gif" width="1" height="12" alt=""><img src="images/shim.gif" width="1" height="11" alt=""><br /></td></tr>');
		document.writeln ('<tr>');
			document.writeln ('<td align="left">&copy; 2009 Cory & Co</td>');
			document.writeln ('<td align="right" class="doNotPrint">');
	
				document.writeln ('<a href="contact.htm" accesskey="E">Contact Us</a> &nbsp;|&nbsp;'); 
				document.writeln ('<a href="privacy.htm" accesskey="P">Privacy</a> &nbsp;|&nbsp;'); 
				document.writeln ('<a href="legal.htm" accesskey="L">Terms &amp; conditions</a> &nbsp;|&nbsp;');
				document.writeln ('<a href="siteMap.htm" accesskey="S">Site map</a> &nbsp;|&nbsp;');
				document.writeln ('<a href="access.htm" accesskey="A">Accessibility</a></td>');
		document.writeln ('</tr>');
		document.writeln ('<tr><td colspan="2"><img src="images/shim.gif" width="1" height="12" alt=""></td></tr>');
	document.writeln ('</table>');
}

function doBanner (helpme) {
	document.writeln ('<table width="460" border="0" cellspacing="0" cellpadding="0">');
		document.writeln ('<tr valign="top">');
			
			
	if (helpme != undefined) {
		
		if (helpme == -1) {
			document.writeln ('<td align="center"><img src="images/shim.gif" width="281" height="26" alt=""><br /><a href="login.htm" target="_self"><img src="images/loginh.gif" alt="Click here to Log in and Retrieve a Quote" name="loginb" width="180" height="36" border="0" id="loginb" /></a></td>');
		}
		
		if (helpme == 1) {
			randomNum = Math.floor (Math.random() * 3) + 1; // 1,2 or 3
			document.writeln ('<td align="center"><img src="images/shim.gif" width="281" height="12" alt=""><br /><a href="javascript:NewWindow(\'helpme.htm\', \'helpmeWin\', 420, 260, \'no\', \'no\', \'no\', \'yes\', \'yes\')" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'help\',\'\',\'images/help' + randomNum + '-o.gif\',1)" onclick="this.blur()"><img src="images/help' + randomNum + '-n.gif" alt="Click here for help" name="help" width="130" height="50" border="0" id="help" /></a></td>');
		} else if (helpme == 2) {
				document.writeln ('<td align="center"><img src="images/shim.gif" width="242" height="12" alt=""><br /><a href="javascript:NewWindow(\'refineme.htm\', \'helpmeWin\', 420, 260, \'no\', \'no\', \'no\', \'yes\', \'yes\')" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'help\',\'\',\'images/help1-o.gif\',1)" onclick="this.blur()"><img src="images/help1-n.gif" alt="Click here for help" name="help" width="130" height="50" border="0" id="help" /></a></td>');
		}

	} else {	
			document.writeln ('<td align="center" class="banner"><img src="images/shim.gif" width="281" height="12" alt=""><br /><p class="bannerTxt">Get a Quote - Complete online or call</p><p class="bannerPhone">0845 465 0025</p><p class="bannerTxt"><a href="contact.htm" target="_self" class="black">Click here for Xmas opening hours</a></p></td>');
	}
			
			
			
			
			document.writeln ('<td><img src="images/shim.gif" width="1" height="73" alt="" /></td>'); // HEIGHT FIXER
			document.writeln ('<td class="toplinks" align="right"><img src="images/shim.gif" alt="" width="178" height="51" border="0" /><br />');
				document.writeln ('<a href="home.htm" target="_self" accesskey="1">Home</a>&nbsp;&nbsp;|&nbsp;'); // *** logged in/out FUDGED ***
				document.writeln ('<a href="about.htm" target="_self" accesskey="2">About</a>&nbsp;&nbsp;|&nbsp;'); // *** logged in/out FUDGED ***
				document.writeln ('<a href="contact.htm" target="_self" accesskey="3">Contact us</a>&nbsp;&nbsp;</td>'); // *** logged in/out FUDGED ***
		document.writeln ('</tr>');
	document.writeln ('</table>');


	

}


function doLogOut () { // ****** TEMPORARY BILL HACK ******
	if (confirm ('Are you sure you want to Log Out?    ')) {
		window.close ();
	} else {
		//
	}
}


// Externalisation of ActiveX content to avoid the user having to Activate interactivity every time the Flash loads.
// Necessary due to forthcoming IE update by Microsoft as a result of their patent dispute with Eolas Technologies.
// For further info see http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/overview/activating_activex.asp
var help = 2;

function createProgressBar (Qset, page, loop) {
document.write ('<object id=progressBar classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0 width=700 height=55><param name=movie value=progressBar.swf /><param name=FlashVars value=movieid=progressBar&Qset=' + Qset + '&page=' + page + '&loopanim=' + loop +' /><param name=allowScriptAccess VALUE=always /><param name=quality value=high /><param name=bgcolor value=#ffffff /><param name=wmode value=transparent /><embed src=progressBar.swf swLiveConnect=true name=progressBar FlashVars=progressBar=helppanel&Qset=' + Qset + '&page=' + page + ' allowScriptAccess=always quality=high wmode=transparent bgcolor=#ffffff width=700 height=55 type=application/x-shockwave-flash pluginspage=https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash></embed></object>');
}

function showFlashWaitAnim () {
document.write ('<div align="center"><object id=pleaseWaitAnim classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0 width=628 height=140><param name=movie value=pleaseWaitAnim.swf /><param name=allowScriptAccess VALUE=always /><param name=quality value=high /><param name=bgcolor value=#ffffff /><param name=wmode value=transparent /><embed src=pleaseWaitAnim.swf swLiveConnect=true name=pleaseWaitAnim allowScriptAccess=always quality=high wmode=transparent bgcolor=#ffffff width=628 height=140 type=application/x-shockwave-flash pluginspage=https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash></embed></object></div>');
}

function doFlashCardCheckAnim () {
document.write ('<object id=cardCheckAnim classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0 width=166 height=22><param name=movie value=cardCheckAnim.swf /><param name=FlashVars value=movieid=cardCheckAnim /><param name=allowScriptAccess VALUE=always /><param name=quality value=high /><param name=bgcolor value=#ffffff /><param name=wmode value=transparent /><embed src=cardCheckAnim.swf swLiveConnect=true name=cardCheckAnim FlashVars=movieid=cardCheckAnim allowScriptAccess=always quality=high wmode=transparent bgcolor=#ffffff width=166 height=22 type=application/x-shockwave-flash pluginspage=https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash></embed></object>');
}

function doFlashAddressCheckAnim (pc1, pc2) {
document.write ('<object id=addressCheckAnim classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0 width=166 height=22><param name=movie value=addressCheckAnim.swf /><param name=FlashVars value=movieid=addressCheckAnim /><param name=allowScriptAccess VALUE=always /><param name=quality value=high /><param name=bgcolor value=#ffffff /><param name=wmode value=transparent /><embed src=addressCheckAnim.swf swLiveConnect=true name=addressCheckAnim FlashVars=movieid=addressCheckAnim allowScriptAccess=always quality=high wmode=transparent bgcolor=#ffffff width=166 height=22 type=application/x-shockwave-flash pluginspage=https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash></embed></object>');
}

// these 2 functions are for showing / hiding content
function showXtra(theid){
	if (document.getElementById) {
		var switch_id = document.getElementById(theid);
		if (switch_id) { switch_id.className = 'show'; }
    	}
}
function hideXtra(theid){
	if (document.getElementById) {
		var switch_id = document.getElementById(theid);
		if (switch_id) { switch_id.className = 'hide'; }
	}
}

// these 4 functions are bog-standard Dreamweaver functions for button rollover images
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
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;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// opens a new window centered on screen
function NewWindow(mypage, myname, w, h, tools, menu, scrolling, resize, stat) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',toolbar='+tools+',menubar='+menu+',scrollbars='+scrolling+',resizable='+resize+',status='+stat;
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function AlertCallUs () {
	alert ('As you cannot confirm this we are unable to give you a quotation online.    \n\nPlease call one of our Account Executives on 0845 465 0025 Monday to \nFriday 9am to 7pm, and we will provide you with a quotation in a\nmatter of minutes.');
}

function AlertAssumpsFail () {
	alert ('Please confirm that you agree to the assumptions in all of the sections to proceed.\n\nIf you cannot confirm any of the assumptions, contact one of our Account Executives     \non 0845 465 0025 Monday to Friday 9am to 7pm, and we will provide you with a more\ntailored quotation in a matter of minutes.');
}

function prodUnavailable(){
	alert ("Sorry - this product is not yet available.  ");
}

function linkUnavailable(){
	alert ("Sorry - this link is not yet available.  ");
}

function underConstruction(){
	alert ("Sorry - this Product is under development.  ");
}

function doAlreadyLoggedIn(){
	alert ("\n\rYou are already Logged In!\n\r\n\rTo Log In to a different iprism account, please Log Out first.    ");
}

function doAlreadyLoggedOut(){
	alert ("You are not currently Logged In!    ");
}


// -----------------
// Flash set vars
// -----------------
var ua        = navigator.userAgent.toLowerCase(); 
var is_pc_ie  = ( (ua.indexOf('msie') != -1 ) && ( ua.indexOf('win') != -1 ) && ( ua.indexOf('opera') == -1 ) && ( ua.indexOf('webtv') == -1 ) );

/* -----------------------------------------------------------
function setFlashVariables(movieid, flashquery)

movieid: id of object tag, name of movieid passed in through FlashVars
flashquery: querystring of values to set. example( var1=foo&var2=bar )
----------------------------------------------------------- */
function setFlashVariables(movieid, flashquery){
	var i,values;
	if(is_pc_ie){
		var chunk = flashquery.split("&");
		for(i in chunk){
			values = chunk[i].split("=");
			document[movieid].SetVariable(values[0],values[1]);
		}
	}else{
		var divcontainer = "flash_setvariables_"+movieid;
		if(!document.getElementById(divcontainer)){
			var divholder = document.createElement("div");
			divholder.id = divcontainer;
			document.body.appendChild(divholder);
		}
		document.getElementById(divcontainer).innerHTML = "";
		var divinfo = "<embed src='gateway.swf' FlashVars='lc="+movieid+"&fq="+escape(flashquery)+"' width='0' height='0' type='application/x-shockwave-flash'></embed>";
		document.getElementById(divcontainer).innerHTML = divinfo;
	}
}
// ----------------------
// end of Flash set vars
// ----------------------

// ----------------------------
// stripey tables
// ----------------------------
addEvent(window, "load", stripes_init);

function stripes_init() {
	// Find all tables with class sortable and make them sortable
	if (!document.getElementsByTagName) return;
	tbls = document.getElementsByTagName("table");
	for (ti=0; ti<tbls.length; ti++) {
		thisTbl = tbls[ti];
		if (((' '+thisTbl.className+' ').indexOf("stripesColour") != -1) && (thisTbl.id)) { doStripes(thisTbl); }
		if (((' '+thisTbl.className+' ').indexOf("stripesFaded") != -1) && (thisTbl.id)) { doStripes(thisTbl); }
		if (((' '+thisTbl.className+' ').indexOf("stripesGrey") != -1) && (thisTbl.id)) { doStripes(thisTbl); }
	}
}

function doStripes(table) {
	// Take object table and get all its tbodies.
	var tableBodies = table.getElementsByTagName("tbody");
	// Loop through these tbodies
	for (var i = 0; i < tableBodies.length; i++) {
		// Take the tbody, and get all its rows
		var tableRows = tableBodies[i].getElementsByTagName("tr");
		
		// Loop through these rows
		for (var j = 0; j < tableRows.length; j++) {
			// Check if j is even, and apply classes for both possible results
			if ( (j % 2) == 0  ) {
				if (tableRows[j].className == 'odd' || !(tableRows[j].className.indexOf('odd') == -1) ) {
					tableRows[j].className = swap(tableRows[j].className, 'odd', 'even');
				} else {
					tableRows[j].className += " even";
				}
			} else {
				if (tableRows[j].className == 'even' || !(tableRows[j].className.indexOf('even') == -1) ) {
					tableRows[j].className = swap(tableRows[j].className, 'even', 'odd');
				}
				tableRows[j].className += " odd";
			} 
		}		
	}
}

function addEvent(elm, evType, fn, useCapture)
// addEvent and removeEvent
// cross-browser event handling for IE5+, NS6 and Mozilla
{
	if (elm.addEventListener){
		elm.addEventListener(evType, fn, useCapture);
		return true;
	} else if (elm.attachEvent){
		var r = elm.attachEvent("on"+evType, fn);
		return r;
	} else {
		alert("Handler could not be removed");
	}
} 

function swap(s, t, u) {
  /*
  **  Replace a token in a string
  **    s  string to be processed
  **    t  token to be found and removed
  **    u  token to be inserted
  **  returns new String
  */
  i = s.indexOf(t);
  r = "";
  if (i == -1) return s;
  r += s.substring(0,i) + u;
  if ( i + t.length < s.length)
    r += replace(s.substring(i + t.length, s.length), t, u);
  return r;
}
// ----------------------------
// end of stripey tables
// ----------------------------


// ****************** start of BUBBLE HELP code ******************
var overdiv="0";
var xMouse=0;
var yMouse=0;
MSIE=document.all //prepare for IE kludge

if (!MSIE) { document.captureEvents(Event.MouseMove); }

document.onmousemove=getMouse; // initiate event handler

function getMouse(Event){ //set globals for mouse coordinates
	MSIE?xMouse=event.clientX+document.body.scrollLeft:xMouse=Event.pageX;
	MSIE?yMouse=event.clientY+document.body.scrollLeft:yMouse=Event.pageY;
}

function showBubble(content,xpos){
	if ((GetBrowserType == "ie") && (ieVersion < 7)) { hideSelectLists(); } // *** for IE (pre v7) Select layering headache ***
	
	desc="<table class='pop' summary='*'>\n<tr class='pop'><td class='pop'>\n";
	desc+=content+"<\/td><\/tr><\/table>";
	document.getElementById("object1").innerHTML = desc;
	
	// ie: -document.body- won't work with DTD XHTML 1.0 DocType so use -document.documentElement- instead
	if (GetBrowserType == "ie") {
		scrollDepth = document.documentElement.scrollTop;
		activeHeight = document.documentElement.clientHeight;
		activeWidth = document.documentElement.clientWidth;
	} else {
		scrollDepth = window.pageYOffset;
		activeHeight = window.innerHeight;
		activeWidth = window.innerWidth;
	}
	popupHeight = document.getElementById("object1").clientHeight;
	popupWidth = 280; // as dictated in CSS
	
	if (yMouse + popupHeight + 20 > activeHeight) { // if the popup's going to fall off the bottom of the page, move it up
		if (GetBrowserType == "ie") {
			yPos = yMouse + scrollDepth - popupHeight;
		} else {
			yPos = yMouse - popupHeight;
		}
		if (yPos < scrollDepth) { yPos = scrollDepth + 2; } // make sure it doesn't fall off the top of the screen
		document.getElementById("object1").style.top = yPos + 'px';
	} else { // otherwise display it below the cursor
		if (GetBrowserType == "ie") {
			document.getElementById("object1").style.top = yMouse + scrollDepth + 20 + 'px';
		} else {
			document.getElementById("object1").style.top = yMouse + 20 + 'px';
		}
	}	

	if (xMouse + popupWidth + 15 > activeWidth) { // make sure it doesn't fall off the right edge of the screen
		document.getElementById("object1").style.left = xMouse - 15 - popupWidth +'px';
	} else {
		document.getElementById("object1").style.left = xMouse + 15 +'px';
	}
}

function hideBubble(){
	if ((GetBrowserType == "ie") && (ieVersion < 7)) { showSelectLists(); } // *** for IE (pre v7) Select layering headache ***
	if (overdiv == "0") { document.getElementById("object1").style.top = "-1000px"; }
}
// ****************** end of BUBBLE HELP code ******************