
//changed on Dec. 28 - two cookies (videos and articles are stored sep.)

// 'enum' for keys
var PERSONCOOKIE = "RealEstateBookUserPers";
var PERSONCOOKIE_USERID = "uid";
var PERSONCOOKIE_NAME = "fln";
var PERSONCOOKIE_EMAIL = "email";
var PERSONCOOKIE_ZIP = "zip";
var PERSONCOOKIE_SEARCHCOUNT = "scnt";
var PERSONCOOKIE_LISTINGS = "lid";

//the keys to read from second cookie
var PERSONCOOKIE2 = "RealEstateBookUserPers2";
var PERSONCOOKIE_ARTICLES = "aid";
var PERSONCOOKIE_VIDEOS ="vid";

function articleExists(articleID){var exists=false;arrArticles=readArticlesPersCookie();if(null!=arrArticles){if(inArray(articleID,arrArticles)!=-1){exists=true;}}return exists;}function videoExists(videoID){var exists=false;arrVideos=readVideosPersCookie();if(null!=arrArticles){if(inArray(videoID,arrVideos)!=-1){exists=true;}}return exists;}function listingExists(listingID){var exists=false;arrListings=readListingsPersCookie();if(null!=arrListings){if(inArray(listingID,arrListings)!=-1){exists=true;}}return exists;}function readSearchCountPersCookie(){var arrResult=readPersonCookie(PERSONCOOKIE_SEARCHCOUNT);if(arrResult){return arrResult[0];}else{return 0;}}function DisplayName(){if(readUserPersCookie(PERSONCOOKIE_NAME)==""){return readUserPersCookie(PERSONCOOKIE_EMAIL);}else{return readUserPersCookie(PERSONCOOKIE_NAME);}}function readListingCountPersCookie(){if(readListingsPersCookie()!=undefined){if(readListingsPersCookie()[0]!=""){return readListingsPersCookie().length;}else{return 0;}}else{return 0;}}function readArticleCountPersCookie(){if(readArticlesPersCookie()!=undefined){if(readArticleCountPersCookie()[0]!=""){return readArticlesPersCookie().length;}else{return 0;}}else{return 0;}}function readVideoCountPersCookie(){if(readVideosPersCookie()!=undefined){if(readVideosPersCookie()[0]=""){return readVideosPersCookie().length;}else{return 0;}}else{return 0;}}function readArticlesPersCookie(){var arrArticles=readPersonCookie(PERSONCOOKIE_ARTICLES);if(arrArticles){return arrArticles;}else{return undefined;}}function readVideosPersCookie(){var arrVideos=readPersonCookie(PERSONCOOKIE_VIDEOS);if(arrVideos){return arrVideos;}else{return undefined;}}function readListingsPersCookie(){var arrResult=readPersonCookie(PERSONCOOKIE_LISTINGS);if(arrResult){return arrResult;}else{return undefined;}}function readUserPersCookie(key){var arrResult=readPersonCookie(key);if(arrResult){return arrResult[0];}else{return"";}}function readPersonCookie(key){var myCookie;if((key==PERSONCOOKIE_ARTICLES)||(key==PERSONCOOKIE_VIDEOS)){myCookie=readCookie(PERSONCOOKIE2);}else{myCookie=readCookie(PERSONCOOKIE);}if(myCookie){var value="";arrPersCookie=myCookie.split('&');for(var i=0;i<arrPersCookie.length;i++){var keyvalue=arrPersCookie[i].split('=');if(key==keyvalue[0]){value=keyvalue[1];var arrValues=value.split('|');return arrValues;}}}else{return null;}}function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=unescape(ca[i]).replace(/\+/g," ");while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}return null;}function inArray(element,arr){if(arr!=undefined){for(var i=0,arrl=arr.length;i<arrl;i++){if(arr[i]==element){return i;}}}return-1;}