// JavaScript Document

<!-- Begin query string parsing function -->

    function getQueryStringParamValue(keyvalue) {
        var params = {};
        var strURL = document.location.href;
        var qs = '';
 
        if (strURL.indexOf('?') != -1) {
            qs = strURL.substr(strURL.indexOf('?') + 1);
        }
        if (qs.length == 0) {
            return '';
        }
 
        // Turn <plus> back to <space>
        // See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
        qs = qs.replace(/\+/g, ' ');
        var args = qs.split('&'); // parse out name/value pairs separated via &
 
        for (var i = 0; i < args.length; i++) {
            var pair = args[i].split('=');
            var name = decodeURIComponent(pair[0]);
            var value = (pair.length == 2) ? decodeURIComponent(pair[1]) : name;
            params[name] = value;
        }
 
        var qsparam = params[keyvalue];
        //alert(qsparam);
        return (qsparam != null) ? qsparam : '';
    }

<!-- End query string parsing function -->


<!-- Begin append cid to links -->

	$(document).ready( function()
	{
    	var valueCid= getQueryStringParamValue('cid');

		if(valueCid != '')
		{
				
			$("a").each( function()
			{

				checkLink = $(this).attr("href");
				
				if( checkLink != null )			
				{
				
					//If link contains executiveboard.com and contains www or
					// doesn't start with http:
					// and doesn't start with mail
					
					if( (  (checkLink.toLowerCase().indexOf("executiveboard.com") != -1 && checkLink.toLowerCase().indexOf("www.") != -1 ) || checkLink.substr(0,4).toLowerCase() != "http" ||  checkLink.toLowerCase().indexOf("events.executiveboard.com") != -1 || checkLink.toLowerCase().indexOf("forms.executiveboard.com") != -1) && checkLink.substr(0,6).toLowerCase() != "mailto")
					{
						
						if( $(this).attr("href").indexOf("#") == -1)
						{
							//There are parameters in the link  
							if( $(this).attr("href").indexOf("?") != -1)
							{
								//If cid does not exist, append to URL    
								if ($(this).attr("href").toLowerCase().indexOf("cid=") == -1)
								{
									
									
									if( valueCid != '')
										$(this).attr("href", $(this).attr("href") + "&cid=" + valueCid);	
										
										
									
										
								}
								else
								//Already exist, replace the current ones with the new one
								{
								
									if( valueCid != '') 
										$(this).attr("href", $(this).attr("href").replace(/(cid=.*?&)|(cid=.*)/i, "cid="+valueCid+"&").replace(/&$/, ""));
									
								}
							}
							//There are no parameters in the link  
							else
							{
	
								if( valueCid != '')
									$(this).attr("href", $(this).attr("href") + "?cid=" + valueCid);
									
								
									
							}
						}
					}
				}

			});
		}
	});

<!-- End append cid to links -->

