var setTimeID;
var leftRight = 1;
var rightLeft = 2;
var topDown = 3;
var bottopUp = 4;
var leftSide = 1;
var rightSide = 2;
var topCorner = 1;
var bottomCorner = 2;
var _title = 'Put here your title';
var popupWidth = 210;
var popupHeight = 81;
var only_once_per_browser = false;
var ns4 = document.layers;
var ie4 = document.all;
var ns6 = document.getElementById&&!document.all;
var crossobj;
var isStop=false;
function getCrossObj()
{
    var contentDiv;
    var titleDiv;
    if (ns4)
    {
        crossobj = document.layers.postit;
        contentDiv = document.layers.postit_content;
        titleDiv = document.layers.postit_title;
    }
    else if (ie4||ns6)
    {
        crossobj = ns6? document.getElementById("postit") : document.all.postit;
        contentDiv = ns6? document.getElementById("postit_content") : document.all.postit_content;
        titleDiv = ns6? document.getElementById("postit_title") : document.all.postit_title;
    }   
    crossobj.style.width = popupWidth + 'px';
    crossobj.style.height = popupHeight + 'px';
    contentDiv.style.width = (popupWidth-8) + 'px';
    contentDiv.style.height = (popupHeight-26) + 'px';
    titleDiv.style.width = (popupWidth-8) + 'px';
}
function buildPopup_Frame(width, height, title, framesrc)
{
    if (width)
        popupWidth = width;
    if (height)
        popupHeight = height;
    if (title)
        _title = title
    document.write('<div id="postit" class="postit" >');
    document.write('<div id="postit_title" class="title" ><b>' + _title + ' <span class="spantitle" onMouseOver="javascript:clearTimeOut(null);"><img src="/images/close.gif" border="0" title="Close" align="right" WIDTH="11" HEIGHT="11" onclick="closeit()">&nbsp;</b></span></div>');
    document.write('<div id="postit_content" class="content" > '); 
    document.write('<iframe src="' + framesrc + '" width="100%" height="100%" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" bordercolor="#000000"></iframe>');
    document.write('</div></div>');
    getCrossObj();
}
function buildPopup_HtmlCode(width, height, title, htmlCode)
{
    if (width)
        popupWidth = width;
    if (height)
        popupHeight = height;
    if (title)
        _title = title
    document.write('<div id="postit" class="postit" >');
    document.write('<div id="postit_title" class="title"><b>' + _title + ' <span class="spantitle"><img src="/images/close.gif" border="0" title="Close" align="right" WIDTH="11" HEIGHT="11" onclick="closeit()">&nbsp;</b></span></div>');
    document.write('<div id="postit_content" class="content">'); 
    document.write(htmlCode);				
    document.write('</div></div>');
    getCrossObj();
}
function closeit()
{
 if (this.isStop) 
 {
  setTimeout("closeit()",10000);
  return;
 }
 if (ie4||ns6)
   crossobj.style.visibility="hidden";
 else if (ns4)
   crossobj.visibility="hide";
}
function get_cookie(Name) 
{
    var search = Name + "=";
    var returnvalue = "";
    if (document.cookie.length > 0) 
    {
        offset = document.cookie.indexOf(search);
        if (offset != -1) 
        { 
            offset += search.length;
            end = document.cookie.indexOf(";", offset);
            if (end == -1)
                end = document.cookie.length;
            returnvalue=unescape(document.cookie.substring(offset, end));
         }
    }
    return returnvalue;
}
function showOrNot(direction)
{
    var showit = false;
    if (get_cookie('postTheBoxDisplay')=='')
    {
        showit = true;
        document.cookie = "postTheBoxDisplay=yes";
    }
    return true;
}
function showIt(direction)
{
    var steps;
    steps = Math.floor(popupHeight / 4)+5;
    if (ie4||ns6)
    {
        crossobj.style.visibility = "visible";
        if ((direction == rightLeft) || (direction == leftRight))
            flyTheBox(direction, 0, popupWidth , steps, 1000);
        else 
            flyTheBox(direction, 0, popupHeight , steps, 1000);
    }
    else if (ns4)
    {
        crossobj.visibility = "show";
    }
    else
    {
	crossobj.style.visibility = "visible";
        if ((direction == rightLeft) || (direction == leftRight))
            flyTheBox(direction, 0, popupWidth , steps, 1000);
        else 
            flyTheBox(direction, 0, popupHeight , steps, 1000);
    }
}
function flyTheBox(direction, start, end, steps, msec, counter)
{
	if(!counter)
		counter = 1;
	var tmp;
	if(start < end)
	{
	    if (direction == rightLeft)
	        crossobj.style.width = end / steps * counter + 'px'; 
	    else if (direction == bottopUp)
	        crossobj.style.height = end / steps * counter + 'px'; 
	    else if (direction == topDown)
	        crossobj.style.top = ((end / steps * counter) - popupHeight) + 'px'; 
            else if (direction == leftRight)
	        crossobj.style.left = (end / steps * counter)-popupWidth + 'px'; 
	}
	else 
	{ 
	    tmp=steps -	counter; 
	    if (direction == rightLeft)
	        crossobj.style.width = start / steps * tmp + 'px'; 
	    else if (direction == bottopUp)
	        crossobj.style.height = start / steps * tmp + 'px'; 
	    else if (direction == topDown)
	        crossobj.style.top = ((end / steps * counter) - popupHeight) + 'px'; 
	} 
	if(counter != steps) 
	{ 
	    counter++; 
	    flyTheBox_timer=setTimeout('flyTheBox('+ direction + ',' + start + ','+ end + ',' + steps + ',' + msec + ', '+ counter + ')', msec/steps); 
	} 
	else 
	{ 
	    if(start > end)
		crossobj.style.display = 'none';
	}
}
function ShowTheBox(only_once, side, corner, direction)
{
    if (side == leftSide)
    {
        if (direction == rightLeft)
            return;
        crossobj.style.left = '1px';
    }
    else
    {
        if (direction == leftRight)
            return;
	    crossobj.style.right = '1px'; 
    }
    if ((corner == topCorner) && (direction == bottopUp))
        return;
    if ((corner == bottomCorner) && (direction == topDown))
        return;
    if ((direction == topDown) && (corner == topCorner))
        crossobj.style.top = '-' + popupHeight + 'px';    
    else if (((direction == rightLeft)||(direction == leftRight)) && (corner == topCorner))
        crossobj.style.top = '1px';
    else if (corner == bottomCorner)
        crossobj.style.bottom = '2px';
    if (only_once)
        only_once_per_browser = only_once;
    if (only_once_per_browser)
    {
	    if (showOrNot())
	        showIt(direction);
    }
    else
	    setTimeout("showIt("+ direction + ")",1030);
    setTimeout("closeit()",10000);
}

function stopstart(flg)
{
   if (flg==0)
   {   
	this.isStop=false;
   }
   else
   {
  	this.isStop=true;
   }
}
var html_code = "<div id='Alertpop' onmouseover='stopstart(1);' onmouseout='stopstart(0);'><table border='0' width='100%'><tr>	<td align='right'><a href='#' class='hsublink12'>Option<a></td><tr></tr><td align='center'><span class='boxcontent'>You have New Email Alert for Enquires/Quotaion in <b>SulekhaB2B</b></span><br> <a href='/MessageCenterInquiries.aspx?mem=message' class='msglink'>Click Here</A> <span class='boxcontent'>goto Message Center</span></td><tr></tr><td align='center'><hr><img src='/images/Sulekha-B2b.gif'>	</td></tr></table></div>";
buildPopup_HtmlCode(250, 160, 'New Email Alert(s)', html_code);