function Check_Password(pwd) {

// alert ("Check_Password: " + pwd);

   if (pwd == "6066") {
//    alert ("Check_Password: set cookie")

      SetTheCookie(pwd);

//    alert ("Check_Password: " + pwd + " go to Distributor");

      window.location.href = "distributor_portal.htm";

   }

   else if (pwd == "2185") {

//    alert ("Check_Password: set cookie")

      SetTheCookie(pwd);

//    alert ("Check_Password: " + pwd + " go to Trade");

      window.location.href = "trade_portal.htm";

   }

   else if (pwd == "8521") {

//    alert ("Check_Password: set cookie")

      SetTheCookie(pwd);

//    alert ("Check_Password: " + pwd + " go to FloorsDirect");

      window.location.href = "fd_portal.htm";

   }

   else if (pwd == "4321") {

//    alert ("Check_Password: set cookie")

      SetTheCookie(pwd);

      window.location.href = "topc_portal.htm";

//
   }

   else if (pwd == "mrmrva") {

//    alert ("Check_Password: set cookie")

      SetTheCookie(pwd);

      window.location.href = "suntupsdealerlocation.htm";

   }


   else {

//      alert ("Invalid password " & pwd);

   }

}




function getCookieVal(offset)
{

//   alert("getCookieval1: " + offset);

   var endstr = document.cookie.indexOf (";", offset);

//   alert("getCookieval2: " + endstr);

   if (endstr == - 1) {

      endstr = document.cookie.length;

   }

//   alert ("getCookieval3: " + unescape(document.cookie.substring(offset, endstr)));

   return unescape(document.cookie.substring(offset, endstr));
}




function GetCookie(name)
{

//   alert ("GetCookie1: " + name + " " + document.cookie.length);

   var arg = name + "=";

   var alen = arg.length;

   var clen = document.cookie.length;

   var i = 0;
   while (i < clen)

   {

      var j = i + alen;

      if (document.cookie.substring(i, j) == arg) {

//	 alert ("GetCookie2: " + document.cookie.substring(i, j));

         return getCookieVal(j);

      }

      i = document.cookie.indexOf(" ", i) + 1;

      if (i == 0) {

//	 alert ("GetCookie: " + name + " break");

         break;

      }

   }

//   alert ("GetCookie: " + name + " exit");

   return null;

}




function SetCookie(name, value)
{

//   alert ("SetCookie: " + name);

   var argv = SetCookie.arguments;

   var argc = SetCookie.arguments.length;

   var expires = (argc > 2) ? argv[2] : null;

   var path = (argc > 3) ? argv[3] : null;

   var domain = (argc > 4) ? argv[4] : null;

   var secure = (argc > 5) ? argv[5] : false;

   document.cookie = name + "=" + escape (value) +

   ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +

   ((path == null) ? "" : ("; path=" + path)) +

   ((domain == null) ? "" : ("; domain=" + domain)) +

   ((secure == true) ? "; secure" : "");

//   alert ("SetCookie: " + document.cookie)

}





function DeleteCookie()
{

   var exp = new Date();
   exp.setTime (exp.getTime() - 1000000000);

// This cookie is history (changed - 1 to make it previous time)
   var cval = GetCookie ('SuntupsDistributor');

   document.cookie = 'Suntups' + "=" + cval + "; expires=" + exp.toGMTString();

//   alert("deleted " + cval);

   var cval = GetCookie ('SuntupsTrade');

   document.cookie = 'Suntups' + "=" + cval + "; expires=" + exp.toGMTString();

//   alert("deleted " + cval);

}





function SetTheCookie(pwd)
{

//    alert ("SetTheCookie: " + pwd);

    var expdate = new Date();

    expdate.setTime(expdate.getTime() + (30 * 60 * 1000));

    if (pwd == "6066")

    {

       SetCookie('SuntupsDistributor', 'logon', expdate);

    }

    if (pwd == "2185")
    {

       SetCookie('SuntupsTrade', 'logon', expdate);

    }

    if (pwd == "8521")

    {

       SetCookie('SuntupsFD', 'logon', expdate);

    }

    if (pwd == "4321")

    {

       SetCookie('SuntupsTOPC', 'logon', expdate);

    }

    if (pwd == "mrmrva")

    {

       SetCookie('SuntupsSteven', 'logon', expdate);

    }


//    alert ("SetTheCookie: " + pwd + " complete");

    return false;

}



function emailpopUp(dealeremail, dealer) {

	var strDealerEmail = dealeremail;

	var strDealer = dealer;
	day = new Date();
	
	URL = "http://www.suntups.co.za/eMail/feedback_form.asp?initial=Yes&dealer=" + strDealer + "&email=" + strDealerEmail;

	id = day.getTime();
	
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,"

		+ "statusbar=0,menubar=0,resizable=0,width=500,height=500,left = 390,top = 262');");

}



function reg_confirm(Floortype) {

	var strFloortype = Floortype;

	URL = "http://www.suntups.co.za/registration_confirm.asp?Floortype=" + strFloortype;
	self.location = URL;

}


