function SetCookie(cookieName,cookieValue,nDays) {

 var today = new Date();
 var expire = new Date();

 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*12*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString() +  "; path=/" + ";domain=bercoexpress.co.za";
}


function ReadCookie(cookieName) {

 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);

 if (ind==-1 || cookieName=="") return ""; 
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}

function DeleteCookie(cookieName) {
  var today = new Date();
  today.setTime(today.getTime() -1);
  var cval = ReadCookie(cookieName);
  document.cookie = cookieName + "=" + cval + ";expires=" + today.toGMTString() +  "; path=/" + "; domain=e-com.co.za";
}

function Browser_type() {

 if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 ))
 {
   return "IE";
 }
 else if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4 ))
 {
   return "NS"; 
 }
 else return "OT"; 
}


function ReadReferrer() {

 if (document.referrer) return document.referrer
 else return "";
}


function cookie_browser_referrer_link(cookiename) {
//  self.location.href = "CaissaAsp.asp?save=H&type=W&page=itb&_cookie=" +
//  ReadCookie(cookiename) + "&_browser=" + Browser_type() + "&_referrer=" + ReadReferrer();
   document.forms[0].cookie.value = ReadCookie(cookiename);
   document.forms[0].browser.value = Browser_type();
   document.forms[0].referrer.value  = ReadReferrer();
   document.forms[0].submit();
}
//........................    END   ...........................................................


var popWin = null    // use this when referring to pop-up window
var winCount = 0
var winName = "popWin"

function openPopWin(winURL, winWidth, winHeight, winFeatures){
  winName = "popWin" + winCount++ //unique name for each pop-up window
  closePopWin()           // close any previously opened pop-up window
  if (openPopWin.arguments.length == 4)  // any additional features? 
    winFeatures = "," + winFeatures
  else 
    winFeatures = "" 
  popWin = window.open(winURL, winName, "width=" + winWidth 
           + ",height=" + winHeight + winFeatures)
  }

function closePopWin(){    // close pop-up window if it is open 
  if (navigator.appName != "Microsoft Internet Explorer" 
      || parseInt(navigator.appVersion) >=4) //do not close if early IE
    if(popWin != null) if(!popWin.closed) popWin.close() 
  }
function checkcase()
{
        for (i=0;i<=1;i++)
	{
            document.form.elements[i].value = document.form.elements[i].value.toUpperCase();
 	}
}

function validate() 
{
	checkcase();
	DeleteCookie("USERNAME");
        Errs = false;
      	ErrString = "Please correct the following:\n\n";
	if (document.form.UserName.value == "") 
	{
		ErrString = ErrString + "\  Enter your user name\n";
	   	Errs = true;
	   	document.form.UserName.focus();
	}
	else
	{
		SetCookie("USERNAME", document.form.UserName.value, 1)
	}
	if (document.form.PassWord.value == "") 
	{
		ErrString = ErrString + "\  Enter your password\n";
		Errs = true;
		document.form.PassWord.focus();
	}
	if (Errs == true) 
	{
		alert(ErrString);
	  	return(false);
	}
	document.form.submit();
}
	
	
