﻿function setCookie(c_name,value,expiredays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + "=");
        if (c_start!=-1)
        {
            c_start=c_start + c_name.length+1;
            c_end=document.cookie.indexOf(";",c_start);
            if (c_end==-1) c_end=document.cookie.length;
            return unescape(document.cookie.substring(c_start,c_end));
        }
    }

    return ("");
}

function IsValidEMail(EMail)
{
 var strEMail = EMail;
 var reFilter =/^.+@.+\..{2,3}$/

 if (reFilter.test(strEMail))
 {
    return(true);
 }
 else
 {
    return(false);
 }
}

function NationalCostGuide()
{
    var hWnd;
    var strURL;
    
    strURL = "/members/reporting/NationalCostTool.aspx";
    
    hWnd = window.open(strURL,"wTool","height=600,width=600,location=no,scrollbars=yes,toolbar=no");
    hWnd.focus();
}

function SendBulkMessage()
{
    var strURL = "SendBulkMessage.aspx";
    var hwndEdit;
    
    hwndEdit = window.open(strURL,"wMessage","height=600,width=700,location=no,scrollbars=yes,menubar=no,status=yes");
    hwndEdit.focus();
}

function SignupNow()
{
    var hSignup;
    
    hSignup = window.open("Signup.aspx","wSignup","height=600,width=650,location=no,scrollbars=yes,menubar=no");
    hSignup.focus();
}

function ExpandLayer(strLayerName)
{
    var obj;

    obj = document.getElementById(strLayerName);

    if (obj)
    {
        if(obj.style.display == "none") 
        {
		    obj.style.display = "block";
 	    }	
 	    else 
 	    {
		    obj.style.display = "none";
		}
	}   
}

function addBookmark(title,url) 
{
   if (window.sidebar) 
    { 
        window.sidebar.addPanel(title, url,""); 
    } 
    else if( document.all) 
    {
        window.external.AddFavorite( url, title);
    } 
        else if( window.opera && window.print ) 
    {
        return true;
    }
}

function setRememberMe()
{
    var frm;
    var date = new Date();

    frm = document.forms[0];
    
    if (frm.keyRem.checked)
    {
        date.setTime(date.getTime()+(90*24*60*60*1000));
        document.cookie = "LHU_Username=" + frm.Login.value + "; expires="+date.toGMTString() + "; path=/;"
        document.cookie = "LHU_Password=" + frm.Password.value + "; expires="+date.toGMTString() + "; path=/;";
    }
    else
    {
        date.setTime(date.getTime()-(1*24*60*60*1000));
        document.cookie = "LHU_Username=; expires="+date.toGMTString() + "; path=/;"
        document.cookie = "LHU_Password=; expires="+date.toGMTString() + "; path=/;";
    }
    
}

function getRememberMe()
{
    var frm;
    var strCookie;
    var arrCookie;
    var arrPair;
    var iCookie;
    
    strCookie = document.cookie;
    
    if (strCookie != "")
    {
        arrCookie = strCookie.split(";");

        frm = document.forms[0];
        
       
        for (iCookie=0; iCookie < arrCookie.length; iCookie++)
        {
            arrPair = arrCookie[iCookie].split("=");
            if (arrPair[0] == "LHU_Username")
            {
                frm.Login.value = arrPair[1];
                frm.keyRem.checked = true;
            }
            else if (arrPair[0] == " LHU_Password")
            {
                frm.Password.value = arrPair[1];
                frm.keyRem.checked = true;
            }
        }
    }
    
    
}

function ForgottenPasswordClick(btn)
{
    var frm;
    
    frm = document.forms[0];
    
    if (frm.ctl00$Login.value == "")
    {
        alert ("Forgotten Password:\n\nYou must enter the e-mail address of the LeaseholdersUnited account, the welcome e-mail will then be resent to this address.");
        return(false);
    }
    else
    {
        btn.value = "please wait ....";
    }
        
}


