<!--
/*	-------------------------------------------------------------
	OUTRIGHTPLC
	e-commerce
	+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 
	Copyright:		Tom Carrington <tom.carrington@outrightltd.com>
	Description:	Shared Scripts / Functions
	Filename:		common.js
	Version:		0.1
	Date:			Sep 25, 2006
	-------------------------------------------------------------	
	FUNCTIONS:		showHelp()
					showGlossary()
	-------------------------------------------------------------	
	INITIALISE VARIABLES
	+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 
	------------------ vv EDIT VALUES BELOW vv ------------------
	-------------------------------------------------------------*/
	var str_liveServerName 		= "www.myserver.co.uk";
	var str_pcFolder 			= "/car-insurance/"
	var str_hcFolder 			= "/home-insurance/"
	var str_tsFolder 			= "/travel-insurance/"
	var str_gvFolder 			= "/van-insurance/"
/*	-------------------------------------------------------------	
	LOGIC:			
	+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 
	Description:	Sets up policy types and https link
					prefix
	-------------------------------------------------------------*/
	var str_currentHREF = window.location.href.toLowerCase();
	var str_liveServerName = str_liveServerName.toLowerCase();
	var str_policyType = "root"
	// On a live server?
	if (str_currentHREF.indexOf(str_liveServerName) == -1 ){
		// NOT on a live server
		var str_prefix = "";
	} else{
		var str_prefix = "https://"+str_liveServerName;
	}
	// Setup policy type
	if (str_currentHREF.indexOf(str_pcFolder.toLowerCase()) > 0){str_policyType = "pc"; }
	if (str_currentHREF.indexOf(str_hcFolder.toLowerCase()) > 0){str_policyType = "hc"; }
	if (str_currentHREF.indexOf(str_tsFolder.toLowerCase()) > 0){str_policyType = "ts"; }
	if (str_currentHREF.indexOf(str_gvFolder.toLowerCase()) > 0){str_policyType = "gv"; }
/*	-------------------------------------------------------------
	FUNCTION:		showHelp()
	+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 
	Description:	This function invokes a Help popup
					
	Requires:		Case sensitive help term
	-------------------------------------------------------------*/	
	function showHelp(str_HREF){
		var wHelp = window.open(str_HREF,'helpPopup','scrollbars=yes,resizable=no,width=530,height=400');
		wHelp.focus();
	}
	
/*	-------------------------------------------------------------
	FUNCTION:		popup()
	+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 
	Description:	This function invokes a popup
					
	Requires:		href
	-------------------------------------------------------------*/	
	function popup(str_HREF){
		var wPop = window.open(str_HREF,'Popup','scrollbars=yes,resizable=no,width=530,height=350');
		wPop.focus();
	}
	
	
	
	
/*	-------------------------------------------------------------
	FUNCTION:		getXmlHttpRequestObject()
	+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 
	Description:	This function returns an AJAX obj

	-------------------------------------------------------------*/		
	function getXmlHttpRequestObject() {
		if (window.XMLHttpRequest) {
			return new XMLHttpRequest();
		} else if(window.ActiveXObject) {
			return new ActiveXObject("Microsoft.XMLHTTP");
		} else {
			alert("Your Browser Sucks!\nIt's about time to upgrade don't you think?");
		}
	}

/*	-------------------------------------------------------------
	FUNCTION:		drinkRelatedExtras()
	+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 
	Description:	This function shows/hides & enables/disables
					the extra drink questions on the conviction 
					page
	Requires:		value of the cnv_type
	-------------------------------------------------------------*/	
	function drinkRelatedExtras(myval, myid){
		
		var str_cnvid = myid.substr(0,4)
		var arr_drkRelatedCodes = new Array("CD40","CD60","DR10", "DR20", "DR40", "DR50");
		var bln_isDrink = false;
		
		for (var i = 0; i < arr_drkRelatedCodes.length; i++) {
			if (myval == arr_drkRelatedCodes[i]){
				bln_isDrink = true;
			}
		}
			
		if (bln_isDrink){//open
			$(str_cnvid + "_ReadingType").disabled = false;
			$(str_cnvid + "_ReadingLevel").disabled = false;
			show(str_cnvPrefix + "ReadingType_req",str_cnvPrefix + "ReadingLevel_req");
		}else{//close
			$(str_cnvid + "_ReadingType").value = "";
			$(str_cnvid + "_ReadingLevel").value = "";
			$(str_cnvid + "_ReadingType").disabled = true;
			$(str_cnvid + "_ReadingLevel").disabled = true;
			hide(str_cnvPrefix + "ReadingType_req",str_cnvPrefix + "ReadingLevel_req")
		}
	}
//-->