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 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 checkMessageCookie()
{
username=getCookie('message');
if (username!=null && username!="")
  {
  alert('Welcome again '+username+'!');
  }
  else 
  {
  username=prompt('Please enter your name:',"");
  if (username!=null && username!="")
    {
    setCookie('username',username,365);
    }
  }
}

function contactMessage(message)
{
setCookie('message','I am interested in receiving information regarding 24hourtek ' + message, 1);
location.href="contact.aspx";

}

function updateFromMessageCookie()
{
message=getCookie('message');
if (message!=null && message!="")
  {
    document.getElementById('Message').innerHTML = message;
  }
}


function cwLogin()
{
    var strEmail = document.loginform.txtemail.value;
    var strPassword = document.loginform.txtpass.value;
    
    	var strEmail = document.loginform.txtemail.value;

		if (strEmail.length == 0)
			alert("Please enter your email address.");
		else if (strPassword.length == 0)
		    alert("Please enter your password.");
		else
		    location.href = "https://cw.24hourtek.com/v4_6_Release/services/system_io/portal/Default.aspx?gotoparams=&txtemail=" + strEmail + "&txtpass=" + strPassword;
		
}

// open the client email with the specified address
function sendEmail(encodedEmail)
{
  // do the mailto: link
  location.href = "mailto:" + decodeEmail(encodedEmail);
}

// return the decoded email address
function decodeEmail(encodedEmail)
{
  // holds the decoded email address
  var email = "";

  // go through and decode the email address
  for (i=0; i < encodedEmail.length;)
  {
    // holds each letter (2 digits)
    var letter = "";
    letter = encodedEmail.charAt(i) + encodedEmail.charAt(i+1)

    // build the real email address
    email += String.fromCharCode(parseInt(letter,16));
    i += 2;
  }
  
  return email;
}

function emailPassword() {
			var strEmail = document.loginform.txtemail.value;

			if (strEmail.length == 0 || strEmail.indexOf("@") < 0)
				alert("Please enter your email address and we will email you the password.");
			else
			{
				self.location = "https://cw.24hourtek.com/v4_6_release/services/system_io/Portal/EmailPassword.aspx?e=" + strEmail;
			}
		}

