﻿function DetailView(companyId, companyTitle){
    createTip('aMoreInfo_'+companyId, 'dvMoreInfo_'+companyId, 2);
    
    $('aMoreInfo_'+companyId).observe('click', function() {
      //alert(companyId+'+'+companyTitle);
      if (Prototype.Browser.IE){
        $('aMoreInfo_'+companyId).prototip.hide();
      }
      alterStyle();
      var pageTracker = _gat._getTracker("<asp:literal id='ltlAnalytics' runat='server' />");
      pageTracker._trackPageview('/clicks/localCompanies/'+companyId+'-'+companyTitle);
    });
    
    if (Prototype.Browser.IE){
        $('aMoreInfo_'+companyId).observe('prototip:shown', function() {
         //alert('test');
          alterStyle();
        });
    }
    return false;
}

function createTip(target, tip, style)
{

    switch(style)
    {
        case 1:
           new Tip($(target), $(tip), {
            title: '',
            border: 1,
            borderColor: '#a3b6c4',
            radius: 1,
            width: 350,
            closeButton: true,
            showOn: 'click',
            hideOn: { element: 'closeButton', event: 'click'},
            stem: 'bottomMiddle',
            hook: { target:'topMiddle', tip: 'bottomMiddle'},
            //fixed: true,
            viewport: true,
            offset: { x: 0, y: 0 }
            });
          break;
        case 2:
           new Tip($(target), $(tip), {
            title: '',
            border: 1,
            borderColor: '#a3b6c4',
            radius: 1,
            width: 350,
            closeButton: true,
            showOn: 'click',
            hideOn: { element: 'closeButton', event: 'click'},
            fixed: true,
            stem: 'topLeft',
            hook: { tip: 'topLeft', mouse: true },
            offset: { x: 0, y: 8 } 

            });
          break;
        default:
          new Tip($(target), $(tip), {
            title: '',
            border: 1,
            borderColor: '#a3b6c4',
            radius: 1,
            width: 350,
            closeButton: true,
            showOn: 'click',
            hideOn: { element: 'closeButton', event: 'click'},
            stem: 'bottomMiddle',
            //stem: 'topLeft',
            hook: { tip: 'topLeft', mouse: false },
            //fixed: true,
            viewport: true,
            offset: { x: 0, y: 0 }
            });
        } //switch
}

function alterStyle(){
/*Work around to shift popups' stem div position up so that triangle stem would not be separated by the shadow div
left -1px is for IE to display offset correctly
*/
    var divsImg = $$('div.prototip_StemImage');
    //alert(divsImg.size());
    
    divsImg.each(function(e) {
        var url = e.getStyle('background');
        if(url.indexOf('bottomleft')>-1){
            e.parentNode.setStyle(
                { position: "relative", top: "-18px", left: "-1px" }
            );
        }
        else{
            e.parentNode.setStyle(
                { position: "absolute", top: "0px", left: "-1px" }
            );
        }
    });
}

function trackDetailLink(companyId,companyTitle){
    var pageTracker = _gat._getTracker("<asp:literal id='ltlAnalytics' runat='server' />");
    pageTracker._trackPageview('/clicks/localCompanies/'+companyId+'-'+companyTitle);
    return false;

}

function toggleContent(id){
    Effect.toggle(id, 'appear'); 
//    $(id).show();
//    $(id).hide();
    return false;
}