﻿var Contact = (function() {
	var w = document.body.clientWidth, h=document.body.clientHeight;
    document.getElementById('lcCenter').style.left = (w / 2);
    var c = document.getElementById('ContactUs');
    c.onclick = function () {
        Contact.open('contact_us.aspx', {initialWidth : 490, initialHeight:320});
        return false;  }
    c.href='#'
    c=document.getElementById('SendNews');
    c.onclick = function () {
        Contact.open('sendNews.aspx', {initialWidth : 480, initialHeight:365});
        return false; }
    c.href='#'
});

Contact.open = function(url, options){
    var centerWidth = (options.initialWidth)?options.initialWidth:250,
        centerHeight= (options.initialHeight)?options.initialHeight:250,
        center = document.getElementById('lcCenter'),
        middle = document.body.scrollTop + (document.body.clientHeight / 2),
        frame = document.getElementById('lbIframe'),
        overlay = document.getElementById('lcOverlay');

    center.style.top= Math.max(0, middle - (centerHeight / 2)), 
    center.style.width= centerWidth, 
    center.style.height= centerHeight, 
    center.style.marginLeft= -centerWidth/2, 
    center.style.display= "";
    overlay.style.height = document.body.scrollHeight;
    overlay.style.width = document.body.clientWidth;
    overlay.style.display = "";
	frame.src = url;
	return false;
}

Contact.isActive = function(){
    return document.getElementById('lcCenter').style.display != "none";
}

Contact.close = function(){
    document.getElementById('lcCenter').style.display = "none";
    document.getElementById('lcOverlay').style.display = "none";

    return false;
}
