function _showPopup(str,config){ 
   var bordercolor;
   var msgw = config.popupWidth;
   var msgh = config.popupHeight;
   titleheight=config.headerHeight; //title Height
   bordercolor=config.borderColor;//boder color
   titlecolor="#99CCFF";//title color
   var sWidth,sHeight; 
   sWidth=document.body.offsetWidth; 
   sHeight=screen.height; 
   var msgObj=document.createElement("div") 
   msgObj.setAttribute("id","popup__msgDiv"); 
   msgObj.setAttribute("align","center"); 
   msgObj.style.background=config.backgroundColor; 
   msgObj.style.border=config.borderWidth+"px solid " + bordercolor; 
   msgObj.style.position = "absolute"; 
   msgObj.style.ovarflow = "hidden"; 
   msgObj.style.left = "50%"; 
   msgObj.style.top = "50%"; 
   msgObj.style.marginLeft = -(msgw/2)+Math.max(document.body.scrollLeft,document.documentElement.scrollLeft)+"px" ; 
   msgObj.style.marginTop = -(msgh/2)+Math.max(document.body.scrollTop,document.documentElement.scrollTop)+"px"; 
   msgObj.style.width = msgw + "px"; 
   msgObj.style.height =msgh + "px"; 
   msgObj.style.textAlign = "center"; 
   msgObj.style.zIndex = "10001"; 
   var title=document.createElement("h4"); 
   title.setAttribute("align","right"); 
   title.style.margin="0"; 
   title.style.padding="3px"; 
   title.style.background=config.headerBackgroundColor; 
   title.style.height=titleheight+"px"; 
   title.style.font=config.headerFontStyle; 
   title.style.color=config.headerFontColor; 
   title.style.cursor="pointer"; 
   title.innerHTML=config.closeText; 
   title.onclick=closePopup;
   document.body.appendChild(msgObj); 
   document.getElementById("popup__msgDiv").appendChild(title); 
   var txt=document.createElement("p"); 
   txt.style.margin="1em 0" 
   txt.setAttribute("id","msgTxt"); 
   txt.innerHTML=str; 
   document.getElementById("popup__msgDiv").appendChild(txt);
   
}

function closePopup(){
	document.body.removeChild(document.getElementById("popup__msgDiv")); 
}

function showPopup(html, config){
   if(config.displayPerBrowserSession && Get_Cookie('notShowPopup')){
		return;
   }
   
   var timeout = config.displayTimeout*1000;
   
	setTimeout(function(){
		_showPopup(html, config);
		Set_Cookie( 'notShowPopup', 1);
	}, timeout);

	

}


function Set_Cookie( name, value, expires, path, domain, secure )
{
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

function Get_Cookie( check_name ) {
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}
