﻿// JScript File

function encodeUrl(url)   
{   
    if (url.indexOf("?")>0)   
    {   
        encodedParams = "?";   
        parts = url.split("?");   
        params = parts[1].split("&");   
        for(i = 0; i < params.length; i++)   
        {   
            if (i > 0)   
            {   
                encodedParams += "&";   
            }   
            if (params[i].indexOf("=")>0) //Avoid null values   
            {   
                p = params[i].split("=");   
                encodedParams += (p[0] + "=" + escape(encodeURI(p[1])));   
            }   
            else  
            {   
                encodedParams += params[i];   
            }   
        }   
        url = parts[0] + encodedParams;   
    }   
    return url;   
}  

function dialogReturnValue(Value)
{
    if ((Value == '') || (Value == null))
    {
        alert('Please select a value first!');
    }
    else
    {
        window.returnValue=Value; 
        window.close();    
    }
}



function dialogWindow(width, height)
{
    return 'toolbars:yes;status:no;' + 
            'dialogWidth:' + width + 'px;' + 
            'dialogHeight:' + height + 'px;' +
            'dialogHide:false;' +
            'help:no;' +
            'scroll:no'
}

function dialogParams(width, height)
{
    return 'Height=' + (height - 60) + '&Width=' + width;
}

function Confirmation(button, msg, width, height)
{
    var retval="";

    retval=window.showModalDialog(
        Path + 'dlg_YesNo.aspx' +
        '?Title=QUESTION&Message=' + msg + '&' + dialogParams(width, height),
        window,
        dialogWindow(width, height));
        
            
    if(retval!="" && retval!=null)
    {
        return true;
    } else
    {
        return false;
    }
}


function ShowMessage(title,msg, width, height)
{
//    if(width==null){width=370;}
//    if(height==null){height=180;}
//    
//    window.showModalDialog(Path + 'dlg_Message.aspx' +
//        '?Title=' + title + '&Message=' + msg + '&' + dialogParams(width, height),
//        window,
//        dialogWindow(width, height));
//    
    alert(title + "\n\n" + msg);
        
}
function dialogChangePwd()
{
    window.showModalDialog(Path + 'dlg_ChangePwd.aspx', window, dialogWindow(500, 300) );
    
    document.location='Default.aspx';
}
function dialogSignout(msg)
{
    var retval="";

    retval=window.showModalDialog(
        Path + 'dlg_YesNo.aspx' +
        '?Title=QUESTION&Message=' + msg + '&' + dialogParams(370, 180),
        window,
        dialogWindow(370, 180));
        
            
    if(retval!="" && retval!=null)
    {
        window.location = 'AdminLogin.aspx?Signout=Y';
    }            
}

function dialogPic(PhotoUrl, Width, Height) {
    window.showModalDialog(PhotoUrl, window, 'toolbars:no;status:no;' +
            'dialogWidth:' + Width + 'px;' +
            'dialogHeight:' + Height + 'px;' +
            'dialogHide:false;' +
            'help:no;' +
            'scroll:yes');
}