﻿  var myWidth = 0, myHeight = 0;
  var scrOfX = 0, scrOfY = 0;

function showlogin()
{
	var container = document.getElementById('lightboxcontainer');
	container.style.width = "110%";
	container.style.height = "200%";
	container.style.top = "0";
	container.style.left="0";
	container.style.background = "#000000";
	$("div[id=lightboxcontainer]").fadeTo("slow",.95);
	alertSize();
	getScrollXY();
	
	//jQuery.fx.interval = 1;

	var join = document.getElementById('joinnews');
	var lightbox = document.getElementById('lightbox');
	lightbox.style.top = ((myHeight / 2) -100) + scrOfY;
	lightbox.style.top = ((myHeight / 2) -100) + scrOfY;
	lightbox.style.left= ((myWidth / 2) -150) + scrOfX;
	lightbox.style.left= ((myWidth / 2) -150) + scrOfX;
	lightbox.style.top = ((myHeight / 2) -100) + scrOfY;
	lightbox.style.left= ((myWidth / 2) -150) + scrOfX;
	$("div[id=lightbox]").toggle(500);	

}
function alertSize() 
{
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
}

function getScrollXY() {
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
}

function hidelogin()
{
	var container = document.getElementById('lightboxcontainer');
	var lightbox = document.getElementById('lightbox');
	container.style.width = "1%";
	container.style.height = "1%";
	$("div[id=lightboxcontainer]").toggle();
	
	$("div[id=lightbox]").toggle(500);	
	//container.style.visibility= "hidden";
	//lightbox.style.visibility= "hidden";	
}

//find left position of object
function findPosLeft(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
		} while (obj = obj.offsetParent);
	}
	return curleft;
}
//find top position of object
function findPosTop(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return curtop;
}

function joinnewsletter()
{
	var lightbox = document.getElementById('lightbox');
	var flag = 1;
	var email = document.getElementById('Email');
	
	
	if (email.value.indexOf("@") <=0 || email.value.indexOf(".")<=0)
	{	flag = 0;}
	
	if (flag == 1) 
	{
		mydata = "email=" + email.value;
		$.ajax({
				   type: "POST",
				   url: "joinnewsletter.asp",
				   data: mydata,
				   contentType: "application/x-www-form-urlencoded; charset=utf-8",
				   success: function(msg){ 
				   	  //alert(msg);
				   	  //lightbox.innerHTML = msg;		   	 
				   	  hidelogin();
				   	  alert ("Thank you for your submission");
		
				   }
				 });
	}
	else
	{
		//alert(email.value);
		alert("Please enter a valid email address.");
	}
}
