﻿var Contact = (function(el) {
    var el = el||['ContactUs'];
	for($c in el)
	{
	    var c = document.getElementById(el[$c])
	    c.onclick = function () {
        	Contact.open('../contactus.aspx', {width:525, height:400, top: this.Top});
	        return false;  }
    	c.href='#';
	}
});

Contact.setup = function(open){
	if(open)
	{
		window.onresize=function(){Contact.position()};
	} else {
		window.onresize=null;
	}
}

Contact.open = function(url, options) {
    this.setup(true)
    var frame = document.getElementById('lbIframe'),
		center = document.getElementById('lcCenter'),
        middle = document.body.scrollTop + (document.body.clientHeight / 2),
		centerWidth = (options.width) ? options.width : 250,
	    centerHeight = (options.height) ? options.height : 250;

    center.style.top = ((window.pageYOffset + 100) || Math.min(window.event.offsetY - window.event.clientY + Number(options.top ? options.top : (window.event.srcElement.offsetTop + 300)), document.body.scrollHeight - 600)) + "px";
    center.style.width = centerWidth + "px";
    center.style.height = centerHeight + "px";
    center.style.marginLeft = -centerWidth / 2 + "px";

    this.position();
    frame.src = url;

    return false;
}
Contact.position = function(){
    var center = document.getElementById('lcCenter'),
        overlay = document.getElementById('lcOverlay');
		
    center.style.display= "";
    overlay.style.display = "";
    overlay.style.height = document.body.scrollHeight+"px";
    overlay.style.width = document.body.clientWidth+"px";
	overlay.style.position=(this.trident())?"absolute":"fixed";
}
Contact.trident=function(){return(!window.ActiveXObject)?false:((window.XMLHttpRequest)?5:4);}
Contact.isActive=function(){return document.getElementById('lcCenter').style.display!="none";}

Contact.close = function(){
	this.setup(false)
    document.getElementById('lcCenter').style.display = "none";
    document.getElementById('lcOverlay').style.display = "none";

    return false;
}
