//============================================================================||
//                      Alpine Login JavaScript                               ||
//                                                                            ||
// JavaScript Shop Module, V.4.4.0                                            ||
//============================================================================||


var params=new Array(5);
var alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI";
var target_site   = "";



//----------------------------------------------------------------------------||
// Browser type								      ||
//----------------------------------------------------------------------------||



//----------------------------------------------------------------------------||
// FUNCTION:    check                                                         ||
// PARAMETERS:  Form Object                                                   ||
// RETURNS:     Url to goal location                                          ||
// PURPOSE:     decode password and URL to location and determin address      ||
//----------------------------------------------------------------------------||
function check(form) {
which=form.memlist.selectedIndex;			//index of the choice in username field 0 = blank(x)
choice = form.memlist.options[which].value+"|";		//the string of the index plus ending "|"
//alert("choice :" choice);		
if (choice=="x|") {
alert("Please Select Your Name From The List");
return;
}
p=0;
for (i=0;i<4;i++) {					//reads each string to "|"
a=choice.indexOf("|",p);				//counts number of chars in string
params[i]=choice.substring(a,p);			//sets string in array
p=a+1;
}
h1=makehash(form.pass.value,3);
h2=makehash(form.pass.value,10)+" ";
if (h1!=params[1]) {
alert("Incorrect Password!"); return; };
//Branch = "00000";
//if (ship <= "00100") {branch = "CACU/"};
//if (ship >= "00101" && ship < "00199") { target_site = "MHM/" };
//if (ship >= "00200") {alert("Branch or shipping information dose not exist")};

                                                  	// sets source page
var page="";
for (var i=0;i<8;i++) {
letter=params[2].substring(i,i+1);
ul=letter.toUpperCase();
a=alpha.indexOf(ul,0);
a-=(h2.substring(i,i+1)*1);
if (a<0) a+=26;
page+=alpha.substring(a,a+1); };
top.location=target_site+"cacu/"+page.toLowerCase()+".htm";
}


//----------------------------------------------------------------------------||
// FUNCTION:    makehash                                                      ||
// PARAMETERS:  password, multiplyer                                          ||
// RETURNS:                                                                   ||
// PURPOSE:                                                                   ||
//----------------------------------------------------------------------------||
function makehash(pw,mult) {
pass=pw.toUpperCase();
hash=0;
for (i=0;i<8;i++) {
letter=pass.substring(i,i+1);
c=alpha.indexOf(letter,0)+1;
hash=hash*mult+c;
}
return(hash);
}

//----------------------------------------------------------------------------||


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function createurl() {
var ftpuser = document.loginform.ftpuser.value;
var ftppass = document.loginform.ftppass.value;
	if (ftpuser == "") {
		alert ("Please Enter your Username");
		document.loginform.ftpuser.focus();
		}
	else if (ftppass == "") {
		alert ("Please Enter your Password");
		document.loginform.ftppass.focus();
		}
	else {
		ftpurl = ('ftp://' + ftpuser + ':' + ftppass + '@ftp.alpinelitho.com');
		window.open(ftpurl);
		document.loginform.ftpuser.value = "";
		document.loginform.ftppass.value = "";
	}
}

// End -->