/**
 * @ this code is to handle the global URLs to make the ajax calls to the servers
 * And to handle the most basic operations such as showing the curtains and hiding them
 * which prevents the user interactions before the site loads its information
 */


var HolidayHomeURL = '/holidayhomeinsurance/insureme4couk/';
var IndexURL = '/holidayhomeinsurance/insureme4couk/index';
var Quotes_URL = '/holidayhomeinsurance/insureme4couk/instant-quote';  
var ClientInfo_URL = '/holidayhomeinsurance/insureme4couk/client-info'; 
var PaymentInfo_URL = '/holidayhomeinsurance/insureme4couk/payment-info';
var Confirmation_URL = '/holidayhomeinsurance/insureme4couk/confirmation';
var Error_URL = '/holidayhomeinsurance/insureme4couk/message-page';

var HomePage = '/holiday-home-insurance/search';
var QuotesPage = '/holiday-home-insurance/quotes';  
var ClientInfoPage = '/holiday-home-insurance/clientinfo'; 
var PaymentInfoPage = '/holiday-home-insurance/carddetails';
var ConfirmationPage = '/holiday-home-insurance/confirmation';
var ErrorPage = '/holiday-home-insurance/errorpage';



function $isSecurePage(){
	
	if (document.location.host == "83.138.171.5:8380") return false;
	if (document.location.host == "83.138.171.5:8280") return false;
	
	return true;
}

j = jQuery.noConflict();


function showCurtain(){
	
	if(isIE6()){
		j('#Curtain').css('top', '0px');
		j('#Curtain').css('position', 'absolute');
		j('#Curtain').css('height', j(document).height() + 'px');
		j('select').hide();
	}
	
	j('#Curtain').show();
	j('#AjaxLoader').show();
	
}

function hideCurtain(){
	
	if(isIE6()){
		j('select').show();
	}
	j('#Curtain').fadeOut('slow');
	j('#AjaxLoader').fadeOut('slow');
	
}

var customErrorHandler = function(error,message){
	document.location.href = ErrorPage;
	return true;
}

var errorData = null;

$errorHandler = function(data){
    errorData = data;
    if(data.success != 'true'){
        if(customErrorHandler == null){
            alert(data.message);
            return false; //not specifically handled
        }else{
            return customErrorHandler(data.error,data.message);
        }
    }

    return false; //success is not handled
}

function getLastErrorData(){
    return errorData;
}

function errorFree(){
    if(errorData != null && errorData.success != 'true'){
        alert(errorData.message);
        return false;// Error found
    }

    return true; //No errors
}

/* 
 * this function determines whether the user is using IE6
 */
function isIE6(){
	var browser=navigator.appName;
	var version=navigator.appVersion;

	if (( browser=="Netscape" || browser=="Microsoft Internet Explorer") && (version.indexOf('MSIE 6.0') > -1)){
		return true;
	}
	else{
		return false;
	}
}


