// JScript source code
function setFormEvent(){
	for (var i=0;i<document.forms.length;i++){
		if (document.forms[i].action) {
  			var findcart= document.forms[i].action.split("cart.cgi");
  			if (findcart.length > 1){
    				document.forms[i].onsubmit = SecurityCertificate;
			}
 		 }
	}
}
function SecurityCertificate(){
	event.returnValue = checkPass();
}
function checkPass(){
	if (getCookie(getUserName()) == getPass())
		return true;
	else{
		showModalDialog("login.htm", null, "dialogHeight: 350px; dialogWidth: 400px;");
		if (getCookie(getUserName()) == getPass())
			return true;
		else
			return false;
	}
}
function getCookie(sName)
{
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
      return unescape(aCrumb[1]);
  }
  return null;
}
function getPass(){
	//decode the pass
	return "parresel_07";
}
function getUserName()
{
	return "parres_07";
}
function setPass(userName, password){
	if (password != getPass() || userName != getUserName())
	{
		alert("Reseller ID or Password is not correct!");
		return;
	}
	else
	{
		var oTimeNow = new Date(); 
		oTimeNow.setMinutes(oTimeNow.getMinutes() + 10);
		document.cookie = userName + "=" + password + "; expires="+ oTimeNow.toUTCString();
		window.close();
	}
}
function windowOnloadDone(){
	if(document.onmousedown){
		document.onmousedown = null;
	}
	setFormEvent();	
}
window.onload = windowOnloadDone;
document.onmousedown=setFormEvent;
