//--------------------------------------------------------------------------------
//
//    File name   : dynamicTemplate.js
//    Project     : UWS Dynamic Template
//    Description : This js file used to display the Dynamic template menus 
//                  ,footer and tools js file loading process.
//    version     : 1.0 
//--------------------------------------------------------------------------------


//--------------------------------------------------------------------------------
// Dynamic Template server (Do not customoize)
// Server - http://www.honeywell.com
// Note: For testing, we have given staging server URL in the below.
//--------------------------------------------------------------------------------

var dtServer = "http://www51.honeywell.com";

//------------------------------------------------------------------------------------

/*  Secured pages (https) redirect code below  */



// Set the variable is to "Yes" if site is COMPLETELY secure and "No" if site is partially secure
var siteSecure="No";

// Set the Path of the Pages without any parameters
// For example:
// URL http://www.honeywell.com/sample/sample.html?c=41 should be entered into the array as
// /sample/sample.html

var secureList=[
['/sm/rheochem/contact-us.html']

];

if(siteSecure=="Yes") {
	// Site is completely secure
	if(window.location.protocol!="https:") {
		// Change the protocol from http -> https
	   	var secure_url = location.href;
	    	secure_url = "https://" + secure_url.substring(secure_url.indexOf('http://')+7, secure_url.length);
	    	window.location = secure_url;
  	}
} else {
	// Site may be completely insecure or partially secure
	var currURL = location.href;
	var currURLPath = location.pathname;
	var currURLProtocol = location.protocol;

	doesURLExist = false;
	for(index=0;index<secureList.length;index++) {
		if(currURLPath==secureList[index])	{
			doesURLExist = true;
			if(window.location.protocol!="https:") {
				// Redirect http to https protocol
			   	var secure_url = location.href;
			    secure_url = "https://" + secure_url.substring(secure_url.indexOf('http://')+7, secure_url.length);
	    		window.location = secure_url;
	  		}
	  		break;
		}
	}

	if(!doesURLExist) {
		if(window.location.protocol!="http:") {
			// Redirect https to http protocol
			var secure_url = location.href;
		  	secure_url = "http://" + secure_url.substring(secure_url.indexOf('https://')+8, secure_url.length);
    		window.location = secure_url;
    	}
	}
}

if (window.location.protocol!="http:") {
	dtServer = "https://www51.honeywell.com";
} else {
	dtServer = "http://www51.honeywell.com";
}


//----------------------------------------------------------------------------------

//--------------------------------------------------------------------------------
//
//  Color palettes are defined in the UWS Style Guide and different colors 
//  are typically aligned with different business units.
//   
//  Possible colours
//       - green
//       - navy
//       - indigo
//       - brightblue
//       - red
//       - darktan
//--------------------------------------------------------------------------------

var uws_palette = 'green';

//--------------------------------------------------------------------------------
var site = 'mysite';
//--------------------------------------------------------------------------------

//--------------------------------------------------------------------------------
//   N1N2 Menu controlling variable   
//        -  uws (menus will be loaded from the uws server)
//        -  custom (menus will be loaded from the n1n2filepath value) 
//---------------------------------------------------------------------------------

var menuType = "custom";  

//-------------------------------------------------------------------------------------
//  File path of the N1N2 menu variable.This value is needed if menuType set as 'own' 
//-------------------------------------------------------------------------------------

var n1n2filepath = '/sm/rheochem/common/scripts/N1N2menu.js';   

//--------------------------------------------------------------------------------
//  N1N2 Menu site id: Based on this value menus will be displayed.
//    Possible values
//          - honeywell (Honeywell)
//          - sm        (Specialty Material)
//          - em        (Electronic Material)
//          - rlss      (Research and Life science solutions)
//          - bandj     (Burdick & Jackson)
//          - gen       (Genetron® Refrigerants)
//          - genesolv  (Genesolv® Solvents)
//          - acs       (Automation and Control Solutions)
//          - aero      (Aerospace)
//          - turbo     (Turbo Technologies)       
//          - enovate   (Enovate® 3000)       
//--------------------------------------------------------------------------------

var n1n2MenuSiteID = 'honeywell';  


//--------------------------------------------------------------------------------
//
//  Breadcrumb type. 
//        -  uws (Breadcrumb will be loaded from the uws server.uws_breadcrumb must needed)
//        -  custom (Breadcrumb will be loaded from the n1n2filepath value) 
//
//--------------------------------------------------------------------------------

var breadcrumbType = 'uws';

//--------------------------------------------------------------------------------
//
//  UWS Breadcrumb
//          - honeywell (Honeywell)
//          - sm        (Specialty Material)
//          - em        (Electronic Material)
//          - rlss      (Research and Life science solutions)
//          - bandj     (Burdick & Jackson)
//          - gen       (Genetron® Refrigerants)
//          - genesolv  (Genesolv® Solvents)
//          - acs       (Automation and Control Solutions)
//          - aero      (Aerospace)
//          - turbo     (Turbo Technologies)       
//          - enovate   (Enovate® 3000)       
//  Custom Breadcrumb
//          - siteID ( Site id of your website)
//--------------------------------------------------------------------------------

var uws_breadcrumb = 'em';

//--------------------------------------------------------------------------------
//
//  Custom Breadcrumb 
//
//  custom_taxonomy_bc = { 'siteID' : ['ParentSiteID','mySiteURL','ImageFileWithSiteName'] };
//
//--------------------------------------------------------------------------------

var custom_taxonomy_bc = { 
          
          'parent' : ['honeywell','http://www.myserver.com','images/txt_mySite.gif'] ,
          'mysite' : ['parent','http://www.myserver.com/mysite/','images/txt_mySite.gif'] 
          
          };


//--------------------------------------------------------------------------------
// eMetrics enabling field.value can be true or false.(can be customize)
//--------------------------------------------------------------------------------

var use_eMetrics = true;


var pageNameTaxonomySuffix = document.title;

if(pageNameTaxonomySuffix.indexOf(" - ")) 
{
pageNameTaxonomySuffix = pageNameTaxonomySuffix.substr(0,pageNameTaxonomySuffix.indexOf(" - "));	
}


function hideDropDown(val){
	if(document.getElementById("sm") != null)
	document.getElementById("sm").style.visibility="hidden";
	if(document.getElementById("sy") != null)
	document.getElementById("sy").style.visibility="hidden";
	if(document.getElementById("em") != null)
	document.getElementById("em").style.visibility="hidden";
	if(document.getElementById("ey") != null)
	document.getElementById("ey").style.visibility="hidden";
}

function showDropDown(val){
	if(document.getElementById("sm") != null)
	document.getElementById("sm").style.visibility="visible";
	if(document.getElementById("sy") != null)
	document.getElementById("sy").style.visibility="visible";
	if(document.getElementById("em") != null)
	document.getElementById("em").style.visibility="visible";
	if(document.getElementById("ey") != null)
	document.getElementById("ey").style.visibility="visible";
}
//--------------------------------------------------------------------------------
// loading N1N2 menu code  (Do not customoiz)
//--------------------------------------------------------------------------------

document.write("<script language='JavaScript' src='"+dtServer+"/common/scripts/serverprops.js'></script>");
/* inculde of the omnitue file */
var omniture_sbu='sm';
document.write("<script language='JavaScript' src='"+dtServer+"/sm/common/scripts/s_code.js'></script>");
document.write("<script language='JavaScript' src='"+dtServer+"/sm/common/scripts/omniture_sm_common.js'/></script>");
document.write("<script language='JavaScript' src='"+dtServer+"/sm/rheochem/common/scripts/rheochem-product-list-url.js'></script>");

/* inculde of the omnitue file ends*/

if(menuType == "uws")
document.write("<script language='JavaScript' src='"+dtServer+"/aero/common/scripts/"+n1n2MenuSiteID+"_N1N2.js'></script>");
else
document.write("<script language='JavaScript' src='"+n1n2filepath+"'></script>");
document.write("<script language='JavaScript' src='"+dtServer+"/common/scripts/uws_main.js'></script>");
document.write("<script language='JavaScript' src='"+dtServer+"/common/scripts/hw_bc_taxonomy.js'></script>");

//--------------------------------------------------------------------------------

//--------------------------------------------------------------------------------
// loading tools code (Path can be customize)
//--------------------------------------------------------------------------------

function uws_tools(Login,Search,Download)
{   
    
   if(Login)                                                                                            
   	document.write('<script language="JavaScript" src="/sm/common/scripts/login.js"></script>');                
   if(Search)
   	document.write('<script language="JavaScript" src="/sm/rheochem/common/scripts/search.js"></script>'); 
   if(Download)
   	document.write('<script language="JavaScript" src="/sm/common/scripts/download.js"></script>');      
}

//--------------------------------------------------------------------------------
// Region selector (can be customized)
//--------------------------------------------------------------------------------

// No ofRegions 
var noOfRegions = 14;

// Based on this value drop list will display.(If noOfRegions less than 7 this value is needed)
var region_name_url = [
	['United States','http://www.honeywell.com'] ,
	['India', 'http://www.honeywell.com/sites/htsl'],
	['Austria', 'http://www.honeywell.at/'],
	['China', 'http://www.honeywell.com/sites/china'],
	['Finland', 'http://www.honeywell.com/sites/fi'],
	['Germany', 'http://www.honeywell.com/sites/de'],
	['France', 'http://www.honeywell.com/sites/fr'],
	['Poland', 'http://www.honeywell.com.pl/'],
	['South Africa', 'http://www.honeywell.com/sites/za'],
	['United Kingdom ', 'http://www.honeywell.com/sites/uk'],
	['Denmark', 'http://www.honeywell.dk/'],
	['Canada', 'http://www.honeywell.ca/'],
	['Belgium', 'http://www.honeywell.be/'],
	['Czech Republic', 'http://www.honeywell.com/sites/cz']
];
if(noOfRegions < 8)
noOfRegions = region_name_url.length;

// Region selector page url (if noOfRegions greater than 7 this value is needed)
var region_selector_url = 'http://www.honeywell.com/sites/portal?smap=honeywell&page=honeywellglobal&theme=T8';

//--------------------------------------------------------------------------------

//--------------------------------------------------------------------------------
// Region selector (can be customized)
//--------------------------------------------------------------------------------

// Based on this value language drop down list will display.
var language_url = [
	['English','http://www.honeywell.com?ln=en'] ,
	['German','http://www.honeywell.com?ln=gr'] 
];

//--------------------------------------------------------------------------------



//--------------------------------------------------------------------------------
// Footer code (can be customized)
//--------------------------------------------------------------------------------

// For providing the sitemap link in the footer
var sitemapURL = '/sm/rheochem/sitemap.html';
var privacyURL = '/privacy/en.html';
var termsconditionsURL = '/terms-conditions/termsconditions.html';
// For providing the advance search in the footer

//var advanceSearchURL = 'http://search.honeywell.com/search?site=aero&q=&output=xml_no_dtd&client=www_en_frontend&proxystylesheet=www_en_frontend&proxycustom=<ADVANCED/>&baseSite=aero';
var advanceSearchURL = 'http://search.honeywell.com/search?site=sm&q=&output=xml_no_dtd&client=ecm_en_frontend&proxystylesheet=ecm_en_frontend&proxycustom=<ADVANCED/>&baseSite=rheochem';
var myAerospace='http://portal.honeywell.com/wps/portal/aero';



var footerLinks = [
		["Site Map", sitemapURL, "", ""],
		["Advanced Search",advanceSearchURL,"",""]
	 ];

document.write('<script language="JavaScript" src="/common/scripts/dctmFooter.js"></script>'); 

function uws_getFooterAndGlobalLinks(showRegion, showTranslate) {

	document.writeln(objFooter.footer.getHTML("", "", showRegion, showTranslate));
}

function openWindow(opt)
{
	if(opt.options.selectedIndex != -1 && opt.options.selectedIndex != 0)
	{
		window.open(opt.options[opt.options.selectedIndex].value);		
	}
}
//--------------------------------------------------------------------------------


function getLeftSpace(preLeftSpace,charLength)
{
	var emptySpace = (preLeftSpace + (eval(parseInt(charLength)*fontWidth)+19));
	if(is_nav4)
	emptySpace = emptySpace - nav4Buff;	
	return emptySpace;		
}



function loadN2()
{	
	if(n1_popup_menus[currsection] != undefined && (n1_popup_menus.length == undefined || n1_popup_menus.length > 0))
	{	
		for(var i=1;i<n1_popup_menus[currsection].length;i++)
			
 		menulist2[i-1] = n1_popup_menus[currsection][i];
 		
 		
 		if(currsection == 1 ){
 			n2_empty_pixels =710;
 		}else if(currsection == 2){
 			n2_empty_pixels =110;
 		}else if(currsection == 4){
 			n2_empty_pixels =230;
 		}else if(currsection == 5){
 			n2_empty_pixels =657;
 		}else{
 			n2_empty_pixels =300;
 		}
 		//calN2emptySpace(i);
 	
 		//calN2emptySpace();
	}
	
}

function calculateN1_empty()
{
  var totalLength = 0;
  var tp = 0;
  var j = 0;
  for(var i=0;i<menulist.length;i++)
  {
	   j = menulist[i][0].search('&');
       if(j!=-1)
      	  tp = tp + 2;
      totalLength = totalLength + 20 + eval(parseInt(menulist[i][0].length)*fontWidth)+2;
  }   
  if(totalLength < 760)
     n1_empty_pixels = 760 - totalLength;
 n1_empty_pixels = n1_empty_pixels - tp;

}

function calN2emptySpace()

{

            var n2LeftSpace = 0;

            for(var i=0;i<menulist2.length;i++)

            {
			 //n2LeftSpace = eval(parseInt(n2LeftSpace) - ) + eval(parseInt(menulist2[i][0].length)*fontWidth);
			 
			  n2LeftSpace =700; 
			 
             }
            //if(n2LeftSpace < 760)
           // n2_empty_pixels = 760 - n2LeftSpace;  
          
           n2_empty_pixels =200;
}


function setCurrsection()
{
	
	var strURL = new String(location.href);
	var splitStr = strURL.split('/');
	var len = splitStr.length;
	len = len - 1;
	var link = splitStr[len];
	var strn = link.substring(0,4);
	strn = strn.toLowerCase();
	var menulen = menulist.length;
	var sturl = location.search;
	lc1 = sturl.indexOf("c=");
	var j;
	if(lc1>0){
		lc1 = lc1 + 2;
		lc2 = lc1 + 2;
		stc = sturl.substring(lc1,lc2);
		c1 = stc.substring(0,1);
		c2 = stc.substring(1,2);
		if(stc!=''){
			currsection=c1;
			currsection2=c2;
		}
	}
	else{
	k = location.href;
	k = k.substring(0,k.indexOf(".html"));
	for(i=0;i<menulen;i++)
	{
		if(menulist[i][1]!='.html'){
			k = k + '.html';
			j = k.search(menulist[i][1]);
		}
		else
			j = k.search(menulist[i][1]);
		if(j!=-1){
			currsection = menulist[i][2];
			break;
		}
		else
		{	
			 // currsection = 'home';
		}
	}
}
}

function setCurrsection2()
{
	if(currsection!=''){
		if(n1_popup_menus[currsection]==undefined)
			currsection2='';
		else{
			var sturl = location.search;
			lc1 = sturl.indexOf("c=");
			if(lc1>0){
				lc1 = lc1 + 2;
				lc2 = lc1 + 2;
				stc = sturl.substring(lc1,lc2);
				c1 = stc.substring(0,1);
				c2 = stc.substring(1,2);
				if(stc!=''){
					currsection=c1;
					currsection2=c2;
				}
			}
			else
				currsection2='-11';
		}
	}
	else {
	var strURL = new String(location.href);
	//strURL = strURL.substring(0,strURL.indexOf(".html"));
	var splitStr = strURL.split('/');
	var len = splitStr.length;
	len = len - 1;
	var link = splitStr[len];
	len = len - 1;
	var str_news = splitStr[len];
	var strn = link.substring(0,4);
	str_news = str_news.toLowerCase();
	var menulen = menulist.length;
	var keylen = n1_keys.length;
	if(str_news=='news')
	{
		for(i=0;i<menulen;i++){
			tmp = menulist[i][0].toLowerCase();
			j = tmp.search(str_news);
			if(j!=-1){
				currsection = menulist[i][2];			
				if(n1_popup_menus[currsection]!=undefined)
					currsection2 = '1';
			}
		}
		
	}
	else {
	outer_loop:
	for(var m=1;m<keylen;m++){
		if(n1_popup_menus[m]==undefined){
		currsection2='';
	}
	else {
	if(n1_popup_menus[m] != undefined && (n1_popup_menus.length == undefined || n1_popup_menus.length > 0))
		{	
			for(var i=1;i<n1_popup_menus[m].length;i++){
				menu2 = new String(n1_popup_menus[m][i]);
				dr = menu2.split(',');
				tp_dr = dr[1].split('/');
				len = tp_dr.length;
				len = len - 1;
				if(tp_dr[len]==link){
					currsection = m;
					currsection2 = dr[2];
					break outer_loop;
				}
				else{
					currsection2='';
				}
			}
 		}	
	     }
           }
          }
       }
}


function setCurrsection3()
{

	/*	if(menulist3==undefined)
	alert("in curSec3 - menulist value")
	if(menulist3!=undefined){
	alert("in curSec3 -  length="+menulist3.length); }
	
	if(menulist3!=undefined){ */
	var sturl = location.search;
	//var mlen =menulist3.length;
	lc1 = sturl.indexOf("c=");
	lc1 = lc1 + 2;
	lc2 = lc1 + 2;
	lc3=lc2+2;
	
	
	stc = sturl.substring(lc1,lc2);
	stc1= sturl.substring(lc1,lc3);
	
	
	c1 = stc.substring(0,1);
	c2 = stc.substring(1,2);
	c3= stc1.substring(2,3);
	
	if(stc!=''){
		currsection=c1;
		currsection2=c2;
		sturl = location.href;
		if(c3 !='a')
		{
		out_loop:
		for(i=0;i<menulist3.length;i++)
		{	
			j = sturl.search(menulist3[i][1]);
			if(c3 !='')
				{

					currsection3 = c3;	
				}
				if(j!=-1)
			{
				currsection3 = menulist3[i][2];
				break out_loop;
			}
		
			
				
			
			if(n4_menus[menulist3[i][2]]!=undefined)
			{
				m4 = n4_menus[menulist3[i][2]];
				out_loop1:
				for(k=0;k<m4.length;k++){
					j = sturl.search(m4[k][1]);
					if(j!=-1){
						currsection3 = menulist3[i][2];
						currsection4 = m4[k][2];
						break out_loop1;
					}
				}
			}
		}//upper for ending
		
	}else
		{
			
			currsection3=0;
		}
		
	} 
	
}
	
//
// MSDS Drop downs //

// ----------------------------------------------------------------------------------
// contains the html and style code for the download box.  
//                 
//   Note:
//      Business logic is not implemented. Please implement it before using.       
// ----------------------------------------------------------------------------------
function showDoc(){
	var selObj = document.search.pdflistbox;
	if(selObj.selectedIndex==0){
		alert("Please select a Document you wish to download.");
		return;
	}
	//Opening a new window where the document gets downloaded.

	window.open(selObj.options[selObj.selectedIndex].value, "win1", "width=700, height=600, location=no, menubar=no, status=no, toolbar=yes, scrollbars=yes, resizable=yes");
}	



function populate(){
	if(MSDS!=undefined && MSDS.length>0){
document.write('<table cellpadding="0" cellspacing="0" border="0" width="161" class="bgwhite" id="searchmod3">');
document.write('<tr><td rowspan="5" width="1" class="search_outerrule"><img src="/common/images/c.gif" alt="" width="1" height="1" border="0"></td>');
document.write('<td rowspan="4" width="1"><img src="/common/images/c.gif" alt="" width="1" height="1" border="0"></td>');
document.write('<td colspan="4"><img src="/common/images/c.gif" alt="" width="1" height="1" border="0"></td>');
document.write('<td rowspan="4" width="1"><img src="/common/images/c.gif" alt="" width="1" height="1" border="0"></td>');
document.write('<td rowspan="4" width="1" class="search_innerrule"><img src="/common/images/c.gif" alt="" width="1" height="1" border="0"></td>');
document.write('<td rowspan="5" width="1" class="search_outerrule"><img src="/common/images/c.gif" alt="" width="1" height="1" border="0"></td>');
document.write('</tr><tr><td colspan="4" style="vertical-align :top;" class="search_innerrule">');
document.write('<table cellpadding="0" cellspacing="0" border="1" width="158" bordercolor="#606060" class="searchbg" id="searchmod3a">');
document.write('<tr><td><div class="searchhdr1"><img vpsace="2" src="/aero/common/images/Download_Tech_Docs.gif" alt="Download Technical Docs" title="Download Technical Docs" height="8" border="0"></div></td>');
document.write('<td width="15"><div id="docplus"><a onClick=\'showMod("doc","downloadCookie");\'><img src="/common/images/but_plus_gray.gif" alt="+" width="15" height="15" border="0"></a></div><div id="docminus"><a onClick=\'hideMod("doc","downloadCookie");\'><img src="/common/images/but_minus_gray.gif" alt="-" width="15" height="15" border="0"></a></div></td>');
document.write('</tr></table>');
document.write('<table cellpadding="0" cellspacing="0" border="0" width="158" id="searchmod3b">');
document.write('<tr class="bgwhite"><td><img src="/common/images/c.gif" alt="" width="1" height="2" border="0"></td></tr>');
document.write('<tr><td class="search"><form name="search"><div class="search" id="doc">');
document.write('<table cellpadding="0" cellspacing="0" border="0"><tr><td>');
document.write('<select name="pdflistbox" class="search"><option value="">Select a Document</option>');
for(i=0;i<MSDS.length;i++){
	document.write('<option value="'+MSDS[i][0]+'">');
	document.write(MSDS[i][1]);
	document.write('</option>');
}
document.write('</select></td><td rowspan="2"></td>');
document.write('<td class="search"><a href="javascript:showDoc();"><img src="/common/images/icon_arrow_circ.gif" width="14" height="14" alt="Download Technical Docs" title="Download Technical Docs" border="0"/></a></td></tr>');
document.write('</table></div></form></td></tr></table></td></tr>');
document.write('<tr><td colspan="8"><img src="/common/images/c.gif" alt="" width="1" height="1" border="0"></td></tr>');
document.write('<tr><td colspan="8" class="search_innerrule"><img src="/common/images/c.gif" alt="" width="1" height="1" border="0"></td></tr>');
document.write('<tr><td colspan="8" class="search_outerrule"><img src="/common/images/c.gif" alt="" width="1" height="1" border="0"></td></tr>');
document.write('</table>');
}
}

//      *************** dcs_tag code added to implement the webtrens functionlity for the documents ******************
document.write('<script language="JavaScript" src="'+dtServer+'/hfl/inc/webtrends/dcs_tag.js"></script>'); 

//      *************** dcs_tag code end here to implement the webtrens functionlity for the documents ******************
