Commit ae686605 authored by Geoffroy ARNOUD's avatar Geoffroy ARNOUD
Browse files

Added Select2 on embedded WAYF #K11

parent e3a51554
<?php // Copyright (c) 2019, SWITCH ?>
<?php // Copyright (c) 2019, SWITCH?>
<!-- Identity Provider Selection: Start -->
<h1><?php echo getLocalString('header'); ?></h1>
<form id="IdPList" name="IdPList" method="post" onSubmit="return checkForm()" action="<?php echo $actionURL ?>">
<h1><?php echo getLocalString('header'); ?></h1>
<form id="IdPList" name="IdPList" method="post" onSubmit="<?php echo printSubmitAction() ?>" action="<?php echo $actionURL ?>">
<div id="userInputArea">
<p class="promptMessage"><?php echo $promptMessage ?></p>
<div style="text-align: center">
<select name="user_idp" id="userIdPSelection">
<option value="-" <?php echo $defaultSelected ?>><?php echo getLocalString('select_idp') ?> ...</option>
<?php printDropDownList($IDProviders, $selectedIDP) ?>
<select name="user_idp" id="userIdPSelection" class="userIdPSelection" tabindex="0">
<?php
// If we use select2, we don't want IDP to be in DOM, but to use AJAX instead
if (!$useSelect2) {
echo '<option value="-" '.$defaultSelected.'>'.getLocalString('select_idp').' ...</option>';
printDropDownList($IDProviders, $selectedIDP);
}
?>
</select>
<input type="submit" name="Select" accesskey="s" value="<?php echo getLocalString('select_button') ?>">
<input type="submit" name="Select" accesskey="s" value="<?php echo getLocalString('select_button') ?>">
</div>
<div style="text-align: left">
<p class="selectOptions">
......@@ -26,7 +33,9 @@
</div>
</form>
<?php if (getLocalString('additional_info') != '') { ?>
<?php if (getLocalString('additional_info') != '') {
?>
<p><?php echo getLocalString('additional_info') ?></p>
<?php } ?>
<?php
} ?>
<!-- Identity Provider Selection: End -->
<?php // Copyright (c) 2019, SWITCH ?>
<?php // Copyright (c) 2019, SWITCH?>
<!-- EMBEDDED-WAYF-START -->
<script type="text/javascript"><!--
// To use this JavaScript, please access:
// https://<?php echo $host ?><?php echo $path ?>/embedded-wayf.js/snippet.html
// and copy/paste the resulting HTML snippet to an unprotected web page that
// and copy/paste the resulting HTML snippet to an unprotected web page that
// you want the embedded WAYF to be displayed
......@@ -36,18 +36,18 @@ var wayf_return_url = "https://my-app.switch.ch/aai/index.php?page=show_welcome"
//////////////////// RECOMMENDED SETTINGS ////////////////////
// Width of the embedded WAYF in pixels or "auto"
// This is the width of the content only (without padding and border).
// Add 2 x (10px + 1px) = 22px for padding and border to get the actual
// This is the width of the content only (without padding and border).
// Add 2 x (10px + 1px) = 22px for padding and border to get the actual
// width of everything that is drawn.
// [Optional, default: "auto"]
// var wayf_width = 250;
// Height of the embedded WAYF in pixels or "auto"
// This is the height of the content only (without padding and border).
// Add 2 x (10px + 1px) = 22px for padding and border to get the actual
// This is the height of the content only (without padding and border).
// Add 2 x (10px + 1px) = 22px for padding and border to get the actual
// height of everything that is drawn.
// [Optional, default: "auto"]
// Example for fixed size:
// Example for fixed size:
// var wayf_height = 150;
// Whether to show the checkbox to remember settings for this session
......@@ -86,7 +86,7 @@ var wayf_return_url = "https://my-app.switch.ch/aai/index.php?page=show_welcome"
//var wayf_auto_login = true;
// Whether to hide the WAYF after the user was logged in
// This requires that the _shib_session_* cookie is set when a user
// This requires that the _shib_session_* cookie is set when a user
// could be authenticated, which is the default case when Shibboleth is used.
// For other Service Provider implementations have a look at the setting
// wayf_check_login_state_function that allows you to customize this
......@@ -128,16 +128,16 @@ var wayf_return_url = "https://my-app.switch.ch/aai/index.php?page=show_welcome"
// Use the SAML2/Shibboleth 2 Discovery Service protocol where
// the user is sent back to the Service Provider after selection
// of his Home Organisation.
// This feature should only be uncommented and set to false if there
// This feature should only be uncommented and set to false if there
// is a good reason why to use the old and deprecated Shibboleth WAYF
// protocol instead.
// [Optional, default: true]
// var wayf_use_discovery_service = false;
// If enabled, the Embedded WAYF will activate the
// improved drop down list feature, which will transform the list of
// If enabled, the Embedded WAYF will activate the
// improved drop down list feature, which will transform the list of
// organisations into a search-field while keeping its original function as
// a select list. To make this work, the JQuery library will dynamically be
// a select list. To make this work, the JQuery library will dynamically be
// loaded if it is not yet present. Additionally, another Javascript and CSS
// file are loaded to perform the actual transformation.
// Please note that this feature will also display the organisations' logos,
......@@ -147,10 +147,17 @@ var wayf_return_url = "https://my-app.switch.ch/aai/index.php?page=show_welcome"
// [Optional, default: false]
// var wayf_use_improved_drop_down_list = false;
// Whether or not use Select2 drop down
// Attention: setting this to true, overrides $useImprovedDropDownList param
// var wayf_use_select2 = false;
// Config to change the number of IdP fetched when using Select2 dropdown
// var wayf_select2_page_size = 100;
// If true the improved drop-down-list will not display IdP logos that
// have to be loaded from remote URLs. That way the web browser
// does not have to make requests to third party hosts.
// Logos that are embedded using data URIs
// Logos that are embedded using data URIs
// (src="data:image/png;base64...") will however still be displayed
// Don't confuse this with wayf_hide_logo, which shows or hides
// the logo of this WAYF instance
......@@ -159,7 +166,7 @@ var wayf_return_url = "https://my-app.switch.ch/aai/index.php?page=show_welcome"
// If true the improved drop-down-list automatic filtering
// of entries while typing content in the search box will
// allow matching IdPs either by their name or entityID,
// allow matching IdPs either by their name or entityID,
// whereas otherwise only the name is considered
// [Optional, default: true]
// wayf_enable_entityid_matching = true;
......@@ -168,7 +175,7 @@ var wayf_return_url = "https://my-app.switch.ch/aai/index.php?page=show_welcome"
// current browser session. If wayf_show_remember_checkbox is true
// the checkbox will be shown but will be read only.
// WARNING: Only use this feature if you know exactly what you are doing
// This option will cause problems that are difficult to find
// This option will cause problems that are difficult to find
// in case they accidentially select a wrong Home Organisation
// [Optional, default: false]
//var wayf_force_remember_for_session = false;
......@@ -178,7 +185,7 @@ var wayf_return_url = "https://my-app.switch.ch/aai/index.php?page=show_welcome"
// This will implicitely be set to wayf_sp_samlDSURL = wayf_sp_handlerURL + "/Login";
// or will be set automatically if the page where the Embedded WAYF is placed is called
// with a 'return' and an 'entityID' GET Arguments
// [Optional, if wayf_use_discovery_service = true
// [Optional, if wayf_use_discovery_service = true
// or if wayf_additional_idps is not empty, default: wayf_sp_handlerURL + "/Login"]
// var wayf_sp_samlDSURL = wayf_sp_handlerURL + "/Login";
......@@ -188,7 +195,7 @@ var wayf_return_url = "https://my-app.switch.ch/aai/index.php?page=show_welcome"
// var wayf_default_idp = "https://aai-logon.switch.ch/idp/shibboleth";
// Number of last used IdPs to show
// Will not be shown if wayf_show_categories is false
// Will not be shown if wayf_show_categories is false
// Set to 0 to deactivate
// [Optional, default: 3]
// var wayf_num_last_used_idps = 3;
......@@ -227,7 +234,7 @@ var wayf_return_url = "https://my-app.switch.ch/aai/index.php?page=show_welcome"
// var wayf_overwrite_from_other_federations_text = 'Other organisations';
// Whether to hide the WAYF after the user was logged in
// This requires that the _shib_session_* cookie is set when a user
// This requires that the _shib_session_* cookie is set when a user
// could be authenticated
// If you want to hide the embedded WAYF completely, uncomment
// the property and set it to "". This then won't draw anything
......@@ -236,7 +243,7 @@ var wayf_return_url = "https://my-app.switch.ch/aai/index.php?page=show_welcome"
// If the user is already logged in and this variable is set to true, the WAYF
// will automatically redirect the user to the URL set in wayf_return_url.
// If the WAYF is embedded on a dedicated login page, this value should be set
// If the WAYF is embedded on a dedicated login page, this value should be set
// to true. Else, it should be left at its default value 'false'.
// [Optional, default: false]
// var wayf_auto_redirect_if_logged_in = true;
......@@ -244,19 +251,19 @@ var wayf_return_url = "https://my-app.switch.ch/aai/index.php?page=show_welcome"
// Provide the name of a JavaScript function that checks whether the user
// already is logged in. The function should return true if the user is logged
// in or false otherwise. If the user is logged in, the Embedded WAYF will
// hide itself or draw a custom message depending on the
// hide itself or draw a custom message depending on the
// setting wayf_logged_in_messsage. The default check will access a Shibboleth
// session handler which typically is found at /Shibboleth.sso/Session.
// [Optional, default: none]
// var wayf_check_login_state_function = function() {
// var wayf_check_login_state_function = function() {
// if (# specify user-is-logged-in condition#)
// return true;
// else
// else
// return false;
// }
// EntityIDs, Names and SSO URLs of Identity Providers from other federations
// that should be added to the drop-down list.
// EntityIDs, Names and SSO URLs of Identity Providers from other federations
// that should be added to the drop-down list.
// name: Name of the Identity Provider to display
// entityID: SAML entityID/providerID of this Identity Provider
// SAML1SSOurl: Endpoint for the SAML1 SSO handler
......@@ -264,17 +271,17 @@ var wayf_return_url = "https://my-app.switch.ch/aai/index.php?page=show_welcome"
// and it should be loaded from an HTTPS URL. Otherwise IE and other
// browsers complain
// data: Non-visible data that may be used to find this Identity Provider when the
// improve drop-down feature is enabled. This string for example can include
// the domain names, abbreviations, localities or alternative names of the
// improve drop-down feature is enabled. This string for example can include
// the domain names, abbreviations, localities or alternative names of the
// organisation. Basically, anything the user could use to search his institution.
//
//
// The IdPs will be displayed in the order they are defined
// [Optional, default: none]
// var wayf_additional_idps = [ ];
// Example of how to add Identity Provider from other federations
// var wayf_additional_idps = [
//
// var wayf_additional_idps = [
//
// {name:"International University X",
// entityID:"urn:mace:example.org:example.university.org",
// SAML1SSOurl:"https://int.univ.org/shibboleth-idp/SSO",
......@@ -290,13 +297,13 @@ var wayf_return_url = "https://my-app.switch.ch/aai/index.php?page=show_welcome"
// Whether to load Identity Providers from the Discovery Feed provided by
// the Service Provider.
// IdPs that are not listed in the Discovery Feed and that the SP therefore is
// the Service Provider.
// IdPs that are not listed in the Discovery Feed and that the SP therefore is
// not are able to accept assertions from, are hidden by the Embedded WAYF
// IdPs that are in the Discovery Feed but are unknown to the SWITCHwayf
// are added to the wayf_additional_idps.
// are added to the wayf_additional_idps.
// The list wayf_additional_idps will be sorted alphabetically
// The SP must have configured the discovery feed handler that generates a
// The SP must have configured the discovery feed handler that generates a
// JSON object. Otherwise it won't generate the JSON data containing the IdPs.
// [Optional, default: false]
// var wayf_use_disco_feed = false;
......@@ -309,7 +316,7 @@ var wayf_return_url = "https://my-app.switch.ch/aai/index.php?page=show_welcome"
//////////////////// ADDITIONAL CSS CUSTOMIZATIONS ////////////////////
// To further customize the appearance of the Embedded WAYF you could
// define CSS rules for the following CSS IDs that are used within the
// define CSS rules for the following CSS IDs that are used within the
// Embedded WAYF:
// #wayf_div - Container for complete Embedded WAYF
// #wayf_logo_div - Container for logo
......@@ -333,10 +340,10 @@ var wayf_return_url = "https://my-app.switch.ch/aai/index.php?page=show_welcome"
<script type="text/javascript" src="https://<?php echo $host ?><?php echo $path ?>/embedded-wayf.js"></script>
<noscript>
<!--
Fallback to Shibboleth DS Session Initiator for non-JavaScript users
Value of the target GET parameter should be set to an URL-encoded
absolute URL that points to a Shibboleth protected web page where the user
<!--
Fallback to Shibboleth DS Session Initiator for non-JavaScript users
Value of the target GET parameter should be set to an URL-encoded
absolute URL that points to a Shibboleth protected web page where the user
is logged in into your application.
-->
<p>
......
......@@ -14,7 +14,6 @@
if ($useSelect2) {
echo '<link rel="stylesheet" href="'. $_SERVER['SCRIPT_NAME'] .'/select2.css" type="text/css" >'.PHP_EOL;
// echo '<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />'.PHP_EOL;
echo '<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>'.PHP_EOL;
echo '<script type="text/javascript" src="'.$javascriptURL .'/select2Functions.js"></script>'.PHP_EOL;
} elseif ($useImprovedDropDownList) {
......@@ -71,7 +70,6 @@
// Perform input validation on WAYF form for select2
function select2CheckForm() {
// FIXME : to be reviewed for select2 !!!
console.log("checkForm ", $('.userIdPSelection option:selected').text());
if (
document.IdPList.user_idp && (
......
<?php // Copyright (c) 2019, SWITCH ?>
<?php // Copyright (c) 2019, SWITCH?>
<!-- Identity Provider Selection: Start -->
<h1><?php echo getLocalString('permanent_select_header'); ?></h1>
<form id="IdPList" name="IdPList" method="post" onSubmit="<?php
if ($useSelect2) {
echo "return select2CheckForm()";
} else {
echo "return checkForm()";
}
?>" action="<?php echo $actionURL ?>">
<form id="IdPList" name="IdPList" method="post" onSubmit="<?php echo printSubmitAction() ?>" action="<?php echo $actionURL ?>">
<div id="userInputArea">
<p class="promptMessage"><?php echo getLocalString('permanent_cookie'); ?></p>
<p><?php echo getLocalString('select_idp'); ?></p>
......
......@@ -1116,3 +1116,13 @@ function isRunViaInclude()
{
return basename($_SERVER['SCRIPT_NAME']) != 'readMetadata.php';
}
function printSubmitAction()
{
global $useSelect2;
if ($useSelect2) {
return "return select2CheckForm()";
} else {
return "return checkForm()";
}
}
......@@ -5,13 +5,13 @@
// The API is compliant with select2 (https://select2.org/)
/*------------------------------------------------*/
// TODO : gérer la pré-sélection
$topLevelDir = dirname(__DIR__);
require('common.php');
require('idpApiObjects.php');
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
$repo = new IdpRepository($IDProviders, $IDPArray);
......
......@@ -291,6 +291,7 @@ function printEmbeddedWAYFScript()
global $langStrings, $language, $imageURL, $javascriptURL, $cssURL, $logoURL, $smallLogoURL, $federationURL;
global $selectedIDP, $IDProviders, $SAMLDomainCookieName, $redirectCookieName, $redirectStateCookieName;
global $customStrings;
global $apiURL, $developmentMode;
// Set values that are used in the java script
$loginWithString = getLocalString('login_with');
......
(function(global, factory) {
if (typeof global.define === 'function' && global.define.amd) {
define("wayfGlobalObject", [], global);
define("embeddedWayf", ["jquery", "wayfGlobalObject"], factory);
} else {
typeof global.$ === 'function' ? factory(global.$, global) :
typeof global.jQuery === 'function' ? factory(global.jQuery, global) :
typeof global.jquery === 'function' ? factory(global.jquery, global) :
factory(null, global); // allow dynamic loading of the libraries on default
}
if (typeof global.define === 'function' && global.define.amd) {
define("wayfGlobalObject", [], global);
define("embeddedWayf", ["jquery", "wayfGlobalObject"], factory);
} else {
typeof global.$ === 'function' ? factory(global.$, global) :
typeof global.jQuery === 'function' ? factory(global.jQuery, global) :
typeof global.jquery === 'function' ? factory(global.jquery, global) :
factory(null, global); // allow dynamic loading of the libraries on default
}
})(this, function($, global) {
// Copyright (c) 2019, SWITCH
// To use this JavaScript, please access:
// <?php echo $configurationScriptUrl ?>
// and copy/paste the resulting HTML snippet to an unprotected web page that
// you want the embedded WAYF to be displayed
// ############################################################################
// Declare all global variables
// Essential settings
var wayf_sp_entityID = global.wayf_sp_entityID;
var wayf_URL = global.wayf_URL;
var wayf_return_url = global.wayf_return_url;
var wayf_sp_handlerURL = global.wayf_sp_handlerURL;
// Other settings
var wayf_use_discovery_service = global.wayf_use_discovery_service;
var wayf_use_improved_drop_down_list = global.wayf_use_improved_drop_down_list;
var wayf_disable_remote_idp_logos = global.wayf_disable_remote_idp_logos;
var wayf_enable_entityid_matching = global.wayf_enable_entityid_matching;
var wayf_use_small_logo = global.wayf_use_small_logo;
var wayf_width = global.wayf_width;
var wayf_height = global.wayf_height;
var wayf_background_color = global.wayf_background_color;
var wayf_border_color = global.wayf_border_color;
var wayf_font_color = global.wayf_font_color;
var wayf_font_size = global.wayf_font_size;
var wayf_hide_logo = global.wayf_hide_logo;
var wayf_auto_login = global.wayf_auto_login;
var wayf_logged_in_messsage = global.wayf_logged_in_messsage;
var wayf_auto_redirect_if_logged_in = global.wayf_auto_redirect_if_logged_in;
var wayf_hide_after_login = global.wayf_hide_after_login;
var wayf_most_used_idps = global.wayf_most_used_idps;
var wayf_overwrite_last_used_idps_text = global.wayf_overwrite_last_used_idps_text;
var wayf_overwrite_most_used_idps_text = global.wayf_overwrite_most_used_idps_text;
var wayf_overwrite_checkbox_label_text = global.wayf_overwrite_checkbox_label_text;
var wayf_overwrite_submit_button_text = global.wayf_overwrite_submit_button_text;
var wayf_overwrite_intro_text = global.wayf_overwrite_intro_text;
var wayf_overwrite_from_other_federations_text = global.wayf_overwrite_from_other_federations_text;
var wayf_default_idp = global.wayf_default_idp;
var wayf_num_last_used_idps = global.wayf_num_last_used_idps;
var wayf_show_categories = global.wayf_show_categories;
var wayf_hide_categories = global.wayf_hide_categories;
var wayf_hide_idps = global.wayf_hide_idps;
var wayf_unhide_idps = global.wayf_unhide_idps;
var wayf_show_remember_checkbox = global.wayf_show_remember_checkbox;
var wayf_force_remember_for_session = global.wayf_force_remember_for_session;
var wayf_additional_idps = global.wayf_additional_idps;
var wayf_sp_samlDSURL = global.wayf_sp_samlDSURL;
var wayf_sp_samlACURL = global.wayf_sp_samlACURL;
var wayf_use_disco_feed = global.wayf_use_disco_feed;
var wayf_discofeed_url = global.wayf_discofeed_url;
// Internal variables
var wayf_improved_dropdown_url = '<?php echo $javascriptURL ?>/improvedDropDown.js';
var wayf_jquery_url = '<?php echo $javascriptURL ?>/jquery.js';
var wayf_dropdown_icon_url = '<?php echo $imageURL ?>/drop_icon.png';
var wayf_disco_feed_idps;
var wayf_html = "";
var wayf_categories = { <?php echo $JSONCategoryList ?>};
var wayf_idps = { <?php echo $JSONIdPList ?> };
var wayf_other_fed_idps = {};
// Functions
function redirectTo(url){
// Make sure the redirect always is being done in parent window
if (window.parent){
window.parent.location = url;
} else {
window.location = url;
}
}
function submitForm(eventObj){
if (document.IdPList.user_idp && document.IdPList.user_idp.selectedIndex == 0){
alert('<?php echo $makeSelectionString ?>');
return false;
}
// Set local cookie
var selectedIdP = document.IdPList.user_idp[document.IdPList.user_idp.selectedIndex].value;
setDomainSAMLDomainCookie(selectedIdP);
// User chose federation IdP entry
if( wayf_idps[selectedIdP]) {
return true;
}
// User chose IdP from other federation
var redirect_url;
// Redirect user to SP handler
if (wayf_use_discovery_service){
var entityIDGETParam = getGETArgument("entityID");
var returnGETParam = getGETArgument("return");
if (entityIDGETParam != "" && returnGETParam != ""){
redirect_url = returnGETParam;
} else {
redirect_url = wayf_sp_samlDSURL;
redirect_url += getGETArgumentSeparator(redirect_url) + 'target=' + encodeURIComponent(wayf_return_url);
}
// Prevent default submit action
eventObj.preventDefault();
// Append selected Identity Provider
redirect_url += '&entityID=' + encodeURIComponent(selectedIdP);
redirectTo(redirect_url);
} else {
redirect_url = wayf_sp_handlerURL + '?providerId='
+ encodeURIComponent(selectedIdP)
+ '&target=' + encodeURIComponent(wayf_return_url);
// Prevent default submit action
eventObj.preventDefault();
redirectTo(redirect_url);
}
// If input type button is used for submit, we must return false
return false;
}
function writeOptGroup(IdPElements, category){
if (!wayf_categories[category]){
writeHTML(IdPElements);
return;
}
if (IdPElements === ''){
return;
}
var categoryName = wayf_categories[category].name;
if (wayf_show_categories){
writeHTML('<optgroup label="' + categoryName + '">');
}
writeHTML(IdPElements);
if (wayf_show_categories){
writeHTML('</optgroup>');
}
}
function writeHTML(a){
wayf_html += a;
}
function isEmptyObject(obj){
if (typeof(obj) != "object"){
return true;
}
for (var index in obj){
return false;
}
return true;
}
function isAllowedIdP(IdP){
var type = '';
if (wayf_idps[IdP]){
type = wayf_idps[IdP].type;
} else if (wayf_other_fed_idps[IdP]){
type = wayf_other_fed_idps[IdP].type;
}
// Check if IdP should be hidden
for ( var i = 0; i < wayf_hide_idps.length; i++){
if (wayf_hide_idps[i] == IdP){
return false;
}
}
// Check if category should be hidden
// Check if IdP is unhidden in this category
for ( var i = 0; i < wayf_hide_categories.length; i++){
if (wayf_hide_categories[i] === "all" || wayf_hide_categories[i] == type){
for ( var i=0; i < wayf_unhide_idps.length; i++){
// Show IdP if it has to be unhidden
if (wayf_unhide_idps[i] == IdP){
return true;
}
}
// If IdP is not unhidden, the default applies
return false;
}
}
// Default
return true;
}
function setDomainSAMLDomainCookie(entityID){
// Create and store SAML domain cookie on host where WAYF is embedded
var currentDomainCookie = getCookie('_saml_idp');
var encodedEntityID = encodeBase64(entityID);
if (currentDomainCookie == null){
currentDomainCookie = '';
}
// Ensure current IdP is not already in array
var currentIdPs = currentDomainCookie.split(' ');
var newIdPs = new Array();
for (var i = 0; i < currentIdPs.length; i++) {
if (currentIdPs[i] != encodedEntityID && currentIdPs[i] != ''){
newIdPs.push(currentIdPs[i]);
}
}
// Add new IdP
newIdPs.push(encodedEntityID);
// Ensure array is no longer than 5 IdPs
while (newIdPs.length > 5){
newIdPs.shift();
}
// Compose cookie value
var newDomainCookie = '';
for (var i = 0; i < newIdPs.length; i++) {
newDomainCookie += newIdPs[i] + ' ';
}
// Set cookie value
setCookie('<?php echo $SAMLDomainCookieName ?>', newDomainCookie.trim() , 100);
}
function setCookie(c_name, value, expiredays){
var exdate = new Date();
exdate.setDate(exdate.getDate() + expiredays);
document.cookie=c_name + "=" + escape(value) +
((expiredays==null) ? "" : "; expires=" + exdate.toGMTString());
}
function getCookie(check_name){
// First we split the cookie up into name/value pairs
// Note: document.cookie only returns name=value, not the other components
var a_all_cookies = document.cookie.split( ';' );
var a_temp_cookie = '';
var cookie_name = '';
var cookie_value = '';
for ( var i = 0; i < a_all_cookies.length; i++ ){
// now we'll split apart each name=value pair
a_temp_cookie = a_all_cookies[i].split('=');