// PSN URL
// Called to get the correct URL for the PSN Support pages
function PSNURL( sPage) {
	return "http://pmb001.3m.com/pmbpages/" + sPage;
}

// Called when there is an error loading the Post-it(R) Messenger Client Control
//	Usually because PSN is not installed
function noPSN( sSpec) {
	noPSN2( sSpec, PSNURL( "") );
}
// Called when there is an error loading the Post-it(R) Messenger Client Control
//	Usually because PSN is not installed
function noPSN2( sSpec, sDir) {
  popup_window = window.open( sDir + "nopsn.htm", "NO" + sSpec, "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=514,height=235");
}

// Displays the preview window with the flash video
var wndPreview = null;
function PSNPreview( sSpec) {
        if ((wndPreview == null) || wndPreview.closed)
	  wndPreview = window.open(PSNURL( "preview.htm") , "VIEW" + sSpec,"toolbar=0,location=50,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=250,height=250");
       	wndPreview.focus();
}

// Default function to display the download popup.  Assumes that there is a pmbpages/ folder under the current
//	folder.  If this is not correct, use the downloadPSN2 method and specify the location of the psn folder
function PSNDownload( sSpec) {
	PSNDownload2( sSpec, PSNURL( ""));
}

// Displays the download popup windows.  You can specify where the popups reside.  
//	Usually that's in "pmbpages/" or in the current directory ""
var dlWindow = null;
function PSNDownload2( sSpec, sDir) {

  bLite = (sSpec == "") || (sSpec == "FiltreteLite") || (sSpec == "Progressive");

  if (sSpec == "")
	sName = "Download";
  else
 	sName = sSpec;

  if ((dlWindow == null) || dlWindow.closed)
  {
  	if(navigator.userAgent.indexOf("Win") == -1)
  	{	
    		dlWindow = window.open(sDir + "non_windows.htm","PostItnowin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=375,height=160");
	}else{
      		// IE Download Window
      		if(navigator.userAgent.indexOf("MSIE") >= 0 || navigator.userAgent.indexOf("Microsoft Internet Explorer") >= 0){
			if (bLite)
	  			dlWindow = window.open(sDir+ "download_liteie.htm", sName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=514,height=480");
			else
				dlWindow = window.open(sDir + "download_ie.htm", sName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=514,height=327"); 
		}else{
		// Netscape Download Window
			if (bLite)
				dlWindow = window.open(sDir + "download_litens.htm", sName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=514,height=496");
		        else
				dlWindow = window.open(sDir + "download_ns.htm", sName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=514,height=496");
		}
	}
  }
  dlWindow.focus();
}

// Simple parameter extraction from a URL
function PSNGetParam( sIn, sParam)
{
  rEXP = new RegExp( sParam + "=(.*)&", "i");
  if ((match = rEXP.exec( sIn)))
  {
    return match[1];
  } else {
    rEXP = new RegExp( sParam + "=([^&]*)$", "i");
    if ((match = rEXP.exec( sIn)))
    {
       return match[1];
    }
  }
  return "";
}

// Extracts parameters from the context string of a Post-it(R) Messenger Server
function PSNExtractParam( sContext, sParam) 
{
    var sRet = "";
    if (sContext.indexOf( sParam) >= 0) 
    {
      var sWorking;
      sWorking = sContext.substr( sContext.indexOf( sParam));
      if (sWorking.indexOf( "=") >= 0) 
      {
        sWorking = sWorking.substr( sWorking.indexOf( "=") + 1);
		sRet = sWorking;
		if (sWorking.indexOf("&") >= 0) 
		{
		  sRet = sWorking.substr( 0, sWorking.indexOf( "&"));
		  sWorking = sWorking.substr( sWorking.indexOf( "&") + 1);
			
		  // include all & until the last one  
 		  while ((sWorking.indexOf("&") >= 0) && (sWorking.indexOf( "&") < sWorking.indexOf("=")))
		  {
  			sRet = sRet + "&" + sWorking.substr( 0, sWorking.indexOf( "&"));
			sWorking = sWorking.substr( sWorking.indexOf( "&") + 1);
	          }
		  if (sWorking.indexOf( "=") < 0)
  	        	sRet = sRet + "&" + sWorking;
           }
       }
    }
    return sRet;	
 }

// Inserts the Post-it(R) Logo image with Preview, download and (optional) subscribe button
// Assumes the caller implements three javascript methods
//	popup_preview
//	popup_download
//	popup_subscribe (optional if not using the subscribe button)
function PSNMedallion( bSubscribe, sSpec )
{
	if (bSubscribe) {
	  document.writeln( "<IMG height=173 alt=\"Post-it Software Notes\" src=\"" + PSNURL( "images/post_it_note.gif") + "\" width=150 useMap=#psn border=0>");
	  document.writeln( "<MAP name=psn>");
	  document.writeln( "<AREA shape=RECT alt=Preview coords=37,104,109,122  href='javascript:PSNPreview(\"" + sSpec + "\")'>");
	  document.writeln( "<AREA shape=RECT alt=\"Free Download\" coords=32,126,117,142 href='javascript:PSNDownload( \"" + sSpec + "\")'>");
	  document.writeln( "<AREA shape=RECT alt=Subscribe coords=39,147,109,162 href=\"javascript:PSNSubscribe()\">");
	  document.writeln( "</MAP>");
	} else {
	  document.writeln( "<IMG height=154 alt=\"Post-it Software Notes\" src=\"" + PSNURL( "images/post_it_note1.gif") + "\" width=150 useMap=#psn border=0>");
	  document.writeln( "<MAP name=psn>");
	  document.writeln( "<AREA shape=RECT alt=Preview coords=37,104,109,122  href='javascript:PSNPreview(\"" + sSpec + "\")'>");
	  document.writeln( "<AREA shape=RECT alt=\"Free Download\" coords=32,126,117,142 href='javascript:PSNDownload( \"" + sSpec + "\")'>");
	  document.writeln( "</MAP>");
	}
}

// Inserts the Post-it(R) Logo image with Preview, download and (optional) subscribe button
// Assumes the caller implements three javascript methods
//	popup_preview
//	popup_download
//	popup_subscribe
function PSNMedallion_Small( bSubscribe, sSpec )
{
	document.writeln( "<IMG height=110 alt=\"Post-it Software Notes\" src=\"" + PSNURL( "images/post_it_notesmall.gif") + "\" width=95 useMap=#psnsmall border=0>");
	document.writeln( "<MAP name=psnsmall>");
	document.writeln( "<AREA shape=RECT alt=Preview coords=12,56,81,69  href='javascript:PSNPreview(\"" + sSpec + "\")'>");
	document.writeln( "<AREA shape=RECT alt=\"Free Download\" coords=6,75,88,87 href='javascript:PSNDownload( \"" + sSpec + "\")'>");
	document.writeln( "<AREA shape=RECT alt=Subscribe coords=15,92,82,104 href=\"javascript:PSNSubscribe()\">");
	document.writeln( "</MAP>");
}


function PSNDownloadButton( sSpec)
{
	//  document.writeln( "Hello WOrld");
	document.writeln( "<A href='javascript:PSNDownload( \"" + sSpec + "\")'>");
	document.writeln( "<IMG width=100 height=78 alt=\"Post-it Software Notes\" src=\"" + PSNURL( "images/download2.jpg") + "\" border=0 /></A>");
}


function IsIE7OnVista()
{
	//Browser and OS variables
	var Win, IE, IE7;
	var strPos, subStr;
	
	// Are we running on Windows
	if ( ( (navigator.appVersion.indexOf('Win')!=-1) || (navigator.appVersion.indexOf('NT')!=-1) ) && !(navigator.appVersion.indexOf('Mac')!=-1) )
		Win = true;
	else
		Win = false;

	// Determine if using Internet explorer..don't know what version of IE yet		
	IE = ((navigator.userAgent.indexOf('MSIE')!=-1) && !(navigator.userAgent.indexOf('Opera')!=-1)) ? true : false;
	
	if( IE )
	{
		strPos = navigator.userAgent.indexOf('MSIE');
		subStr = navigator.userAgent.substr( (strPos + 5), 3 );
		
		// Are we running IE7?
		IE7 = (IE && (subStr.substring(0, 1) == 7)) ? true : false;
	}
	
	if( (true == IE7) && (true == Win) )
		return true;
	else
		return false;
}

function IsIE7()
{
    var ie7 = (document.all && !window.opera && window.XMLHttpRequest) ? true : false;
    
    if( ie7 )
		return true;
    else
        return false;
}




