<!--
/*	-------------------------------------------------------------
	OUTRIGHTPLC
	e-commerce
	+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 
	Copyright:		Tom Carrington <tom.carrington@outrightltd.com>
	Description:	Generic Scripts / Functions
	Filename:		Library.js
	Version:		0.5
	Date:			Nov 01, 2006
	-------------------------------------------------------------	
	FUNCTIONS:		$F()
					$()
					SelectSet()
					IsNumeric()
					hide()
					show()
					toggle()
					toTop()
					initRows()
					initHighlight()
					initErrors()
					formHint()
					attachFormHintFunction
					Find_PositionX()
					Find_PositionY()
	-------------------------------------------------------------*/
	var ie6						= false
	if(navigator.userAgent.indexOf('MSIE 6')>=0 || navigator.userAgent.indexOf('MSIE 5')>=0 || navigator.userAgent.indexOf('MSIE 4')>=0) {
		  ie6						= true
	}
	/*-------------------------------------------------------------
	FUNCTION:		$F()
	+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 
	Description:	These functions returns the value of a form
					element (pass it the name attribute)
					
	Requires:		NAME
	-------------------------------------------------------------*/
	function $F(str_var){
		var elements = document.getElementsByName(str_var);
		var el = elements[0];
		switch(el.type) {
			case 'text':   				return el.value; break
			case 'hidden':   			return el.value; break
			case 'select-one':  		return el.options[el.selectedIndex].value; break
			case 'select-multiple':  	return el.options[el.selectedIndex].value; break
			case 'radio':  				return get_selected(elements); break  
		}
	}
	
	function get_selected(radio_group){
		selected_element = -1;
		for (i=radio_group.length-1; i > -1; i--) {
			if (radio_group[i].checked){selected_element = i;}
		}
		if (selected_element == -1) {
			return "none selected";
		}else{
			return radio_group[selected_element].value;
		}
	}
/*	-------------------------------------------------------------
	FUNCTION:		SelectSet()
	+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 
	Description:	This function sets the value of a select box
					
	Requires:		Name, Value
	-------------------------------------------------------------*/	
	function SelectSet(SelectName, Value){
	var elements = document.getElementsByName(SelectName);
	var el = elements[0];
	
	for(index = 0; index < el.options.length; index++){
		if(el.options[index].value == Value)
			el.selectedIndex = index;
		}
	}
/*	-------------------------------------------------------------
	FUNCTION:		$()
	+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 
	Description:	This function returns the form element 
					object.
					
	Requires:		ID
	-------------------------------------------------------------*/
	function $() {
		var elements = new Array();
		for (var i = 0; i < arguments.length; i++) {
			var element = arguments[i];
			if (typeof element == 'string')
				element = document.getElementById(element);
			if (arguments.length == 1)
				return element;
			elements.push(element);
		}
		return elements;
	}	
/*	-------------------------------------------------------------
	FUNCTION:		IsNumeric()
	+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 
	Description:	This function returns true or false depending 
					if the passed number is numeric
	-------------------------------------------------------------*/
	function IsNumeric(sText){
		var ValidChars = "0123456789";
		var IsNumber=true;
		var Char;
		
		for (i = 0; i < sText.length && IsNumber == true; i++){ 
			Char = sText.charAt(i); 
			if (ValidChars.indexOf(Char) == -1){
				IsNumber = false;
			}
		}
		return IsNumber;
	}
/*	-------------------------------------------------------------

	FUNCTION:		hide(), show(), toggle()
	+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 
	Description:	These little functions hide or show 
					elements (pass the id attribute)
					
	Requires:		ID (Single || Array )
	-------------------------------------------------------------*/
	function hide(){
		for (var i = 0; i < arguments.length; i++) {
			var el = $(arguments[i]);
			el.style.display = 'none';
		}
	}
	
	function show(){
		for (var i = 0; i < arguments.length; i++) {
			var el = $(arguments[i]);
			el.style.display = '';
		}
	}
	
	function toggle() {
		for (var i = 0; i < arguments.length; i++) {
			var el = $(arguments[i]);
			if ( el.style.display != 'none' ) {
				el.style.display = 'none';
			}
			else {
				el.style.display = '';
			}
		}
	}
/*	-------------------------------------------------------------
	FUNCTION:		initRows()
	+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 
	Description:	This function performs a smooth scroll 
					from the bottom to the top of the page.
	-------------------------------------------------------------*/
	function initRows(){
	var even = false;
	var altname = "alt";
	var divs = document.getElementsByTagName("li");
	for (var i = 0; i < divs.length; i++) {
		if (divs[i].className != "title"){
			divs[i].className = even ? divs[i].className + " " + altname : divs[i].className;
			even = ! even;
		}
	}
		initDates();
		formHint();
	}
/*	-------------------------------------------------------------
	FUNCTION:		initDates()
	+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 
	Description:	This function performs a smooth scroll 
					from the bottom to the top of the page.
	-------------------------------------------------------------*/
	function initDates() {
		if (!document.getElementsByTagName){ return; }
		var allfields = document.getElementsByTagName("input");
		var dateadded = false;
		var calendaradded = false;
		if (!calendaradded && document.getElementById('container')){
			html = document.getElementById('container').innerHTML;
			html = html + "<div id='calendar_' class='calendar_'></div>";
			document.getElementById('container').innerHTML = html;
			calendaradded = true;
		}
		// loop through all input tags and add events
		for (var i=0; i<allfields.length; i++){
			var field = allfields[i];
			if (field.getAttribute("type") == "text" &&  field.getAttribute("maxlength") == 10 && field.name != "Proposer.id.1_DateOfBirth" && field.name != "Driver.id_DateOfBirth" && field.name != "Proposer.id.1_Licence.date" && field.name != "Driver.id_Licence.date" && field.name != "Date_of_birth") {
				//write calendar_ div
				
					
				var link = document.createElement('a');

				//link.href=    "Javascript:show_calendar('"+field.name+"', $F('"+field.name+"'));";
				link.id	= field.name + ".link";
				link.href=    "Javascript:calStartDate_.select('"+field.name+"','"+field.name+".link','dd/MM/y'); //return false;";
				//link.onClick	= "calStartDate_.select('"+field.name+"',''"+field.name+"'.link','dd/MM/y'); return false;";
				link.tabIndex = field.tabIndex+1;
				link.title=   "Click here to choose a date";
				link.alt=   "Click here to choose a date";
				link.className=   "datepicker";
				
				var image = document.createElement('img');
				image.src = "/_resources/images/spacer.gif";
				image.className = "iconcalendar";
				image.alt = "Click here to choose a date";
				//image.border = "0";
				//image.width = 15;
				//image.height = 15;
				link.appendChild(image);

				if (field.nextSibling){
					field.parentNode.insertBefore(link, field.nextSibling);
				}else{
					field.parentNode.appendChild(link);
				}
				dateadded=true;
			}
		}
		if(dateadded){
			html = document.getElementById('page').innerHTML;
			html = html + "<div id='calendar_' class='calendar_'></div>";
			document.getElementById('page').innerHTML = html;
			
			script = document.createElement('script');
			script.type = 'text/javascript';
			script.src = '/_resources/javascript/calendar_init.js';
			document.getElementsByTagName('head')[0].appendChild(script);
		}
	}
/*	-------------------------------------------------------------
	FUNCTION:		initHighlight()
	+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 
	Description:	This function adds onfocus/onblur methods to 
					all input/select objects adding classes of
					ipt & iptf
	-------------------------------------------------------------*/
	function initHighlight() {
		if (!document.getElementsByTagName){ return; }
		var allfields = document.getElementsByTagName("input");
		//var allselects = document.getElementsByTagName("select");
		var alltextareas = document.getElementsByTagName("textarea");
	
		// loop through all input tags and add events
		for (var i=0; i<allfields.length; i++){
			var field = allfields[i];
			if ((field.getAttribute("type") == "text") || (field.getAttribute("type") == "password") ) {
				
				if (!field.getAttribute("onfocus")){
					field.onfocus = function () {this.className = 'iptf';}
				}
				if (!field.getAttribute("onBlur")){
					field.onblur = function () {this.className = 'ipt';}
				}
			}
		}
		
		// loop through all select tags and add events
		//for (var i=0; i<allselects.length; i++){
			//var field = allselects[i];
			//field.onfocus = function () {this.className = 'iptf';}
			//field.onblur = function () {this.className = 'ipt';}
		//}
		
		// loop through all select tags and add events
		for (var i=0; i<alltextareas.length; i++){
			var field = alltextareas[i];
			field.onfocus = function () {this.className = 'iptf';}
			field.onblur = function () {this.className = 'ipt';}
		}
	}
/*	-------------------------------------------------------------
	FUNCTION:		initCancelReturnSubmit()
	+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 
	Description:	This function stope a form from submitting 
					if  ENTER is pressed
	-------------------------------------------------------------*/	
	function initCancelReturnSubmit() {
		if (!document.getElementsByTagName){ return; }
		var allinputs = document.getElementsByTagName("input");
		// loop through all input tags and add events
		for (var i=0; i<allinputs.length; i++){
			var field = allinputs[i];
			if (field.type != "image" && field.name != "x_Button" && field.type != "submit"){			
				field.onkeypress = function (obj) {
					if (document.all){
						return event.keyCode!=13;	//IE
					}else{
						return obj.keyCode!=13;		//FIREFOX
					}
				}
			}
		}
	}
/*	-------------------------------------------------------------
	FUNCTION:		initErrors(), get_previoussibling(), 
					get_firstChild()
	+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 
	Description:	This function adds a class to inputs with 
					errors & the parent row
	-------------------------------------------------------------*/
	function initErrors(){
		var arr_span = document.getElementsByTagName("span");
		
		for (var i = 0; i < arr_span.length; i++) {
			if (arr_span[i].className == "error" && arr_span[i].innerHTML != ""){
				arr_span[i].parentNode.className = "haserror";
				bln_errors = true;
			}
		}
	}
	
	// Two functions for Firefox's 
	// miss-handling of whitespace in the DOM
	function get_previoussibling(n){
		var x=n.previousSibling;
		while (x.nodeType!=1){
			x = x.previousSibling;
		}
		return x;
	}
	
	function get_firstChild(n){
		for (i=0;i<n.childNodes.length;i++){
			if(n.childNodes[i].nodeType==1){
				return n.childNodes[i];
			}

		}
	}
	
	function get_nextsibling(n){
		var x=n.nextSibling;
		if(!x){return false;}
		while (x.nodeType!=1){
			x = x.nextSibling;
			if(!x){return false;}
		}
		return x;
	}
	
	function get_secondChild(n){
		firstchild = 0
		for (i=0;i<n.childNodes.length;i++){
			if(n.childNodes[i].nodeType==1 & firstchild == 0){
				firstchild = 1
			}else if(n.childNodes[i].nodeType==1 & firstchild == 1){
				return n.childNodes[i];
			}
		}
	}
	
	
////////////////////////////////////////////////////////////////////////////////
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
////////////////////////////////////////////////////////////////////////////////
	function driver_Sex(driverTitle){
		var bln_driverM = false;
		var bln_driverF = false;
		var arr_male = new Array('Mr','Sir','Lord');
		var arr_femail = new Array('Mrs','Miss','Ms','Dame','Lady');
		var obj_QF;
		
		if ($("Proposer.id.1_Name.title") != null) {
			obj_QM = $("Proposer.id.1_SexM");
			obj_QF = $("Proposer.id.1_SexF");
		}
		else if ($("Driver.id_Name.title") != null) {
			obj_QM = $("Driver.id_SexM");
			obj_QF = $("Driver.id_SexF");
		}
		//else {
		//	sQuestion = document.xml_form.ProposerSex;
		//}
		
		if (driverTitle != "") {
			for (i=0;i<arr_male.length;i++) {
				if (driverTitle == arr_male[i]) {
					bln_driverM = true;
				}
			}
			for (j=0;j<arr_femail.length;j++) {
				if (driverTitle == arr_femail[j]) {
					bln_driverF = true;
				}
			}
			
			//obj_QM.checked = false;
			//obj_QF.checked = false;
			
			if (bln_driverM) { obj_QM.checked = true; }
			if (bln_driverF) { obj_QF.checked = true; }
		}
		
	}
////////////////////////////////////////////////////////////////////////////////
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
////////////////////////////////////////////////////////////////////////////////	
	function defaultOccupation(EmploymentStatusObject){
		EmploymentStatus = EmploymentStatusObject.value;
		EmploymentScope = EmploymentStatusObject.name.split("_")[1].substr(0,4);
		// test to see whether called from proposer or additional driver page
		// and setup name of form fields appropriately
		var insuredSex;
		var occupationSearchField;
		var occupationResultsField;
		var employerSearchField;
		var employerResultsField;
		
		if ($("Proposer.id.1_SexM") != null) 
		{
		    var alertMsgBoth = "Your occupation and employer's business have been automatically set to the most suitable for your employment status";
		    var alertMsgStudent = "Please select the most appropriate choice from the occupation selection (Your employer's business has been automatically set to the most suitable for your employment status)";
			if ($("Proposer.id.1_SexM").checked) {
				insuredSex = $("Proposer.id.1_SexM").value;
			}
			else {
				insuredSex = $("Proposer.id.1_SexF").value;
			}
			occupationSearchField = $("Proposer.id.1_" + EmploymentScope + "TimeOccupation.occDesc");
			occupationResultsField = $("Proposer.id.1_" + EmploymentScope + "TimeOccupation.occCode");
			
			employerSearchField = $("Proposer.id.1_" + EmploymentScope + "TimeOccupation.empDesc");
			employerResultsField = $("Proposer.id.1_" + EmploymentScope + "TimeOccupation.empCode");
		}else {
			var alertMsgBoth = "Their occupation and employer's business have been automatically set to the most suitable for their employment status";
			var alertMsgStudent = "Please select the most appropriate choice from the occupation selection (Their employer's business has been automatically set to the most suitable for their employment status)";
			if ($("Driver.id_SexM").checked) {
				insuredSex = $("Driver.id_SexM").value;
			}else {
				insuredSex = $("Driver.id_SexF").value;
			}
			occupationSearchField = $("Driver.id_" + EmploymentScope + "TimeOccupation.occDesc");
			occupationResultsField = $("Driver.id_" + EmploymentScope + "TimeOccupation.occCode");
			
			employerSearchField = $("Driver.id_" + EmploymentScope + "TimeOccupation.empDesc");
			employerResultsField = $("Driver.id_" + EmploymentScope + "TimeOccupation.empCode");
		}

		switch (EmploymentStatus) {
			case "R":
				occupationSearchField.value = "Retired";
				occupationResultsField.options.length = 0;
				occupationResultsField.options[0] = new Option("Retired","R09");
				occupationResultsField.options[0].selected = true;
				
				employerSearchField.value = "Not In Employment";
				employerResultsField.options.length = 0;
				employerResultsField.options[0] = new Option("Not In Employment","186");
				employerResultsField.options[0].selected = true;
				alert(alertMsgBoth);
				break;
			case "FTE":
				occupationSearchField.value = "Student";
				occupationResultsField.options.length = 0;
				// CREATE AN OBJECT TO PASS TO AJAX REQUEST
				var theStatus = new Object;
				theStatus.keyCode = 0;
				
				if (EmploymentScope =="Part"){
					searchOccupationPt(theStatus);
				}else{
					searchOccupation(theStatus);
				}
				
				employerSearchField.value = "Not In Employment";
				employerResultsField.options.length = 0;
				employerResultsField.options[0] = new Option("Not In Employment","186");
				employerResultsField.options[0].selected = true;
				alert(alertMsgStudent);
				break;
			case "U":
				occupationSearchField.value = "Unemployed";
				occupationResultsField.options.length = 0;
				occupationResultsField.options[0] = new Option("Unemployed","U03");
				occupationResultsField.options[0].selected = true;
				
				employerSearchField.value = "Not In Employment";
				employerResultsField.options.length = 0;
				employerResultsField.options[0] = new Option("Not In Employment","186");
				employerResultsField.options[0].selected = true;
				alert(alertMsgBoth);
				break;
			case "H":
				if (insuredSex == "M") {
					occupationSearchField.value = "Househusband";
					occupationResultsField.options.length = 0;
					occupationResultsField.options[0] = new Option("Househusband","163");
					occupationResultsField.options[0].selected = true;
				}else {
					occupationSearchField.value = "Housewife";
					occupationResultsField.options.length = 0;
					occupationResultsField.options[0] = new Option("Housewife","H09");
					occupationResultsField.options[0].selected = true;
				}
				
				employerSearchField.value = "Not In Employment";
				employerResultsField.options.length = 0;
				employerResultsField.options[0] = new Option("Not In Employment","186");
				employerResultsField.options[0].selected = true;
				alert(alertMsgBoth);
				break;
			default: return false;
		}
	}
	
	function formHint(){
		//	CREATE A NEW SPAN ELEMENT
		var span = document.createElement("span");
		span.id = "hint";
		span.className = "hint";
		span.innerHTML = "";
		document.getElementsByTagName("body")[0].appendChild(span);
		// ATTACH FUNCTIONS TO INPUTS
		attachFormHintFunction(document.getElementsByTagName('input'));
		attachFormHintFunction(document.getElementsByTagName('select'));
		attachFormHintFunction(document.getElementsByTagName('textarea'));
	}
	
	function attachFormHintFunction(HTMLCollection){
		for (var i = 0; i < HTMLCollection.length; i++) {
			if (HTMLCollection[i].title != "" && HTMLCollection[i].type != "submit" && HTMLCollection[i].type != "image" && HTMLCollection[i].type != "button"){
				HTMLCollection[i].onfocus = function () {
					$("hint").innerHTML = this.title + "<span class='hint-pointer'>&nbsp;</span>";
					$("hint").style.top = (Find_PositionY(this) - 10) + "px";
					$("hint").style.left = (Find_PositionX(this) + 210) + "px";
				}
				HTMLCollection[i].onblur = function () {
					$("hint").innerHTML = "";
					$("hint").style.top = "-1000px";
				}
			}
		}
	}
	
	function Find_PositionX(obj) {
		var curleft = 0;
		if (obj.offsetParent) {
			while (1) {
				curleft+=obj.offsetLeft;
				if (!obj.offsetParent) {
					break;
				}
				obj=obj.offsetParent;
			}
		} else if (obj.x) {
			curleft+=obj.x;
		}
		return curleft;
	}
	
	function Find_PositionY(obj) {
		var curtop = 0;
		if (obj.offsetParent) {
			while (1) {
				curtop+=obj.offsetTop;
				if (!obj.offsetParent) {
					break;
				}
				obj=obj.offsetParent;
			}
		} else if (obj.y) {
			curtop+=obj.y;
		}
		return curtop;
	}
	
	function showHelp(term,local){
	if (ie6){
		if (local == 1){
			var wHelp = window.open('/car-insurance/help/inline.asp?qt=PC&amp;q='+term,'helpPopup','scrollbars=yes,resizable=no,width=530,height=350');
		}else{
			var wHelp = window.open('/car-insurance/help/pop.asp?qt=PC&amp;q='+term,'helpPopup','scrollbars=yes,resizable=no,width=530,height=350');
		}
		wHelp.focus();
	}
	else{
		$('box').className = 'loading';
		var _docHeight = (document.height !== undefined) ? document.height : document.body.offsetHeight;
		show('overlay');
		center('box');
		help('on',term,'PC',local);
 		$("overlay").style.height = _docHeight + "px"
	}
}
  //***************************************** Ajax help ***************************************
var obj_ajax 	= getXmlHttpRequestObject();
var helpmessage	= "";
var hoverid;

function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert("Your current browser does not support ActiveX controls.\nPlease upgrade your browser.");
	}
}

function stateHandler(){
	if (obj_ajax.readyState == 4){
		helpmessage = obj_ajax.responseText;
		$("helpcopy").innerHTML = helpmessage;
		$('box').style.height = 'auto';
		$('box').className = 'loaded';
	}
	return true;
}

function help(helpstate,helpid, helptype, local){
	if(helpstate == "on"){
		if(obj_ajax.readyState == 4 || obj_ajax.readyState == 0){
			hoverid = helpid;
			if (local == 1){
				url = '/car-insurance/Help/inline.asp?q=' + helpid + '&qt=' + helptype;
			}else{
				//url = '/_resources/usercontrols/application.proxy.asp?url=http://www.outrightplc.co.uk/WebServices/Help/title_message.asp?q=' + helpid + '&qt=' + helptype;
				url = '/car-insurance/Help/inline.asp?q=' + helpid + '&qt=' + helptype;
			}
			obj_ajax.open("GET", url , true);
			obj_ajax.onreadystatechange = stateHandler;
			obj_ajax.send(null);
		}
	}
}
//********************************************************************************************
function hideHelp(){
	$('Quote').style.overflow = '';
	hide('box');
	$('box').className = 'loading';
	$('helpcopy').innerHTML = '';
	hide('overlay');
	return false;
}


function center(element){
	elementType = element;
    try{
        element = $(element);
    }catch(e){
        return;
    }

    var my_width  = 0;
    var my_height = 0;

    if ( typeof( window.innerWidth ) == 'number' ){
        my_width  = window.innerWidth;
        my_height = window.innerHeight;
    }else if ( document.documentElement &&( document.documentElement.clientWidth || document.documentElement.clientHeight ) ){
        my_width  = document.documentElement.clientWidth;
        my_height = document.documentElement.clientHeight;
    }
    else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ){
        my_width  = document.body.clientWidth;
        my_height = document.body.clientHeight;
    }

    element.style.position = 'absolute';
    element.style.zIndex   = 99;

    var scrollY = 0;

    if ( document.documentElement && document.documentElement.scrollTop ){
        scrollY = document.documentElement.scrollTop;
    }else if ( document.body && document.body.scrollTop ){
        scrollY = document.body.scrollTop;
    }else if ( window.pageYOffset ){
        scrollY = window.pageYOffset;
    }else if ( window.scrollY ){
        scrollY = window.scrollY;
    }

    var elementDimensions = getDimensions(element);

    var setX = ( my_width  - elementDimensions.width  ) / 2;
    var setY = ( my_height - elementDimensions.height ) / 2 + scrollY;

    setX = ( setX < 0 ) ? 0 : setX;
    setY = ( setY < 0 ) ? 0 : setY;

    element.style.left = setX + "px";
    element.style.top  = setY + "px";
	
	//element.style.top  = (setY-200) + "px";
	if (elementType == 'callbackForm'){ element.style.top  = "96px";}
    element.style.display  = 'block';
}

function getDimensions(element) {
    element = $(element);
    var display = $(element).style.display;
    if (display != 'none' && display != null) // Safari bug
      return {width: element.offsetWidth, height: element.offsetHeight};

    // All *Width and *Height properties give 0 on elements with display none,
    // so enable the element temporarily
    var els = element.style;
    var originalVisibility = els.visibility;
    var originalPosition = els.position;
    var originalDisplay = els.display;
    els.visibility = 'hidden';
    els.position = 'absolute';
    els.display = 'block';
    var originalWidth = element.clientWidth;
    var originalHeight = element.clientHeight;
	//alert(originalHeight);
    els.display = originalDisplay;
    els.position = originalPosition;
    els.visibility = originalVisibility;
    return {width: originalWidth, height: originalHeight};
}
function opexFloat(term){
	if (ie6){
		var wHelp = window.open('/car-insurance/help/pop.asp?qt=PC&amp;q='+term,'helpPopup','scrollbars=yes,resizable=no,width=530,height=350');
		wHelp.focus();
	}
	else{
		$('boxopex').className = 'loading';
		var _docHeight = (document.height !== undefined) ? document.height : document.body.offsetHeight;
		show('overlayopex');
		center('boxopex');
		$('boxopex').style.height = 'auto';
 		$("overlayopex").style.height = _docHeight + "px"
	}
}

/*************************************** Callback ***********************************************/
var obj_callback 	= getXmlHttpRequestObject();
var callbackhtml	= "";
bsendform = true;

function callback(){
		$('header').style.height = '230px';
		show('callbackForm')
		callbackOn();
}
function callbackOn(){
	if(obj_callback.readyState == 4 || obj_callback.readyState == 0){
		url = '/Car-insurance/sub_callbackajax.asp';
		obj_callback.open("GET", url , true);
		obj_callback.onreadystatechange = callbackHandler;
		obj_callback.send(null);
	}
}
function callbackHandler(){
	if (obj_callback.readyState == 4){
		callbackhtml = obj_callback.responseText;
		$("callbackForm").style.display = 'block';
		$("callbackForm").innerHTML = callbackhtml;
		
	}
	return true;
}
function callbackOff(){
	$('header').style.height = '85px';
	hide('callbackForm')
}
function validate_callback(){
	bsendform = true;
	validate('CallbackName');
	var objRegExp = /^(0)([\d|\d\s\d]+)$/
	 if(!objRegExp.test($F('CallbackPhone'))){
		 $('eCallbackPhone').innerHTML = 'Enter a valid contact number';
		bsendform = false;
	 }
	 else{
		 $('eCallbackPhone').innerHTML = '';
	 }
	validate('CallbackTime');
	return(bsendform);
}
function validate(inputid){
	if($F(inputid) == ''){
		$(inputid+'_row').className = 'haserror';
		$('e'+inputid).innerHTML = 'Required Field.';
		bsendform = false;
	}else{$(inputid+'_row').className = '';}
}
function callbackSend(){
	if (validate_callback()){
		if(obj_callback.readyState == 4 || obj_callback.readyState == 0){
			url = '/Car-insurance/sub_callbackajax.asp?CallbackName='+$F('CallbackName')+'&CallbackTime='+$F('CallbackTime')+'&CallbackPhone='+$F('CallbackPhone')+'&CallbackAdditional='+$('CallbackAdditional').value;
			obj_callback.open("GET", url , true);
			obj_callback.onreadystatechange = callbackHandler;
			obj_callback.send(null);
		}
	}
}

  

  