/********** IdeaBlade JavaScript For 2nd Website*****************
 *
 *
 * Load on every page before menu_var and menu_com
 *
 * Date      Who      Comment
 * --------  -------  ----------------------------------
 * 05/24/05  ---      Created to provide standard material
  ********************************************************/
  
function Go(){return;} // needed by menu_com.js

//******** IBGlobals = collection of IdeaBlade global vars
  function IBGlobalsInit(){
		// Path = Current URL path after domain & port & 1st '/' (corrected for local test)
		// Level = Current URL's depth from domain (from www.ideablade.com). 0=root level
		// Art = rel. addr of art directory (where most images kept)
		// PathToRoot = rel. addr to root
		// Section = Current URL's website section name; derived from directory off root
			if (!window.IBGlobals) IBGlobals = new Object();
		// Derivation of base path is messy when site is on local drive. Have to strip from front to root dir
		// These are known local root directory names.
		IBGlobals.LocalBasePathJunk = new Array ("IdeaBladeWebsite", "IdeaBlade");
		IBGlobals.Path = path = FindPagePath();
		IBGlobals.Level = level = FindDirLevel(path); // depth: 0 = top level
		IBGlobals.Root = "/";
		IBGlobals.PathToRoot=IBGlobals.Root; // old name.
 	 	
		IBGlobals.Images=IBGlobals.Root+"images/"
		IBGlobals.PrivacyPolicy = IBGlobals.Root + "privacy.html";
		IBGlobals.Spacer=IBGlobals.Images+'spacer.gif'
		
		IBGlobals.SubscriptionHref='http://visitor.constantcontact.com/email.jsp?m=1100999988889';
		IBGlobals.SubscriptionAnchorTag = '<a href="'+IBGlobals.SubscriptionHref+'" target="_blank">';

}

IBGlobalsInit();

// Find depth (level) in a path. 0= top level
function FindDirLevel(pPath) {
	var slashes = path.match(/[\\\/]/g); // count forward & backward slashes for directory depth
	return (slashes == null) ? 0 : slashes.length-1;
}

// Find the page path of this site (from protocol through the root dir)
function FindPagePath() {
	var path=document.location.pathname;
	// strip junk from front of local drive pathname
	if (""==document.location.host || "localhost" == document.location.host) {
	  // junk in local path names change depending on local environment; Which one are we using now?
	  basePathJunk = IBGlobals.LocalBasePathJunk;
	  for (var i=0; i < basePathJunk.length; i++) {
	    var ix = path.indexOf(basePathJunk[i]);
	    if (ix > -1)  {
	     // alert(path+" : "+basePathJunk[i]+" : "+(ix + basePathJunk[i].length));
	     path = path.substring(ix + basePathJunk[i].length);
	     break;
	    }
	  }
	}
	return path;
}

//********* Html Snippets *****

function TourLaunch(pTourURL) {
	pTourURL=IBGlobals.PathToRoot+pTourURL
    var w=window.open(pTourURL,"Tour","width=768,height=550,border=0");
    w.focus();
}

function BannerHtml() {
  var s = '<tr><td valign="top">'+
				'<div id="toolbar"><a href="/forum">Forum</a> | <a href="https://store.ideablade.com/default.asp" target="_blank">Online Store</a> | <a href="'+IBGlobals.Root+'contact_us.html">Contact Us</a></div>'+
				'<a href="'+IBGlobals.Root+'index.html"><img src="'+IBGlobals.Images+'ideablade_logo_tm.png" style="float:left;" border="0"></a><img src="'+IBGlobals.Images+'tagline2.gif" alt="Build Better Apps Faster" style="float:right;">'+
			'</td></tr>';

  //alert(s);
  return s;
}

function WriteBannerHtml() {
  document.write(BannerHtml())
}

function SpaceAfterBannerTable() {
    var s = '<tr><td width="800"><table width="626" border="0" cellspacing="0" cellpadding="0"><tr><td height="21"></td></tr></table></td></tr>';
    document.write(s);
}

// Menus HTML at top of page
function MenuHtml() {
	var s='<tr><td width="800"><table width="626" border="0" cellspacing="0" cellpadding="0" height="21"><tr height="21">'+
		'<td width="114" height="21"><a href="'+IBGlobals.Root+'index.html"><img src="'+IBGlobals.Images+'home_off.jpg" alt="" height="21" width="114" border="0" /></a></td>'+
		'<td width="114" height="21"><a href="'+IBGlobals.Root+'about_summary.html"><img src="'+IBGlobals.Images+'about_off.jpg" alt="" height="21" width="114" border="0" /></a></td>'+
		'<td width="114" height="21"><a href="'+IBGlobals.Root+'products_summary.html"><img src="'+IBGlobals.Images+'products_off.jpg" alt="" height="21" width="114" border="0" /></a></td>'+
		'<td width="115" height="21"><a href="'+IBGlobals.Root+'customers_summary.html"><img src="'+IBGlobals.Images+'customers_off.jpg" alt="" height="21" width="115" border="0" /></a></td>'+
		'<td width="114" height="21"><a href="'+IBGlobals.Root+'partners_summary.html"><img src="'+IBGlobals.Images+'partners_off.jpg" alt="" height="21" width="114" border="0" /></a></td>'+
		'<td width="115" height="21"><a href="'+IBGlobals.Root+'developers_summary.html"><img src="'+IBGlobals.Images+'developers_off.jpg" alt="" height="21" width="115" border="0" /></a></td>'+
		'<td width="114" height="21"><a href="'+IBGlobals.Root+'support_summary.html"><img src="'+IBGlobals.Images+'support_off.jpg" alt="" height="21" width="114" border="0" /></a></td>'+
		
		
		'</tr></table></td></tr>';
  //alert(s);
  return s;
}

function WriteMenuHtml() {
  document.write(MenuHtml())
}

// Html for the right-side column material such as "Free version"
// Can exclude item(s) by providing item name(s), separated by ";"
// For example, "Nutshell;Videos" will omit those items.
// Spelling must be exact.
function RightColumnHtml(pExclude){
  
  var download =
    '<tr><td align="center" valign="top" width="122"><a href="'+IBGlobals.Root+'downloads.html"><img src="'+IBGlobals.Images+'secondary_free_version.jpg" alt="" height="81" width="116" border="0"></a></td></tr>';
  var news =
    '<tr><td align="center" valign="top" width="122">'+IBGlobals.SubscriptionAnchorTag+'<img src="'+IBGlobals.Images+'secondary_news.jpg" alt="" height="29" width="116" border="0"></a></td></tr>';
  var videos =
    '<tr><td align="center" valign="top" width="122"><a href="'+IBGlobals.Root+'videos.html"><img src="'+IBGlobals.Images+'secondary_videos.jpg" alt="" height="29" width="116" border="0"></a></td></tr>';
  var tour =
    '<tr><td align="center" valign="top" width="122"><a href="'+IBGlobals.Root+'ArchitectureStackMovie/ArchitectureStackMovie.html"><img src="'+IBGlobals.Images+'secondary_architecture.jpg" alt="" height="29" width="116" border="0"></a></td></tr>';
  var nutshell =
    '<tr><td align="center" valign="top" width="122"><a href="'+IBGlobals.Root+'product_nutshell.html"><img src="'+IBGlobals.Images+'ideaBladeInANutshell.gif" alt="" border="0"></a></td></tr>';
    
	var s='<td align="center" valign="top" width="172" background="'+IBGlobals.Images+'right_dots.jpg">'+						  
  '<table width="172" border="0" cellspacing="10" cellpadding="0">';

  // Exclusions. Must match the spelling in the 'indexOf(...)' expression  
  var excluded = pExclude+";";
  if (-1 == excluded.indexOf("Download;")) s+=download;
  if (-1 == excluded.indexOf("News;")) s+=news;
  if (-1 == excluded.indexOf("Videos;")) s+=videos;
  if (-1 == excluded.indexOf("Tour;")) s+=tour;
  if (-1 == excluded.indexOf("Nutshell;")) s+=nutshell;
    
  s+='</table></td></tr></table></td>';
  return s;
}

// Write the Html for the right-side column material
// See RightColumnHtml() for details
function WriteRightColumnHtml(pExclude){
  document.write(RightColumnHtml(pExclude));
}

// Html for the title in the middle column + the "Keep me updated" advisory.
// pTitleHtml is the title stuff. 
// Could be as simple as "The Title" or complex with an embedded image (see Funhouse.html).
function TitleWithSubscriptionHtml(pTitleHtml, pWidth){
var width = (!pWidth) ? "95%" : pWidth;
var s='<table width="'+width+'" border="0" cellspacing="0" cellpadding="0">'+
  '<tr valign="middle"><td align="left" valign="middle" class="blue">'+
  pTitleHtml+ //e.g. 'Videos <img src="../images/viewmovie.jpg" alt="">'
	'</td><td align="right">'+
	'<table border="0" cellspacing="0" cellpadding="0" align="right"><tr><td width="24" >'+
	IBGlobals.SubscriptionAnchorTag +
	'<img src="../images/mail_icon.gif" width="24" height="23" border="0">'+
	'</a></td><td align="right">'+
	IBGlobals.SubscriptionAnchorTag +
	'&nbsp;Keep me updated</a></td></tr></table>'+
	'<td></tr></table><br>';
	//alert(s);
	return s;
}

function WriteTitleWithSubscriptionHtml(pTitleHtml, pWidth){
  document.write(TitleWithSubscriptionHtml(pTitleHtml, pWidth));
}

// HTML at foot of page
function FooterHtml() {
var s= '<tr><td><table cellpadding="0" cellspacing="0" border="0" width="100%"><tr>'+
				  	'<td class="footer">&nbsp;&nbsp;&nbsp;&copy; Copyright IdeaBlade</td>'+
					'<td class="footer-links"><a href="'+IBGlobals.Root+'sitemap.html">Sitemap</a> | <a href="'+IBGlobals.Root+'privacy.html">Privacy</a> | <a href="'+IBGlobals.Root+'feedback.html">Feedback</a>'+
					'</td>'+
		'</tr></table></tr>';

  return s;
}

function SubscribeLinkHtml() {
  return IBGlobals.SubscriptionAnchorTag+'Subscribe</a>';
  // return '<a href="'+IBGlobals.Root+'subscribe.html">Subscribe</a>';
}

function WriteFooterHtml() {
  document.write(FooterHtml())
}

// Wrap text in a note block
// "Performance note" is an example
function NoteHtml(pText, pClass) {
  if (!pClass) pClass="note";
  s='<table class="'+pClass+'" cellpadding="4px" ><tr><td>'+pText+'</tr><td></table>';
  return s;
}

function WriteNoteHtml(pText, pClass) {
  document.write(NoteHtml(pText, pClass));
}

//===============================================================
// Privacy Note Html
function PrivacyNoteHtml() {
  var privacy ='<span class="header2">Your Privacy:</span>&nbsp; We do not share this information with third parties.&nbsp; '+
     'Please review our '+ PrivacyPolicyLinkHtml() + ' to learn more.</p>'; 
	return NoteHtml(privacy);
}

function WritePrivacyNoteHtml() {
  document.write(PrivacyNoteHtml())
}

function PrivacyPolicyLinkHtml(pStyle){
 var style = (pStyle == null) ? "" : style=' style="'+pStyle+'" ';
  return '<a href="'+IBGlobals.PrivacyPolicy+'" target="_blank" '+style+'>Privacy Policy</a>';
}

function WritePrivacyPolicyLink(pStyle) {document.write(PrivacyPolicyLinkHtml(pStyle));}

//===============================================================
// IdeaBlade for .NET 1.1 System Requirements
// Carried forward from ideablade.js

function WriteIBDownloadSystemRequirements(pIsDevForce) {
  if (!pIsDevForce) {
    var s='<p><Div class="blurb" style="FONT-WEIGHT: bold; MARGIN-BOTTOM: 4px">IdeaBlade 2.x System requirements:</Div>'+
          'IdeaBlade applications built with releases prior to version 3.0 (such as IdeaBlade-Lite) require <a href="http://msdn.microsoft.com/netframework/downloads/howtoget.aspx" target="_blank">'+
          '.NET framework 1.1</a>. IdeaBlade development requires <a href="http://msdn.microsoft.com/vstudio/Previous/2003/" target="_blank">'+
          'Visual Studio 2003</a>. '+
          'Additionally, our tutorials require Microsoft SQL Server 2000 or Microsoft SQL Server 2000 Desktop Engine (MSDE).'+
          '<p>We often feature the Developer Express UI controls suite in our tutorials. '+
          'Here you can <a href="/resources/DevExEval.exe">'+
          'download the DevEx evaluation copy</a> that works with this IdeaBlade version.</p>';
    } else {
    var s='<p><Div class="blurb" style="FONT-WEIGHT: bold; MARGIN-BOTTOM: 4px">IdeaBlade DevForce 3.x System requirements:</Div>'+
          'IdeaBlade DevForce 3.x applications require the commercial release of .NET framework 2.0. '+
          'DevForce developers can use any edition of Visual Studio 2005 although we recommend a version that includes TeamTest. '+
          'Our tutorials require Microsoft SQL Server 2000 or later; '+
          'They work fine with Microsoft SQL Server 2005 Express and Microsoft SQL Server 2000 Desktop Engine (MSDE). '+
          'DevForce Express and Professional Editions are licensed for use with Microsoft SQL Server databases only.' +
          '</p>'
    }
    document.write(s);
  }
  
//===============================================================
// Ward's Blog
  		
		function WardBlogHtml(){
		  var label = "Ward's blog";
		  var s='<span class="link"><a class="link" href="http://www.neverindoubtnet.blogspot.com/" target="_blank">'+
		  label+'&nbsp;<img src="../images/blog.gif" alt="blog" border="0"/></a></span>';
		  return s;
		}
		
		function WriteWardBlog() {
		document.write(WardBlogHtml());
		}

//===============================================================
// Cookie Management Fns

function Get_Cookie(name) { 
   var start = document.cookie.indexOf(name+"="); 
   var len = start+name.length+1; 
   if ((!start) && (name != document.cookie.substring(0,name.length))) return null; 
   if (start == -1) return null; 
   var end = document.cookie.indexOf(";",len); 
   if (end == -1) end = document.cookie.length; 
   return unescape(document.cookie.substring(len,end)); 
} 

function Set_Cookie(name,value,expires,path,domain,secure) { 
    var cookieString = name + "=" +escape(value) + 
       ( (expires) ? ";expires=" + expires.toGMTString() : "") + 
       ( (path) ? ";path=" + path : "") + 
       ( (domain) ? ";domain=" + domain : "") + 
       ( (secure) ? ";secure" : ""); 
    document.cookie = cookieString; 
} 

function Delete_Cookie(name,path,domain) { 
   if (Get_Cookie(name)) document.cookie = name + "=" + 
      ( (path) ? ";path=" + path : "") + 
      ( (domain) ? ";domain=" + domain : "") + 
      ";expires=Thu, 01-Jan-70 00:00:01 GMT"; 
} 

//===============================================================
// Site Entrance Info

var mEntranceInfoCookieName = "EntranceInfo"; // cookie name

///<summary>Entrance Info "Class".</summary>
function EntranceInfo() {
	this.Referrer="" ;
	this.Url="";
	this.Hash="";
	this.Search="" ;
	this.Agent="";
}

// Add "ToString" method to EntranceInfo class
EntranceInfo.prototype.toString = EntranceInfoToString;

function EntranceInfoToString(){
	result="url="+this.Url;
	result+=";hash="+this.Hash;
	result+=";search="+this.Search;
	result+=";referrer="+this.Referrer;
	result+=";agent="+this.Agent;
	return result;
}

// Add "SetFromCookieText" method to EntranceInfo class
EntranceInfo.prototype.SetFromCookieText = SetFromCookieText;

function SetFromCookieText(pText){
  splitText = pText.split(";");
  s=splitText[0];
  this.Url = s.substring(s.indexOf("=")+1);
  s=splitText[1];
  this.Hash = s.substring(s.indexOf("=")+1);
  s=splitText[2];
  this.Search = s.substring(s.indexOf("=")+1);
  s=splitText[3];
  this.Referrer = s.substring(s.indexOf("=")+1);
  s=splitText[4];
  this.Agent = s.substring(s.indexOf("=")+1);
}

///<summary>Get Entrance Info from cookie if exists, else make it and save cookie.</summary>
function GetEntranceInfo() { 
 var result = new EntranceInfo();
 if (Get_Cookie(mEntranceInfoCookieName)) {
   result.SetFromCookieText(Get_Cookie(mEntranceInfoCookieName)); 
 }else{ 
   result = MakeEntranceInfo();
   SetEntranceInfoCookie(result);
 } 
 return result;
}

///<summary>Save EntranceInfo in EntranceInfo cookie.</summary>
function SetEntranceInfoCookie(pEntranceInfo) { 
  Set_Cookie(mEntranceInfoCookieName, pEntranceInfo.toString(), GetEntranceInfoCookieExpireDate()); 
} 

///<summary>Get EntranceInfo cookie expiration date.</summary>
///<remarks>14 days from today.</remarks>
function GetEntranceInfoCookieExpireDate() {
	expireDate = new Date();
	expireDate.setDate(expireDate.getDate() + 14) ; // Today + 2 weeks
	return expireDate;
}

///<summary>Make EntranceInfo from current document.</summary>
function MakeEntranceInfo(){
 	if(top.document.location==document.referrer || (document.referrer == '' && top.document.location != '')) {
 	  urlSource = top.document;
 	} else {
    urlSource = document;
 	}
  
  result = new EntranceInfo();
	result.Url=""+urlSource.location.protocol+urlSource.location.host+urlSource.location.port+urlSource.location.pathname;

  SetHashAndSearchFromUrl(result, urlSource);
	
	result.Referrer="" +urlSource.referrer;
	result.Agent="" 
	if (urlSource.agent) result.Agent="" + urlSource.agent;
	
	return result
}

///<summary>Set EntranceInfo's Hash and Search properties from Url text.</summary>
///<remarks>
/// Extract both hash and search parts from the Url text.
/// Accounts from peculiar fact that, if url has both parts,
/// the location.hash property has both and the location.search property is empty.
///</remarks>
function SetHashAndSearchFromUrl(pEntranceInfo, pUrl){
	hash = "" + pUrl.location.hash.substring(1);
	questionIndex = hash.indexOf("?"); // '?' marks start of search part
	if (-1 < questionIndex) {
	  pEntranceInfo.Hash=hash.substring(0, questionIndex);
	  pEntranceInfo.Search=hash.substring(questionIndex+1);
	} else {
	  pEntranceInfo.Hash = hash;
	  pEntranceInfo.Search ="" +pUrl.location.search.substring(1);
	}
}

///<summary>Write HTML for EntranceInfo's hidden field in form.</summary>
///<remarks>
///Invoke in a registration page that captures EntranceInfo "cookie".
///For ex: http://www.ideablade.com/DevForceExpress_Home/registerDownload.aspx
///</remarks>
function WriteEntranceInfoField(){
  s='<INPUT type="hidden" id="EntranceInfo" name="EntranceInfo" value="' + 
    mEntranceInfo.toString() + '" runat="server">';
  document.write(s);
}
//===============================================================
// Get EntranceInfo

var mEntranceInfo= GetEntranceInfo(); // Get module EntranceInfo from cookie

//Delete_Cookie(mEntranceInfoCookieName); // uncomment during testing
//alert(mEntranceInfo.toString()); // testing
//
//pop up window function
// This is the function that will open the
// new window when the mouse is moved over the link
         function open_new_window() {
             new_window = open("", "hoverwindow", "width=600,height=400,left=900,top=100");

             // open new document 
             new_window.document.open();

             // Text of the new document
            // Replace your " with ' or \" or your document.write statements will fail
            new_window.document.write("<html><title>IdeaBlade at MIX 2009</title>");
            new_window.document.write("<body bgcolor=\"#FFFFFF\">");
            new_window.document.write("<h3>MIX09-T69M Microsoft Silverlight Is Ready for Business</h3>");
            new_window.document.write("<div style=color:\#008000\>Thursday March 19 |4:40 PM-5:00 PM | San Polo 3401<br>");
            new_window.document.write("By: Ward Bell<br>Tags: Silverlight<br></div>");
            new_window.document.write("<hr \align=left width=300\>");
            new_window.document.write("<p>Come learn how to build a Silverlight business application today with the new UI features including DataGrid, DataForm, validation and navigation. Also see an example of how to connect to services using a LINQ enabled, Entity Framework-backed, data management solution.</p>");
            new_window.document.write("<p>Ward Bell is Vice President of Technology at IdeaBlade where he is responsible for the product direction of the DevForce .NET application framework, a product targeting smart client development. That product extends the ADO.NET Entity Framework with n-tier, client caching, and Silverlight support. Ward spent much of the last 30 years programming line-of-business applications for numerous companies including several of the Fortune 100. He is a Solutions Architect MVP. His blog is Never In Doubt. </p>");
            new_window.document.write("</body></html>");

             // close the document
             new_window.document.close();
         }

         // This is the function that will close the
         // new window when the mouse is moved off the link
         function close_window() {
             new_window.close();
         }
         
         // These functions will swap images on mouseover
         function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
         
         function MM_swapImgRestore() { //v3.0
            var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
         }
         
        function MM_swapImage() { //v3.0
        var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
        if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
        }