/*
 * $Id: mobileSMS.js,v 1.1.2.2 2008/03/31 15:44:36 cschulze Exp $
 *
 * Events used to display/submit mobile SMS features
 */
var g_PopupIFrame;

$('mobileSMSLink').observe('click', function(event){
    $('mobileSMS').show();
    $('mobileSMS').setStyle({zIndex: 1001});
    var iFrame = document.createElement("IFRAME");
    iFrame.setAttribute('src','');
    iFrame.style.position="absolute";
    iFrame.style.left = $('mobileSMS').offsetLeft + 20 + 'px';
    iFrame.style.top = $('mobileSMS').offsetTop + 10 + 'px';
    iFrame.style.width = $('mobileSMS').offsetWidth - 40 + 'px';
    iFrame.style.height = $('mobileSMS').offsetHeight - 30 + 'px';
    
    $('mobileSMSContainer').appendChild(iFrame);
    g_PopupIFrame = iFrame;
});

$('mobileCloseBtn').observe('click', function(event) {
    $('mobileSMS').hide();
    
    $('mobileSMSContainer').removeChild(g_PopupIFrame);
    g_PopupIFrame=null;
});

$('mobileCloseBtn').observe('mouseover', function(event) {
    $('mobileCloseBtn').setAttribute('src','images/activSearch/mobileSMS/mobileXOn.gif');
});

$('mobileCloseBtn').observe('mouseout', function(event) {
    $('mobileCloseBtn').setAttribute('src','images/activSearch/mobileSMS/mobileXOff.gif');
});

$('mobileSendBtn').observe('mouseover', function(event) {
    $('mobileSendBtn').setAttribute('src','images/activSearch/mobileSMS/sendOn.gif');
});

$('mobileSendBtn').observe('mouseout', function(event) {
    $('mobileSendBtn').setAttribute('src','images/activSearch/mobileSMS/sendOff.gif');
});

$('mobileSendBtn').observe('click', function(event) {
    var form = $('mobileSMSForm');
    var phone = $F(form['areaCode']) + $F(form['exchange']) + $F(form['local']);
    var provider = $F(form['provider']);
    
    if(phone.length != 10 || provider.length == 0) {
        return false;
    }
    
    $('mobileSMSForm').submit();
});

$('mobileSMS').setStyle({display: 'none'});