function CloseControls()
{
	if(b = document.getElementById('DV_PRESENTER'))
		document.body.removeChild(b);
	if(a = document.getElementById('DV_PRESENTER_WINDOW'))
		document.body.removeChild(a);	
}

function AlignCenter()
{
	
	if(document.getElementById('DV_PRESENTER_WINDOW'))
		var bck = document.getElementById('DV_PRESENTER_WINDOW');
	else
	{
		var bck = document.createElement("DIV");
		document.body.appendChild(bck);
		bck.id = 'DV_PRESENTER_WINDOW';
	}
	axe = getPageSize();
	wdt = axe[0];
	hgt = axe[1];
	
	if(detectBrowser())//check lt ie7
	{
		position = 'absolute';
		left = '0';
		atop = 0 + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop );
	}
	else
	{
		position = "fixed";
		left = '0';
		atop = '0';
	}	
	bck.style.cssText = "position:"+position+"; left:"+left+"; top:"+atop+" ; z-index:1999; background:#000; height:"+hgt+"px; width:100%; opacity:0.3; filter:alpha(opacity=30);";
	bck.style.position = position;
	bck.style.left = left;
	bck.style.top = atop + 'px';
	bck.style.zIndex = '1999';
	bck.style.background = '#000';
	bck.style.height = hgt +'px';
	bck.style.width = '100%';
	bck.style.opacity = '0.3';
	bck.style.filter = 'alpha(opacity=30)';
	
	
	atop = (hgt > 300) ? parseInt((hgt - 300)/2) : 0;
	if(detectBrowser())//check lt ie7
	{
		position = 'absolute';
		left = (wdt > 500) ? parseInt((wdt - 500)/2) : 0;
		atop = atop + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop );
	}
	else
	{
		position = "fixed";
		left = (wdt > 500) ? parseInt((wdt - 500)/2) : 0;
		atop = atop;
	}	
	if(document.getElementById('DV_PRESENTER'))
	{
		var fgd = document.getElementById('DV_PRESENTER');		
	}
	else
	{
		var fgd = document.createElement("DIV");
		document.body.appendChild(fgd);
		fgd.id = 'DV_PRESENTER';
	}	
	fgd.style.cssText = "position:"+position+"; left:"+left+"px; top:"+atop+"px; z-index:2000; width:500px; height:300px;";
	fgd.style.position = position;
	fgd.style.left = left+'px';
	fgd.style.top = atop+'px';
	fgd.style.zIndex = '2000';	
	fgd.style.width = '500px';
	fgd.style.height = '300px';
		
}

function ShowCenterContent()
{	
	AlignCenter();
	if(a = document.getElementById('DV_PRESENTER_WINDOW'))
	{
		window.onresize = function(){
			if(document.getElementById('DV_PRESENTER_WINDOW'))
				AlignCenter();
			};
		window.onscroll = function(){
			if(document.getElementById('DV_PRESENTER_WINDOW'))
				AlignCenter();
			};
		if(document.getElementById('DV_PRESENTER_WINDOW'))
			document.getElementById('DV_PRESENTER_WINDOW').onclick = CloseControls;
		presenter = document.getElementById('DV_PRESENTER');		
	}	
}

function getPageSize()
{
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;	
	arrayPageSize = [w,h];	
	return arrayPageSize;
}

function detectBrowser() 
{
	var userAgent = navigator.userAgent.toLowerCase();	
	if (userAgent.indexOf('msie')!=-1)
	{
		axe = userAgent.substr(eval(userAgent.indexOf('msie') + 5), 1);		
		if(axe < 7)		
	    	return true;		
	}
	return false;
}

function showNotification(cnt)
{
	ShowCenterContent();	
	presenter.innerHTML = '<DIV id="TOTAL_DV_CONTENT"><div class="popup"><div id="DV_HEAD"><div class="pw-tl"></div><div class="pw-tc"><h1 class="signup-title">Sign up for email alerts</h1><div class="close-btn"><a href="javascript:CloseControls()" title="Close this message">Close</a></div></div><div class="pw-tr"></div></div><div class="clear"></div><div id="DV_CONTENT"><div class="pw-mc"><div class="txtborder"></div><p class="info"><strong>Thanks for Signing up!</strong> Watch your inbox for Asian Energy News.</p><div class="txtborder"></div></div></div><div class="clear"></div><div class="pw-bl"></div><div class="pw-bc"></div><div class="pw-br"></div><div class="clear"></div></div></DIV>';	
}

function showNotificationIncorrectEmail(cnt)
{
	ShowCenterContent();	
	presenter.innerHTML = '<DIV id="TOTAL_DV_CONTENT"><div class="popup"><div id="DV_HEAD"><div class="pw-tl"></div><div class="pw-tc"><h1 class="signup-title">Sign up for email alerts</h1><div class="close-btn"><a href="javascript:CloseControls()" title="Close this message">Close</a></div></div><div class="pw-tr"></div></div><div class="clear"></div><div id="DV_CONTENT"><div class="pw-mc"><div class="txtborder"></div><p class="" style="padding:20px 0; font-size:17px; line-height:22px;"><strong>Incorrect Email!</strong><br /> Please enter the email in correct format.</p><div class="txtborder"></div></div></div><div class="clear"></div><div class="pw-bl"></div><div class="pw-bc"></div><div class="pw-br"></div><div class="clear"></div></div></DIV>';		
}

function showNotificationEmailAlready(cnt)
{
	ShowCenterContent();	
	presenter.innerHTML = '<DIV id="TOTAL_DV_CONTENT"><div class="popup"><div id="DV_HEAD"><div class="pw-tl"></div><div class="pw-tc"><h1 class="signup-title">Sign up for email alerts</h1><div class="close-btn"><a href="javascript:CloseControls()" title="Close this message">Close</a></div></div><div class="pw-tr"></div></div><div class="clear"></div><div id="DV_CONTENT"><div class="pw-mc"><div class="txtborder"></div><p class="" style="padding:20px 0; font-size:17px; line-height:22px;"><strong>Already Signed Up!</strong><br /> You have already been signed up for newsletter.</p><div class="txtborder"></div></div></div><div class="clear"></div><div class="pw-bl"></div><div class="pw-bc"></div><div class="pw-br"></div><div class="clear"></div></div></DIV>';	
}

