//          Title: Antique Padlock Cookie Objects
// File Name: ap_cookie_objects.js
//      Author: David J. Heuermann
//           Use: Private - Antique Padlocks

// New - Replaces padlock_options (padlock_cookie.js)
//                 Title: Antique Padlocks Gallery Options
//   Cookie Name: ap_gallery_options
//           revision: Current revision number
//     split_screen: y=split screen multiple pictures n=full screen
//                        : updated by setup.htm
//             control: any characters=watermark on, off=watermark off
//      time_stamp: Current Time     
ap_gallery_options = new ap_cookie(document, "ap_gallery_options", 8760);
ap_gallery_options.load();
if (ap_gallery_options.revision === undefined) {	ap_gallery_options.revision = "001";}
if (ap_gallery_options.split_screen === undefined) {ap_gallery_options.split_screen = "n";}
if (ap_gallery_options.control === undefined) {ap_gallery_options.control = "on";}  // Obsolete
if (ap_gallery_options.picture_url === undefined) {ap_gallery_options.picture_url = "";}
if (ap_gallery_options.time_stamp === undefined) {ap_gallery_options.time_stamp = 0;}

ap_gallery_options.store();

// Remove - padlock_options - Remove Code on 11/1/2011
ap_z_padlock_options = new ap_cookie(document, "padlock_options");
ap_z_padlock_options.load();
if (ap_z_padlock_options.picture === undefined)
	{ap_z_padlock_options.notdefined = "";} else ap_z_padlock_options.remove();

//          Title: User Identification Cookie
//      Author: David J. Heuermann
//           Use: Private - Antique Padlocks
//                                                                        TEST
ap_user_id = new ap_cookie(document, "ap_user_id", 8760);
ap_user_id.load();
if (ap_user_id.revision === undefined) {	ap_user_id.revision = "001";}
if (ap_user_id.user_id === undefined) {ap_user_id.user_id = "";}
if (ap_user_id.user_password === undefined) {ap_user_id.user_password = "";}
if (ap_user_id.last_name === undefined) {ap_user_id.last_name = "";}
if (ap_user_id.first_name === undefined) {ap_user_id.first_name = "";}
ap_user_id.store();

//          Title: User Session Cookie
//      Author: David J. Heuermann
//           Use: Private - Antique Padlocks
//                                                                        TEST
ap_session = new ap_cookie(document, "ap_session");
ap_session.load();
if (ap_session.login_complete === undefined) {ap_session.login_complete = "n";}
if (ap_session.login_cancelled === undefined) {ap_session.login_cancelled = "n";}
if (ap_session.security_codes === undefined) {ap_session.security_codes = "";}
if (ap_session.target_page === undefined) {ap_session.target_page = "";}
if (ap_session.target_security_code === undefined) {ap_session.target_security_code = "";}
ap_session.store();

function ap_uid_record_update(uid_record)
{
var uid_elements = new Array();
uid_elements = uid_record.split("~");
if (uid_elements.length<5) {uid_elements.length=5;}
var len=uid_elements.length;
for(var i=0; i<len; i++) {if (uid_elements[i] === undefined) {uid_elements[i]="";}}
ap_user_id.user_id = uid_elements[0];
ap_user_id.user_password = uid_elements[1];
ap_user_id.last_name = uid_elements[2];
ap_user_id.first_name = uid_elements[3];
ap_user_id.store();
ap_session.security_codes = uid_elements[4];
ap_session.login_complete = "y";
ap_session.login_cancelled = "n";
ap_session.store();
}

function ap_validate_page(sc)
{
var target_page;
ap_session.target_page=window.location.href.substring(window.location.href.lastIndexOf('/') + 1);
ap_session.target_security_code=sc;
ap_session.login_cancelled = "n";
ap_session.store();
if (ap_session.login_complete == "n") {target_page = "login_ask.asp";}
else if ((ap_session.target_page == "") && (ap_session.target_security_code == "")) {target_page = "index.htm";}
else if (ap_user_authorized(sc) == "n") {target_page = "login_not_authorized.htm";}
else {return;}
location.replace(target_page);
}

function ap_user_authorized(sc)
{
var rc = "n";
var user_codes = new Array;
user_codes=ap_session.security_codes.split(",");
var len=user_codes.length;
for(var i=0; i<len; i++) {if (user_codes[i] == sc) {rc="y";}}
return rc;
}




