﻿var pageTimeout = 25; //default timeout before warning is displayed

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.parentNode.parentNode);">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 toggleOccBox(title, soc_code) {
   
    if( $("#occBox").attr("name")== soc_code)
    {  $("#occBox").attr("name", "");
       $("#occBox").hide();
    }
    else
    {
       showOccBox(title, soc_code);       
    }
}


function showOccBox(title, occ) {

   occStr = "'" + occ + "'";
    
   $("#occBox").html('<div id="occBoxIn"><h3>' +
   title + '</h3><ul>' +
   '<li><a href="javascript://" onclick="OccDetail(' + occStr + ');return false;">More Detail</a></li>' +
   '<li><a href="' + WebRoot + 'content/career/WillingAble.aspx?o=' + occ + ' ">Willing & Able</a></li>' +
   '<li><a href="' + WebRoot + 'content/career/AltInd.aspx?o=' + occ + ' ">Alt Industries</a></li>' +
   '<li><a href="' + WebRoot + 'content/career/AltOcc.aspx?o=' + occ + ' ">Alt Occupations</a></li>' +
   '</ul>');

    var pos = $("#div" + occ).offset();
    var width = $("#div" + occ).width();
    $("#occBox").css({ "left": (pos.left + width) + "px", "top": pos.top + "px" });
    $("#occBox").attr("name", occ);
    
   
   
    _svcOcc = Cea.WebApp.JobsEq.ws.Occupation;
    _svcOcc.set_defaultUserContext(this);
    
   _svcOcc.GapStats(occ, _statsLdDone );
   
}
function OccDetail( occ)
{
  oWin(WebRoot+'content/occ/OccDetail.aspx?o=' + occ, 900,700,"OccDetail");
}

function _statsLdDone(result,uc,m) {
    $("div#occBox #occBoxIn").append(result.StatsHtml);
    $("div#occBox #occBoxIn").append('<a href="javascript://" onclick="CloseOccBox();return false;">Close</a>');
    $("div#occBox #occBoxIn").append('<div class="reset"></div></div>');
    Nifty('div#occBox div#occBoxIn', 'big');
   
    $("#occBox").show(200);
}

function CloseOccBox() {

    $("#occBox").attr("name",  "");
    $("#occBox").hide(200);

}


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,675,"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() {
    ///<summary>toggle visiblity of the analytic parameters section</summary>
    if (!(ctlParamBody && ctlArrow)) return;

    var isVis = $(ctlParamBody).attr('IsVis');
    if (isVis=='true')
    {
        $(ctlParamBody).attr('IsVis', 'false');        
        ctlArrow.src = WebRoot+'images/arrow_down.gif';
    }
    else
    {
        $(ctlParamBody).attr('IsVis','true')        
        ctlArrow.src =  WebRoot +'images/arrow_up.gif';
    }

    $(ctlParamBody).toggle(200);
}


function qHide() {
    ///<summary>queue's the toggle vis method to run after 1 second</summary>
    window.setTimeout('_swVis();', 1000);
}

function ttNaics(el) {
    var d = $('#dNaicsChange');
    var ev = window.event;        
    d.css('left', ev.pageX);
    d.css('top', ev.pageY);
    d.show("slide", { direction: "left" }, 250);
}    

function ttNaicsHide(el) {
    $('#dNaicsChange').hide();    
}         

/* print a div element.  requires jquery */
function printEl(el)
{
   var iframe=document.createElement('IFRAME');
   var doc = null; 
   $(iframe).css({ '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="'+$('#'+el).attr("class")+'">'+$('#'+el).html()+'</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);
    }
}


//toggle regions
    
var cDispString="table-row";
var browser=navigator.appName;

function addRegion2(trrega, trreg, txtreg, trregoa, txtrego){

    if(browser=="Microsoft Internet Explorer")
        cDispString="block";
       
   
    $("#"+trrega).css("display","none");                 
    $("#"+trreg).css("display",cDispString);
  
    $("#"+txtreg).attr("value", cDispString);
    if( $("#"+txtrego).attr("value")=="none")
       $("#"+trregoa).css("display",cDispString);

}

function removeRegion2(trrega, trreg, txtreg, trregoa, txtrego){
   
   if(browser=="Microsoft Internet Explorer")
        cDispString="block";
  
   $("#"+trrega).css("display",cDispString);                 
    $("#"+trreg).css("display","none" );
    
  
   //document.getElementById(txtreg).setAttribute("value", "none");
   
   $("#"+txtreg).attr("value", "none");
   $("#"+trregoa).css("display","none" );      
}


function addRegion3(trrega, trreg, txtreg, trregoa, txtrego){
 
   if(browser=="Microsoft Internet Explorer")
        cDispString="block";
  
  
   $("#"+trrega).css("display","none");                 
   $("#"+trreg).css("display",cDispString);
  
 
   $("#"+txtreg).attr("value", cDispString);
 
 
}

function removeRegion3(trrega, trreg, txtreg, trregoa, txtrego){
  
   if(browser=="Microsoft Internet Explorer")
        cDispString="block";

   if( $("#"+txtrego).attr("value")==cDispString)
        $("#"+trrega).css("display",cDispString);                 
   $("#"+trreg).css("display","none" );
  
  
   $("#"+txtreg).attr("value","none" );


}

/*var isResizing = false;
var _lTagSel = 'div#topNav a.LogoTag';
//setup the resize event for a window
function hookResize() {
    try {
        $(_lTagSel).attr('IsSmall', 'false');
        window.setTimeout(function() { doResizeWork() }, 500);
        $(document).ready(function() {
            $(window).resize(function() {
                if (!isResizing) {
                    isResizing = true;
                    window.setTimeout(function() {
                        doResizeWork();
                    }, 20);
                }
            });
        });

        $(_lTagSel).hover(
        function() { if ($(_lTagSel).attr('IsSmall')=='true') showLogoTag(); },
        function() { if ($(_lTagSel).attr('IsSmall') == 'true') hideLogoTag(); });
    }
    catch (e) { }
}
//perform the logo tag resize animation
function doResizeWork() {
    var w = $('.SubNavCont').width();
    var ww = $(window).width();
    var t = $(_lTagSel).position().top;
        
    if (ww < w + 120 && t == 0) {
        $(_lTagSel).attr('IsSmall', 'true');
        hideLogoTag();
    }
    else if (ww >= w + 120 && t < 0) {
        $(_lTagSel).attr('IsSmall', 'false');
        showLogoTag();
    }
    isResizing = false;
}*/

function roundCorners() {
    
    $(function() {
        Nifty('div.RoundPanel','transparent');
        Nifty('div.RoundPanelIn');
        Nifty('div.NoDataIn','transparent');
        Nifty('div.OptCont','transparent bottom');
        Nifty('div.LbpNote','big');
        Nifty('div.LbpDashAnal','big');
        Nifty('div.LbpBody','big');
        Nifty('div.LbpHeader','big');
        Nifty('div.LbpDemandSec');
        Nifty('div.RoundBottom','bottom');
        Nifty('div#DialogCont');
        Nifty('div.FormBox');
        Nifty('div.FormBoxIn');
        Nifty('div.Form h3');
        Nifty('div.cc_pub_content','top big');
        Nifty('div.Feature','top');
        Nifty('div.cc_toolbar','bottom big');
        Nifty('div#FeatureContent','bottom');
        Nifty('div.Form div.BigLink');
        Nifty('div.NoteBox','small');
    });
}

function doLoadCancel() {
    if (goTimer) clearTimeout(goTimer);
    
    if ($.browser.msie) {
        window.document.execCommand('Stop');
    }
    else {
        window.stop();
    }

    lastBtn.removeAttr('disabled');
    lastBtn.val('Go');
    
    $.unblockUI();
}

function doLoadTimeout() {
    doLoadCancel();

    $.blockUI({ css: { padding: '10px' }, message: "<p>We apologize; your query timed-out. Slow response can be do to a number of issues including a slow or lost internet connection or heavy server load.  Please close this mesasge and try your query again.</p><p><a class='nav_cancel' href='javascript://' onclick='$.unblockUI();return false'>Close</a></p>" });
}

var lastBtn = null;
var goTimer = null;
function blockLoading(btn) {
    if (goTimer) clearTimeout(goTimer);
    
    lastBtn = $('#' + btn);
    $.blockUI({ message: '<h1>Please wait while we process your results...</h1><a class="nav_cancel" href="javscript://" onclick="doLoadCancel();return false;">(cancel)</a><br /><br />' });

    goTimer = window.setTimeout('doLoadTimeout()', pageTimeout * 1000);
    
    return true;
}

if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();

