﻿	
function hideToolTips(id) {
    try {
        // tips code from global.js
        var tips = $('#' + id + ' .tooltip');
	    tips.hide();
	    aTips = new Array();
	    for (i = 0; i < tips.length; i++)
	    {
		    aTips[i] = new Tooltip(tips.get(i));
	    }
	    for (i = 0; i < aTips.length; i++)
	    {
		   aTips[i].positionTip();
	    }
    } catch (err) {}
}

function toggleElement(id) {
    $('#' + id).toggle();
}

function Overlay(overlayId, elementToCover, move) {
    $(document).ready(function() {
        move = move.toLowerCase();
    
        var progressGif = 31;
        
        var e = $("#" + elementToCover);
        var top = e.offset().top;
        var left = e.offset().left;
	    var width = e.width();
	    var height = e.height();
        
        // get left absolute position
        left = left - ($(document).width()-$('#wrapper').width())/2;
    	
        var o;
        var i;
        var divs = $('.overlay');
	    for (x=0;x<divs.length;x++) {
            if (divs.get(x).id.indexOf(overlayId) != -1) {
                o = $('#' + divs.get(x).id);
                try {
                    i = $('#' + divs.get(x).id + '-img');
                } catch (ex) {}
                break;
            }
	    }
    	
	    // logic to show progress panel
	    var show = false;
	    if (overlayId.indexOf('dashboardLoading') != -1 || elementToCover == 'content' || elementToCover == 'logo' || elementToCover == 'content-inner' || (top > 0 && left > 0)) {
	        show = true;
	    }
    	
        if (elementToCover == 'content' || elementToCover == 'content-inner') {
            width = $('#wrapper').width()-2;
            height = $('#footer').offset().top - ($('#header').offset().top+$('#header').height());
            left = ($(window).width()-width)/2;
        }
        
        // overlay panel
	    if (o != null) {
	        if (show) {
	            if (move == 'true') {
                    o.css('top', top);
                    o.css('left', left);
                }
                o.height(height);
                o.width(width);
	            o.show();
	        } else {
	            o.hide();
	        }
        }
        // overlay progress image
	    if (i != null) {
	        if (show) {
                //left = left + (width-progressGif)/2;
                i.width(width);
	            if (move == 'true') {
                    top = top + (height-progressGif)/2;
                    i.css('top', top);
                    i.css('left', left);
                } else {
                    top = (height-progressGif)/2;
                    i.css('top', top);
                }
	            i.show();
	        } else {
	            i.hide();
	        }
        }
    });
}

function GetWindowSize() {
    var win = new Object();
    var x = 0, y = 0;
    // get window height
    if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        x = window.innerWidth;
        y = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        x = document.documentElement.clientWidth;
        y = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        x = document.body.clientWidth;
        y = document.body.clientHeight;
    }
    win.x = x;
    win.y = y;
    return win;
}

function fixToggle() {
    $(document).ready(function() {
        // hide all of the elements with a class of 'toggle'
        $('.toggle').hide();
        //style heading spans like links
        $('.togglelink').addClass('toggler');
        //remove anchor-links and bck-to-top links
        $('ul.anchor-links').remove();
        $('a.back-to-top').remove();
        // capture clicks on the headings
        $('.togglelink').click(function() {
            // toggle the display
            $(this).parent().next('.toggle').toggle(5);
            if ($('.togglelink').hasClass('toggler')) {
                $('.togglelink').removeClass('toggler');              
                $('.togglelink').addClass('toggler-open');  
                } else {                
                    $('.togglelink').removeClass('toggler-open');              
                    $('.togglelink').addClass('toggler');  
                } 
        });
    });
}

function PositionLogo() {
    var e = $('#logo');
    var top = e.offset().top;
    var left = e.offset().left;
	var width = e.width();
    
    var win = GetWindowSize();
    left = left - (win.x-$('#wrapper').width())/2;
	
    var o = $('#custom-logo');
    o.css('top', top);
    o.css('left', left);
    //o.height(e.height());
    //o.width(width);
    //o.show();
}

function pinReminder() {
    $(function() {
        $(document).keydown(function(event) {
            if (event.keyCode == 13) {
                $('#ctl00_login_area_pnlPinSuccess').hide();
                $('#ctl00_login_area_pnlPinError').hide();
                $('#ctl00_login_area_btnReminder').focus();
            }
            return true;
        });
    });
}

function focusLogin() {
    $(function() {
        $(document).keydown(function(event) {
            if (event.keyCode == 13) {
                $('#ctl00_ContentPlaceHolder1_btnLogin1').focus();
            }
            return true;
        });
    });
}

/* checkbox toggle */
function togglecheckbox(id) {
	var c = document.getElementById(id);
	var cl = document.getElementById(id + 'Label');
	if (c.checked) {
		cl.className = 'togglecheckboxlabel togglecheckbox-on';
	} else {
		cl.className = 'togglecheckboxlabel togglecheckbox-off';
	}
}

function togglecheckboxOver(id) {
	var c = document.getElementById(id.replace('Label',''));
	var cl = document.getElementById(id);
	if (!c.disabled) {
		if (c.checked) {
			cl.className = 'togglecheckboxlabel togglecheckbox-on-hover';
		} else {
			cl.className = 'togglecheckboxlabel togglecheckbox-off-hover';
		}
	}
}

function togglecheckboxOut(id) {
	var c = document.getElementById(id.replace('Label',''));
	var cl = document.getElementById(id);
	if (!c.disabled) {
		if (c.checked) {
			cl.className = 'togglecheckboxlabel togglecheckbox-on';
		} else {
			cl.className = 'togglecheckboxlabel togglecheckbox-off';
		}
	}
}
/* end checkbox toggle */