var valid = new Array();
valid['Email'] = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890@._-';
valid['First Name'] = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
valid['Last Name'] = valid['First Name'];
valid['Title'] = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890., ';
valid['Company'] = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890._-, ';
valid['Address Line 1'] = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890._-, ';
valid['Address Line 2'] = valid['Address Line 1'];
valid['Address Line 3'] = valid['Address Line 1'];
valid['Telephone'] = '01234567890@.-+()';
valid['Fax'] = '01234567890@.-+()';


var Geometry = {};

if(window.screenLeft)
{
    Geometry.getWindowX = function() { return window.screenLeft; };
    Geometry.getWindowY = function() { return window.screenTop; };
}
else if (window.screenX)
{
    Geometry.getWindowX = function() { return window.screenX; };
    Geometry.getWindowY = function() { return window.screenY; };

}

if(window.innerWidth)
{  // All but IE
    Geometry.getViewPortWidth = function() { return window.innerWidth; };
    Geometry.getViewPortHeight = function() { return window.innerHeight; };
    Geometry.getHorizontalScroll = function() { return window.pageXOffset };
    Geometry.getVerticalScroll = function() { return window.pageYOffset };
}
else if(document.documentElement && document.documentElement.clientWidth)
{
    // IE6 when there is a doctype
    Geometry.getViewPortWidth = function() { return document.documentElement.clientWidth; };
    Geometry.getViewPortHeight = function() { return document.documentElement.clientHeight; };
    Geometry.getHorizontalScroll = function() { return document.documentElement.scrollLeft; };
    Geometry.getVerticalScroll = function() { return  document.documentElement.scrollTop;};
}
else if(document.body.clientWidth)
{
    // IE4, IE5, IE6 Without a doctype

    Geometry.getViewPortWidth = function() { return document.body.clientWidth; };
    Geometry.getViewPortHeight = function() { return document.body.clientHeight; };
    Geometry.getHorizontalScroll = function() { return document.body.scrollLeft; };
    Geometry.getVerticalScroll = function() { return  document.body.scrollTop;};

}


function subscribeOnClick()
{
    var url = '/news/csminsights/subscribe';
    var md = document.getElementById('modalDialogBox');
    var style = md.style;
    var ajax = new Ajax.Updater( {success: 'modalDialogBox'}, url, {method: 'get'} );

    style.backgroundColor='#ffffcc';
    style.border='solid 1px #000000';
    style.padding='10px';

    var center = ((Geometry.getViewPortWidth() + Geometry.getHorizontalScroll() )/2)-200;
    var top = (Geometry.getViewPortHeight()/2)+Geometry.getVerticalScroll()-200;

    style.top=top+'px';
    style.left=center+'px';



    style.width='400px';
    style.height='340px';
    style.display='none';
    new Effect.Grow(md);
    //new Effect.Highlight(md,{duration:2,startcolor: '#f9f9f9',endcolor: '#ffffcc'});

}


function submitNewsLetterSubscription(form)
{

    var url = '/news/csminsights/subscribe'
    new Ajax.Updater('modalDialogBox', url, { asynchronous: true, parameters: Form.serialize(form), method: 'post'} );
    var md = document.getElementById('modalDialogBox');
    new Effect.Highlight(md,{duration:2,startcolor: '#f9f9f9',endcolor: '#ffffcc'});
    return false;

}


function closeSubscriptionWindow()
{
    var md = document.getElementById('modalDialogBox');
    new Effect.Shrink(md);
    md.innerHTML='';
    return false;

}

// filtering function for input data
// we do it again on the server, but if we can save
function nlFilter(field)
{

    return true;
    var nval = '';
    for(i=0;i< field.value.length; i++)
    {
        for(j=0;j<valid[field.name].length;j++)
        {
            if( valid[field.name][j] == field.value[i] )
            {
                nval += field.value[i];
                break;
            }

        }
    }
    field.value=nval;    

}



function showImage(url,width,height)
{   var params = 'width='+width+', height='+height;
    var xw = window.open(url,'imgwin',params);
    xw.focus();
    return false;

}





