<!--
/* Sound & Video Creations Inc.
 * JAVASCRIPT Password Generator
 * The intention of the script is to build a password
 * base upon input from the client form. This function
 * can be used in multiple place where it is
 * required to protect some type of data without having
 * the ability to recall the original information.
*/

function hash(pass){
    var code= 0;
    var acum = 0;
    var aux = 0;
    for(var i = 0; i < pass.length; i++){
		code = pass.charCodeAt(i);
		if(i%2 == 0){
			aux = acum + code;
			acum = Math.sin(aux);	 
		}else{ 
			aux = acum + code;
			acum = Math.cos(aux);
		}
	}
	
	acum = acum * Math.round(Math.pow(10, 9));
	acum = Math.round(acum);
	return acum += '';
}

function checkpass(emailstring, productstring, pword)
{ 

    var passwrd = "svcmanualadmin";
    var prodname = "";

    /* Manual Administartion */    
    if (pword.toLowerCase() == passwrd)
    {
      if (productstring == 'audio6')
      {
        prodname = "Audio 6.x: ";
      }
      else if (productstring == 'varsity6')
      {
        prodname = "Varsity 6.x: ";
      }
      else if (productstring == 'audio4')
      {
        prodname = "Audio 4.x: ";
      }
      else if (productstring == 'varsity4')
      {
        prodname = "Varsity 4.x: ";
      }
      else if (productstring == 'audio3')
      {
        prodname = "Audio 3.x: ";
      }
      else if (productstring == 'proav2')
      {
        prodname = "ProAV 2.x: ";
      }
      else if (productstring == 'replay3')
      {
        prodname = "Replay 3.x: ";
      }
	  else if (productstring == 'crossfire')
	  {
	  	prodname = "Crossfire: ";
	  }	  
	  	  
      alert(prodname + hash(emailstring.toLowerCase() + productstring.toLowerCase()).substring(1, 7));
      return "#";
    }
    
    /* Manual Download */
    if ((hash(emailstring.toLowerCase() + productstring.toLowerCase()).substring(1, 7)) == (pword.toLowerCase()))
    {
      return "manuals\\" + productstring + "manual.pdf";
    }
    else
    {
      return false;
    }
}

function genCode(emailstring, productstring){
	  return (hash(emailstring.toLowerCase() + productstring.toLowerCase()).substring(1, 7));
}
//-->