﻿function setCookie(name, value, expires, path, domain, secure) 
{
    var date = new Date();
    date.setMonth(1000);
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "; expires=" + date.toGMTString()) +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name) 
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

function openPopupWindow(url,name,width,height,posX,posY)
{
    var sFeatures = 'status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=0,width='+width+',height='+height;
    
    if(posX==null)
    {
        var leftPos = (screen.width - width) / 2;
        var topPos = (screen.height - height) / 2;
       
        sFeatures += ',left='+leftPos+',top='+topPos;
    }
    else
        sFeatures += ',left='+posX+',top='+posY;
        
    return window.open(url,name,sFeatures,true);
}

function openSlideShow(name,cnt)
{
    openPopupWindow('/Pages/Tools/PowerPointViewer.aspx?Name='+name+'&slides='+cnt,null,920,720,null,null);   
}

function getBackUrlParam()
{
    var s = document.location.href;
    
    if(s.indexOf('&#')!=-1)
    {
        s = s.replace('&#','&&');
    }
    return "backurl="+encodeURIComponent(s);
}

function isEmpty(str)
{
	if(str==null) return true;
	if(str.length==0) return true;	

	for(var i=0;i<str.length;i++)
	{			
		if(str.charAt(i)!=' ')
			return false;
	}
	
	return true;
}