// JavaScript Document

var req = null

function Click4() {

    var sURL;
    sURL = 'https://v3vi.click4assistance.co.uk/c4a.aspx?AccNo=Quest71520';
    window.open(sURL,'_blank','menubar=no,location=no,resizable=yes,scrollbars=no,status=no');
}

function SubNavText(txtID) {
    var a = document.getElementById("subNav");
    if (txtID==1) {
        a.innerHTML="<p>Stage 1 of 5: Buy policy</p>"
    }

    if(txtID==2) {
        a.innerHTML="<p>Stage 2 of 5: Login or Create an Account</p>"
    }           

    if(txtID==3) {
        a.innerHTML="<p>Stage 3 of 5: Checkout</p>"
    }
    
    if(txtID==4) {
        a.innerHTML="<p>Stage 4 of 5: Pre-Payment</p>"
    }
    
    if(txtID==5) {
        a.innerHTML="<p>Stage 5 of 5: Pay for your insurance</p>"
    }
}

function wlMenu(ID, AppPath, AgentID) {
    // Create variables
    var req = initXMLHttpClient();
  	var url=AppPath + "/_code/_script/wlMenu.aspx?zone=" + ID + "&AgentID=" + AgentID;
    var a = document.getElementById("subNav")
    
    // Lets monitor the HttpRequestObject
    req.onreadystatechange = function() {
    if (req.readyState == 4) {
        if (req.status == 200) {
   	        var b=""
	        b=req.responseText
	        a.innerHTML = b
        } else {
            alert('Loading Error: ['+req.status+'] ' +req.statusText);
        }
        }
    }
    req.open('GET', url, true);    
    req.send(null);
}

function initXMLHttpClient() {
    var xmlhttp;
    try {
    // Mozilla / Safari / IE7
        xmlhttp = new XMLHttpRequest();
    } catch (e) {
    
    // IE
    var XMLHTTP_IDS = new Array('MSXML2.XMLHTTP.6.0', 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP' );    
    var success = false;
    for (var i=0;i < XMLHTTP_IDS.length && !success; i++) {
        try {
            xmlhttp = new ActiveXObject(XMLHTTP_IDS[i]);
            success = true;
            } catch (e) {}
          }
          if (!success) {
              throw new Error('Unable to create XMLHttpRequest.');
          }
     }
     return xmlhttp;
}

function InitiatePage(ID, AppPath) {
	var xmlHttp = initXMLHttpClient();
	var url=AppPath + "/_code/_script/page.aspx?page=" + ID;
	xmlHttp.open ("GET", url, true);
	xmlHttp.send(null);
}


function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
  //code example
  //onclick="MM_goToURL('parent','index.aspx');return document.MM_returnValue
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
  // code example
  // onclick="MM_openBrWindow('index.aspx','setup','width=600,height=600')"
}

function MainMenuBck(ID, Agent) {
    var a=document.getElementById(ID);
    var b = ''
    
    if (Agent == 102916) {
        b='#FF0000'
    }
    
    a.style.backgroundColor=b;
}

function BookmarkThisSite(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else if (navigator.appName == "FireFox") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}

function DivDisplayStatus(Obj, Status) {

    var a = document.getElementById(Obj);
    a.style.display=Status;
}

/* Custom variables */

/* Offset position of tooltip */
var x_offset_tooltip = 10;
var y_offset_tooltip = 0;

/* Don't change anything below here */

var ajax_tooltipObj = false;
var ajax_tooltipObj_iframe = false;

var ajax_tooltip_MSIE = false;
if(navigator.userAgent.indexOf('MSIE')>=0)ajax_tooltip_MSIE=true;

function ajax_showTooltip(externalFile,inputObj)
{
	if(!ajax_tooltipObj)	/* Tooltip div not created yet ? */
	{
		ajax_tooltipObj = document.createElement('DIV');
		ajax_tooltipObj.style.position = 'absolute';
		ajax_tooltipObj.className = 'help';
		ajax_tooltipObj.id = 'ajax_tooltipObj';		
		document.body.appendChild(ajax_tooltipObj);

		
		//var leftDiv = document.createElement('DIV');	/* Create arrow div */
		//leftDiv.className='ajax_tooltip_arrow';
		//leftDiv.id = 'ajax_tooltip_arrow';
		//ajax_tooltipObj.appendChild(leftDiv);
		
		//var contentDiv = document.createElement('DIV'); /* Create tooltip content div */
		//contentDiv.className = 'ajax_tooltip_content';
		//ajax_tooltipObj.appendChild(contentDiv);
		//contentDiv.id = 'ajax_tooltip_content';
		
		if(ajax_tooltip_MSIE){	/* Create iframe object for MSIE in order to make the tooltip cover select boxes */
			ajax_tooltipObj_iframe = document.createElement('<IFRAME frameborder="0">');
			ajax_tooltipObj_iframe.style.position = 'absolute';
			ajax_tooltipObj_iframe.border='0';
			ajax_tooltipObj_iframe.frameborder=0;
			ajax_tooltipObj_iframe.style.backgroundColor='#FFF';
			ajax_tooltipObj_iframe.src = 'about:blank';
			ajax_tooltipObj.appendChild(ajax_tooltipObj_iframe);
			ajax_tooltipObj_iframe.style.left = '0px';
			ajax_tooltipObj_iframe.style.top = '0px';
		}

			
	}
	// Find position of tooltip
	ajax_tooltipObj.style.display='block';
	var a = document.getElementById('ajax_tooltipObj');
	a.innerHTML='Hello peeps';
	if(ajax_tooltip_MSIE){
		ajax_tooltipObj_iframe.style.width = ajax_tooltipObj.clientWidth + 'px';
		ajax_tooltipObj_iframe.style.height = ajax_tooltipObj.clientHeight + 'px';
	}

	ajax_positionTooltip(inputObj);
}

function ajax_positionTooltip(inputObj)
{
	var leftPos = (ajaxTooltip_getLeftPos(inputObj) + inputObj.offsetWidth);
	var topPos = ajaxTooltip_getTopPos(inputObj);
	
	/*
	var rightedge=ajax_tooltip_MSIE? document.body.clientWidth-leftPos : window.innerWidth-leftPos
	var bottomedge=ajax_tooltip_MSIE? document.body.clientHeight-topPos : window.innerHeight-topPos
	*/
	var tooltipWidth = document.getElementById('ajax_tooltipObj').offsetWidth +  document.getElementById('ajax_tooltipObj').offsetWidth; 
	// Dropping this reposition for now because of flickering
	//var offset = tooltipWidth - rightedge; 
	//if(offset>0)leftPos = Math.max(0,leftPos - offset - 5);
	
	ajax_tooltipObj.style.left = leftPos + 'px';
	ajax_tooltipObj.style.top = topPos + 'px';	
	
	
}

function ajax_hideTooltip()
{
	ajax_tooltipObj.style.display='none';
}

function ajaxTooltip_getTopPos(inputObj)
{		
  var returnValue = inputObj.offsetTop;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetTop;
  }
  return returnValue;
}

function ajaxTooltip_getLeftPos(inputObj)
{
  var returnValue = inputObj.offsetLeft;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetLeft;
  }
  return returnValue;
}