
// $Id: popupfunctions.js,v ab909423d56b 2010/01/05 17:10:14 kharlin $

function popIFrameWindow()
{
    if(!document.getElementById || !document.getElementsByTagName)
    {
       return;
    }

    if(!document.getElementById('popupcontent') ) {return;}

    var popupLink;
    // get all a's in the div, loop through them
    popupLink=document.getElementById('popupcontent').getElementsByTagName('a');
    for(i=0;i<popupLink.length;i++)
    {
        //if the div has the class itemPromo, call the showIFramePopup function to display the text
        if(/itemPromo/.test(popupLink[i].className))
        {
           popupLink[i].onclick=function(e)
          {
               var posx = 0;
               var posy =0;
               if (!e)
                 e = window.event;
               if (e.pageX || e.pageY){
                    posx = e.pageX;
                    posy = e.pageY;

                }
                else if (e.clientX || e.clientY){
                    posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
                    posy = e.clientY + document.body.scrollLeft + document.documentElement.scrollLeft;

                }

                return showIFramePopup(this,posx,posy);

            } //end function e
        } //end test
    } //end for
} //end function popIFrameWindow

function showIFramePopup(o,ix,iy)
{
//create the popup div, an IFRAME, a "P" tag and an "A" tag
    var newdiv=document.createElement('DIV');
    var newIf=document.createElement('IFRAME');
    var newp=document.createElement('P');
    var newa=document.createElement('A');
    var x=ix -18;
    var y=iy;
    newIf.src=o.href;
    newIf.id='promoIf';
    newIf.scrolling = 'auto';
    newIf.frameBorder = '0';
    newa.href='#';
    newa.appendChild(document.createTextNode('Close'));
    newp.appendChild(newa);
    newdiv.id='pb';
    newdiv.className='promoBox';
    newdiv.appendChild(newIf);
    newdiv.appendChild(newp);
    document.body.appendChild(newdiv);
    newdiv.style.position='absolute';
    newdiv.style.left=x+'px';
    newdiv.style.top=y+'px';
    newa.onclick = function(){newdiv.parentNode.removeChild(newdiv);};
    return false;
}

function RedirectOpenerAndClose(redirectUrl)
{
    if( window.opener )
    {
        var targetWindow;
        targetWindow = window.opener;
        while(targetWindow.opener)
            targetWindow = targetWindow.opener;
        targetWindow.location.href=redirectUrl;
        window.close();
    }
    else
    {
        window.location.href=redirectUrl;
    }
}

function showUpdateBox(event, noPositioning, idName, noTimeOut )
{
	
	var elm = document.getElementById(idName);
	var transparencyDiv = document.getElementById("transparency");
	
	if (!noPositioning)
	{
		if (!event) event = window.event;
		if ( window.ActiveXObject ) 
		{
			posY = event.clientY + document.documentElement.scrollTop - 300;
		}
		else
			posY = event.pageY - 230;
		 
		if (posY < 250)
			posY = 250;
		 
		
	}
	else
	{
		posY = document.documentElement.scrollTop + 400;
	}
	elm.style.top = posY + 'px';
	if (idName == 'warningMsg')
		elm.className = 'visibilityYes updatingCart';
	else
		elm.className = 'visibilityYes overlayBox';	
	transparencyDiv.style.left = 0+"px"; 
    transparencyDiv.style.top = 1 + "px";
     
    
    transparencyDiv.style.height = 30000+ "px";
    
    if (!noTimeOut)
		setTimeout ( "hideUpdateBox('" + idName + "')", 1000 );
}

function hideUpdateBox(idName)
{
	var elm = document.getElementById(idName);
	var transparencyDiv = document.getElementById("transparency");
	if (idName == 'warningMsg')
		elm.className = 'visibilityNo updatingCart';
	else
		elm.className = 'visibilityNo overlayBox';
	transparencyDiv.style.left = -1340+"px"; 

}
