﻿
function SubmitForm() {
    $('frmForm').request({
        method: 'get',
        onSuccess: function(transport) {
            return transport.responseText;
        },
        onFailure: function(transport) {
            return transport.responseText;
        },
        onException: function(transport) {
            return transport.responseText;
        }
    });
}
window.addEvent('domready', function() {
    $('ctl00_txtSearch').addEvent('click', function() {
        if (this.value == "Search") {
            this.value = "";
            this.setStyle('color', '#000000');
        }
    });
    $('ctl00_txtSearch').addEvent('blur', function() {
        if (this.value == "") {
            this.setStyle('color', '#9DA2A8');
            this.value = "Search";
        }
    });

    var myTips = new Tips('.tooltip');
    myTips.addEvent('show', function(tip) {
        //tip.fade('in');
        tip.setStyle('opacity', '0.9');
        
    });

    $('imgEmailUs').store('tip:title', 'Email Us');
    $('imgEmailUs').store('tip:text', 'Click to Email Lombard.');

    $('imgPrint').store('tip:title', 'Print');
    $('imgPrint').store('tip:text', 'Click to print this page.');

    $('imgHome').store('tip:title', 'Home');
    $('imgHome').store('tip:text', 'Click to go to the home page.');
    
    $('navConstructionBonds').store('tip:title', 'Construction Bonds');
    $('navConstructionBonds').store('tip:text', 'Bid / tender bonds. Advance payment bonds.<br>Performance bonds. Retention bonds.<br>Guarantees / bonds for temporary import.<br><i>Click to read more.</i>');
    
    $('navEngineering').store('tip:title', 'Engineering Insurance');
    $('navEngineering').store('tip:text', 'Consort underwrites all classes of Engineering Insurance<br> on behalf of Lombard, including Contract Works and<br>Public Liability, Plant All Risks, Machinery Breakdown, Electronic<br>Equipment and Business Interruption Insurance.<br><i>Click to read more.</i>');
    
    $('navTradeCredit').store('tip:title', 'Trade Credit');
    $('navTradeCredit').store('tip:text', 'Domestic and export credit insurance.<br><i>Click to read more.</i>');
    
    $('navIncomeProtection').store('tip:title', 'Income Protection');
    $('navIncomeProtection').store('tip:text', 'FMI\'s product offering spans the following areas:<ul><li>Products for individuals<ul><li>Business Person Elect o Professional Elect</li></ul></li><li>Products for Groups<ul><li>Vision</li></ul></li></ul><i>Click to read more.</i>');
    
    $('navProfessionalIndemnity').store('tip:title', 'Professional Indemnity');
    $('navProfessionalIndemnity').store('tip:text', 'Leppard and Associates was incorporated in 1991<br>as a Professional Indemnity underwriting agency.<br>They are fully tribunalised Lloyd’s Underwriting Managers<br>for all short term business and since their inception<br>have established themselves as a market leader in their field.<br><i>Click to read more.</i>');
    
    $('navConsumerCreditProtection').store('tip:title', 'Consumer Credit Protection');
    $('navConsumerCreditProtection').store('tip:text', 'Consumer Credit Insurance business is built around the<br>provision of insurance products to consumers and corporate<br>customers in distinct market segments namely<br>Banks, Retailers, Brokers, the Motor Trade<br>and other consumer credit markets.<br><i>Click to read more.</i>');
    
    $('navGeneralCommercialBonds').store('tip:title', 'General & Commercial Guarantees');
    $('navGeneralCommercialBonds').store('tip:text', 'Fuel Guarantees. Customs and Excise guarantees.<br>Facilities management. Department of education.<br>Travel bonds.<br><i>Click to read more.</i>');
    
    $('navMiningBonds').store('tip:title', 'Mining Rehabilitation Bonds');
    $('navMiningBonds').store('tip:text', 'Mining rehabilitation guarantees.<br><i>Click to read more.</i>');
    
    $('navTradeFinance').store('tip:title', 'Trade Finance');
    $('navTradeFinance').store('tip:text', 'Trade Finance.<br><i>Click to read more.</i>');
    
    $('navDepositAdvantage').store('tip:title', 'Deposit Advantage');
    $('navDepositAdvantage').store('tip:text', 'A guarantee issued as a substitute for a cash deposit<br>in a property transaction.<br><i>Click to read more.</i>');
});

function ZoomElement(element) {
    var myEffect = new Fx.Morph(element, { duration: 'short', transition: Fx.Transitions.Sine.easeOut });
    var size = element.getSize();
    myEffect.start({
        'height': 12,
        'width': 18 
    });
}

function ResetElement(element) {
    var myEffect = new Fx.Morph(element, { duration: 'short', transition: Fx.Transitions.Sine.easeOut });
    var size = element.getSize();
    myEffect.start({
        'height': size.y,
        'width': size.x
    });
}

function MoveElementLeft(element) {
    var myEffect = new Fx.Morph(element, { duration: 'short', transition: Fx.Transitions.Sine.easeOut });
    myEffect.start({
        'padding-left': 8
    });
}
function MoveElementRight(element) {
    var myEffect = new Fx.Morph(element, { duration: 'short', transition: Fx.Transitions.Sine.easeOut });
    myEffect.start({
        'padding-left': 0
    });
}

function checkEmail() {
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($('txtEmail').value)) {
        return (false)
    }
    return (true)
}

function SubmitContactMeForm() {
    if (CheckForm()) {
        $('btnSubmit').set('disabled', 'disabled'); 
        $('tdSubmit').set('html', "<img src='images/ajax-loader.gif' border='0'> Submitting email...");
        //$('tdSubmitText').set('html', "");
        
        $('frmContactMe').set('send', {
            onComplete: function(response) {
                //log.removeClass('ajax-loading');
                $('TB_ajaxContent').set('html', response);
            }
        });
        //Send the form.
        $('frmContactMe').send();
    }
}

function CheckForm() {
    myOption = -1;
    for (i = frmContactMe.rbIAm.length - 1; i > -1; i--) {
        if (frmContactMe.rbIAm[i].checked) {
            myOption = i; i = -1;
        }
    }
    if (myOption == -1) {
        alert("Please specify client or broker.");
        return false;
    }

    if ($('txtName').value == '') { alert("Please enter a your name."); return false; }
    if ($('txtCell').value == '') { alert("Please enter your cellphone number."); return false; }
    if ($('txtTelephone').value == '') { alert("Please enter your telephone number."); return false; }    
    if (checkEmail()) { alert("Please enter a valid email address."); return false; }
    return true;
}