﻿//////////////////////////////Error & Alert Popups///////////////////////////////////////
var intTimeErr = 3000;
var intTimeMsg = 1500;


function showErr(msg) 
{
    var path;
    if (document.referrer.indexOf("Admin") < 0 && document.referrer.indexOf("Authors") < 0)
    {
        path = "JSFunctions/Err.aspx?err=";
    }
    else
    {
        path = "../JSFunctions/Err.aspx?err=";
    }
    
    document.getElementById("iErr").style.top = ((f_clientHeight()*0.3) + f_scrollTop()) + "px";
    document.getElementById("iErr").src = path + msg;
    //document.getElementById("iErr").style.visibility = 'visible';
    
}
function hideErr() 
{
    document.getElementById("iErr").style.visibility = 'hidden';
}
function showMsg(msg) 
{
    document.getElementById("iMsg").style.top = ((f_clientHeight()*0.3) + f_scrollTop()) + "px";
    var path;
    if (document.referrer.indexOf("Admin") < 0 && document.referrer.indexOf("Authors") < 0)
    {
        path = "JSFunctions/Msg.aspx?msg=";
    }
    else
    {
        path = "../JSFunctions/Msg.aspx?msg=";
    }
    
    document.getElementById("iMsg").src = path + msg;
    //document.getElementById("iMsg").style.visibility = 'visible';
    
}
function hideMsg() 
{
    document.getElementById("iMsg").style.visibility = 'hidden';
}

function killQueryString() 
{
    var url = document.location.href;
    if (url.indexOf("?") != -1) {
        url = url.substring(0, url.indexOf("?"));
        document.location.href = url;
    }
}

function popupWin(win) 
{
     window.open (win,"MPWin","left=100, top=100, width=700, height=500,status=1,toolbar=0, menubar=0, scrollbars=1, location=0");
}

var helpon = 0;
function helpme() {
    if (helpon == 0) {
        iHelp1 = document.getElementById("iHelp");
        iHelp1.style.visibility = 'visible';
        //alert(document.getElementById["iHelp"].window.Document.getElementById("help").innerHTML);
        //iHelp.src = "JSFunctions/Msg.asp";
        //window.frames["iHelp"].document.getElementById("help").innerHTML = "b";
        helpon = 1;
    } else {
        document.getElementById("iHelp").style.visibility = 'hidden';
        helpon = 0;
    }
}


function f_clientWidth() {
        return f_filterResults (
	        window.innerWidth ? window.innerWidth : 0,
	        document.documentElement ? document.documentElement.clientWidth : 0,
	        document.body ? document.body.clientWidth : 0
        );
    }
    function f_clientHeight() {
        return f_filterResults (
	        window.innerHeight ? window.innerHeight : 0,
	        document.documentElement ? document.documentElement.clientHeight : 0,
	        document.body ? document.body.clientHeight : 0
        );
    }
    function f_scrollLeft() {
        return f_filterResults (
	        window.pageXOffset ? window.pageXOffset : 0,
	        document.documentElement ? document.documentElement.scrollLeft : 0,
	        document.body ? document.body.scrollLeft : 0
        );
    }
    function f_scrollTop() {
        return f_filterResults (
	        window.pageYOffset ? window.pageYOffset : 0,
	        document.documentElement ? document.documentElement.scrollTop : 0,
	        document.body ? document.body.scrollTop : 0
        );
    }
    function f_filterResults(n_win, n_docel, n_body) {
        var n_result = n_win ? n_win : 0;
        if (n_docel && (!n_result || (n_result > n_docel)))
	        n_result = n_docel;
        return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
    }