<!-- 
//  EyeCreate's Javascript code, copyright 1999
//  .htaccess file generation script 
//  Feel free to borrow and modify this javascript, 
//  but be sure leave this credit in the source and
//  include a link back to our site!  
//                    -Ken Tuck-    
//        http://www.eyecreate.net/

// Error Codes
function makeHT() {
var addError = document.htAccess.error404.value
var ooPs = document.htAccess.errorcode.value

         
if (addError.length<5){
alert("Please fill out the path/filename to your custom error page\nie: errorpages/404.html or 404.html");
document.htAccess.error404.focus();
return false
        }
else {document.htAccess.htaccessOut.value += ('ErrorDocument '+ooPs+' /'+addError+'\n')}
return true
}

//301 Redirect
function makeRD() {
var fromaddy = document.htAccess.fromaddy.value
var toaddy = document.htAccess.toaddy.value

if (fromaddy.length<2){
alert("Please fill out the filename of the page that you are deleting\ninclude the \'/\' prior to the filename");
document.htAccess.fromaddy.focus();
return false
} else if (toaddy.length<1){
alert("Please fill out the filename of the page that you are redirecting traffic to.");
document.htAccess.toaddy.focus();
} else {document.htAccess.htaccessOut.value += ('Redirect PERMANENT '+fromaddy+' '+toaddy+'\n')}
return true
}

// Different Default Home Page

function makeHT2() {
var FileNm = document.htAccess.fileName.value
var dI = 'DirectoryIndex'


if (FileNm.length<5){
alert("Please fill out the filename\nie: default.html");
document.htAccess.fileName.focus();
return false
        }
else {document.htAccess.htaccessOut.value += (''+dI+' '+FileNm+'\n')}
return true
}


// Block IP address
function makeHT2a() {
var FileNm = document.htAccess.block.value
var dI = document.htAccess.access.value


if (FileNm.length<5){
alert("Please fill out the IP address\nie: 218.83.155.134");
document.htAccess.block.focus();
return false
        }
else {document.htAccess.htaccessOut.value += (''+dI+' '+FileNm+'\n')}
return true
}

// Password Protection

function makeHT3() {
var passPath = document.htAccess.passWdpath.value
var htpass= '.htpasswd'
var db = document.htAccess.dialogBox.value
var pswdPth = 'AuthUserFile'
var unauth = document.htAccess.unauthpage.value
var AthNm = 'AuthName'
var aub = 'AuthType Basic'
var rvu = 'require valid-user'
var quote = '"'
var noaccess = 'ErrorDocument 401'



if (passPath.length<5){
alert("Please enter the Server Path to the password file\nie: /var/www/html/secret");
document.htAccess.passWdpath.focus();
return false
        }

if (db.length<5){
alert("Please enter the text you would like for the\nUsername and Password dialog box");
document.htAccess.dialogBox.focus();
return false
        }


if (unauth.length<5){
alert("Please enter the relative path and the name of the \nfile you wish unauthorized users to be sent to/");
document.htAccess.unauthpage.focus();
return false
        }

else {document.htAccess.htaccessOut.value += (''+pswdPth+' '+passPath+''+htpass+'\n'+AthNm+' '+quote+''+db+''+quote+'\n'+aub+'\n'+rvu+'\n'+noaccess+' '+unauth+'')}
return true
}


//Cache Control

function makeHTcacheCTRL(){
var ExpiresOn = 'ExpiresActive on'
var ExpiresDt = 'ExpiresDefault '
i = document.htAccess.type.selectedIndex
j = document.htAccess.aTime.selectedIndex
var AccessMod = document.htAccess.type.options[i].value
var time = document.htAccess.aTime.options[j].value

document.htAccess.htaccessOut.value += (''+ExpiresOn+'\n'+ExpiresDt+''+AccessMod+''+time+'\n')
}

//Functions to select text in the text area boxes

function selectAll(){
var htOut = document.htAccess.htaccessOut
if (htOut.length<5){
alert("You need to put something in before you try to create the .htaccess file");
return true
        }
else{
htOut.focus();
htOut.select();}
return false
}

function selectAll2(){
var pwdOut = document.PassWd.htpasswd
pwdOut.focus();
pwdOut.select();
}

// Form validation for username and password input boxes

function noEntryGen() {
umt=document.passEntry.username
mt=document.passEntry.username.value;
pmt=document.passEntry.password.value;
pmt2=document.passEntry.password2.value;

if ((mt.length<1)||(mt.substring(0,35)=="******")) {
alert("You forgot to put your username in the form.");
umt.value="";
umt.focus();
return false;
    }
if (pmt==pmt2) {	
if ((pmt.length<1)||(mt.substring(0,35)=="******")) {
alert("You forgot to put your password in the form.");
document.passEntry.password.value="";
document.passEntry.password.focus();
return false;
    }
} else {
alert("Your passwords don't match, please try again.");
document.passEntry.password.focus();
return false;
}
	
if (mt.length&&pmt.length>4){
document.passEntry.htpasswdOut.focus();    
return true;
    }
}
