String.prototype.stripSpaces = function( ){ return this.replace( /\s/g, "" ); };
String.prototype.stripTicks = function() { return this.replace(/'/g, "");};
function checkLicKey(licKey,aitLicKey)
{
	if(aitLicKey=="") aitLicKey = "||"; // just in case
	if(aitLicKey != "||")
	{
		
		var arrLicKey = aitLicKey.split("|");
		var nFeatureBitmask = 0x00000000;
		nFeatureBitmask = arrLicKey[2];
		if(!(nFeatureBitmask & licKey)) 
		{
			// If in CHM, revert to generic topics (with _CHM on filename)
			var strBodyURL=location.href;
			var chmIndex=strBodyURL.lastIndexOf('@MSIT');
			if (chmIndex == -1) 
			{
				var filename = 'IPSLicense_' + arrLicKey[2] + '.htm';
			}
			else
			{
				var filename = 'IPSLicense_' + arrLicKey[2] + '_CHM.htm';
			}
			
			try 
			{
				setTimeout("showLicenseMessage('" + filename +"')",400);
			}
			catch(e) 
			{
				alert(filename + ' could not be found.')
			}
		}
	}
}


function createXHR() 
{
    var request = false;
        try 
        {
            request = new ActiveXObject('Msxml2.XMLHTTP');
        }
        catch (err2) 
        {
            try {
                request = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (err3) 
            {
				try 
				{
					request = new XMLHttpRequest();
				}
				catch (err1) 
				{
					request = false;
				}
            }
        }
    return request;
}

function getBody(content)
{
	var x = content.indexOf('<div id="bodycontent"');
	if(x == -1) return "";
	x = content.indexOf(">", x);
	if(x == -1) return "";
	var y = content.lastIndexOf("</div>");
	if(y == -1) return "";
	var z = content.slice(x + 1, y);
	return z;
}

function showLicenseMessage(url)
{
	var xhr = createXHR();
	xhr.onreadystatechange=function()
	{ 
		if(xhr.readyState == 4)
		{
			var message = document.getElementById("licenseMessage");
			message.innerHTML = getBody(xhr.responseText);
			
			var mySlider = new Fx.Slide('licenseMessage', {duration: 1000});
			message.className = "licenseMessageShow";
			mySlider.hide();
			mySlider.slideIn();
 		}
	}
	xhr.open("GET", url , true);
	xhr.send(null); 
} 
function setCookie(c,value,expiredays)
{
var c_name = c.stripSpaces().stripTicks();
var exdate=new Date()
exdate.setDate(exdate.getDate()+expiredays)
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}

function getCookie(c)
{
var c_name = c.stripSpaces().stripTicks();
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return ""
}



