﻿
function Me(){};
Me.type=-1;Me.os=-1;
var Nav=navigator.userAgent.toLowerCase();

var pWin=null;
var _ld;
var _debug=true;

function OpenExport(id)
{
    window.setTimeout('dExp(\'' + id + '\')',10);
    
    
    //document.location.href = url;
    //oWin(url, 900,700,'ExcelExport');
}
function dExp(id)
{
    var url = WebRoot+'excel.axd?id=' + id;

    var d = document.createElement('div');
    d.className='DlPop';
    d.align='center';
    document.body.appendChild(d);
    
    var dI = document.createElement('div');
    dI.className = 'BlueGrad';
    dI.innerHTML = 'Your export is complete.  Click the link below to download your excel file.<br /><br />';
    dI.innerHTML += '<a href="' + url + '" target="_blank" onclick="document.body.removeChild(this.parentElement.parentElement);return true;">Download File</a> <br />or<br /><a href="javascript://" onclick="document.body.removeChild(this.parentElement.parentElement);">Cancel</a>';
    d.appendChild(dI);
}

function CompassLink(link)
{
    oWin(WebRoot+'content/compass/compassLink.aspx?link=' + link, 600,600,'Compass');
}

function DataDict(ddKey)
{
    oWin(WebRoot+'DataDict.aspx?key=' + ddKey, 350,550,'DataDict');
}

function OccDetail(occ)
{
    oWin(WebRoot+'content/occ/OccDetail.aspx?o=' + occ, 900,700,"OccDetail");
}

function IndDetail(type,code)
{
    oWin(WebRoot+'industry_desc.aspx?t=' + type + '&c=' + code,750,500,"IndDetail");
}

function RegDetail(type,code)
{
    oWin(WebRoot+'region_map.aspx?t=' + type + '&c=' + code, 620,450,"RegDetail");
}

function EditUser(uid)
{
    oWin(WebRoot+'content/admin/editUser.aspx?uid=' + uid, 680,250,"EditUser");
}

function oWin(url, w, h, name)
{
	var win=window.open(url, name, "status=yes,toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=yes,width=" + w + ",height=" + h);
	win.focus();
}

var ctlParamBody;
var ctlArrow;

function _swVis()
{
    if (!(ctlParamBody && ctlArrow)) return;
    
    if (ctlParamBody.IsVis=="true")
    {
        ctlParamBody.IsVis="false";
        ctlParamBody.style.display='none';
        ctlArrow.src = WebRoot+'images/arrow_down.gif';
    }
    else
    {
        ctlParamBody.IsVis="true";
        ctlParamBody.style.display='block';
        ctlArrow.src =  WebRoot +'images/arrow_up.gif';
    }
}
function ttNaics(el)
{
    var ev = window.event;        
    var n = $get('dNaicsChange');
    var b = Sys.UI.DomElement.getBounds(el);
    n.style.display='block';           
    var nB = Sys.UI.DomElement.getBounds(n);
    var bW = 250;
    var bH = 180;
    var a = new AjaxControlToolkit.Animation.ResizeAnimation(
        n, 0.10, 30, bW, bH, 'px');
        
    n.style.width='1px';
    n.style.height='1px';
    
    var y = b.y + ev.clientY + document.body.scrollTop;        
    Sys.UI.DomElement.setLocation(n, b.x - bW, y);
    
    a.play();
}    

function ttNaicsHide(el)
{
    var n = $get('dNaicsChange');
    n.style.display='none';        
}         

/* print a div element.  requires dojo */
function printEl(el)
{
   var iframe=document.createElement('IFRAME'); 
   var doc=null; 
   dojo.style(iframe, { 'position':'absolute', 'width': '0px', 'height': '0px', 'left': '-500px', 'top': '-500px'}); 
   document.body.appendChild(iframe); 
   doc=iframe.contentWindow.document; 
   doc.open();
   doc.clear();
   doc.write('<html><head>');
    var links=window.document.getElementsByTagName('link'); 
    for(var i=0;i<links.length;i++) 
        if(links[i].rel.toLowerCase()=='stylesheet') 
            doc.write('<link type="text/css" rel="stylesheet" href="'+links[i].href+'"></link>');                 
    doc.write('</head><body><div class="'+dojo.attr(el,"class")+'">'+dojo.byId(el).innerHTML+'</div></body></html>');    
    doc.close();        
    
    setTimeout(function(){isReadyToPrint(iframe);},1000);
    //alert('Printing...');     
}
function isReadyToPrint(iframe)
{
    if (iframe.contentWindow.document.readyState != "complete")
        setTimeout(function(){isReadyToPrint(iframe);},500);
    else
    {
        iframe.contentWindow.focus(); 
        iframe.contentWindow.print();    
        setTimeout(function(){document.body.removeChild(iframe);iframe=null;},1000);
    }
}