/*Document Name : Left navigation output script
Owner		: GEMS
Type 		: Javascript 1.2 
Author 	: hathip
Description	: To display the links of left navigation in html format which were captured by it's data capture form.
In left navigation , one can have links organised maximum upto 2 levels.
CTQs - 1. The link if points to current page should be marked with 'global bullet' else by 'global arrow'.
 */
//this function is written to check if the Inputted link matches the current url

function IsCurrentUrl( cpath, ipath) 
{
  if( ( cpath.indexOf(ipath) )< 0 )
  {
    return(0);
  }
  else
  {
    return(1);
  }
}

//This function is written to replace the space character in the inputted link to %20 as in the browser 
function ReplaceSpace( str )
{

  var  ipath = "";	
  for ( l=0 ; l< str.length ; l++)
  {

    if (str.charAt(l) == " " )
    {
      ipath += '%20' ;
    }	
    else
    {
      ipath += str.charAt(l) ;
    }
  }

  return(ipath);
}
var CurrentUrl =window.location.href ;	 //This var contains the current window url


var span_arrow = '<span class="globalArrow">&gt;&#160;</span>';
var span_bullet = '<span class="globalBullet">&#8226;&#160;</span>';
var span_space = '<span class="globalArrow">&#160;&#160;</span>' ;
if(typeof(nav)!= "undefined"){
var a='<!-- ========= BEGIN LEFT SUB NAVIGATION (B01) ========== -->';

var nav_ln = nav.length ;
if(isNn != -1){
  nav_ln = nav_ln +1;
}

a += '<table cellpadding="0" cellspacing="0" border="0" width="153">';
a += '<tr><td class="globalBodyCopy">';
for(var i=0;i<(nav_ln-1);i++){
  // The Menu Header starts here
  a += '<div class="sideNavOutdent">';
  if (nav[i][0] != "")
  {
    if (nav[i][1] != "")
    {
      var str = nav[i][1];
      var InputUrl = ReplaceSpace(str);
      if( IsCurrentUrl(CurrentUrl , InputUrl) ) 
      {
	a += span_bullet ;	// This points to current page 
	a += '<span class="sideNavHeadingCurrent">' ;
      }
      else
      {
	a += span_arrow ; 	// This does not point to current page 
	a += '<a href="' + nav[i][1] + '" class="sideNavHeading">' ; //Level 1 link goes here
      }
    }

    else  //If  item is not linked
    {
      a += span_space ;
      a += '<span class="sideNavHeading">';
    }
    a += nav[i][0] ; // The level 1 text goes here

    if ((nav[i][1] != "") && (!IsCurrentUrl(CurrentUrl , InputUrl)))
    {
      a += '</a>' ;
    }
    else
    {
      a += '</span>';
    }

    a +='</div>';
    
  }
  //The menu items will come here 

  var menu_ln = nav[i][2].length ;
  if(isNn != -1){
    menu_ln = menu_ln +1;
  }	
  for(j=0;j<(menu_ln-1);j++)
  {
    //Level 1 item starts here
    a += '<div class="sideNavOutdent">';
    //alert(nav[i][2][j][0]);
    if (nav[i][2][j][1] != null)	// if level 1 item is linked 
    {

      var str = nav[i][2][j][1];
      var InputUrl = ReplaceSpace(str);

      if( IsCurrentUrl(CurrentUrl , InputUrl) ) 
      {
	a += span_bullet ;	// This points to current page 
	a += '<span class="sideNavLinkCurrent">' ;
      }
      else
      {
	a += span_arrow ; 	// This does not point to current page 
	a += '<a href="' + nav[i][2][j][1] + '" class="sideNavLink">' ; //Level 1 link goes here
      }
    }
    else  //If level 1 item is not linked
    {
      a += span_space ;
      a += '<span class="sideNavLink">';
    }
    a += nav[i][2][j][0] ; // The level 1 text goes here

    if ((nav[i][2][j][1] != null) && (!IsCurrentUrl(CurrentUrl , InputUrl)))
    {
      a += '</a>' ;
    }
    else
    {
      a += '</span>';
    }

    a +='</div>';
  }

  a+='<!-- vertical spacers must be enclosed in div tags to ensure cross-browser compatibility -->';
  a+='<div><img src="' + gr + '/images/global/spacer.gif" width="2" height="10" alt="" border="0" /></div>';
}
if (typeof(acct) != "undefined")
{
  a+='<div class="iconOutdent">';
  a+='<a href="'+ accu + '" class="iconLink">';
  a+='<img src="' + gr + '/images/icon_person.gif" width="16" height="11" alt="" border="0"></a>&nbsp;&nbsp;';
  a+='<a href="'+ accu + '" class="iconLink">';
  a+= acct; 
  a+='</a></div>';
  a+='<!-- vertical spacers must be enclosed in div tags to ensure cross-browser compatibility -->';
  a+='<div><img src="' + gr + '/images/global/spacer.gif" width="2" height="10" alt="" border="0" /></div>';
}
if (typeof(mailt) != "undefined")
{
  a+='<div class="iconOutdent">';
  a+='<a href="'+ mailu +'" class="iconLink">';
  a+='<img src="' + gr + '/images/icon_mail.gif" width="16" height="11" alt="" border="0"></a>&nbsp;&nbsp;';
  a+='<a href="'+ mailu +'" class="iconLink">';
  a+= mailt; 
  a+='</a></div>';
  a+='<!-- vertical spacers must be enclosed in div tags to ensure cross-browser compatibility -->';
  a+='<div><img src="' + gr + '/images/global/spacer.gif" width="2" height="10" alt="" border="0" /></div>';
}
if (typeof(contact_us_text) != "undefined")
{
  a+='<div class="iconOutdent">';
  a+='<a href="'+ contact_us_url +'" class="iconLink">';
  a+='<img src="' + gr + '/images/icon_phone.gif" width="16" height="11" alt="" border="0"></a>&nbsp;&nbsp;';
  a+='<a href="'+ contact_us_url +'" class="iconLink">';
  a+= contact_us_text; 
  a+='</a></div>';
  a+='<!-- vertical spacers must be enclosed in div tags to ensure cross-browser compatibility -->';
  a+='<div><img src="' + gr + '/images/global/spacer.gif" width="2" height="10" alt="" border="0" /></div>';
}

a+='<!-- ========= BEGIN LEFT SUB NAVIGATION CONTAINER ========== -->';
for(var i=0;i<navbox.length-1;i++)

{

  if(navbox[i][0]=="b"){
    a+='<table class="relatedItemsContainer" width="153" cellspacing="0" cellpadding="0" border="0" >';
  }
  else
  {
    a+='<table class="salesContainer" width="153" cellspacing="0" cellpadding="0" border="0" >';
  }
  a+='<tr class="layout">';
  a+='<td><img src="' + gr + '/images/global/spacer.gif" alt="" width="1" height="1" border="0" /></td>';
  a+='<td><img src="' + gr + '/images/global/spacer.gif" alt="" width="5" height="1" border="0" /></td>';
  a+='<td><img src="' + gr + '/images/global/spacer.gif" alt="" width="138" height="1" border="0" /></td>';
  a+='<td><img src="' + gr + '/images/global/spacer.gif" alt="" width="5" height="1" border="0" /></td>';
  a+='<td><img src="' + gr + '/images/global/spacer.gif" alt="" width="4" height="1" border="0" /></td>';
  a+='<td><img src="' + gr + '/images/global/spacer.gif" alt="" width="1" height="1" border="0" /></td>';
  a+='</tr>';
  a+='<tr class="layout">';
  a+='<td><img src="' + gr + '/images/global/spacer.gif" alt="" width="1" height="20" border="0" /></td>';
  a+='<td><img src="' + gr + '/images/global/spacer.gif" alt="" width="1" height="1" border="0" /></td>';
  a+='<td style="color:#ffffff;font-weight:bold;">';
  a+=navbox[i][1];
  a+='</td>';
  a+='<td><img src="' + gr + '/images/global/spacer.gif" alt="" width="1" height="1" border="0" /></td>';
  a+='<td align="right" valign="bottom"><img src="' + gr + '/images/global/lower_corner3.gif" width="3" height="3" alt="" border="0"></td>';
  a+='<td><img src="' + gr + '/images/global/spacer.gif" alt="" width="1" height="1" border="0" /></td>';
  a+='</tr>  ';
  a+='<tr class="layout">';
  a+='<td><img src="' + gr + '/images/global/spacer.gif" alt="" width="1" height="5" border="0" /></td>';
  a+='<td colspan="4" style="background:#ffffff;"><img src="' + gr + '/images/global/spacer.gif" alt="" width="1" height="1" border="0" /></td>';
  a+= '<td><img src="' + gr + '/images/global/spacer.gif" alt="" width="1" height="1" border="0" /></td>';
  a+='</tr>';    

  a+='<tr class="layout">';
  a+='<td><img src="' + gr + '/images/global/spacer.gif" alt="" width="1" height="1" border="0" /></td>';
  a+='<td style="background:#ffffff;"><img src="' + gr + '/images/global/spacer.gif" alt="" width="1" height="1" border="0" /></td>';
  a+='<td style="background:#ffffff;">';

  for(var j=0;j<navbox[i][2].length-1;j++)
  {

    a+='<div class="globalOutdent"><span class="globalArrow">&gt; </span>';
    a+='<a href="' + navbox[i][2][j][1] + '" class="sideNavLink">' ; 
    a+=navbox[i][2][j][0];
    a+='</a></div>';   

  }
  a+= '</td>';

  a+='<td colspan="2" style="background:#ffffff;"><img src="' + gr + '/images/global/spacer.gif" alt="" width="1" height="1" border="0" /></td>';
  a+='<td><img src="' + gr + '/images/global/spacer.gif" alt="" width="1" height="1" border="0" /></td>';
  a+='</tr>';
  a+='<tr class="layout">';
  a+='<td><img src="' + gr + '/images/global/spacer.gif" alt="" width="1" height="5" border="0" /></td>';
  a+='<td colspan="4" style="background:#ffffff;"><img src="' + gr + '/images/global/spacer.gif" alt="" width="1" height="1" border="0" /></td>';
  a+= '<td><img src="' + gr + '/images/global/spacer.gif" alt="" width="1" height="1" border="0" /></td>';
  a+='</tr>';  
  a+='<tr class="layout">';
  a+='<td colspan="6"><img src="' + gr + '/images/global/spacer.gif" alt="" width="1" height="1" border="0" /></td>';
  a+='</tr>';
  a+='</table>';

  a+='<!-- ========= END LEFT SUB NAVIGATION CONTAINER ========== -->';

  a+='<!-- vertical spacers must be enclosed in div tags to ensure cross-browser compatibility -->';
  a+='<div><img src="' + gr + '/images/global/spacer.gif" width="2" height="10" alt="" border="0" /></div>';
}
a+='</td>';
a+='</tr>';
a+='</table>';
document.write(a);		
}

