/*
						 ---------------------------------------------------------------------------------------------
						 File 		 	 : Left Navigation Output File
						 Description : This js file will render the left navigation links from a js file in 
						 							 the parent page where this js file is included. 							 						 
						 Creation Date : 23 Nov, 2004.
						 Author        : hathip
						 Last Modified : 23 Nov, 2004. 							
						 Modified By   : hathip
						 Key Changes   : 
						 ---------------------------------------------------------------------------------------------						 
*/


//Function IsCurrentUrl : This function will match the current browser url (cpath) , with the passed link (ipath)
function IsCurrentUrl( cpath, ipath) 
{
  if( ( cpath.indexOf(ipath) )< 0 )
  {
    return(0);
  }
  else
  {
    return(1);
  }
}

//Function ReplaceSpace : 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);
}

if(typeof(nav)!= "undefined"){
var a="" ;
var CurrentUrl =window.location.href ;	 //This var contains the current window url

for(var i=0;i<nav.length;i++){ // Loop for each navigation section
	
	
	// The first level link (i.e Navigation Section Title ) comes here

  if (nav[i][0] != "") //If Navigation Section Title Present 
  {
    if (nav[i][1] != "") // If Title Url present
    {
      var str = nav[i][1];
      var InputUrl = ReplaceSpace(str);
      if( IsCurrentUrl(CurrentUrl , InputUrl) ) 
      {
					a += '<ul class="breadcrumb">' ;
					a += '<li class="selected">' ;
    			a +=  nav[i][0] ;
    			a += '</li>';
    			a += '</ul>';
      }
      else
      {
					a += '<ul class="breadcrumb">' ;
					a += '<li>' ;
    			a += '<a href="' + nav[i][1] + '" target ="' + nav[i][2] + '">' + nav[i][0] + '</a>';
    			a += '</li>';
    			a += '</ul>';
    	}
		}
  	else  //If Navigation Section Title is not linked
  	{
  	 	a += '<ul class="navitemList">' ;
			a += '<li class="title">' ;
  		a += nav[i][0];
  		a += '</li>';
  		a += '</ul>';
  	}    
  }
  
  //The Second Level Link (i.e menu items) will come here   
  a += '<ul class="navitemList">';
  for(j=0;j<nav[i][3].length;j++)
  {
        
    if (nav[i][3][j][1] != null)	// if 2nd level item is linked 
    {

      var str = nav[i][3][j][1];
      var InputUrl = ReplaceSpace(str);       
      if( IsCurrentUrl(CurrentUrl , InputUrl) )  // If this is the link points to current page
      {
				a += '<li class="selected">';
    		a +=  nav[i][3][j][0] ;
  			a += '</li>';						
		  }
      else 		
      {
				 // The 2nd level link has sub links
				 if(nav[i][3][j][2] == "Y")
				 {				 
						a += '<li class="hasChildren">';
    				a += '<a href="' + nav[i][3][j][1] + '" target = "' + nav[i][3][j][3] + '">' + nav[i][3][j][0] + '</a>';
  					a += '</li>';	 				
  			 }
  			else // The 2nd level link has no sub links
  			 {
  					a += '<li>';
    				a += '<a href="' + nav[i][3][j][1] + '" target ="' + nav[i][3][j][3] +'">' + nav[i][3][j][0] + '</a>';
  					a += '</li>';	 				
  			 }  			 
      }
    }    
    else  //If level 1 item is not linked
    {
    		  	a += '<li>';
    				a +=  nav[i][2][j][0] ;
  					a += '</li>';	
    }    
  } 
   a+= '</ul>';
 }
 
 for(var i=0;i<navbox.length;i++)
 {
 		
		if (navbox[i][1] != "") //If Navigation Box Title Present 
  	{
    
  		
	  	 		if (navbox[i][2] != "") // If Title Url present
    	{
      	var str = navbox[i][2];
      	var InputUrl = ReplaceSpace(str);
      	if( IsCurrentUrl(CurrentUrl , InputUrl) ) 
      	{
					a += '<ul class="breadcrumb">' ;
					a += '<li selected">' ;
    			a +=  navbox[i][1] ;
    			a += '</li>';
    			a += '</ul>';
        }
        else
        {
					a += '<ul class="breadcrumb">' ;
					a += '<li>' ;
    			a += '<a href="' + navbox[i][2] + '" target = "' + navbox[i][3] + '">' + navbox[i][1] + '</a>';
    			a += '</li>';
    			a += '</ul>';
    	  }
		   } 
  		 else  //If Navigation Box Title is not linked
  		 {
	  	 	a += '<ul class="navitemList">' ;
				a += '<li class="title">' ;
  			a += navbox[i][1];
  			a += '</li>';
  			a += '</ul>';
  		 }    
  		     
  	 }
		
		//The Second Level Link of Navigation Box (i.e menu items) will come here   
    a += '<ul class="navitemList">';
  	for(j=0;j<navbox[i][4].length;j++)
  	{
		     
    	 if (navbox[i][4][j][1] != null)	// if 2nd level item is linked 
    	 {
      		var str = navbox[i][4][j][1];
      		var InputUrl = ReplaceSpace(str);       
      		if( IsCurrentUrl(CurrentUrl , InputUrl) )  // If this is the link points to current page
      		{
						a += '<li class="selected">';
    				a +=  navbox[i][4][j][0] ;
  					a += '</li>';						
		  		}
       		else 		
      		{
						 // The 2nd level link has sub links
				 	 	if(navbox[i][4][j][2] == "Y")
				 	 	{				 
							 	a += '<li class="hasChildren">';
  a += '<a href="' + navbox[i][4][j][1] + '" target ="' + navbox[i][4][j][3] + '">' + navbox[i][4][j][0] + '</a>';
  					 		a += '</li>';	 				
  			   	}
  				 	else // The 2nd level link has no sub links
  			   	{
		  					a += '<li>';
    						a += '<a href="' + navbox[i][4][j][1] + '" target ="' + navbox[i][4][j][3] + '">' + navbox[i][4][j][0] + '</a>';
  							a += '</li>';	 				
  			   	}  			 
        	}
     		}    
     		else  //If level 1 item is not linked
    		{
    		  	a += '<li>';
    				a +=  navbox[i][4][j][0] ;
  					a += '</li>';	
    		}
     } //End of forloop of  j
     
     a+= '</ul>';
   } //End of For loop of i
     a+='<br clear="all"/>';
if(typeof(acct)!= "undefined"){
if (acct !="")
{
 a+='<ul id="iconMyAccount">';
 a+='<li><a href="' + accu + '" target ="' + accw + '">' + acct + '</a></li>';
 a+='</ul>';
}
}
if(typeof(mailt)!= "undefined"){
if (mailt !="")
{
 a+='<ul id="iconMail">';
 a+='<li><a href="' + mailu + '" target ="' + mailw + '">' + mailt + '</a></li>';
 a+='</ul>';
}
}
if(typeof(contact_us_text)!= "undefined"){
if(contact_us_text != "")
{
 a+='<ul id="iconContactUs">';
 a+='<li><a href="' + contact_us_url + '" target="' + contact_us_window + '">' + contact_us_text + '</a></li>';
  a+='</ul>';
}
}
if(typeof(recommend_this_page_text)!="undefined"){
if(recommend_this_page_text!="")
{
a+='<ul id="iconRecommendthispage">';
a+='<li><a href="' + recommend_this_page_url + '?url='+document.URL+'" target ="' + recommend_this_page_window + '">' + recommend_this_page_text + '</a></li>';
a+='</ul>';
}
}

document.write(a);		
} //End of if


	
  
