
function showImageOverlay(show) {

    //determine if browser is ie6
    temp=navigator.appVersion.split('MSIE');
    ieVer=parseInt(temp[1]);
    var isIE6=(ieVer == 6)?1:0;

    if(!document.getElementById('overlay')){
       var my_overlay = document.createElement('div');
       my_overlay.setAttribute('id', 'overlay');
       document.body.appendChild(my_overlay);
    }


	if(!show) {
		document.getElementById('overlay').style.display = 'none';
        document.getElementById('overlay').onclick = null;
        if(isIE6){
            document.getElementById('shim').style.display = 'none';
        }
	}
	else {
        var scrollX = DomUtils.getWindowScrollX();
        var scrollY = DomUtils.getWindowScrollY();
        var height = DomUtils.getElementHeight(document.body);
        var width = DomUtils.getElementWidth(document.body);
        if(height < screen.height) {
            height = (screen.height * .8);
        }
        //THIS IS FOR OPERA ONLY
        //opacity doesn't exist, so we just don't show the overlay
        if (typeof window.opera == "undefined") {
            document.getElementById('overlay').style.width = width + 'px';
            document.getElementById('overlay').style.height = height + 'px';
            document.getElementById('overlay').style.display = 'block';
            document.getElementById('overlay').onclick = closeLargerImage;
        }

        //ADD IFRAME SHIM - for IE6 so select box doesn't show through the popup
        //instead of adding the code for the shim to each page, and potentially missing one, create it manually and append to the body
        if(isIE6){
            if(document.getElementById('shim') == null){
                var shim = document.createElement('iframe');
                shim.setAttribute('src', 'javascript:false;');
                shim.setAttribute('scrolling', 'no');
                shim.setAttribute('frameborder', '0');
                shim.setAttribute('id', 'shim');

                //set needed styles for the shim
                shim.style.zIndex = 9999;
                shim.style.display = "none";
                shim.style.position = "absolute";
                shim.style.backgroundColor = "transparent";
                shim.style.top = "0px";
                shim.style.left = "0px";
                document.body.appendChild(shim);
            }
            document.getElementById('shim').style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
            document.getElementById('shim').style.width = width + 'px';
            document.getElementById('shim').style.height = height + 'px';
            document.getElementById('shim').style.display = 'block';
        } 
    }
}

var PP_resizeIntervalId;
var PP_popupImage;
var PP_popupImageLinks = Array();

var PP_scaleTime = 300;
var PP_scaleSpeed = 15;
var PP_startTime;
var PP_finishTime;
var PP_totalTime;
var PP_pic;
var News_pic;
var PP_dir;
var PP_scaleQueue;
var PP_imageLoadIntervalId;
var PP_popupProductTitle;
var PP_loadImage = new Image();
PP_loadImage.src = 'http://i.pgcdn.com/images/searchAtt2/imagePopupLoad.gif';
var PP_origDims;
var PP_origLocation;
var PP_content;
var PP_showMerchantInfo = true;

function newsletter_popup(referral) {
    showImageOverlay(true);
    
    News_pic = document.getElementById('NewsletterPopup');
     
    if(News_pic == null){
        var ie_margin;
        
        //ie_margin: margin for adapting newsletter DIV to overlay pop up --- IE(v.5/6/7) ONLY
        //overlay_margin: margin for overlay message div. Different between IE(v.5/6/7), Chrome/Safari/FF3 and FF2/IE8
        //Add HERE different rules for other browsers if necessary.
        if (navigator.appVersion.indexOf("MSIE") != -1 && parseFloat(navigator.appVersion.split("MSIE")[1]) < 8) {
            overlay_margin = '-105px 0 0 6px';
            ie_margin = 'margin: -40px 5px 0;';
        } else if ((navigator.appVersion.indexOf("MSIE") != -1 && parseFloat(navigator.appVersion.split("MSIE")[1]) == 8) || (navigator.userAgent.indexOf("Firefox") && ((parseInt(navigator.userAgent.charAt(navigator.userAgent.indexOf("Firefox")+8))>2)))) {
            overlay_margin = '-77px 0 0 6px';
        } else if (navigator.appVersion.indexOf("Chrome") || navigator.appVersion.indexOf("Safari")) {
            overlay_margin = '-117px 0 0 6px';
        } 
        if (ie_margin == null ) ie_margin = 'margin-top:-40px;';
        
        var newDiv = document.createElement('div');
        newDiv.setAttribute('id','NewsletterPopup');
        newDiv.setAttribute('class','cb');
        newDiv.style.width = "465px";
        
        var picturePopupContent = "<div class=\"bt\"><div></div></div>";
        picturePopupContent += "<div class=\"i1\">";
        picturePopupContent += "<div class=\"i2\">";
        picturePopupContent += "<div class=\"i3\" id=\"NewsletterPopup_content\" style=\"height:125px;width:350px;text-align:center\">";
        picturePopupContent += "<div id=\"picturePopup_close\">";
        picturePopupContent += "<a href='javascript:closeNewsletterPop()' class=\"close_text\">Close</a>";
        picturePopupContent += "<a href='javascript:closeNewsletterPop()'>&nbsp;<img src='http://i.pgcdn.com/images/searchAtt2/overlayImg_btn.png' />";
        picturePopupContent += "</a>";
        picturePopupContent += "</div>";
        
        picturePopupContent += "<div id='getProd_newsletter' style=\"position: relative;text-align: left;\">";
        picturePopupContent += "<div id='getProd_newsletter_img' style=\"position: relative;\">";
        picturePopupContent += "<img src='http://i.pgcdn.com/images/getprod2/getProd_superDealNewsletter2.jpg' />";
        picturePopupContent += "</div>";
        picturePopupContent += "<div id=\"getProd_newsletter_subscribe\" style=\"position: relative;"+ie_margin+"\">";
        picturePopupContent += "<input type=\"text\" id=\"email\" name=\"email\" class=\"email\" value=\"\" size=\"20\" onfocus=\"newsletter();\">";
        picturePopupContent += "<input type=\"image\" class=\"signup\" align='top' onClick=\"return newsletter_submit('"+referral+"','"+overlay_margin+"')\" src=\"http://i.pgcdn.com/images/getprod2/superdeal_signupToday.png\">";
        
        picturePopupContent += "</div>";
       
        picturePopupContent += "</div>";

		picturePopupContent += "</div>";            
		picturePopupContent += "</div>";
    	picturePopupContent += "</div>";
    	picturePopupContent += "<div class=\"bb\"><div></div></div>";
        
        picturePopupContent += "</div>";    

        newDiv.innerHTML = picturePopupContent;
        document.body.appendChild(newDiv);
        News_pic = newDiv;
    } 
    var screenCenter = getScreenCenter(parseInt(News_pic.style.width),parseInt(News_pic.style.height));

    News_pic.style.top = screenCenter[0];
    News_pic.style.left = screenCenter[1];
    var email_field = document.getElementById('email');
    email_field.value = 'your email address';
    
    News_pic.style.display = "block";
    loadImageTop = (parseInt(News_pic.style.height)/2) - parseInt(PP_loadImage.height)/2;
    document.getElementById('picturePopup_close').style.visibility = 'visible';
    
}

function showLargerImage(masterid,dw_search_id,dw_epoch_time, zip_code,view, retid,endcap_cobrand_id, pid, product_type){
    
    is_modal = true;

    if(product_type === undefined || product_type == '') {
        product_type = 'masterid';
    }

    showImageOverlay(true);
    PP_pic = document.getElementById('picturePopup');
     
    if(PP_pic == null){
      
        var newDiv = document.createElement('div');
        newDiv.setAttribute('id','picturePopup');
        newDiv.setAttribute('class','cb');
        newDiv.style.width = "300px";
        var picturePopupContent = "<div class=\"bt\"><div></div></div>";
        picturePopupContent += "<div class=\"i1\">";
        picturePopupContent += "<div class=\"i2\">";
        picturePopupContent += "<div class=\"i3\" id=\"picturePopup_content\" style=\"height:300px;text-align:center\">";
        picturePopupContent += "<div id=\"picturePopup_close\">";
        picturePopupContent += "<a href='javascript:closeLargerImage()' class=\"close_text\">Close</a>";
        picturePopupContent += "<a href='javascript:closeLargerImage()'>&nbsp;<img src='http://i.pgcdn.com/images/searchAtt2/overlayImg_btn.png' />";
        picturePopupContent += "</a>";
        picturePopupContent += "</div>";
        picturePopupContent += "<div id='picturePopup_load' style=\"position:relative;width:100%;text-align:center;display:none;\">";
        picturePopupContent += "<img src='http://i.pgcdn.com/images/searchAtt2/imagePopupLoad.gif' alt=\"Loading\">";
      picturePopupContent += "</div>";
        picturePopupContent += "<div>";
        picturePopupContent += "<img src='' id=\"picturePopup_image\" style=\"margin-left:auto;margin-right:auto\" />";
       picturePopupContent += "</div>";

		picturePopupContent += "</div>";            
		picturePopupContent += "</div>";
    	picturePopupContent += "</div>";
    	picturePopupContent += "<div class=\"bb\"><div></div></div>";

        newDiv.innerHTML = picturePopupContent;
       document.body.appendChild(newDiv);
        PP_pic = newDiv;
    }
    PP_content = document.getElementById('picturePopup_content');  //have to use content box to set height. Setting the container's
                                                                   //height breaks the box. Also, setting the content box's width also breaks it, so we have to use both.
    var ppMerchant = document.getElementById("picturePopup_merchant");
    if(ppMerchant){
        ppMerchant.style.visibility = "hidden";
    }
    var screenCenter = getScreenCenter(parseInt(PP_pic.style.width),parseInt(PP_content.style.height));

    PP_pic.style.top = screenCenter[0];
    PP_pic.style.left = screenCenter[1];

    PP_origDims = [parseInt(PP_content.style.height),parseInt(PP_pic.style.width)];
    PP_origLocation = [PP_pic.style.top.substring(0,PP_pic.style.top.length-2),
                    PP_pic.style.left.substring(0,PP_pic.style.left.length-2)]


    PP_pic.style.display = "block";
    PP_popupImage = new Image();
    PP_popupImage.src = PP_popupImageLinks['link_' + masterid][0];
    PP_popupProductTitle =  PP_popupImageLinks['link_' + masterid][1];
    PP_popupImage.alt = PP_popupImageLinks['link_' + masterid][1];

    //if image loaded, show the image
    if(PP_popupImage.complete){
      //add a slight delay so it doesn't flicker
      setTimeout('getImagePopupMerchant('+masterid+',"'+dw_search_id+'","'+dw_epoch_time+'","'+zip_code+'","'+view+'","'+retid+'","'+endcap_cobrand_id+'","'+pid+'","'+product_type+'")',10);
    }
    //otherwise show loading screen
    else{
        loadImageTop = (parseInt(PP_content.style.height)/2) - parseInt(PP_loadImage.height)/2;
        document.getElementById('picturePopup_load').style.top = loadImageTop + 'px';
        document.getElementById('picturePopup_load').style.display = 'block';
        PP_popupImage.onload = function(){
            getImagePopupMerchant(masterid,dw_search_id,dw_epoch_time, zip_code,view, retid, endcap_cobrand_id, pid, product_type);
        }
    }
}

function getImagePopupMerchant(masterid,dw_search_id,dw_epoch_time, zip_code,view, retid,endcap_cobrand_id, pid, product_type){
    var ajax = new AjaxRequest('POST', '/rpc_getSellers.php', true, 3000);
	if (masterid) {
		ajax.setParameter('product_id', masterid);
	}
	if (dw_search_id) {
		ajax.setParameter('dw_search_id', dw_search_id);
	}
	if (dw_epoch_time) {
		ajax.setParameter('dw_epoch_time', dw_epoch_time);
	}
	if (zip_code) {
		ajax.setParameter('zip_code', zip_code);
	}
	if (retid) {
		ajax.setParameter('retid', retid);
	}
    if (endcap_cobrand_id) {
		ajax.setParameter('endcap_cobrand_id', endcap_cobrand_id);
	}  
	if (pid) {
		ajax.setParameter('pid', pid);
	}
    if (product_type) {
		ajax.setParameter('product_type', product_type);
	}
    ajax.setParameter('total_sellers',1);
    ajax.setCallback(loadPopupImage);
	ajax.send();

}

function loadPopupImage(xml){
    PP_showMerchantInfo = true;
    var merchant_box_width = 0;
    var merchant_box_height = 0;
    var ppContent = document.getElementById('picturePopup_content');
    var ppMerchant = document.getElementById("picturePopup_merchant");
    if(ppContent != null && ppMerchant != null && ppMerchant.parentNode == ppContent){
        var tmpDiv = ppMerchant;
        ppContent.removeChild(ppMerchant);
        document.body.appendChild(tmpDiv);
       // document.getElementById('picturePopup_merchant').style.float = "left";
    }
    if(ppMerchant == null){
        var newDiv = document.createElement('div');
        newDiv.setAttribute('id',"picturePopup_merchant");
        picturePopupContent = " <div id=\"popup_merchant_cont\"><nobr>";
        picturePopupContent += "    <div class=\"popup_pricing_right\"  >";
        picturePopupContent += "        <span class=\"ie6\">";
        picturePopupContent += "            Buy Now At";
        picturePopupContent += "            <span id=\"picturePopup_merchant_logo\"></span>";
          picturePopupContent += "          for";
        picturePopupContent += "            <span id=\"picturePopup_merchant_price\"></span>";
        picturePopupContent += "        </span>";
        picturePopupContent += "        <span id=\"picturePopup_merchant_button\">";
        picturePopupContent += "        </span>";
        picturePopupContent += "    </nobr></div>";

        newDiv.innerHTML = picturePopupContent;
        document.body.appendChild(newDiv);
        ppMerchant = newDiv;
    }
    	if(xml == null) {
		PP_showMerchantInfo = false;
	}
	else {      
        
        var offers = xml.getElementsByTagName('offers');
        var json = offers[0].firstChild;
        var objOffer = eval(json.firstChild.nodeValue);
        if(objOffer[0] != null){
            var merchantName = objOffer[0]['title'];
            var price =          objOffer[0]['price'];
            var merchantLink =      objOffer[0]['merchant_link'];
            var bottomlineText =       objOffer[0]['bottomline_text'];
            var merchantLogo =   objOffer[0]['merchant_logo'];
            var onclick = "onClick=\""+objOffer[0]['om_onclick']+"\"";
            var id_type = objOffer[0]['id_type'];
            target = "";
            if(id_type != 'storefront'){
                target = " target = '_blank'";
            }
            else{

            }
            var price_span = document.getElementById("picturePopup_merchant_price");
            var button_span = document.getElementById("picturePopup_merchant_button");

            price_span.innerHTML = "<a href='" + merchantLink + "'" + target + " " + onclick + ">" + price + "</a>";
			button_span.innerHTML = "<a href='" + merchantLink + "'" + target + " " + onclick + " class=\"shopButton_green\"><span>" + "Shop" + "</span></a>";
            var merchant_logo = document.getElementById("picturePopup_merchant_logo");
            var merchant_logo_html = "<a href='" + merchantLink + "' " + target + " class=\"picturePopup_link\" style=\"color:#0068B3;\" " + onclick + ">";

            if(objOffer[0]['merchant_logo'] ){
                merchant_logo_html += '<img src="http://i.pgcdn.com/images/' + objOffer[0]['merchant_logo'] + '"  alt="'+objOffer[0]['title']+'" class="vAlign">';
            }
            else{
                merchant_logo_html +=  objOffer[0]['title'];
            }
            merchant_logo_html += "</a> ";
            merchant_logo.innerHTML = merchant_logo_html;

            //move the merchant box off of the view, retrieve it's size, and then hide it again.
            //only way to retrieve the correct width
            ppMerchant.style.left = "-1000px";
            ppMerchant.style.visibility = "visible";
            merchant_box_width = ppMerchant.offsetWidth;        
            
            merchant_box_height = DomUtils.getElementHeight( ppMerchant );
            
            ppMerchant.style.visibility = "hidden";
            document.body.removeChild(ppMerchant);
            ppContent.appendChild(ppMerchant);
        }
        else{
            PP_showMerchantInfo = false;
        }       
    }
    document.getElementById('picturePopup_load').style.display = 'none';
    PP_pic = document.getElementById('picturePopup');

    var bwidth = PP_popupImage.width;
    var bheight = PP_popupImage.height + merchant_box_height; 
    
    var total_width = Math.max(bwidth,merchant_box_width) + 112; //112 accounts for padding of the border

    //prepare effects
    PP_scaleQueue = Array();
    var xStretch = new Object();
    var yStretch = new Object();
    xStretch.scaleStart = parseInt(PP_pic.style.width);
    xStretch.scaleEnd =  total_width;
    xStretch.dir = "x";
    yStretch.scaleStart = parseInt(PP_content.style.height);
    yStretch.scaleEnd =   bheight;
    yStretch.dir = "y";

    //only add effects to queue if they are neccessary
    if(yStretch.scaleStart != yStretch.scaleEnd){
         PP_scaleQueue.push(yStretch);
    }
    if(xStretch.scaleStart != xStretch.scaleEnd){
         PP_scaleQueue.push(xStretch);
    }


    PP_startTime = new Date().getTime();
    PP_finishTime = PP_startTime + PP_scaleTime;
    PP_totalTime = PP_scaleTime;
    PP_resizeIntervalId = setInterval('resizePopup()',PP_scaleSpeed);

}

function resizePopup(){
    var timeStamp = new Date().getTime();
    if(PP_startTime > timeStamp){
        return;
    }
    if(PP_scaleQueue.length == 0){
         clearInterval(PP_resizeIntervalId);
         insertImage();

         return;
    }
    //current width and height
    var height = parseInt(PP_content.style.height);
    var width = parseInt(PP_pic.style.width);

    //current scale the popup should be, based off of the current time
    var fraction   = (timeStamp - PP_startTime) / PP_totalTime;
    //finished
    if(timeStamp > PP_finishTime){
        //finalize width/height
        if(PP_scaleQueue[0].dir == "x"){
            PP_pic.style.width= PP_scaleQueue[0].scaleEnd + 'px';
        }
        else{
          PP_content.style.height  = PP_scaleQueue[0].scaleEnd + 'px';
        }
        clearInterval(PP_resizeIntervalId);
        PP_scaleQueue.shift();
        //if there are still effects, pop the next one
        if(PP_scaleQueue.length > 0){
            PP_startTime = new Date().getTime();
            PP_finishTime = PP_startTime + PP_scaleTime;
            PP_totalTime = PP_scaleTime;
            PP_resizeIntervalId = setInterval('resizePopup()',PP_scaleSpeed);
        }
        //completely done with scale effects. Fade in the image
        else{
           insertImage();
        }
        return;
    }
    else{

         if(PP_scaleQueue[0].dir == "x"){
            width = PP_scaleQueue[0].scaleStart + (PP_scaleQueue[0].scaleEnd-PP_scaleQueue[0].scaleStart)*fraction;
         }
         else{
            height = PP_scaleQueue[0].scaleStart + (PP_scaleQueue[0].scaleEnd-PP_scaleQueue[0].scaleStart)*fraction;
         }
    }
    PP_content.style.height = height + "px";
    PP_pic.style.width = width + "px";
    if(PP_scaleQueue[0].dir == "x"){
        PP_pic.style.left = (PP_origLocation[1] - (width - PP_origDims[1])/2) + 'px';
    }
}


function insertImage(){

    var height = parseInt(PP_content.style.height);
    var width = parseInt(PP_pic.style.width);
    var  dWidth = (width  - PP_origDims[1])/2;
    PP_pic.style.left = (PP_origLocation[1]-dWidth) + 'px';
    PP_startTime = new Date().getTime();
    PP_finishTime = PP_startTime + PP_scaleTime;
    PP_totalTime = PP_scaleTime;
    var image = document.getElementById('picturePopup_image');
    image.src = PP_popupImage.src;
    image.alt = PP_popupImage.alt;
    //setOpacity(image, 0);

    //need to set both due to IE6 issue
    image.style.visibility = 'visible';
    image.style.display= 'block';

    PP_imageLoadIntervalId = setInterval('fadeImage()',PP_scaleSpeed);

}
function fadeImage(obj){
    var timeStamp = new Date().getTime();
    if(timeStamp > PP_finishTime){
        clearInterval(PP_imageLoadIntervalId);
        addPopupFoot();
    }
    var fraction = (timeStamp - PP_startTime) / PP_totalTime;
    setOpacity(document.getElementById('picturePopup_image'),100*fraction);
}

function addPopupFoot(){
    //move the merchant popup to its correct location
    if(PP_showMerchantInfo){
        document.getElementById('picturePopup_merchant').style.visibility = "visible";
       // document.getElementById('picturePopup_merchant').style.position = "absolute";
	    document.getElementById('picturePopup_merchant').style.left = (parseInt(PP_pic.style.width)/2 -         
            DomUtils.getElementWidth(document.getElementById('picturePopup_merchant'))/2) + "px";
        document.getElementById('picturePopup_merchant').style.top = (parseInt(PP_content.style.height) ) + "px";
    }
    else {
        document.getElementById('picturePopup_merchant').style.visibility = "hidden";
    }
    document.getElementById('picturePopup_close').style.visibility = 'visible';
}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  obj.style.filter = "alpha(opacity:"+opacity+")";
  obj.style.opacity = opacity/100;
}

/** finds the x,y coordinates of the of the top/left corrner of an element when placed at the center of the browser
  * @param width int width of the element to be centered
  * @param height int height of the element to be centered
  * @return Array -> [0] = top, [1] = left
  */
function getScreenCenter(width,height){

    var screenWidth = DomUtils.getWindowWidth();
    var screenHeight = DomUtils.getWindowHeight();
    var scrollX = DomUtils.getWindowScrollX();
    var scrollY = DomUtils.getWindowScrollY();


	if(screenWidth==0 || screenHeight ==0) {
		if(typeof window.opera=="undefined" && document.documentElement.clientWidth) {
			screenWidth = document.documentElement.clientWidth;
			screenHeight = document.documentElement.clientHeight;
		}
		else {
			screenWidth = document.body.clientWidth;
			screenHeight = document.body.clientHeight;
		}
	}
	if(scrollX==0) {
		scrollX = parseInt(document.documentElement.scrollLeft);
   }
   if(scrollY==0) {
		scrollY = parseInt(document.documentElement.scrollTop);
	}

    //var top =  (scrollY + (screenHeight/2) - (height/2) - 20) + 'px';
    var top = (scrollY + screenHeight*.1) + 'px';
    var left = (scrollX + (screenWidth/2) - (width/2) ) + 'px';
    return Array(top,left);
}

function closeLargerImage(){

    is_modal = false;

    var pic = document.getElementById('picturePopup');
    pic.style.display = "none";

    showImageOverlay(false);
    document.getElementById('picturePopup_close').style.visibility = 'hidden';
    var image = document.getElementById('picturePopup_image');
    setOpacity(image, 0);
    document.getElementById('picturePopup_image').style.visibility = 'hidden';
    document.getElementById('picturePopup_merchant').style.visibility = 'hidden';
    document.getElementById('picturePopup_image').style.display = 'none';

}

function closeNewsletterPop(){
    var news = document.getElementById('NewsletterPopup');
    news.style.display = "none";

    showImageOverlay(false);
    document.getElementById('picturePopup_close').style.visibility = 'hidden';
}

function showProductImageOverlay(masterid,aTag,show){ 
    var overlayBox = document.getElementById('picOverlay_' + masterid); 
    var magImg = document.getElementById('zoom_' + masterid); 
    if(show == true){ 
        /*clearTimeout(SPIO_TimeoutID["'" + masterid + "'"]);
        if(overlayBox.style.display == "block"){
            if(SPIO_curFading["'" + masterid + "'"] == false){
                setOpacity(overlayBox,80);
             }
          return;
        }
        setOpacity(overlayBox,0);
        SPIO_curFading["'" + masterid + "'"] = true;
        overlayBox.style.display = "block";
        SPIO_fadeIn(masterid,0); */ 
        overlayBox.style.display = "block";
    }
    else{
        overlayBox.style.display = "none";
        //SPIO_TimeoutID["'" + masterid + "'"] = setTimeout("SPIO_fadeOut(" + masterid + ",80)",100);          
    }  
}
//TABS JS LOGIC

function getprod_showmenu(){
  var getprod_el = document.getElementById("getprod_channels");
  var getprod_iframe_menu = document.getElementById('getprod_iframe_menu');
  var getprod_moretab=document.getElementById("getprod_menupos");
  if (getprod_el) {
	  	getprod_el.style.top=(DomUtils.getElementTop(getprod_moretab)+23)+"px";
		getprod_el.style.left=(DomUtils.getElementLeft(getprod_moretab))+"px";
		getprod_el.style.visibility = "visible";
		getprod_el.style.zIndex = '100';
		getprod_iframe_menu.style.width = getprod_el.offsetWidth;
		getprod_iframe_menu.style.height = getprod_el.offsetHeight;
		getprod_iframe_menu.style.top = getprod_el.style.top;
		getprod_iframe_menu.style.left = getprod_el.style.left;
		getprod_iframe_menu.style.zIndex = getprod_el.style.zIndex - 1;
		getprod_iframe_menu.style.display = "block";
    getprod_show = 1;
  }
}
function getprod_hidemenu(){
  getprod_show = 0;
  setTimeout("getprod_hide()", 300);
}
function getprod_hide()
{
  var getprod_el = document.getElementById("getprod_channels");
  var getprod_iframe_menu = document.getElementById('getprod_iframe_menu');
  if (getprod_el) {
    if (!getprod_show)
    {
      getprod_el.style.visibility = "hidden";
      getprod_iframe_menu.style.display = "none";
    }
  }
}

function SynOpenWinSNND89_2871(tentoe_id){

	window.open('http://syndicate.tentoe.com/Syndicate/SynMaster?Tentoe=' + tentoe_id + '&ParentUrl=' + escape(window.location.href),'_blank', 'width=536,height=525,scrollbars=no,toolbar=no,personalbar=no,statusbar=no,directories=no,location=no,resizable=no,menubar=no,locationbar=no');
}


/**** Agent Smith *****/
AgentSmith = new Object();
AgentSmith.client = 'BOT';
// bot tracker image
AgentSmith.img = new Image();
AgentSmith.assignEvents = function () {
	var anchors = document.getElementsByTagName('a');
	for ( var i = 0; i < anchors.length; i++ ) {
		if ( anchors[i].href && anchors[i].href.match('rd.php') ) {
			window.addEvent(anchors[i], 'click', function(e) {
				if ( AgentSmith.client != 'BOT' ) {
					var reg = /\/k=([^\/]+)/i;
					var matches = reg.exec(this.href);
					AgentSmith.img.src = '/agntsmth.php/'+ matches[1];
				}
			}, anchors[i], true);
			window.addEvent(anchors[i], 'mouseover', function(e) { AgentSmith.client = 'USR'; }, document, true);
			window.addEvent(anchors[i], 'mouseout',  function(e) { AgentSmith.client = 'USR'; }, document, true);
		}
	}
}
/**** End Agent Smith ***/

function openBookmark(ut)
{
    var bkmrk="http://www.pricegrabber.com/?mode=bkmrk";
    var title="PriceGrabber.com - Shopping Comparison";
	window.external.AddFavorite(bkmrk,title);
	url = "/redirect_bookmark.php?ut="+ ut + "";	
	features = "toolbar=no,width=1,height=1,resizable=yes,bgcolor=#000000,scrollbars=no";
    window.name="bookmark";
	window.open( url, "", features );
}
function pg_openPromo(src) {
url = '/info_rebate.php?masterid='+src;
window.open(url, 'promo','height=450,width=550,innerHeight=450,innerWidth=550,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes');
}
function openSoundclips(masterid)
{
	url = "/info_soundclips.php?masterid=" + masterid + "";	
	features = "toolbar=no,width=500,height=450,resizable=yes,bgcolor=#000000,scrollbars=yes";
	window.open( url, "", features );
}
function openVideo( masterid )
{
	url = "/info_streaming.php?PublishedId=" + masterid;	
	features = "toolbar=no,width=300,height=285,resizable=yes,bgcolor=#000000,scrollbars=no";
    window.name="MyWindow";
	window.open( url, "", features );
}
function openlarge( masterid, big_x, big_y )
{
	url = "/info_picture.php?masterid=" + masterid;
	features = "toolbar=no,width=" + big_x + ",height=" + big_y + ",resizable=no,scrollbars=no";
	window.open( url, "techspecs"+masterid+"image", features );
}
function openptw( masterid, desc, topcat )
{
	if( desc )
	{
		url = "/info_ptw.php?masterid=" + masterid + "#description";
	}
	else
	{
		url = "/info_ptw.php?masterid=" + masterid + "&tab_id=" + topcat;	
	}
	features = "toolbar=no,width=540,height=450,resizable=yes,scrollbars=yes";
	window.open( url, "", features );
}
function opengetproddef(type)
{
	url = "/info_getproddef.php?type=" + type;
	features = "toolbar=no,width=400,height=275,resizable=yes,scrollbars=yes";
	window.open( url, "", features );
}
function open_def_win(type)
{
	url = "/info_minipage.php?type=" + type;
	features = "toolbar=no,width=500,height=250,resizable=yes,scrollbars=yes";
	window.open( url, "", features );
}
function openGetCoupon( coupon_id, masterid, redirurl )
{
url = "/coupons_popup.php?coupon_id=" + coupon_id + "&masterid=" + masterid;
        if (redirurl != undefined) url += "&url=" + redirurl;
		features = "toolbar=no,width=444,height=500,resizable=yes,scrollbars=yes";
		window.open( url, "", features );
}
function openGameTrailers( id )
{
  
	url = "/info_streaming_gt.php?gt_id=" + id;
	features = "toolbar=no,width=660,height=400,resizable=yes,bgcolor=#000000,scrollbars=no";
	window.open( url, "", features );
}
function attrib_toggles(subnum,subtype) { 
   if ( subtype == 'a' ) { 
      document.getElementById("sub" + subnum + "_a").style.display = "none"; 
	  document.getElementById("sub" + subnum + "_b").style.display = "block"; 	  
   } 
   else if ( subtype == 'b' ) { 
      document.getElementById("sub" + subnum + "_a").style.display = "block"; 
	  document.getElementById("sub" + subnum + "_b").style.display = "none"; 	  
   } 
}

function swapProductDescription() {
    //Swap the snippet and raw description
    var snippet_elem = document.getElementById('productDescriptionSnippet');
    var raw_elem = document.getElementById('productDescriptionRaw');
    if( snippet_elem && raw_elem ) {
        var snippet = snippet_elem.innerHTML;
        var raw = raw_elem.innerHTML;
        snippet_elem.innerHTML = raw;
        raw_elem.innerHTML = snippet;
    }
}

/* ***************** JS code related to getprod price alert popup ************************ */
function PPbubbleListClose(){
   is_modal = false;
   if(document.getElementById('modal_popup_content_overlay')){
      document.getElementById('modal_popup_content_overlay').style.display = 'none';
   }
   if(document.getElementById('modal_popup_background_overlay')){
      document.getElementById('modal_popup_background_overlay').style.display = 'none';
   }

   var isIE6 = DomUtils.browser.isIE6();
   if(isIE6){
      document.getElementById('shim').style.display = 'none';
   }
}
function ShowProductPagePopUpAlert(){
   if(is_modal) return;
   if( price_history_overlay && price_history_overlay.isOpened() ) {
       price_history_overlay.close();
   }
   ajax = new AjaxRequest('GET', '/search_getprod_ajax.php', true, 3000);
   ajax.setResponseType('html');
   ajax.setParameter('action', 'defaultAction');
      ajax.setParameter('product_id', product_id);
   ajax.setParameter('id_type', id_type);
   ajax.setParameter('search_id', search_id);
   ajax.setParameter('search_epoch_time', search_epoch_time);
   ajax.setParameter('session_id', session_id);
   ajax.setParameter('session_epoch_time', session_epoch_time);
   ajax.setCallback( callbackShowProductPagePopUpAlert );
   ajax.send();
}
function callbackShowProductPagePopUpAlert(HtmlResp){

   var width = document.body.clientWidth ? document.body.clientWidth : DomUtils.getWindowWidth();
   var height = document.body.clientHeight ? document.body.clientHeight : DomUtils.getWindowHeight();
   var scrollX = DomUtils.getWindowScrollX();
   var scrollY = DomUtils.getWindowScrollY();
   if(width==0 || height==0  || isNaN(width) || isNaN(height) || typeof window.opera !="undefined" || (window.opera == 'undefined' && window.opera.version() > 9.5)) {
      if((typeof window.opera=="undefined" || window.opera.version() > 9.5) && document.documentElement.clientWidth) {
         width = document.documentElement.clientWidth;
         height = document.documentElement.clientHeight;
      }
   }
   if(scrollX==0 || scrollY==0 || isNaN(scrollX) || isNaN(scrollY)) {
      scrollX = document.documentElement.scrollLeft;
      scrollY = document.documentElement.scrollTop;
   }

   var div = document.createElement('div');
   div.id = 'modal_popup_content_overlay';
   div.style.position = 'absolute';
   div.style.left = ((width/2)-220)+'px';
   div.style.top = (DomUtils.getWindowScrollY() ? DomUtils.getWindowScrollY() : scrollY) + (DomUtils.getWindowHeight()/2-260)+'px';
   div.style.zIndex = '10001';

   div.innerHTML = HtmlResp;
   background_overlay(true);
   var db = document.body;
   db.appendChild(div);
   
   // Omniture impression tracking for getprod price alert pop up
   var om_str_imp = 'getprodpopup|impression|'+document.getElementById('ProductPagePopUpAlertTopcatName').value+'|'+document.getElementById('ProductPagePopUpAlertPageId').value;
   om_singleH_link('pgrabcom,pgrabusops,pgrabglobal','','prop34', ''+om_str_imp+'','getprodpopup','266bbf74e525f696');
}

// Onclick tracking for the components inside the getprod price alert popup
function ProdPagePopupAlertOnclick(type){
   var newsletter = document.getElementById('ProductPagePopUpAlertNewsletter').checked ? 'Y' : 'N';
   var om_str = 'getprodpopup|click|'+type+'|newsletter'+newsletter+'|'+document.getElementById('ProductPagePopUpAlertTopcatName').value+'|'+document.getElementById('ProductPagePopUpAlertPageId').value;
   om_singleH_link('pgrabcom,pgrabusops,pgrabglobal','','eVar34', ''+om_str+'','','266bbf74e525f696');}

function ProductPagePopUpAlertSubmit(){
   document.getElementById('ProductPagePopUpAlertErr').innerHTML = 'Setting price alert, please wait...';
   var email = document.getElementById('ProductPagePopUpAlertEmail').value;
   var price = document.getElementById('ProductPagePopUpAlertPrice').value;
   var newsletter = document.getElementById('ProductPagePopUpAlertNewsletter').checked ? 'Y' : 'N';
   var product_id = document.getElementById('ProductPagePopUpAlertProductId').value;
   var id_type = document.getElementById('ProductPagePopUpAlertIdType').value;
   var low_price = document.getElementById('ProductPagePopUpAlertLowPrice').value;
   if(isValidEmail(email)){
      document.getElementById('ProductPagePopUpAlertErr').innerHTML = '';
      if(newsletter){
         ajax = new AjaxRequest('GET', '/search_getprod_ajax.php', true, 3000);
         ajax.setCallback( ProductPagePopUpAlertNewsletterCallback );
         ajax.setParameter('temp_newsletter_req', 'yes');
         ajax.setParameter('email', email);
         ajax.setParameter('price', price);
         ajax.setParameter('newsletter', newsletter);
         ajax.setParameter('product_id', product_id);
         ajax.setParameter('id_type', id_type);
         ajax.setParameter('low_price', low_price);
         ajax.setParameter('action', 'ProductPagePopUpAlertSubmit');
         ajax.send();
      }


   }else
      document.getElementById('ProductPagePopUpAlertErr').innerHTML = 'Invalid email address!';
}

function ProductPagePopUpAlertNewsletterCallback(XmlResp){
   if(!XmlResp){
      document.getElementById('ProductPagePopUpAlertErr').innerHTML = 'There was a problem setting your price alert, please try again!';
   }else{
      var error = XmlResp.getElementsByTagName('error') ? XmlResp.getElementsByTagName('error') : null;
      var success = XmlResp.getElementsByTagName('success') ? XmlResp.getElementsByTagName('success') :  null;
      if(error.length > 0){
         var nb = XmlResp.getElementsByTagName("nb")[0].firstChild.nodeValue;
         var desc = XmlResp.getElementsByTagName("desc")[0].firstChild.nodeValue;
         var action = XmlResp.getElementsByTagName("action")[0].firstChild.nodeValue;
         document.getElementById('ProductPagePopUpAlertErr').innerHTML = desc;
      }
      else if(success.length > 0){
         var verification_email = XmlResp.getElementsByTagName("verification_email")[0] ? XmlResp.getElementsByTagName("verification_email")[0].firstChild.nodeValue : null;
         var optin_update = XmlResp.getElementsByTagName("optin_update")[0] ? XmlResp.getElementsByTagName("optin_update")[0].firstChild.nodeValue : null;
         var price_alert = XmlResp.getElementsByTagName("price_alert")[0] ?  XmlResp.getElementsByTagName("price_alert")[0].firstChild.nodeValue : null;
         var msg = '';
         if(price_alert=='Y'){ msg = 'You have successfully singed up for a PriceGrabber Price Alert!'; }
         else if(verification_email=='Y'){ msg = 'Thank you for signing up for a PriceGrabber Price Alert! A verification email has been sent to you; please take a few seconds to verify your email address and then you will be able to receive Price Alerts.'; }

         document.getElementById('ppPriceAlertBox').style.display = 'none';
         document.getElementById('ppPriceAlertBoxMsg').style.display = 'block';
         document.getElementById('ppPriceAlertBoxMsg').innerHTML = '<font color="green">'+msg+'</font><br><br><a href="#" onclick="RefreshProductPageAlert();return false;">Set another Price Alert</a>';
      }else{
         document.getElementById('ProductPagePopUpAlertErr').innerHTML = 'There was a problem adding your price alert, please try again.';
      }
   }
}

function RefreshProductPageAlert(){
         document.getElementById('ppPriceAlertBoxMsg').innerHTML = '';
         document.getElementById('ppPriceAlertBoxMsg').style.display = 'none';
         document.getElementById('ppPriceAlertBox').style.display = 'block';
         document.getElementById('ProductPagePopUpAlertEmail').value = 'Enter email address';
         document.getElementById('ProductPagePopUpAlertPrice').value = 'Target Price';
}


function background_overlay(show){
   if(show){
      if(!document.getElementById('modal_popup_backgroud_overlay')){

         var width = document.body.clientWidth ? document.body.clientWidth : DomUtils.getWindowWidth();
         var height = document.body.clientHeight ? document.body.clientHeight : DomUtils.getWindowHeight();
         var scrollX = DomUtils.getWindowScrollX();
         var scrollY = DomUtils.getWindowScrollY();
         if(width==0 || height==0  || isNaN(width) || isNaN(height) || typeof window.opera !="undefined" || (window.opera == 'undefined' && window.opera.version() > 9.5)){
            if((typeof window.opera=="undefined" || window.opera.version() > 9.5) && (document.documentElement.clientWidth > document.body.clientWidth )) {
               width = document.documentElement.clientWidth;
               height = document.documentElement.clientHeight;
            }
         }
         if(scrollX==0 || scrollY==0 || isNaN(scrollX) || isNaN(scrollY)) {
            scrollX = document.documentElement.scrollLeft;
            scrollY = document.documentElement.scrollTop;
         }

         var div = document.createElement('div');
         div.id = 'modal_popup_background_overlay';
         div.style.position = 'absolute';
         div.style.left = '0px';
         div.style.top = '0px';
         div.style.width = '100%';
         div.style.height = (document.body.clientHeight ? document.body.clientHeight : (scrollY + DomUtils.getWindowHeight())) + 'px';
         div.style.background = '#666666';
         div.style.zIndex = '10000';
         div.style.opacity = '0.4';
         div.style.MozOpacity = '0.4';
         div.style.filter = "alpha(opacity='40')";
         div.style.display = 'block';
         var db = document.body;
         db.appendChild(div);
      }else{
         document.getElementById('modal_popup_backgroud_overlay').style.display = 'block';
      }


      //ADD IFRAME SHIM - for IE6 so select box doesn't show through the popup
      //instead of adding the code for the shim to each page, and potentially missing one, create it manually and append to the body
      var isIE6 = DomUtils.browser.isIE6();
      if(isIE6){
         if(document.getElementById('shim') == null){
            var shim = document.createElement('iframe');
            shim.setAttribute('src', 'javascript:false;');
            shim.setAttribute('scrolling', 'no');
            shim.setAttribute('frameborder', '0');
            shim.setAttribute('id', 'shim');

            //set needed styles for the shim
            shim.style.zIndex = 9999;
            shim.style.display = "none";
            shim.style.position = "absolute";
            shim.style.backgroundColor = "transparent";
            shim.style.top = "0px";
            shim.style.left = "0px";
            document.body.appendChild(shim);
         }

         scrollX = DomUtils.getWindowScrollX();
         scrollY = DomUtils.getWindowScrollY();
         height = DomUtils.getElementHeight(document.body);
         if(document.body.scrollTop) height += document.body.scrollTop ;
         width = DomUtils.getElementWidth(document.body);
         if(height < screen.height) {
            height = (screen.height * .8);
         }

         document.getElementById('shim').style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
         document.getElementById('shim').style.width = width + scrollX + 'px';
         document.getElementById('shim').style.height = height + scrollY + 150  + 'px';
         document.getElementById('shim').style.display = 'block';
      }


   }else{
      if(!document.getElementById('modal_popup_backgroud_overlay')){
         document.getElementById('modal_popup_backgroud_overlay').style.display = 'none';
      }
   }
}

function newsletterSend(email,referral, margin){
    ajax = new AjaxRequest('GET', '/newsletter_landing.php', true, 3000);
    ajax.setCallback( newsletterCallback );
    ajax.setParameter('temp_newsletter_req', 'yes');
    ajax.setParameter('email', email);
    ajax.setParameter('referral', referral);
    if (margin != '') {
        ajax.setParameter('margin', margin);
    }
    ajax.send();

}

function newsletterCallback(XmlResp){
	if(!XmlResp) {
		return false;
	}
	else {
        var result = XmlResp.getElementsByTagName("result")[0].firstChild.nodeValue;
		var message = XmlResp.getElementsByTagName("message")[0].firstChild.nodeValue;
        try {
            var margin = XmlResp.getElementsByTagName("margin")[0].firstChild.nodeValue;
        } catch(err) {}
       // alert('callback'+result)
        newsletter_overlay(message,result,margin);
        
    }
}


function isValidEmail(emailStr) {
    emailStr = emailStr.replace(/^\s*|\s*$/g,'');
    var emailPat=/^(.+)@(.+)$/;
    var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
    var validChars="\[^\\s" + specialChars + "\]";
    var quotedUser="(\"[^\"]*\")";
    var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
    var atom=validChars + '+';
    var word="(" + atom + "|" + quotedUser + ")";
    var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
    var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
    var matchArray=emailStr.match(emailPat);
    if (matchArray==null) {
        return false;
    }
    var user=matchArray[1];
    var domain=matchArray[2];
    if (user.match(userPat)==null) {
        return false;
    }
    var IPArray=domain.match(ipDomainPat);
    if (IPArray!=null) {
        for (var i=1;i<=4;i++) {
            if (IPArray[i]>255) {
                return false;
            }
        }
        return true;
    }
    var domainArray=domain.match(domainPat);
    if (domainArray==null) {
        return false;
    }
    var atomPat=new RegExp(atom,"g");
    var domArr=domain.match(atomPat);
    var len=domArr.length;
    if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>4) {
        return false;
    }
    if (len<2) {
        return false;
    }
    return true;
}

function newsletter_overlay(show,result,margin){
    var browser=navigator.appName;
    switch (browser) {
        case 'Microsoft Internet Explorer':
          var IE = 1;
        break;
        
        default:
           var IE = 0;
        break;   
    }
    
    var nws = document.getElementById('getProd_newsletter');
    if (document.getElementById('newsletter_overlay')==null) {
        var news = document.createElement('div');
        news.setAttribute('id', 'newsletter_overlay'); 
        if (margin != null) news.style.margin = margin;
        nws.appendChild(news);
    }  
   
    var news_over = document.getElementById('newsletter_overlay');
    
        switch(result){
                case 'ok':
                    if (document.getElementById('news_div')!=null) news_over.removeChild(news_over.childNodes[0]);
                   
                    var over = document.createElement('div');
                    if (IE) over.setAttribute('className','vcenter');
                    else over.setAttribute('class','vcenter'); 
                    
                    over.setAttribute('id', 'news_div');
                    news_over.appendChild(over);
                    
                    var p_append_1 = document.createElement('p');
                    var p_append_2 = document.createElement('p');
                    if (IE) p_append_1.setAttribute('className', 'valid');
                    else p_append_1.setAttribute('class', 'valid');
                    p_append_1.innerHTML = 'Thanks for signing up!';
                    p_append_2.innerHTML = 'We\'ve sent you a confirmation email<br>Just click the link inside, and you\'re all set.';
                    over.appendChild(p_append_1);
                    over.appendChild(p_append_2);
                    
                break;
                
                case 'fail':
                    if (document.getElementById('news_div')!=null) news_over.removeChild(news_over.childNodes[0]);
                    
                        var over = document.createElement('div');
                        if (IE) over.setAttribute('className','vcenter');
                        else over.setAttribute('class','vcenter');
                        over.setAttribute('id', 'news_div');
                        news_over.appendChild(over);
                        
                        
                        var p_append_1 = document.createElement('p');
                        var p_append_2 = document.createElement('p');
                        if (IE) p_append_1.setAttribute('className', 'error');
                        else p_append_1.setAttribute('class', 'error');
                        p_append_1.innerHTML = show;
                        over.appendChild(p_append_1);
                        over.appendChild(p_append_2);
                        
                        var p_append_2_a = document.createElement('a');
                        if (IE) p_append_2_a.setAttribute('className', 'greenemailBtn');
                        else p_append_2_a.setAttribute('class', 'greenemailBtn');
                        p_append_2_a.setAttribute('href', 'javascript:void(0)');
                        p_append_2_a.onclick = new Function( "return hide_overlay_focus();" );
                        p_append_2.appendChild(p_append_2_a);
                        
                        var p_append_2_a_span = document.createElement('span');
                        p_append_2_a_span.innerHTML = 'Try Again';
                        p_append_2_a.appendChild(p_append_2_a_span);
                    
                    break;
                    
                    case 'signed':
                        if (document.getElementById('news_div')!=null) news_over.removeChild(news_over.childNodes[0]);
                    
                        var over = document.createElement('div');
                        if (IE) over.setAttribute('className','vcenter_subscribed');
                        else over.setAttribute('class','vcenter_subscribed');
                        over.setAttribute('id', 'news_div');
                        news_over.appendChild(over);
                        
                        
                        var p_append_1 = document.createElement('p');
                        var p_append_2 = document.createElement('p');
                        var p_append_3 = document.createElement('p');
                        var p_append_4 = document.createElement('p');
                        if (IE) p_append_1.setAttribute('className', 'error');
                        else p_append_1.setAttribute('class', 'error');
                        if (IE) p_append_4.setAttribute('className', 'small');
                        else p_append_4.setAttribute('class', 'small');
                        if (IE) p_append_3.setAttribute('className', 'signed');
                        else p_append_3.setAttribute('class', 'signed');
                        if (IE) p_append_2.setAttribute('className', 'signed');
                        else p_append_2.setAttribute('class', 'signed');
                        p_append_1.innerHTML = 'Whoops! You\'re already subscribed!';
                        p_append_2.innerHTML = 'Please check your spam folder, and add <b>email-alerts@pricegrabber.com</b> to your address book.';
                        p_append_4.innerHTML = '<b>Still having problems?</b> ';
                        
                        
                        
                        var p_append_3_a = document.createElement('a');
                        
                        if (IE) p_append_3_a.setAttribute('className', 'greenemailBtn');
                        else p_append_3_a.setAttribute('class', 'greenemailBtn');
                        p_append_3_a.setAttribute('href', '');
                        p_append_3_a.onclick = new Function( "return hide_overlay_focus();" );
                        p_append_3.appendChild(p_append_3_a);
                        
                        var p_append_3_a_span = document.createElement('span');
                        p_append_3_a_span.innerHTML = 'Try Again';
                        p_append_3_a.appendChild(p_append_3_a_span);
                    
                        var p_append_4_a = document.createElement('a');
                        p_append_4_a.setAttribute('href', 'mailto:email-alerts@pricegrabber.com');
                        p_append_4_a.innerHTML = 'Send us an email';
                        
                        p_append_4.appendChild(p_append_4_a);
                        
                        over.appendChild(p_append_1);
                        over.appendChild(p_append_2);
                        over.appendChild(p_append_3);
                        over.appendChild(p_append_4);
                    break;
                
        }
        news_over.style.zIndex = 6;
        news_over.style.display = 'block';
        setTimeout('hide_overlay()', 4000);
    }
    
function hide_overlay_focus(){
    var shim = document.getElementById('newsletter_overlay');
    if (shim.style.display!='none') {
        shim.style.zIndex = 0;
        shim.style.display='none';
        var email = document.getElementById('email');
        email.focus();
        return false;
    }
}

function hide_overlay(){
    var shim = document.getElementById('newsletter_overlay');
    if (shim.style.display!='none') {
        shim.style.zIndex = 0;
        shim.style.display='none';
        return false;
    }
}


function newsletter() {
    var email = document.getElementById('email');
    if (email.value == 'your email address') email.value='';
    email.style.color = '#444';
}

function newsletter_submit(referral, margin) {
    var email = document.getElementById('email');
    if (!isValidEmail(email.value)) {
        var message = "<b>Whoops!</b> Please type a valid email address.";
        newsletter_overlay(message,'fail',margin);
    } else {
        newsletterSend(email.value, referral, margin);
    }
}

/**
 *
 * $Id: util.js 63843 2009-02-09 23:15:05Z kchiu $
 * $Author: kchiu $
 * $Revision: 63843 $
 * $Name$
 * $Date: 2009-02-09 15:15:05 -0800 (Mon, 09 Feb 2009) $
 *
 * @package     PriceGrabber
 * @category    JavaScript
 *
 * @author      Philip Snyder <philip@pricegrabber.com>
 * @copyright   Copyright &copy; 2006 2007, Philip Snyder, PriceGrabber.com
 * @version     $Revision: 63843 $
 *
 * @todo        Finish documentation.
 */

/**
 * Checks the object to see if it implements a certain function.
 *
 * @access public
 * @since  v1.1
 * @param  string   funcName   Name of function to check for
 * @return boolean
 */



/**
 * Generates an xml string representation of the object.
 *
 * @access public
 * @since  v1.1
 * @param  string   tagname   Tag name to use for the object
 * @return string
 */
/*
Object.prototype.simpleXmlify = function(tagname) {
    var xml = "<"+tagname;
    for (var prop in this) {
        if (!(this[prop] instanceof Function)) {
            xml += " "+prop+"=\""+this[prop]+"\"";
        }
    }
    xml += "/>";
    return xml;
}
*/


/**
 * Finds the index of a value in the array or returns false if not found.
 *
 * @acccess public
 * @since   v1.1
 * @param   mixed val     Value to search array for
 * @return  int | false
 */
Array.prototype.inArray = function(val) {
    for (var i=0; i<this.length; i++) {
        if (this[i] == val) return i;
    }
    return false;
}
// Remove object helper methods from array
Array.prototype.simpleXmlify   = null;
// Remove object helper methods from Error
Error.prototype.simpleXmlify   = null;






/**
 * Generalize namespace for utility functions
 *
 * @access public
 * @since  v1.1
 */
var util = new Object;






/**
 * Manages image cacheing
 *
 * @todo   Confirm this image cacheing scheme works in IE & FF via fiddler
 *
 * @access public
 * @since  v1.1
 */
util.resourceManager = {

    cache: new Array,

    index: new Array,

    /**
     * Handles cacheing and returns the image src of a url.
     * 
     * @access public
     * @since  v1.1
     * @param  string   url
     * @return Image.src
     */ 
    get: function(url) {
        var ptr = util.resourceManager.index.inArray(url);
        if (ptr === false) {
            ptr                                 = util.resourceManager.index.length;
            util.resourceManager.index[ptr]     = url;
            util.resourceManager.cache[ptr]     = new Image;
            util.resourceManager.cache[ptr].src = url;
        }
        return util.resourceManager.cache[ptr].src;
    }
    
};



/**
 * This function returns the name of a given function.
 *
 * It does this by converting the function to a string,
 * then using a regular expression to extract the
 * function name from the resulting code.
 *
 * @access public
 * @since  v1.1
 * @param  Function  f
 * @return string
 */
function funcname(f) {
    var matches = f.toString().match(/function (\w*)/);
    if ((matches == null) || (matches.length == 0)) return "anonymous";
    if (matches.length == 2) return matches[1];
    else return matches.join(',');
}

/**
 * This function returns a string that contains a "stack trace".
 *
 * @access public
 * @since  v1.1
 * @return string
 */
function stacktrace() {
    var s = "";  // This is the string we'll return.
    // Loop through the stack of functions, using the caller property of
    // one arguments object to refer to the next arguments object on the
    // stack.
    for (var a=arguments.caller; a!=null; a=a.caller) {
        // Add the name of the current function to the return value.
        s += funcname(a.callee) + "\n";
        // Because of a bug in Navigator 4.0, we need this line to break.
        // a.caller will equal a rather than null when we reach the end 
        // of the stack. The following line works around this.
        if (a.caller == a) break;
    }
    return s;
}















/***** BEGIN MESSAGE QUEUE *******/




util.MessageQueue = function(type) {
    this.queued = new Array;
    this.containerId = 'message';
    this.type = type || util.MessageQueue.types.ALL;
    this.queueId = util.MessageQueue.queues.length;
    this.waitingForResponse = false;
    util.MessageQueue.queues[this.queueId] = this;
    return this;
};

util.MessageQueue.settings = {
    timer:     null,
    interval:  5, // in seconds
    immediate: true
};

util.MessageQueue.types  = { NONE:0, ERROR:1, DEBUG:2, USER:4, ALL:7 };
util.MessageQueue.queues = [];


util.MessageQueue.attach = function(queue) {
    if (!util.MessageQueue.queues.inArray(queue)) {
        util.MessageQueue.queues.push(queue);
    }
    return true;
}

util.MessageQueue.detach = function(queue) {
    var retain = [];
    var found  = false;
    while (util.MessageQueue.queues.length) {
        var queuePop = util.MessageQueue.queues.pop();
        if (queue !== queuePop) retain.push(queuePop);
        else                    found = queuePop;
    }
    util.MessageQueue.queues = retain;
    return found;
}


util.MessageQueue.prototype.add = function(obj, test) {
    //alert('util.MessageQueue.add called: '+obj.title+' -> '+obj.content);
    test = test === false ? false : true;
    test = true;
    if ((test && this.isMessage(obj)) || !test) {
        //alert(obj);
        this.queued.push(obj);
        //alert(this.queued.toString());
    }
    if (util.MessageQueue.settings.immediate) this.renderNext();
}

util.MessageQueue.prototype.isMessage = function(obj) {
    return obj.implementsProp('title') && obj.implementsProp('content') && obj.implementsProp('type');
} 

util.MessageQueue.prototype.render = function(type) {
    if (this.queued.length > 0) {
        var body = document.getElementsByTagName('body')[0];
        if (body) {
            var types = util.MessageQueue.types;
            type = type <= types.ALL ? type : types.ALL;
            var messages = new Array;
            if (type == types.ALL) {
                messages = this.queued;
                this.queued = new Array;
            } else {
                var retain = new Array;
                for (var i=0; i<this.queued.length; i++) {
                    var msg = this.queued[i];
                    if (msg.type == type) {
                        messages.push(msg);
                    } else {
                        retain.push(msg);
                    }
                }
                this.queued = retain;
            }
            if (!this.container) {
                this.container = document.createElement('div');
                this.container.className = 'messageContainer';
                body.appendChild(this.container);
            }
            for (var i=0; i<messages.length; i++) {
                var mesg = messages[i];
                mesg.displayHandler();
            }
        }
    }
}









util.MessageQueue.prototype.renderNext = function(force) {
    force = force || false;
    if (force) {
        this.waitingForResponse = false;
        clearInterval(this.renderNextTimeout);
        this.renderNextTimeout = null;
    }
    if (this.queued.length > 0) {
        if (!this.waitingForResponse) {
            //Assert.warn('util.MessageQueue.renderNext:displaying from queue '+this.queueId+', queue length = '+this.queued.length);
            var body = document.getElementsByTagName('body')[0];
            if (!body) throw new Error('Unable to find body element');
            var message = null;
            var queueHead = new Array;
            do {
                message = this.queued.shift();
                //Assert.warn('util.MessageQueue.renderNext:shift message type = '+message.type);
                if (message.type != this.type && this.type != util.MessageQueue.types.ALL) {
                    //Assert.warn('util.MessageQueue.renderNext:not all queue, not our message type');
                    queueHead.push(message);
                    message = null;
                }
            } while (!message && this.queued.length > 0);
            while (queueHead.length > 0) {
                this.queued.unshift(queueHead.shift());
            }
            if (message) {
                this.waitingForResponse = true;
                message.displayHandler();
            }
        } else if (!this.renderNextTimer) {
            //Assert.warn('util.MessageQueue.renderNext:setting renderNext timer -- '+this.queued.length+' messages remain');
            this.renderNextTimer = setInterval('util.MessageQueue.queues['+this.queueId+'].renderNext()', 1000);
        }
    }
}




window.messageQueue = new util.MessageQueue(util.MessageQueue.types.ALL);


/***** END MESSAGE QUEUE *******/

















/***** COOKIE MANAGEMENT *****/

/**
 * Creates a cookie via javascript
 *
 * @since  1.1.2.8
 * @access public
 * @param  string    name
 * @param  string    value
 * @param  int       ttl      Time to live, in seconds - defaults to session [optional]
 * @param  string    path     [optional]
 * @param  string    domain   [optional]
 * @param  boolean   secure   [optional]
 * @return void
 */
util.createCookie = function createCookie(name,value) {
    // Support optional arguments
    var argv    = arguments;
    var argc    = arguments.length;
    var ttl     = (argc > 2) ? argv[2]*1000 : null;
    var path    = (argc > 3) ? argv[3]      : null;
    var domain  = (argc > 4) ? argv[4]      : null;
    var secure  = (argc > 5) ? argv[5]      : false;
    // If we have a ttl to work with, calculate the expires
    if (ttl) {
        var expires = new Date();
        expires.setTime(expires.getTime()+ttl);
    }
    // Create the actual cookie
    document.cookie = name + "=" + escape (value) + 
                      ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
                      ((path    == null) ? "" : ("; path=" + path)) + 
                      ((domain  == null) ? "" : ("; domain=" + domain)) + 
                      ((secure  == true) ? "; secure" : "");
}

/**
 * Returns the value of a cookie
 * 
 * @since  1.1.2.8
 * @access public
 * @param  string    name
 * @return string
 */
util.readCookie = function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length,c.length));
    }
    return null;
}

/**
 * Removes a cookie
 *
 * @since  1.1.2.8
 * @access public
 * @param  string    name
 * @return void
 */
util.eraseCookie = function eraseCookie(name) {
    util.createCookie(name,"",-1);
}


/**
 * js/classes/browser.js
 *
 *
 *
 * @package     PriceGrabber
 * @subpackage  Utils
 * @category    JavaScript
 *
 * @author      Philip Snyder <philip@pricegrabber.com>
 * @copyright   Copyright &copy; 2005, Philip Snyder, PriceGrabber.com
 * @version     v0.0.1a
 *
 */







function Browser() { }

Browser.prototype             = Object;
Browser.prototype.constructor = Browser;
Browser.superclass            = Object.constructor;


Browser.regexes = {
    overflowX: new Array(/Firefox\/1\.0/),
    overflowY: new Array(/Firefox\/1\.0/)
};

Browser.supportsOverflowX = function() {
    for (var i=0; i<Browser.regexes.overflowX.length; i++) {
        var regex = Browser.regexes.overflowX[i];
        if (navigator.userAgent.match(regex)) {
            return false;
        }
    }
    return true;
}

Browser.supportsOverflowY = function() {
    for (var i=0; i<Browser.regexes.overflowY.length; i++) {
        var regex = Browser.regexes.overflowY[i];
        if (navigator.userAgent.match(regex)) {
            return false;
        }
    }
    return true;
}

Browser.supportsDom = function() {
    return (document.getElementById) ? true : false;
}

Browser.isIE = function() {
    return (document.all && navigator.appName.indexOf('Microsoft Internet Explorer') > -1) ? true : false;
}

Browser.isSafari = function() {
    return (navigator.userAgent.toLowerCase().indexOf('safari') > -1) ? true : false;
}
/**
 * $Id: baseobject.js 64367 2009-02-20 01:56:36Z kchiu $
 * $Author: kchiu $
 * $Revision: 64367 $
 * $Name$
 * $Date: 2009-02-19 17:56:36 -0800 (Thu, 19 Feb 2009) $
 *
 * @jsRequire interfaces.Interface
 *
 * BaseObject is a starter object for any JavaScript object
 * created. Once an object adds the BaseObject to its prototype
 * chain, it gains the functionality of all methods and variables
 * defined in this object, making BaseObject the perfect place
 * to incorporate other JavaScript libraries such as the Interface
 * library.
 *
 * @version    $Revision: 64367 $
 * @author     Philip Snyder <philip@pricegrabber.com>
 * @copyright  Copyright &copy; 2006, Philip Snyder, PriceGrabber.com
 * @see        interfaces.Interface
 */



/**
 * BaseObject Constructor / Definition
 *
 * @access public
 * @since  v1.1
 * @param  string      id
 * @return BaseObject
 */
function BaseObject(id) {
    // Method definitions
    this.getProperty = BaseObject_GetProperty;
    this.setProperty = BaseObject_SetProperty;
    this.getId       = BaseObject_GetId;
    this.setId       = BaseObject_SetId;
    // Member definitions
    this.properties = [];
    // Initialization
    this.setId(id);
    return this;
}

// Setup BaseObject prototype chain
BaseObject.prototype             = new Object;
BaseObject.prototype.constructor = BaseObject;
BaseObject.superclass            = Object.prototype;



/**
 * Returns the value of a property.
 *
 * @access public
 * @since  v1.1
 * @return mixed
 */
function BaseObject_GetProperty(name) {
    if (this.properties[name]) return this.properties[name];
    else                       return null;
}

/**
 * Sets the value of a property.
 *
 * @access public
 * @since  v1.1
 * @param  string  name
 * @param  mixed   value
 * return  boolean
 */
function BaseObject_SetProperty(name, value) {
    this.properties[name] = value;
    return true;
}

/**
 * Returns the id of the object.
 *
 * @access public
 * @since  v1.1
 * @return string
 */
function BaseObject_GetId() {
    return this.getProperty('id');
}

/**
 * Sets the id of the object.
 *
 * @access public
 * @since  v1.1
 * @param  string   id
 * @return boolean
 */
function BaseObject_SetId(id) {
    return this.setProperty('id', id);
}


/**
 * Extend the BaseObject class with any known included
 * functionality (for example Interface.implement)
 *
 * The reverse of this test can be found in interfaces.Interface
 * so that either file can be included first and the
 * functionality is still in place.
 */
if (typeof(Interface_Implement) == 'function') BaseObject.prototype.implement = Interface_Implement;
/**
 * $Id: interface.js 64367 2009-02-20 01:56:36Z kchiu $
 * $Author: kchiu $
 * $Revision: 64367 $
 * $Name$
 * $Date: 2009-02-19 17:56:36 -0800 (Thu, 19 Feb 2009) $
 *
 *
 *
 * This Interface JavaScript library serves to implement
 * a sort-of hacked interface extension to the standard
 * JavaScript language.
 *
 * The Interface function is never intended to be
 * invoked directly but rather in a prototype chain.
 *
 * Documentation will be available at:
 *
 * http://wiki.pricegrabber.com/moin.cgi/PhilipSnyder
 *
 *
 *
 * @version    $Revision: 64367 $
 * @author     Philip Snyder <philip@pricegrabber.com>
 * @copyright  Copyright &copy; 2006, Philip Snyder, PriceGrabber.com
 */

/**
 * Interface Constructor / Definition
 *
 * This is NOT intended to be instantiated directly. See
 * documentation for a complete explanation.
 *
 * @access public
 * @since  v1.1
 * @return Interface
 */
function Interface() {
    this.implement = Interface_Implement;
    return this;
}

/**
 * Confirms complete implementation of passed in Interface function reference.
 *
 * This method checks the object in question and validates that it has
 * either implemented or borrowed every method & variable defined in
 * the interfaces it claims to implement.
 *
 * @access public
 * @since  v1.1
 * @return void
 */
function Interface_Implement(ifaceRef) {
    var tmpObj  = new ifaceRef();
    var objName = (this.constructor+'').substr(('function ').length, (this.constructor+'').indexOf('(') - 'function '.length);
    for (var prop in tmpObj) {
        var typeCheck = false;
        var isFunc    = false;
        eval('isFunc    = (typeof(tmpObj.'+prop+') == "function");');
        eval('typeCheck = (typeof(this.'+prop+')   == typeof(tmpObj.'+prop+'));');
        if (prop != 'implement' && !typeCheck) {
            if (isFunc) throw new Error(objName+'.'+prop+"() not implemented!");
            else        throw new Error(objName+'.'+prop+" is either a wrong type or missing.");
        }
    }
}

/**
 * Attach the implement() method to our BaseObject as
 * well, and all classes extending BaseObjects will have
 * it available to them (and all at the cost of 1
 * function loaded into memory).
 */
if (typeof(BaseObject) == 'function') BaseObject.prototype.implement = Interface_Implement;
/**
 * $Id: anchoredinterface.js 64367 2009-02-20 01:56:36Z kchiu $
 * $Author: kchiu $
 * $Revision: 64367 $
 * $Name$
 * $Date: 2009-02-19 17:56:36 -0800 (Thu, 19 Feb 2009) $
 *
 * @jsRequire DomUtils
 * @jsRequire interfaces.Interface
 *
 *
 * @version    $Revision: 64367 $
 * @author     Philip Snyder <philip@pricegrabber.com>
 * @copyright  Copyright &copy; 2006, Philip Snyder, PriceGrabber.com
 * @see        interfaces.Interface
 */

/**
 * AnchoredInterface Constructor / Definition
 *
 * This interface is built on top of the Interface object
 * and is NOT intended to be instantiated directly. See
 * documentation on interfaces.Interface for a complete
 * explanation.
 *
 * @access public
 * @since  v1.1
 * @return AnchoredInterface
 */
function AnchoredInterface() {
    this.elemId            = null;
    this.anchorId          = null;
    this.disableScroll     = false;
    this.getAnchorX        = AnchoredInterface_GetAnchorX;
    this.getAnchorY        = AnchoredInterface_GetAnchorY;
    this.getAnchorZ        = AnchoredInterface_GetAnchorZ;
    this.getAnchorWidth    = AnchoredInterface_GetAnchorWidth;
    this.getAnchorHeight   = AnchoredInterface_GetAnchorHeight;
    this.getElemWidth      = AnchoredInterface_GetElemWidth;
    this.getElemHeight     = AnchoredInterface_GetElemHeight;
    this.getAnchorPosition = AnchoredInterface_GetAnchorPosition;
    this.setAnchor         = AnchoredInterface_SetAnchor;
    this.alignElement      = AnchoredInterface_AlignElement;
}

// Setup AnchoredInterface prototype chain
AnchoredInterface.prototype             = new Interface;
AnchoredInterface.prototype.constructor = AnchoredInterface;
AnchoredInterface.superclass            = Interface.prototype;

/**
 * Constants defining anchor points around the element.
 *
 * !DO NOT MODIFY THIS!
 *
 * @access public
 * @since  v1.1
 * @var    AnchoredInterface.ALIGN   struct
 */
AnchoredInterface.ALIGN = { RIGHT_TOP: 1, RIGHT_BOTTOM: 2, LEFT_BOTTOM: 3, LEFT_TOP: 4 };

/**
 * Returns the anchor element's X coordinate.
 *
 * @access public
 * @since  v1.1
 * @return integer
 */
function AnchoredInterface_GetAnchorX() {
    return DomUtils.getElementLeft(document.getElementById(this.anchorId));
}

/**
 * Returns the anchor element's Y coordinate.
 *
 * @access public
 * @since  v1.1
 * @return integer
 */
function AnchoredInterface_GetAnchorY() {
    return DomUtils.getElementTop(document.getElementById(this.anchorId));
}

/**
 * Returns the anchor element's Z index.
 *
 * @access public
 * @since  v1.1
 * @return integer
 */
function AnchoredInterface_GetAnchorZ() {
    return DomUtils.getZIndex(document.getElementById(this.anchorId));
}

/**
 * Returns the anchor element's width.
 *
 * @access public
 * @since  v1.1
 * @return integer
 */
function AnchoredInterface_GetAnchorWidth() {
    //window.messageQueue.add( new Message(funcname(this), 'getting anchor width') );
    return DomUtils.getElementWidth(document.getElementById(this.anchorId));
}

/**
 * Returns the anchor element's height.
 *
 * @access public
 * @since  v1.1
 * @return integer
 */
function AnchoredInterface_GetAnchorHeight() {
    return DomUtils.getElementHeight(document.getElementById(this.anchorId));
}

/**
 * Returns the element's width.
 *
 * @access public
 * @since  v1.1
 * @return integer
 */
function AnchoredInterface_GetElemWidth() {
    //window.messageQueue.add( new Message(funcname(this), 'getting element width') );
    return DomUtils.getElementWidth(document.getElementById(this.elemId));
}

/**
 * Returns the element's height.
 *
 * @access public
 * @since  v1.1
 * @return integer
 */
function AnchoredInterface_GetElemHeight() {
    return DomUtils.getElementHeight(document.getElementById(this.elemId));
}

/**
 * Calculates the best alignment position for the element based on window size and position of the anchor element.
 *
 * Returns a value from the AnchoredInterface.ALIGN struct.
 *
 * @access public
 * @since  v1.1
 * @return integer
 */
function AnchoredInterface_GetAnchorPosition() {
    //window.messageQueue.add( new Message('AnchoredInterface_GetAnchorPosition', 'called') );
    var pos    = false;
    var elem   = document.getElementById(this.elemId);
    if (!elem)   throw new Error('Unable to find element: '+this.elemId);
    var anchor = document.getElementById(this.anchorId);
    if (!anchor) throw new Error('Unable to find anchor element: '+this.anchorId);

    //window.messageQueue.add( new Message(funcname(this), 'starting getElementWidth') );
    var wWidth  = parseInt(DomUtils.getWindowWidth(window));
    var wHeight = parseInt(DomUtils.getWindowHeight(window));
    var scrollX = parseInt(DomUtils.getWindowScrollX(window));
    var scrollY = parseInt(DomUtils.getWindowScrollY(window));
    var aWidth  = parseInt(DomUtils.getElementWidth(anchor));
    var aHeight = parseInt(DomUtils.getElementHeight(anchor));
    var aX      = parseInt(DomUtils.getElementLeft(anchor));
    var aY      = parseInt(DomUtils.getElementTop(anchor));
    var aWidth  = parseInt(DomUtils.getElementWidth(anchor));
    var aHeight = parseInt(DomUtils.getElementHeight(anchor));
    var eWidth  = parseInt(DomUtils.getElementWidth(elem));
    var eHeight = parseInt(DomUtils.getElementHeight(elem));
    //window.messageQueue.add( new Message(funcname(this), 'passed getElementWidth') );


    if (this.disableScroll) {
    
        /**
         * DO NOT TOUCH. I'M SERIOUS. This is difficult enough to figure out the first time. ;)
         */
        var enoughRoomOnTop    = (aY - scrollY > eHeight ? true : false);
        var enoughRoomOnBottom = (wHeight + scrollY - aHeight - aY > eHeight ? true : false);
        var enoughRoomOnLeft   = (aX - scrollX + aWidth > eWidth ? true : false);
        var enoughRoomOnRight  = (wWidth - aX + scrollX > eWidth ? true : false);
    
        /**
         * Preferred position order:
         *
         *   left top
         *   left bottom
         *   right bottom
         *   right top
         *
         * Please note that this is the position of the anchor in
         * relation to the main element, NOT the other way around
         */
//alert('enoughRoomOnTop= '+enoughRoomOnTop+'\nenoughRoomOnBottom= '+enoughRoomOnBottom+'\nenoughRoomOnLeft= '+enoughRoomOnLeft+'\nenoughRoomOnRight= '+enoughRoomOnRight);
        // Left Top
        if (enoughRoomOnBottom && enoughRoomOnRight) {
            pos = AnchoredInterface.ALIGN.LEFT_TOP;
        // Left Bottom
        } else if (enoughRoomOnTop && enoughRoomOnRight) {
            pos = AnchoredInterface.ALIGN.LEFT_BOTTOM;
        // Right Bottom
        } else if (enoughRoomOnTop && enoughRoomOnLeft) {
            pos = AnchoredInterface.ALIGN.RIGHT_BOTTOM;
        // Right Top
        } else if (enoughRoomOnBottom && enoughRoomOnLeft) {
            pos = AnchoredInterface.ALIGN.RIGHT_TOP;
        } else if (!enoughRoomOnRight) {
            pos = AnchoredInterface.ALIGN.LEFT_TOP;
        } else {
            pos = AnchoredInterface.ALIGN.LEFT_TOP;
        }
        return pos;
    
    } else {
    
        //how much is missing to display on the right (<=0 means enough to display)
        var not_enough_right = ((aX-scrollX) +  eWidth) - wWidth;
        //how much is missing to display on the left (<=0 means enough to display)
        var not_enough_left =  eWidth - (aX-scrollX);
        //how much is missing to display on the left if not scrolled (<=0 means enough to display)
        var not_enough_absolute_left = eWidth - aX;
    
        //how much is missing to display on the bottom (<=0 means enough to display)
        var not_enough_bottom = ((aY-scrollY) +  eHeight) - wHeight;
        //how much is missing to display on the top (<=0 means enough to display)
        var not_enough_top =  eHeight - (aY-scrollY);
        //how much is missing to display on the top if not scrolled (<=0 means enough to display)
        var not_enough_absolute_top = eHeight - aY;
    
        //alert("window is "+wWidth+" by "+wHeight+" and scrolled to "+scrollX+" by "+scrollY+"\nthumb is "+aWidth+" by "+aHeight+" and at "+aX+" by "+aY+"\npop is "+eWidth+" by "+eHeight+"\n\nif there is enough room, value <=0:\n\nright: "+not_enough_right+"\nleft: "+not_enough_left+"\nabsleft: "+not_enough_absolute_left+"\nbottom: "+not_enough_bottom+"\ntop: "+not_enough_top+"\nabstop: "+not_enough_absolute_top);
    
        var horiz = '';
        var vertic = '';
        var ss = 10;
    
        // #1 pref position: top right
        // #2 pref position: bottom right
        // #3 pref position: top left
        // #4 pref position: bottom left
        // if we fit or are closer from fitting to the right than to the left or there is not enough room on the left
        if (not_enough_right <= 0 || not_enough_right < not_enough_left || not_enough_absolute_left > 0) {
            horiz = 'right';
            // scroll if necessary
            if (not_enough_right > 0) {
                for (var i=0; i<=(not_enough_right/(ss*2))+1; i++) {
                    setTimeout('window.scroll(parseInt(DomUtils.getWindowScrollX(window))+'+ss+',parseInt(DomUtils.getWindowScrollY(window)))',100);
                }
            }
        // else if we are closer from the left and there is room if we scroll
        } else {
            horiz = 'left';
            // scroll if necessary
            if (not_enough_left > 0 && !this.disableScroll) {
                for (var i=0; i<=(not_enough_left/(ss*2))+1; i++) {
                    setTimeout('window.scroll(parseInt(DomUtils.getWindowScrollX(window))-'+ss+',parseInt(DomUtils.getWindowScrollY(window)))',100);
                }
            }
        }
    
        // if we are closer from fitting to the top than to the bottom and there is enough room at the top
        if (not_enough_top <= 0 || (not_enough_top < not_enough_bottom && not_enough_absolute_top <= 0)) {
            vertic = 'top';
            // scroll if necessary
            if (not_enough_top > 0 && !this.disableScroll) {
                for (var i=0;i<=(not_enough_top/(ss*2))+1;i++) {
                    setTimeout('window.scroll(parseInt(DomUtils.getWindowScrollX(window)),parseInt(DomUtils.getWindowScrollY(window))-'+ss+')',100);
                }
            }
        // else if we are closer from the top and there is room if we scroll
        } else {
            vertic = 'bottom';
            // scroll if necessary
            if (not_enough_bottom > 0 && !this.disableScroll) {
                for (var i=0; i<=(not_enough_bottom/(ss*2))+1; i++) {
                    setTimeout('window.scroll(parseInt(DomUtils.getWindowScrollX(window)),parseInt(DomUtils.getWindowScrollY(window))+'+ss+')',100);
                }
            }
        }
    
        if      (horiz == 'right' && vertic == 'top'   ) pos = AnchoredInterface.ALIGN.RIGHT_TOP;
        else if (horiz == 'right' && vertic == 'bottom') pos = AnchoredInterface.ALIGN.RIGHT_BOTTOM;
        else if (horiz == 'left'  && vertic == 'top'   ) pos = AnchoredInterface.ALIGN.LEFT_TOP;
        else if (horiz == 'left'  && vertic == 'bottom') pos = AnchoredInterface.ALIGN.LEFT_BOTTOM;
    
        return pos;
    }
}

/**
 * Sets the anchor element.
 *
 * @access public
 * @since  v1.1
 * @param  DOMElement  anchor
 * @return void
 */
function AnchoredInterface_SetAnchor(anchor) {
    //alert('anchor id: '+anchor.id);
    this.anchorId = anchor.id;
}

/**
 * Aligns the element based on the best placement determined by AnchoredInterface_GetAnchorPosition.
 *
 * @access public
 * @since  v1.1
 * @param  integer   pos   A value from the AnchoredInterface.ALIGN struct
 * @return void
 */
function AnchoredInterface_AlignElement(pos) {
    //window.messageQueue.add( new Message('AnchoredInterface_AlignElement', 'called') );
    var elem   = document.getElementById(this.elemId);
    if (!elem)   throw new Error('Unable to find element: '+this.elemId);

    var anchor = document.getElementById(this.anchorId);
    if (!anchor) throw new Error('Unable to find anchor element: '+this.anchorId);

    pos = pos || this.getAnchorPosition();

    //window.messageQueue.add( new Message('AnchoredInterface_AlignElement', 'starting getElementWidth') );
    var aLeft   = DomUtils.getElementLeft(anchor);
    var aTop    = DomUtils.getElementTop(anchor);
    var aHeight = DomUtils.getElementHeight(anchor);
    var aWidth  = DomUtils.getElementWidth(anchor);
    var eHeight = DomUtils.getElementHeight(elem);
    var eWidth  = DomUtils.getElementWidth(elem);
    /*alert('aLeft: '+aLeft+"\n"+
          'aTop: '+aTop+"\n"+
          'aHeight: '+aHeight+"\n"+
          'aWidth: '+aWidth+"\n"+
          'eHeight: '+eHeight+"\n"+
          'eWidth: '+eWidth+"\n");*/
    //window.messageQueue.add( new Message('AnchoredInterface_AlignElement', 'passed getElementWidth') );
    switch (pos) {
        /**
         * Right Top alignment means:
         *
         *             +--------+
         *             | anchor |
         *             +--------+
         *    +-----------------+
         *    | elem            |
         *    +-----------------+
         */
        case AnchoredInterface.ALIGN.RIGHT_TOP:
            elem.style.left = parseInt( aLeft - eWidth  + aWidth  )+'px';
            elem.style.top  = parseInt( aTop  + aHeight )+'px';
            break;
        /**
         * Right Bottom alignment means:
         *
         *    +-----------------+
         *    | elem            |
         *    +-----------------+
         *             +--------+
         *             | anchor |
         *             +--------+
         */
         case AnchoredInterface.ALIGN.RIGHT_BOTTOM:
            elem.style.left = parseInt( aLeft - eWidth + aWidth )+'px';
            elem.style.top  = parseInt( aTop  + aHeight )+'px';
            break;
        /**
         * Left Top alignment means:
         *
         *    +--------+
         *    | anchor |
         *    +--------+
         *    +-----------------+
         *    | elem            |
         *    +-----------------+
         */
         case AnchoredInterface.ALIGN.LEFT_TOP:
            elem.style.left = parseInt( aLeft )+'px';
            elem.style.top  = parseInt( aTop + aHeight)+'px';
            break;
        /**
         * Left Bottom alignment means:
         *
         *    +-----------------+
         *    | elem            |
         *    +-----------------+
         *    +--------+
         *    | anchor |
         *    +--------+
         */
         case AnchoredInterface.ALIGN.LEFT_BOTTOM:
        default:
            elem.style.left = parseInt( aLeft )+'px';
            elem.style.top  = parseInt( aTop - eHeight )+'px';
            break;
    }
    // fanatic memory cleanup
    elem   = null;
    anchor = null;
    //window.messageQueue.add( new Message('AnchoredInterface_AlignElement', 'finished') );
}

/**
 * $Id: calloutinterface.js 76074 2009-11-19 20:53:10Z kchiu $
 * $Author: kchiu $
 * $Revision: 76074 $
 * $Name$
 * $Date: 2009-11-19 12:53:10 -0800 (Thu, 19 Nov 2009) $
 *
 * @jsRequire DomUtils
 * @jsRequire interfaces.Interface
 * @jsRequire interfaces.AnchoredInterface
 *
 *
 * @version    $Revision: 76074 $
 * @author     Philip Snyder <philip@pricegrabber.com>
 * @copyright  Copyright &copy; 2006, Philip Snyder, PriceGrabber.com
 * @see        interfaces.Interface
 * @see        interfaces.AnchoredInterface
 */

/**
 * CalloutInterface Constructor / Definition
 *
 * This interface is built on top of the Interface object
 * and is NOT intended to be instantiated directly. See
 * documentation on interfaces.Interface for a complete
 * explanation.
 *
 * @access public
 * @since  v1.1
 * @return CalloutInterface
 */
function CalloutInterface() {
    this.calloutId      = null;
    this.elemId         = null;
    this.anchorId       = null;
    this.calloutPadding = 0;
    // Callout interface implementation
    this.erase             = CalloutInterface_Erase;
    this.draw              = CalloutInterface_Draw;
    this.alignElement      = CalloutInterface_AlignElement;
    // Anchored interface implementation
    this.disableScroll     = false;
    this.getAnchorX        = AnchoredInterface_GetAnchorX;
    this.getAnchorY        = AnchoredInterface_GetAnchorY;
    this.getAnchorZ        = AnchoredInterface_GetAnchorZ;
    this.getAnchorWidth    = AnchoredInterface_GetAnchorWidth;
    this.getAnchorHeight   = AnchoredInterface_GetAnchorHeight;
    this.getElemWidth      = AnchoredInterface_GetElemWidth;
    this.getElemHeight     = AnchoredInterface_GetElemHeight;
    this.getAnchorPosition = AnchoredInterface_GetAnchorPosition;
    this.setAnchor         = AnchoredInterface_SetAnchor;
    this.implement(AnchoredInterface);
    return this;
} // End CalloutInterface

// Setup CalloutInterface prototype chain
CalloutInterface.prototype             = new Interface;
CalloutInterface.prototype.constructor = CalloutInterface;
CalloutInterface.superclass            = Interface.prototype;






/****** BEGIN EDIT SECTION ******/

/**
 * General Settings
 *
 * Defines general settings for the callout interface. These can
 * be overridden by any script after inclusion of this file. 
 *
 * Example:
 *
 *    <script language="JavaScript">
 *    CalloutInterface.settings.images.left.src = 'http://i.pgcdn.com/images/callout/left_arrow.gif';
 *    // Or even...
 *    CalloutInterface.settings.images.left = { src: 'http://i.pgcdn.com/images/callout/left_arrow.gif', height: 20, width: 10 };
 *    </script>
 *
 * Note that 'http://i.pgcdn.com' is included... if you
 * don't include the full path, the url will be relative to your
 * web server -- which in general is wrong except for during
 * development.
 *
 * @access public
 * @since  v1.1
 * @var    CalloutInterface.settings   struct
 */
CalloutInterface.settings = {
    images: {
        left:   { src: util.resourceManager.get('http://i.pgcdn.com/images/balloon/left_arrow.gif'),   height: 23, width: 11 },
        top:    { src: util.resourceManager.get('http://i.pgcdn.com/images/balloon/top_arrow.gif'),    height: 11, width: 23 },
        right:  { src: util.resourceManager.get('http://i.pgcdn.com/images/balloon/right_arrow.gif'),  height: 21, width: 11 },
        bottom: { src: util.resourceManager.get('http://i.pgcdn.com/images/balloon/bottom_arrow.gif'), height: 11, width: 23 }
    }
};

/****** END EDIT SECTION ******/







/**
 * CalloutInterface.erase()
 *
 * "Erases" the callout by removing the dom elements created with CalloutInterface.draw().
 *
 * @access public
 * @since  v0.0.1a
 * @return void
 */
function CalloutInterface_Erase() {
    //window.messageQueue.add( new Message('CalloutInterface_Erase', 'called') );
    var callout = document.getElementById(this.calloutId);
    if (callout) {
        //callout.parentNode.removeChild(callout);
        DomUtils.removeElement(callout);
    }
    callout = null;
    //window.messageQueue.add( new Message('CalloutInterface_Erase', 'finished') );
} // End CalloutInterface_Erase


/**
 * CalloutInterface.draw()
 *
 * "Draws" the actual callout by creating the necessary dom elements and applying them to
 * the object's element.
 *
 * @access public
 * @since  v0.0.1a
 * @return void
 */
function CalloutInterface_Draw() {
    //window.messageQueue.add( new Message('CalloutInterface_Draw', 'called') );
    if (!this.calloutId) this.calloutId = this.id+'_Callout';
    var elem    = document.getElementById(this.elemId);
    if (!elem) throw new Error('Unable to find element: '+this.elemId);
    var anchor  = document.getElementById(this.anchorId);
    if (!anchor) throw new Error('Unable to find anchor element: '+this.anchorId);
    if (elem && anchor) {
        elem.style.padding = '1px';
        elem.style.border  = '1px solid #dadada';
        //elem.style.backgroundColor = '#ffffff';
        var callout = document.getElementById(this.calloutId);
        if (callout && callout.parentNode) DomUtils.removeElement(callout);
        var pos                  = this.getAnchorPosition();
        callout                  = document.createElement('img');
        callout.id               = this.calloutId;
        callout.style.position   = 'absolute';
        callout.style.visibility = 'hidden';
        var body = document.getElementsByTagName('body')[0];
        body.appendChild(callout);
        var imgDetails;
        //alert('Callout interface: '+pos);

        switch (pos) {
            case AnchoredInterface.ALIGN.RIGHT_TOP:
                //if (typeof(writeDebug) == 'function') writeDebug('right_top');
                imgDetails        = CalloutInterface.settings.images.top;
                //window.messageQueue.add( new Message('callout img', 'right_top: '+imgDetails.src) );
                callout.src       = util.resourceManager.get(imgDetails.src);
                callout.height    = imgDetails.height;
                callout.width     = imgDetails.width;
                //callout.style.top = (DomUtils.getElementHeight(elem)+2)+'px';
                //if (DomUtils.browser.isIE() && document.compatMode == 'BackCompat') {
                //    eStyle  = DomUtils.getCurrentStyle(elem);
                //    height  = parseInt(DomUtils.getElementHeight(elem));
                //    callout.style.top = parseInt(height+1)+'px';
                //}
                callout.style.left = this.calloutPadding+'px';
                break;
            case AnchoredInterface.ALIGN.RIGHT_BOTTOM:
                //if (typeof(writeDebug) == 'function') writeDebug('right_bottom');
                imgDetails         = CalloutInterface.settings.images.top;
                //window.messageQueue.add( new Message('callout img', 'right_bottom: '+imgDetails.src) );
                callout.src        = util.resourceManager.get(imgDetails.src);
                callout.height     = imgDetails.height;
                callout.width      = imgDetails.width;
                //callout.style.top  = '-'+(callout.height+(DomUtils.browser.isIE() ? -1 : -1))+'px';
                //callout.style.left = this.calloutPadding+'px';
                break;
            case AnchoredInterface.ALIGN.LEFT_TOP:
                imgDetails         = CalloutInterface.settings.images.top;
                //window.messageQueue.add( new Message('callout img', 'left_top: '+imgDetails.src) );
                callout.src        = util.resourceManager.get(imgDetails.src);
                callout.height     = imgDetails.height;
                callout.width      = imgDetails.width;
                //callout.style.top  = (DomUtils.getElementHeight(elem)+2)+'px';
                //window.messageQueue.add( new Message('CalloutInterface_Draw', 'getting elem width for callout') );
                //callout.style.left = (DomUtils.getElementWidth(elem)-1-callout.width-this.calloutPadding)+'px';
                //window.messageQueue.add( new Message('CalloutInterface_Draw', 'finished elem width for callout') );
                break;
            case AnchoredInterface.ALIGN.LEFT_BOTTOM:
            default:
                //if (typeof(writeDebug) == 'function') writeDebug('left_bottom');
                imgDetails         = CalloutInterface.settings.images.bottom;
                //window.messageQueue.add( new Message('callout img', 'left_bottom: '+imgDetails.src) );
                callout.src        = util.resourceManager.get(imgDetails.src);
                callout.height     = imgDetails.height;
                callout.width      = imgDetails.width;
                //callout.style.top  = '-'+(callout.height+(DomUtils.browser.isIE() ? -1 : -1))+'px';
                //window.messageQueue.add( new Message('CalloutInterface_Draw', 'getting elem width for callout') );
                //callout.style.left = (DomUtils.getElementWidth(elem)-1-callout.width-this.calloutPadding)+'px';
                //callout.style.left = (DomUtils.getElementLeft(elem)-1-callout.width-this.calloutPadding)+'px';
                //window.messageQueue.add( new Message(funcname(this), 'finished elem width for callout') );
                break;
        }

        //elem.appendChild(callout);
        //callout.style.zIndex = parseInt(DomUtils.getZIndex(elem))+1;
        //this.alignElement(pos);
        //CalloutInterface_AlignElement.call(this, pos);
    }
    //window.messageQueue.add( new Message('CalloutInterface_Draw', 'finished') );
} // End CalloutInterface_Draw


/**
 * CalloutInterface.alignElement()
 *
 * Aligns the object's element by adjusting its left & top by the proper calculations (which are done
 * in this function) on the height & width & style of the callout.
 *
 * @access public
 * @since  v0.0.1a
 * @see    AnchoredInterface
 * @param  string    pos      One of the constants defined in AnchoredInterface.ALIGN
 * @return void
 */
function CalloutInterface_AlignElement(pos) {
    //window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'called') );
    pos = pos || this.getAnchorPosition();
    var elem    = document.getElementById(this.elemId);
    if (!elem)    throw new Error('Unable to find element: '+this.elemId);
    var callout = document.getElementById(this.calloutId);
    if (!callout) throw new Error('Unable to find callout element: '+this.calloutId);
    var anchor  = document.getElementById(this.anchorId);
    if (!anchor)  throw new Error('Unable to find anchor element: '+this.anchorId);

    var aTop    = parseInt( DomUtils.getElementTop(anchor) );
    var aLeft   = parseInt( DomUtils.getElementLeft(anchor) );
    var aHeight = parseInt( DomUtils.getElementHeight(anchor) );
    var aWidth  = parseInt( DomUtils.getElementWidth(anchor) );

    var eTop    = parseInt( DomUtils.getElementTop(elem) );
    var eLeft   = parseInt( DomUtils.getElementLeft(elem) );
    var eHeight = parseInt( DomUtils.getElementHeight(elem) );
    var eWidth  = parseInt( DomUtils.getElementWidth(elem) );

    var cHeight = parseInt( DomUtils.getElementHeight(callout) );
    var cWidth  = parseInt( DomUtils.getElementWidth(callout) );
    switch (pos) {
        /**
         * Right Top alignment means:
         *
         *             +--------+
         *             | anchor |
         *             +--------+
         *                 /\
         *    +-----------'  '--+
         *    | elem            |
         *    +-----------------+
         */
        case AnchoredInterface.ALIGN.RIGHT_TOP:
            // Adjust main element's position to accomodate callout element
            elem.style.top       = parseInt( eTop  + cHeight )+'px';
            elem.style.left      = parseInt( eLeft + this.calloutPadding )+'px';
            // Position the callout element
            callout.style.left   = parseInt( aLeft + parseInt( aWidth / 2 ) - parseInt(cWidth / 2) )+'px';
            callout.style.top    = parseInt( aTop  + aHeight + 1)+'px';
            callout.style.zIndex = parseInt(DomUtils.getZIndex(elem))+1;
/*
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'alignment position: right_top') );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'anchor.style.left   = '+DomUtils.getElementLeft(anchor)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'anchor.style.top    = '+DomUtils.getElementTop(anchor)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'anchor.style.height = '+DomUtils.getElementHeight(anchor)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'anchor.style.width  = '+DomUtils.getElementWidth(anchor)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'elem.style.left     = '+DomUtils.getElementLeft(elem)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'elem.style.top      = '+DomUtils.getElementTop(elem)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'elem.style.height   = '+DomUtils.getElementHeight(elem)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'elem.style.width    = '+DomUtils.getElementWidth(elem)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'callout.style.left  = '+DomUtils.getElementLeft(callout)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'callout.style.top   = '+DomUtils.getElementTop(callout)) );
*/
            break;
        /**
         * Right Bottom alignment means:
         *
         *    +-----------------+
         *    | elem            |
         *    +-----------,  ,--+
         *                 \/
         *             +--------+
         *             | anchor |
         *             +--------+
         */
        case AnchoredInterface.ALIGN.RIGHT_BOTTOM:
            // Adjust main element's position to accomodate callout element
            elem.style.top       = parseInt( eTop  + cHeight - 1 )+'px';
            elem.style.left      = parseInt( eLeft + this.calloutPadding )+'px';
            // Position the callout element
            callout.style.left   = parseInt( aLeft + parseInt(aWidth/2) - parseInt( cWidth / 2) )+'px';
            callout.style.top    = parseInt( aTop + aHeight )+'px';
            callout.style.zIndex = parseInt( DomUtils.getZIndex(elem) )+1;
/*
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'alignment position: right_bottom') );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'anchor.style.left   = '+DomUtils.getElementLeft(anchor)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'anchor.style.top    = '+DomUtils.getElementTop(anchor)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'anchor.style.height = '+DomUtils.getElementHeight(anchor)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'anchor.style.width  = '+DomUtils.getElementWidth(anchor)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'elem.style.left     = '+DomUtils.getElementLeft(elem)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'elem.style.top      = '+DomUtils.getElementTop(elem)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'elem.style.height   = '+DomUtils.getElementHeight(elem)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'elem.style.width    = '+DomUtils.getElementWidth(elem)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'callout.style.left  = '+DomUtils.getElementLeft(callout)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'callout.style.top   = '+DomUtils.getElementTop(callout)) );
*/
            break;
        /**
         * Left Top alignment means:
         *
         *    +--------+
         *    | anchor |
         *    +--------+
         *        /\
         *    +--'  '-----------+
         *    | elem            |
         *    +-----------------+
         */
        case AnchoredInterface.ALIGN.LEFT_TOP:
            // Adjust main element's position to account for the callout
            elem.style.top       = parseInt( eTop + cHeight - 1 )+'px';
            elem.style.left      = parseInt( eLeft - this.calloutPadding )+'px';
            // Position the callout element
            callout.style.left   = parseInt( aLeft + parseInt(aWidth / 2) - parseInt(cWidth / 2) - 1 )+'px';
            callout.style.top    = parseInt( aTop + aHeight )+'px';
            callout.style.zIndex = parseInt( DomUtils.getZIndex(elem) )+1;
/*
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'alignment position: left_top') );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'anchor.style.left   = '+DomUtils.getElementLeft(anchor)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'anchor.style.top    = '+DomUtils.getElementTop(anchor)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'anchor.style.height = '+DomUtils.getElementHeight(anchor)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'anchor.style.width  = '+DomUtils.getElementWidth(anchor)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'elem.style.left     = '+DomUtils.getElementLeft(elem)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'elem.style.top      = '+DomUtils.getElementTop(elem)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'elem.style.height   = '+DomUtils.getElementHeight(elem)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'elem.style.width    = '+DomUtils.getElementWidth(elem)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'callout.style.left  = '+DomUtils.getElementLeft(callout)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'callout.style.top   = '+DomUtils.getElementTop(callout)) );
*/
            break;
        /**
         * Left Bottom alignment means:
         *
         *    +-----------------+
         *    | elem            |
         *    +--,  ,-----------+
         *        \/
         *    +--------+
         *    | anchor |
         *    +--------+
         */
        case AnchoredInterface.ALIGN.LEFT_BOTTOM:
        default:
            // Adjust main element's position to account for the callout
            elem.style.top       = parseInt( eTop - cHeight - 2)+'px';
            elem.style.left      = parseInt( eLeft - this.calloutPadding )+'px';
            // Position the callout element
            callout.style.left   = parseInt( aLeft - parseInt( cWidth / 2 ) + parseInt( aWidth / 2 ) - 1 )+'px';
            callout.style.top    = parseInt( aTop - cHeight )+'px';
            callout.style.zIndex = parseInt( DomUtils.getZIndex(elem) )+1;
/*
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'alignment position: left_bottom') );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'anchor.style.left   = '+DomUtils.getElementLeft(anchor)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'anchor.style.top    = '+DomUtils.getElementTop(anchor)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'anchor.style.height = '+DomUtils.getElementHeight(anchor)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'anchor.style.width  = '+DomUtils.getElementWidth(anchor)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'elem.style.left     = '+DomUtils.getElementLeft(elem)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'elem.style.top      = '+DomUtils.getElementTop(elem)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'elem.style.height   = '+DomUtils.getElementHeight(elem)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'elem.style.width    = '+DomUtils.getElementWidth(elem)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'callout.style.left  = '+DomUtils.getElementLeft(callout)) );
            window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'callout.style.top   = '+DomUtils.getElementTop(callout)) );
*/
            break;
    }
    //window.messageQueue.add( new Message('CalloutInterface_AlignElement', 'finished') );
} // End CalloutInterface_AlignElement

