Print();

function getRequestVar(istr) {

        var xstr = window.location.href;
        var xloc = xstr.indexOf('?'), yloc = 0;

        istr += '=';

        if(xloc == -1) return '';
        else {
                xloc = xstr.indexOf(istr, xloc) + istr.length;
                yloc = xstr.indexOf('&', xloc)!= -1?
                        xstr.indexOf('&', xloc) : xstr.indexOf('#', xloc);
                if(yloc == -1) xstr = xstr.substring(xloc);
                else xstr = xstr.substring(xloc, yloc);
        }

        return xstr;
}

function Print() {
	var query;
	var title;
	var hiddenStyle;
	title = document.URL;
	query = title.indexOf('?');

	
	if (getRequestVar('prfview') == 'yes') {
		var requestedJSP = getRequestJsp();

		if(requestedJSP == 'homepage.jsp'){
			//Added for Search History Start Jan 28 ,2008
			document.write('<link rel="stylesheet" href="/shared/stylesheets/pbar_printerfriendly.css" type="text/css"/>');
			//Added for Search History End Jan 28 ,2008
			document.write('<link rel="stylesheet" href="/shared/stylesheets/toplevel_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/files/abstract/misc/TOPLEVEL_DELTA_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/shared/stylesheets/phase2_printerfriendly.css" type="text/css" />');
			document.write('<link rel="stylesheet" href="/shared/stylesheets/serpstyles_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/search/stylesheets/style_printerfriendly.css" type="text/css"/>');
		}else if(requestedJSP == 'overview.jsp'){
			//Added for Search History Start Jan 28 ,2008
			document.write('<link rel="stylesheet" href="/shared/stylesheets/pbar_printerfriendly.css" type="text/css"/>');
			//Added  for Search History End Jan 28 ,2008
			document.write('<link rel="stylesheet" href="/shared/stylesheets/toplevel_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/files/abstract/misc/TOPLEVEL_DELTA_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/shared/stylesheets/phase2_printerfriendly.css" type="text/css" />');
			document.write('<link rel="stylesheet" href="/shared/stylesheets/serpstyles_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/search/stylesheets/style_printerfriendly.css" type="text/css"/>');			
		}else if(requestedJSP == 'prod_summary.jsp'){
			//Added  for Search History Start Jan 28 ,2008
			document.write('<link rel="stylesheet" href="/shared/stylesheets/pbar_printerfriendly.css" type="text/css"/>');
			//Added  for Search History End Jan 28 ,2008
			document.write('<link rel="stylesheet" href="/shared/stylesheets/toplevel_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/files/abstract/misc/TOPLEVEL_DELTA_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/shared/stylesheets/phase2_printerfriendly.css" type="text/css" />');
			document.write('<link rel="stylesheet" href="/shared/stylesheets/serpstyles_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/search/stylesheets/style_printerfriendly.css" type="text/css"/>');			
		}else if(requestedJSP == 'learning_summary.jsp'){
			//Added  for Search History Start Jan 28 ,2008
			document.write('<link rel="stylesheet" href="/shared/stylesheets/pbar_printerfriendly.css" type="text/css"/>');
			//Added  for Search History End Jan 28 ,2008
			document.write('<link rel="stylesheet" href="/shared/stylesheets/toplevel_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/files/abstract/misc/TOPLEVEL_DELTA_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/shared/stylesheets/phase2_printerfriendly.css" type="text/css" />');
			document.write('<link rel="stylesheet" href="/shared/stylesheets/serpstyles_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/search/stylesheets/style_printerfriendly.css" type="text/css"/>');			
		}else if(requestedJSP == 'training_information.jsp'){
			//Added  for Search History Start Jan 28 ,2008
			document.write('<link rel="stylesheet" href="/shared/stylesheets/pbar_printerfriendly.css" type="text/css"/>');
			//Added  for Search History End Jan 28 ,2008
			document.write('<link rel="stylesheet" href="/shared/stylesheets/toplevel_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/files/abstract/misc/TOPLEVEL_DELTA_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/shared/stylesheets/phase2_printerfriendly.css" type="text/css" />');
			document.write('<link rel="stylesheet" href="/shared/stylesheets/serpstyles_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/search/stylesheets/style_printerfriendly.css" type="text/css"/>');			
		}else if(requestedJSP == 'event_calendar.jsp'){
			//Added for Search History Start Jan 28 ,2008
			document.write('<link rel="stylesheet" href="/shared/stylesheets/pbar_printerfriendly.css" type="text/css"/>');
			//Added  for Search History End Jan 28 ,2008
			document.write('<link rel="stylesheet" href="/shared/stylesheets/toplevel_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/files/abstract/misc/TOPLEVEL_DELTA_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/shared/stylesheets/phase2_printerfriendly.css" type="text/css" />');
			document.write('<link rel="stylesheet" href="/shared/stylesheets/serpstyles_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/search/stylesheets/style_printerfriendly.css" type="text/css"/>');			
		}else if(requestedJSP == 'taxonomy.jsp'){
			//Added for Search History Start Jan 28 ,2008
			document.write('<link rel="stylesheet" href="/shared/stylesheets/pbar_printerfriendly.css" type="text/css"/>');
			//Added for Search History End Jan 28 ,2008
			document.write('<link rel="stylesheet" href="/shared/stylesheets/toplevel_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/shared/stylesheets/phase2_printerfriendly.css" type="text/css" />');
			document.write('<link rel="stylesheet" href="/shared/stylesheets/serpstyles_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/search/stylesheets/style_printerfriendly.css" type="text/css"/>');
		} else if(requestedJSP == 'application.jsp'){
			//Added for Search History Start Jan 28 ,2008
			document.write('<link rel="stylesheet" href="/shared/stylesheets/pbar_printerfriendly.css" type="text/css"/>');
			//Added for Search History End Jan 28 ,2008
			document.write('<link rel="stylesheet" href="/shared/stylesheets/toplevel_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/shared/stylesheets/phase2_printerfriendly.css" type="text/css" />');
			//Added for ASP redesign Start May 12 ,2009 
			document.write('<link rel="stylesheet" href="/files/abstract/misc/TOPLEVEL_DELTA_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/shared/stylesheets/serpstyles_printerfriendly.css" type="text/css"/>');
			document.write('<link rel="stylesheet" href="/search/stylesheets/style_printerfriendly.css" type="text/css"/>');			
			//Added for ASP redesign End May 12 ,2009 
		}
	}
} 

function printPage() {
	////Added for Search History Start Jan 28 ,2008
	//print_page_metrics();
	call_pbar_metrics('pb_print_page');
	//Added for Search History Start Jan 28 ,2008
	var param = "&prfview=yes";
	new_url = window.location.href + param;
	var obj = window.open(new_url,'SRWindow','resizable=yes,menubar=yes,scrollbars=yes,toolbar=no,status=yes,location=yes');
	obj.focus();
}

function getRequestJsp () {
	var str = new String();
	str = window.location.href;
	str = str.substring(str.lastIndexOf("/") + 1,str.indexOf("?"));	
	return(str);
}


function displayPrinterFriendlyMessage() {
	var query;
	var title;
	var hiddenStyle;
	title = document.URL;
	query = title.indexOf('?');

	
	if (getRequestVar('prfview') == 'yes') {
		var requestedJSP = getRequestJsp();
		var printerFriendlyMessage;
		var printerFriendlyMessage_Text;
		var printerFriendlyMessage_Header;
		if(requestedJSP == 'homepage.jsp'){
			printerFriendlyMessage = document.getElementById("previewMessage");
			printerFriendlyMessage_Header = document.createElement('h5');
			printerFriendlyMessage_Text = document.createTextNode('This is a preview of the page you are about to print. To print this view, use the Print command in your browser (in the File menu, choose Print).');
			printerFriendlyMessage.appendChild(printerFriendlyMessage_Header);
			printerFriendlyMessage_Header.appendChild(printerFriendlyMessage_Text);
		}else if(requestedJSP == 'overview.jsp'){
			printerFriendlyMessage = document.getElementById("previewMessage");
			printerFriendlyMessage_Header = document.createElement('h5');
			printerFriendlyMessage_Text = document.createTextNode('This is a preview of the page you are about to print. To print this view, use the Print command in your browser (in the File menu, choose Print).');
			printerFriendlyMessage.appendChild(printerFriendlyMessage_Header);
			printerFriendlyMessage_Header.appendChild(printerFriendlyMessage_Text);
		}else if(requestedJSP == 'prod_summary.jsp'){
			printerFriendlyMessage = document.getElementById("previewMessage");
			printerFriendlyMessage_Header = document.createElement('h5');
			printerFriendlyMessage_Text = document.createTextNode('This is a preview of the page you are about to print. To print the information under other tabs (Software and Tools, Buy/Parametrics), close this window, select a Tab, and click Export to Excel. To print this view, use the Print command in your browser (in the File menu, choose Print).');
			printerFriendlyMessage.appendChild(printerFriendlyMessage_Header);
			printerFriendlyMessage_Header.appendChild(printerFriendlyMessage_Text);
		}else if(requestedJSP == 'learning_summary.jsp'){
			printerFriendlyMessage = document.getElementById("previewMessage");
			printerFriendlyMessage_Header = document.createElement('h5');
			printerFriendlyMessage_Text = document.createTextNode('This is a preview of the page you are about to print (Orientation tab only). To print this view, use the Print command in your browser (in the File menu, choose Print).');
			printerFriendlyMessage.appendChild(printerFriendlyMessage_Header);
			printerFriendlyMessage_Header.appendChild(printerFriendlyMessage_Text);
		}else if(requestedJSP == 'training_information.jsp'){
			printerFriendlyMessage = document.getElementById("previewMessage");
			printerFriendlyMessage_Header = document.createElement('h5');
			printerFriendlyMessage_Text = document.createTextNode('This is a preview of the page you are about to print. To print this view, use the Print command in your browser (in the File menu, choose Print).');
			printerFriendlyMessage.appendChild(printerFriendlyMessage_Header);
			printerFriendlyMessage_Header.appendChild(printerFriendlyMessage_Text);
		}else if(requestedJSP == 'event_calendar.jsp'){
			printerFriendlyMessage = document.getElementById("previewMessage");
			printerFriendlyMessage_Header = document.createElement('h5');
			printerFriendlyMessage_Text = document.createTextNode('This is a preview of the page you are about to print. To print this view, use the Print command in your browser (in the File menu, choose Print).');
			printerFriendlyMessage.appendChild(printerFriendlyMessage_Header);
			printerFriendlyMessage_Header.appendChild(printerFriendlyMessage_Text);
		}else if(requestedJSP == 'taxonomy.jsp'){
			printerFriendlyMessage = document.getElementById("previewMessage");
			printerFriendlyMessage_Header = document.createElement('h5');
			printerFriendlyMessage_Text = document.createTextNode('This is a preview of the page you are about to print. To print the tables, close this window and click Export to Excel. To print this view, use the Print command in your browser (in the File menu, choose Print).');
			printerFriendlyMessage.appendChild(printerFriendlyMessage_Header);
			printerFriendlyMessage_Header.appendChild(printerFriendlyMessage_Text);
		} else if(requestedJSP == 'application.jsp'){
			printerFriendlyMessage = document.getElementById("previewMessage");
			printerFriendlyMessage_Header = document.createElement('h5');
			//Modified for ASP redesign Start  May 12 , 2009
			printerFriendlyMessage_Text = document.createTextNode('This is a preview of the page you are about to print. To print the information under other tabs (Software and Tools), close this window, select a Tab, and click Export to Excel. To print this view, use the Print command in your browser (in the File menu, choose Print).');
			//Modified for ASP redesign End  May 12 , 2009

			printerFriendlyMessage.appendChild(printerFriendlyMessage_Header);
			printerFriendlyMessage_Header.appendChild(printerFriendlyMessage_Text);
		}
	}
} 

var inmenu=false;
var insubmenu=false;
var lastmenu=0;
var lastsubmenu=0;
var hoverSuffix = "_hover";
var menuToUse=0;
var itemToUse=0;

var headTop = -1;
var FloatHead1;
var FloatHead2;
var headBottom = 50000;

function processScrollStatic()
{
    if (headTop < 0)
    {
    	saveHeadPosStatic();
	}
	if (headTop > 0)
	{
		if (document.documentElement && document.documentElement.scrollTop)
			theTop = document.documentElement.scrollTop;
		else if (document.body) 
			theTop = document.body.scrollTop;
		//theTop = getTop();
    	//FloatHead1.style.position = "absolute";
		if (theTop > headTop){
			if(theTop < headBottom){
				if(FloatHead1 != null){
					FloatHead1.style.top = (theTop-headTop+5) + 'px';
				}
				if(FloatHead2 != null){
					FloatHead2.style.top = (theTop-headTop-35) + 'px';
				}
			}
		}
		else{
			if(FloatHead1 != null){
				FloatHead1.style.top = '0px';
			}
			if(FloatHead2 != null){
				FloatHead2.style.top = '0px';
			}
		}
			
	}	
	//FloatHead1.style.margin='1px';
}

function saveHeadPosStatic()
{	
    parTable = document.getElementById("headStart");
    parTableEnd = document.getElementById("headEnd");
    if (parTable != null)
    {
	    headTop = parTable.offsetTop + 3;	  
	    FloatHead1 = document.getElementById("HeaderRow");
		FloatHead2 = document.getElementById("head1");
		if(FloatHead1 != null){
			FloatHead1.style.position = "relative";
			//FloatHead1.style.margin='8px';
			//FloatHead1.style.padding='1px';
		}
		if(FloatHead2 != null){
			FloatHead2.style.position = "relative";
			//FloatHead1.style.margin='8px';
			//FloatHead1.style.padding='1px';
		}
	    
	}
	if (parTableEnd != null)
    {
	    headBottom = parTableEnd.offsetTop - 150;	  
	   
	}
}



/*var headTop = -1;
var FloatHead1;

function processScroll()
{
	var use_gebi=false, use_css=false, use_layers=false;
	if(document.getElementById){
		use_gebi=true;
	}else if(document.all){
		use_css=true;
	}else if(document.layers){
		use_layers=true;
	}

	if (headTop < 0)
    {
    	saveHeadPos();
	}
	if (headTop > 0)
	{
		if (document.documentElement && document.documentElement.scrollTop){
			theTop = document.documentElement.scrollTop;			
		}
		else if (document.body) 
			theTop = document.body.scrollTop;
	
		if (theTop > headTop)
		{ 
			var endFloat = document.getElementById("end_float");
			if(endFloat!=null){
				var endFloatTop = AnchorPosition_getPageOffsetTop(endFloat);
				if( (theTop+FloatHead1.offsetHeight) <endFloatTop ){
					var head1 = document.getElementById("head1");
					if (head1!=null){
						head1.style.top = (theTop-headTop) + "px";	
					}
				}
			}
		}
		else
			FloatHead1.style.top = "0px";
	}	
}

*/

function AnchorPosition_getPageOffsetTop(el){
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null){
		ot += el.offsetTop;
	}
	return ot;
}

function AnchorPosition_getPageOffsetWidth(el){
	var ot=el.offsetLeft;
	while((el=el.offsetParent) != null){
		ot += el.offsetLeft;
	}
	return ot;
}


/*function saveHeadPos()
{	
    parTable = document.getElementById("headStart");
    if (parTable != null)
    {
	    headTop = parTable.offsetTop + 3;	  
	    FloatHead1 = document.getElementById("head1");
	    FloatHead1.style.position = "relative";
	}
}*/


function Menu(current) {
	var _parentCoords = null;
	if (!document.getElementById) return;
	inmenu=true;
	oldmenu=lastmenu;
	lastmenu=current;
	if (oldmenu) Erase(oldmenu);
	t=document.getElementById("ConfigureTable-"+current);
    m=document.getElementById(current.split("Menu")[0]);
    box=document.getElementById(current);

	if(current=="CustomizeMenu"){
		parent1=document.getElementById("customizeParent");
		_parentCoords= getCoords(parent1);
		var _left = _parentCoords.left +_parentCoords.width + m.offsetWidth
		box.style.left = _parentCoords.left + m.offsetWidth +'px';

		//box.style.top = _parentCoords.top + m.offsetTop +  box.offsetHeight +10 +'px';
		box.style.top = AnchorPosition_getPageOffsetTop(t) + m.offsetHeight+ 'px';

		if(_left < document.documentElement.scrollLeft){
			box.style.left = document.documentElement.scrollLeft;
		}
		box.style.visibility="visible";
		
		//Added By b02195 for IPS Enhancements Start
		var tableEle = document.getElementById("CustomizeMenuTable");
		//alert(tableEle);
		if(tableEle != null){
			//alert("inside");
			if(tableEle.style.visibility!='visible'){
				tableEle.style.visibility = "visible";
			}
		}
  		//Added By b02195 for IPS Enhancements End  
  	}
    else if(current=="DownloadMenu"){

		var parent=document.getElementById("downloadParent");
		_parentCoords= getCoords(parent);
	
		var _left = _parentCoords.left + m.offsetWidth  + box.offsetWidth/2;
		
		box.style.left = AnchorPosition_getPageOffsetWidth(t) +'px';
		box.style.top = AnchorPosition_getPageOffsetTop(t) + m.offsetHeight+ 'px';
		if(_left < document.documentElement.scrollLeft){
			box.style.left = document.documentElement.scrollLeft;
		}
		box.style.visibility="visible";

	}
	if (m.className.indexOf(hoverSuffix)<0) {
		m.className = m.className + hoverSuffix;
	}
}


function getCoords(elm) {
	var _height = elm.offsetHeight;
	var _width = elm.offsetWidth;
	var _top = elm.offsetTop;
	var _left = elm.offsetLeft;
	return new Coords(_top,_left,_height,_width);
}

function Coords(top,left,height,width) {
	this.top = top;
	this.left = left;
	this.height = height;
	this.width = width;
}


function Erase(current) {
   if (!document.getElementById) return;
   if (inmenu && lastmenu==current) {
	 return;
   }
   if(insubmenu && lastsubmenu==current){
 	 return;
   }
   m=document.getElementById(current.split( "Menu" )[0]);
   if(m==null)
		 m=document.getElementById(current);
   box=document.getElementById(current);
   if(box!=null){
	   box.style.visibility="hidden";   
   }
   m.className = m.className.split( hoverSuffix )[0];
}

function Timeout(current) {
   inmenu=false;
   insubmenu=false;
   window.setTimeout("Erase('" + current + "')",2000) ;
}

function Highlight(menu,item,submenu) {
   if (!document.getElementById) return;
   //alert(menu+":"+menuToUse);
   menu=menuToUse;
   item=itemToUse;
   switchClass (document.getElementById('filterMenus'), '');
   
   if(submenu != undefined){
		subMenu(menu,item,submenu);
   }
}

function UnHighlight(menu,item,submenu) {
   if (!document.getElementById) return;
   if(menuToUse!=0) menu='null';
   if(menu!='null') Timeout(menu);
   obj=document.getElementById(item);
   if(submenu != undefined){
		EraseSubMenu(item,submenu);
   }else{
	   obj.className = obj.className.split( hoverSuffix )[0];
   }
}

function setElems(menu,item) {
   menuToUse=menu;
   itemToUse=item;
}

function unsetElems() {
   menuToUse=0;
   itemToUse=0;
}

function subMenu(menu,item,submenu) {
   if (!document.getElementById) return;
   insubmenu=true;
   oldsubmenu=lastsubmenu;
   lastsubmenu=submenu;
   if (oldsubmenu) EraseSubMenu(item,oldsubmenu);   
   pm=document.getElementById(menu);
   m=document.getElementById(item);
   if(pm!=null){
	   pm.style.position="relative";
   }

	_parentCoords =  getCoords(document.getElementById(menu));
	var _elm = document.getElementById(submenu);
	var item_elm =	document.getElementById(item);
	if (null!=_parentCoords) {
		// set element to 0:0 for countig its offset
		_elm.style.top=0 + 'px';
		_elm.style.left=0 + 'px';
		var _popupCoords = getCoords(_elm);
		// count layout offset
		var topPos = _parentCoords.top + item_elm.height ;
		_elm.style.top=topPos +'px';
			 
		var leftPos = _parentCoords.left + item_elm.width -3;
		// fixing the position in case submenu is over the menu
		if ((leftPos<_parentCoords.left && leftPos+_popupCoords.width>_parentCoords.left + _parentCoords.width) &&
			((topPos<_parentCoords.top && topPos+_popupCoords.height>_parentCoords.top) ||
			 (topPos>_parentCoords.top && topPos<_parentCoords.top + _parentCoords.height))) {
			leftPos = _parentCoords.left + _parentCoords.width/2;
		}	
		_elm.style.left=leftPos +'px';
		_elm.style.width=_popupCoords.width +'px';
	    box=document.getElementById(submenu);
		if(document.documentElement.scrollWidth){
			if((leftPos+_elm.offsetWidth)>= document.documentElement.scrollWidth){
				leftPos = leftPos - _elm.offsetWidth;
			}
		}
		else if(document.body.scrollWidth){
			if((leftPos+_elm.offsetWidth)>=document.body.scrollWidth){
				leftPos = leftPos - _elm.offsetWidth;
				//alert("left 3 = " + leftPos);
			}
		}
		box.style.left = leftPos+'px';
		box.style.top = _elm.style.top;	 
		box.style.visibility="visible";
   }   
   if(m!=null){
	   if (m.className.indexOf(hoverSuffix)<0) {
			m.className = m.className + hoverSuffix;
	   }
   }
}

function EraseSubMenu(item,submenu) {
   if (!document.getElementById) return;   
   m=document.getElementById(item);
   box=document.getElementById(submenu);
   if(box!=null)  box.style.visibility="hidden";
}

function HighlightSubMenu(submenu,item) {
   if (!document.getElementById) return;
   insubmenu=true;   
   lastsubmenu=submenu;
   obj=document.getElementById(item);
   if (obj.className.indexOf(hoverSuffix)<0) {
	  // alert(obj.className);
	   obj.className = obj.className + hoverSuffix;
   } 
}

function UnHighlightSubMenu(item) {	
   if (!document.getElementById) return;
   obj=document.getElementById(item);
   obj.className = obj.className.split( hoverSuffix )[0];
}

function hoverImage(imageId) {
   if (!document.getElementById) return;
   obj=document.getElementById(imageId);
   if (obj.src.indexOf(hoverSuffix)<0) {
		obj.src = obj.src.split(".gif")[0] + hoverSuffix + ".gif";
   } 
}

function unhoverImage(imageId) {	
   if (!document.getElementById) return;
   obj=document.getElementById(imageId);
   if(obj.src.indexOf(hoverSuffix)>0) {
	  obj.src = obj.src.split( hoverSuffix)[0] + ".gif";
   }
}

function toolbar_button_over(button, parent) {
   if (!document.getElementById) return;
   if(parent != undefined){
		Menu(parent);
   }
   m=document.getElementById(button);
   if (m.className.indexOf(hoverSuffix)<0) {
	 	m.className = m.className + hoverSuffix;
   }
}

function toolbar_button_out(button,parent) {
   if (!document.getElementById) return;
   if(parent != undefined){
		Timeout(parent);
   }
   m=document.getElementById(button);
   m.className = m.className.split( hoverSuffix )[0];
}

// sets element with id elmName checked value to true(default) or false
function setChecked(elementId, checked) {
   if (checked==null) {
	   //default is true
	   checked=true;
   }
   var obj = document.getElementById(elementId);
   if (obj!=null) {
	   obj.checked=checked;
   }
}

function addParams()
{
  var listShow = document.getElementById("paramsShow");
  var listHide = document.getElementById("paramsHide");
  var toRemoveArr = new Array();
  for(i=0;i<listShow.options.length;i++) {
    if (listShow.options[i].selected)
    {
      var opt = new Option(listShow.options[i].text, listShow.options[i].value, false, false);
      listHide.options[listHide.options.length] = opt;
      toRemoveArr.push(listShow.options[i].value);
    }    
  }
  for (j=0; j<toRemoveArr.length; j++)
  {
    for(k=0;k<listShow.options.length;k++) {
      if (listShow.options[k].value == toRemoveArr[j])
      {
        listShow.options[k] = null;
      }
    }
  }
}

function removeParams()
{
  var listShow = document.getElementById("paramsShow");
  var listHide = document.getElementById("paramsHide");
  //Added By b02195 for IPS Enhancements Start
  var noOfColumns = listShow.options.length;
  var addColumnsFlag = true;
  //Added By b02195 for IPS Enhancements End
  var toRemoveArr = new Array();
	for(i=0;i<listHide.options.length;i++) {
		if (listHide.options[i].selected)
		{
			noOfColumns++;
			if(noOfColumns>MAX_COLUMN){
				addColumnsFlag = false;
			}
		}
	}
	if(addColumnsFlag==true){
		for(i=0;i<listHide.options.length;i++) {
			if (listHide.options[i].selected)
			{
				var opt = new Option(listHide.options[i].text, listHide.options[i].value, false, false);
				listShow.options[listShow.options.length] = opt;
				toRemoveArr.push(listHide.options[i].value);
			}
		}
	}else{
		alert("You can not add more than " + MAX_COLUMN + " columns");
		//addColumnsFlag = false;
	}
  /*for(i=0;i<listHide.options.length;i++) {
    if (listHide.options[i].selected)
    {
    	//Added By b02195 for IPS Enhancements Start
		noOfColumns++;
		if(noOfColumns<=MAX_COLUMN){
			//alert(noOfColumns+"="+MAX_COLUMN);
		//Added By b02195 for IPS Enhancements End
      		var opt = new Option(listHide.options[i].text, listHide.options[i].value, false, false);
      		listShow.options[listShow.options.length] = opt;
      		toRemoveArr.push(listHide.options[i].value);
      	//Added By b02195 for IPS Enhancements Start
		}else{
			alert("You can not add more than " + MAX_COLUMN + " columns");
			addColumnsFlag = false;
		}
	//Added By b02195 for IPS Enhancements End
    }
  }*/
//Added By b02195 for IPS Enhancements Start

  if(addColumnsFlag==true){
  for (j=0; j<toRemoveArr.length; j++)
  {
    for(k=0;k<listHide.options.length;k++) {
      if (listHide.options[k].value == toRemoveArr[j])
      {
        listHide.options[k] = null;
      }
    }
  } 
   //Added By b02195 for IPS Enhancements End
  }
}
//Added By b02195 for IPS Enhancements Start
function removeAllParams(){
	var listShow = document.getElementById("paramsShow");
	var listHide = document.getElementById("paramsHide");
	//var toRemoveArr = new Array();
	for(i=0;i<listShow.options.length;i++) {
		//if (listHide.options[i].selected){
			var opt = new Option(listShow.options[i].text, listShow.options[i].value, false, false);
			listHide.options[listHide.options.length] = opt;
			//toRemoveArr.push(listHide.options[i].value);
		//}
	}
	//for (j=0; j<toRemoveArr.length; j++){
		var len = listShow.options.length;
		for(k=0;k<len;k++) {
			//if (listHide.options[k].value == toRemoveArr[j]){
			if(listShow.options[k]!=null){
				listShow.options[k] = null;
				k--;
			}
			//}
		}
	//}

}
//Added By b02195 for IPS Enhancements End
function appendClass (elm, clsName) {
	if (elm==null) {
		return;
	}
	elm.className=elm.className + ' ' + clsName;
}

function switchClass (elm, newClassName) {
	if (elm==null) {
		return;
	}
	var classes = elm.className.split(' ');
	var clsName = "";
	var separator = "";
	for (i=0; i<classes.length; i++) {
		clsName = clsName + separator + classes[i];
		separator = " ";
	}
	if(clsName==""){
		clsName = "filterMenuItem" + "_hover";
	}
	elm.className=clsName;
}

function image_button_over(imageId) {
   if (!document.getElementById) return;
   m=document.getElementById(imageId);
   
   if (m.src.indexOf(hoverSuffix)<0) {
		m.src = m.src.split( ".gif" )[0] + hoverSuffix+".gif";
   }
}

function image_button_out(imageId) {
   if (!document.getElementById) return;
    m=document.getElementById(imageId);
   m.src = m.src.split( hoverSuffix )[0]+".gif";
}


function Coords(top,left,height,width) {
	this.top = top;
	this.left = left;
	this.height = height;
	this.width = width;
}

function getCoords(elm) {
	if(elm!=null){
		var _height = elm.offsetHeight;
		var _width = elm.offsetWidth;
		var _top = elm.offsetTop;
		var _left = elm.offsetLeft;
		var _x = elm;	
		var _p = null;
		var _lastParent = null;
		while ( _x != null && _x.tagName.toUpperCase() != "BODY" ) {
				_p = _x.offsetParent;
				if (_p!=_lastParent) {
					_top += _p.offsetTop;
					_left += _p.offsetLeft;						   
				}
				_lastParent = _p;
					// here we finish, becase body is at the top
					_x = null;
		}
		return new Coords(_top,_left,_height,_width);
	}
}

function posDecrease()
{
  var listShow = document.getElementById("paramsShow");
  for(i=0;i<listShow.options.length;i++) {
	if (listShow.options[i].selected)
    {
		if (i > 0)
		{
			var prevOpt = listShow.options[i - 1];
			var selOpt = listShow.options[i];
			listShow.options[i] = new Option(" "," ",false, false);    
			listShow.options[i - 1] = selOpt;
			listShow.options[i] = prevOpt;
		}
    }  
  }  
}

function posIncrease()
{
  var listShow = document.getElementById("paramsShow");
  for(i=listShow.options.length-1; i>=0; i--) {
    if (listShow.options[i].selected)
    {
		if (i < listShow.options.length -1)
		{
			var nextOpt = listShow.options[i + 1];
			var selOpt = listShow.options[i];
			listShow.options[i] = new Option(" "," ",false, false);
			listShow.options[i + 1] = selOpt;
			listShow.options[i] = nextOpt;
		}
    }    
  }  
}
/* 	modified for CCT43585 by r1051z start 5 Jan 2007 */
function OpenClose(id){
	var ele = document.getElementById(id);
	var imName = ele.src.substring(ele.src.lastIndexOf('/')+1);
	if(ele!=null){

		
		var id = id.substring(4);
		var idtext = "pfId";
		
		if(imName=="mon.gif"){
			
			ele.alt="open";
			ele.src=ele.src.substring(0,ele.src.lastIndexOf('/')+1)+"pon.gif";
			id++;
			
			document.getElementById(idtext+id).style.display="none";
		}else if(imName=="pon.gif"){
			
			ele.alt="close";
			ele.src=ele.src.substring(0,ele.src.lastIndexOf('/')+1)+"mon.gif";
			id++;
			
			document.getElementById(idtext+id).style.display="";
		}else if(imName=="clo.gif"){
			
			ele.alt="close";
			ele.src=ele.src.substring(0,ele.src.lastIndexOf('/')+1)+"open.gif";
			id++;
			
			document.getElementById(idtext+id).style.display="";
		}else if(imName=="open.gif"){
			
			ele.alt="open";
			ele.src=ele.src.substring(0,ele.src.lastIndexOf('/')+1)+"clo.gif";
			id++;
			
			document.getElementById(idtext+id).style.display="none";
		}
	}
}
/* 	modified for CCT43585 by r1051z End 5 Jan 2007 */
//added by b17090 for cct70835 START 21-12-09
function getCookie(name) {
 var bikky = document.cookie;
 var index = bikky.indexOf(name + "=");
 if (index == -1) return null;
 index = bikky.indexOf("=", index) + 1; // first character
 var endstr = bikky.indexOf(";", index);
 if (endstr == -1) endstr = bikky.length; // last character
 return unescape(bikky.substring(index, endstr));
}
//added by b17090 for cct70835 END 21-12-09
function search(stateStr){
	stateStr = leftTrim(stateStr);
	var search_visitor_id = getCookie("freescale_visitor_id");
	stateStr+="`!svi="+search_visitor_id;
	
	var fromSearch = document.getElementById("fromSearch");
	if(fromSearch!=null){
		fromSearch.value="true";
	}
	/*var staticFile = document.getElementById("staticFile");
	if(staticFile!=null){
		staticFile.style.display="none";
		staticFile.innerHTML="";
	}*/
	var state = document.getElementById("searchState");

	state.innerHTML=stateStr;
	callSearch();
	//staticFile.style.display="none";
	//staticFile.innerHTML = "";
}

function changePageSize(pageDropBox,sep,field){
	var state = document.getElementById("searchStateString");
	state.innerHTML = field+"="+pageDropBox.options[pageDropBox.selectedIndex].value+sep+leftTrim(state.innerHTML) ;
	var newString = leftTrim(state.innerHTML);
	//document.write(newString);
	search(newString);
}
function pageNumClick(i,sep,field){
	//alert(i+","+sep+","+field);
	var state = document.getElementById("searchStateString");
	state.innerHTML = field +"="+i+sep+leftTrim(state.innerHTML) ;
	var newString = leftTrim(state.innerHTML);
	search(newString);
}
function advanceClick(str){
	var state = document.getElementById("searchStateString");
	state.innerHTML = state.innerHTML + str ;
	var newString = leftTrim(state.innerHTML);
	search(newString);
}
function headerSort(str,sep){
	//sep="`!";
	var state = document.getElementById("searchStateString");
	state.innerHTML = state.innerHTML + str;
	var newString = leftTrim(state.innerHTML);
	search(newString);
}
function updateCustomize(field,sep,multivaluedSep){
	/*var ele = document.getElementById("paramsShow");
	var str ="";
	for(var i=0;i<ele.options.length;i++){
		str += ele.options[i].value + multivaluedSep;
	}
	*/
	var state = document.getElementById("searchStateString");
	var newString = leftTrim(state.innerHTML);
	search(newString);
}

function showAllColumnsForStatic(field, allColumns, sep){
	var str="";
	str = field+"="+allColumns;
	var state = document.getElementById("searchStateString");
	
	var newString = leftTrim(state.innerHTML);
	newString = newString + str;
	search(newString);
}

function leftTrim(sString)
{
	while (sString.substring(0,1) == ' ' || sString.substring(0,1) == '\n'){
		sString = sString.substring(1, sString.length);
	}
	return sString;
}

function moreSubmit(field,colOrder,sep,elemCheckBox,num,multivaluedSep){
	var str="";
	var select_all_flag = false;
	for (var j = 0; j < num; j++){
		checkBoxElem = document.getElementById(eval("'"+(elemCheckBox+j)+"'"));
		if (checkBoxElem.checked || select_all_flag==true){
			if(checkBoxElem.value=='SELECT ALL'){
				select_all_flag = true;
			}else{
				str = str + checkBoxElem.value + multivaluedSep;
			}
		}		
	}
	var state = document.getElementById("searchStateString");
	state.innerHTML = state.innerHTML + field +"="+ str + colOrder;
	var newString = leftTrim(state.innerHTML);
	search(newString);
}

function filterSubmit(field,colOrder,headerId,sep,elemCheckBox,num){
	var str="";

	for (var j = 0; j < num; j++){
		checkBoxElem = document.getElementById(eval("'"+(elemCheckBox+j)+"'"));
	//	alert(checkBoxElem.checked);
		if (checkBoxElem.checked){
			str = str + headerId + "=" + checkBoxElem.value + sep;
		}		
	}
	//alert(str);
	var state = document.getElementById("searchStateString");
	state.innerHTML = state.innerHTML + str+ field +"="+ colOrder;
	//alert(state.innerHTML);
	var newString = leftTrim(state.innerHTML);
	state.innerHTML = newString + str;
	var newString = leftTrim(state.innerHTML);
	search(newString);
}
//Added by B11079 for CCT56849 Start on 28/05/2008
function inActiveStatusOPSubmit(field,colOrder){
	var str = "";
	var state = document.getElementById("searchStateString");
	state.innerHTML = state.innerHTML + str+ field +"="+ colOrder;
	//alert(state.innerHTML);
	var newString = leftTrim(state.innerHTML);
	state.innerHTML = newString + str;
	var newString = leftTrim(state.innerHTML);
	search(newString);
}
//Added by B11079 for CCT56849 End on 28/05/2008

function performComparison(searchTypeString,fieldId,sep,elemCheckBox,num,multivalueSep){
	var str="";
	var count=0;
	if(multivalueSep==null){
		multivalueSep="!`";
	}
	for (var j = 0; j < num; j++){
		checkBoxElem = document.getElementById(eval("'"+(elemCheckBox+j)+"'"));
		if (checkBoxElem.checked){
			if(str==""){
				str = checkBoxElem.value + multivalueSep;
			}else{
				str = str + checkBoxElem.value + multivalueSep;
			}
			count=count+1;
		}		
	}
	if(count<2){
		alert('Please select more than two rows for comparison');
		return;
	}
	str = fieldId + "=" + str;
	//alert(str);
	var state = document.getElementById("searchStateString");
	state.innerHTML = str + sep + searchTypeString+ sep+"isComparison=true"+sep+leftTrim(state.innerHTML);
	var newString = leftTrim(state.innerHTML);
	search(newString);
}
function columnHide(field,columnOrder,sep,headerId,multivaluedSep){
	//alert(columnOrder);
	//alert(sep);
	multivaluedSep="!`";
	//alert(headerId);
	var str="";
	var newColumnOrder="";
	var columns = columnOrder.split(multivaluedSep);
	//alert( columns.length);
	for (var i = 0; i < columns.length; i++){
		if (columns[i]!=headerId){
			//alert(columns[i]+","+headerId);
			if(newColumnOrder==""){
				newColumnOrder = columns[i];
			}else{
				newColumnOrder = newColumnOrder + multivaluedSep + columns[i];
			}
		}
	}
	str = field + "=" + newColumnOrder;
	var state = document.getElementById("searchStateString");
	state.innerHTML = state.innerHTML + sep + str;
	var newString = leftTrim(state.innerHTML);
	search(newString);
}


//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var xScroll, yScroll;

	if (self.pageYOffset) {
		xScroll = self.pageXOffset;
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		xScroll = document.documentElement.scrollLeft;
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		xScroll = document.body.scrollLeft;
		yScroll = document.body.scrollTop;
	}
	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}



//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	//alert(pageWidth+","+pageHeight+","+windowWidth+","+windowHeight) ;
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function getLoadingHeight(){
	var n_win = window.pageYOffset ? window.pageYOffset : 0;
	var n_docel = document.documentElement ? document.documentElement.scrollTop : 0;
	var n_body = document.body ? document.body.scrollTop : 0;

	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function getLoadingWidth(){
	var n_win = window.pageXOffset ? window.pageXOffset : 0;
	var n_docel = document.documentElement ? document.documentElement.scrollLeft : 0;
	var n_body = document.body ? document.body.scrollLeft : 0;

	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;	
}
function selectall(elemCheckBox,num){
	var checkBoxElem;
	var select_all_flag = false;
	for (var j = 0; j < num; j++){
		checkBoxElem = document.getElementById(eval("'"+(elemCheckBox+j)+"'"));
		if(j==0){
			if(checkBoxElem.checked){
				select_all_flag = true;
			}
		}
		else{
			if(select_all_flag==true){
				checkBoxElem.checked = true;
			}else{
				checkBoxElem.checked = false;
			}
		}		
	}
}
function doNothing(){
	//alert("in");
}
/* add event handlers here */
//window.onscroll = processScroll;

//added by b05535 for PPI start 10-Mar-08
function loadGWTComponent(){
	var str="";
	var state = document.getElementById("searchStateString");
	state.innerHTML = state.innerHTML + str;
	//alert(state.innerHTML);
	var newString = leftTrim(state.innerHTML);
	state.innerHTML = newString + str;
	var newString = leftTrim(state.innerHTML);
	search(newString);
}
//added by b05535 for PPI end 10-Mar-08<!--//--><![CDATA[//><!--
sfPBarHover = function() {
	var navPbar = document.getElementById("pbarNav");
	if (navPbar){
		var sfEls = document.getElementById("pbarNav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfpbarhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfpbarhover\\b"), "");
			}
		}
	}
}
if (window.attachEvent) window.attachEvent("onload",sfPBarHover);
//--><!]]>

var popupTimerHandle = null;
 var popupHandlerForPageAction= null;
 function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x) 
        curleft += obj.x;
		return curleft;
  }

function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
				
    return curtop;
  }

function setPosPageAction(refObj, childObj) 
	{
			
        var referenceObj = document.getElementById(refObj);

        var parentTop= referenceObj.offsetTop;
		var parentHeight = referenceObj.offsetHeight;
        var parentLeft = referenceObj.offsetLeft;
        var parentWidth = referenceObj.offsetWidth;
        var parentRight = findPosX(referenceObj) + parentWidth;
		var childObj = document.getElementById(childObj);
        var childWidth = childObj.offsetWidth;
		childObj.style.top =parentHeight +findPosY(referenceObj)+ 'px';
        childObj.style.left =parentRight-childWidth+ 'px';
     
     
     }
function showMenu(div) {
    if (popupTimerHandle != null) {
        clearTimeout(popupTimerHandle);
        popupTimerHandle = null;
    }
	  if (popupHandlerForPageAction != null) {
        clearTimeout(popupHandlerForPageAction);
        popupHandlerForPageAction = null;
    }

    divObj = document.getElementById(div);
    divObj.style.display = 'block';
}
function popupTimerHandleShow(div) {
    if (popupTimerHandle != null) {
        clearTimeout(popupTimerHandle);
        popupTimerHandle = null;
    }
    divObj = document.getElementById(div);
    divObj.style.display = 'block';
}
function popupHandlerPAShow(div) {
    if (popupHandlerForPageAction  != null) {
        clearTimeout(popupHandlerForPageAction );
        popupHandlerForPageAction = null;
    }
    divObj = document.getElementById(div);
    divObj.style.display = 'block';
}
function hideMenu(div) {
    popupTimerHandle = setTimeout("hideMenuAct('" + div + "');", 250);
}
function hideMenuForPA(div) {
    popupHandlerForPageAction= setTimeout("hideMenuAct('" + div + "');",50);
}
function hideMenuAct(div) {
    divObj = document.getElementById(div);
    divObj.style.display = 'none';
}   
function displayWhyReg(code){ 
		var url = "/webapp/shared/components/inc_collateral.jsp?code="+code;
		var window_title = "Why Should I Register?"
		var width = "700";
		var height = "350";
		ajaxwin=dhtmlwindow.open('ajaxbox',url,window_title, 'width='+width+'px,height='+height+'px,left=100px,top=100px,resize=0,scrolling=1');
		return ajaxwin ;
}

function call_pbar_metrics(action)
{
if (window.personalization_bar_metrics && action!= 'undefined' ){
		personalization_bar_metrics(action);
	}
}// -------------------------------------------------------------------
// DHTML Window Widget- By Dynamic Drive, available at: http://www.dynamicdrive.com
// v1.0: Script created Feb 15th, 07'
// v1.01: Updated to v1.01 Feb 21th, 07'
// -------------------------------------------------------------------
/* WOW: params for adding addthis widget :start*/
var videoURL="";
var videoTitle="";
var recalonload ="";
var progressdiv;
/* WOW: params for adding addthis widget: end*/
var dhtmlwindow={

ajaxbustcache: true, //Bust caching when fetching a file via Ajax?

minimizeorder: 0,
tobjects: [], //object to contain references to dhtml window divs, for cleanup purposes

init:function(t){
	var domwindow=document.createElement("div") //create dhtml window div
	domwindow.id=t
	domwindow.className="dhtmlwindow"
	var domwindowdata=''
	domwindowdata='<div class="drag-handle">'
	if(typeof recalonload != "undefined" && ( recalonload == 'history'|| recalonload == 'webnote'|| recalonload == 'training'|| recalonload == 'downloaded')){
	domwindowdata+='DHTML Window:<div class="drag-controls"><img src="/shared/images/blockViewerDevider.gif" style="margin-right:10px;"><img  onclick="hideselectsHistory();" src="/shared/images/blockViewerClose.gif" title="Close" style="margin-right:18px;" /></div>'
	domwindowdata+='</div>'
	}
	else
	{
	domwindowdata+='DHTML Window:<div class="drag-controls"><img src="/shared/images/blockViewerDevider.gif" style="margin-right:10px;"><img src="/shared/images/blockViewerClose.gif" title="Close" style="margin-right:18px;" /></div>'
	domwindowdata+='</div>'
	
	}
	/* WOW: params for adding addthis widget : start*/
	if(typeof recalonload != "undefined" && recalonload == 'video'){
		domwindowdata+='<div id="addThis" ></div>';
	}
	/* WOW: params for adding addthis widget : end */

	if(typeof recalonload != "undefined" && ( recalonload == 'history'|| recalonload == 'webnote'|| recalonload == 'training'|| recalonload == 'downloaded')){
		domwindowdata+='<div id='+recalonload+' class="drag-contentarea"></div>'
	}
	else
	{
	domwindowdata+='<div class="drag-contentarea"></div>'
	}
	
	domwindowdata+='</div>'
	domwindow.innerHTML=domwindowdata


	document.getElementById("dhtmlwindowholder").appendChild(domwindow)
		

	this.zIndexvalue=(this.zIndexvalue)? this.zIndexvalue+1 : 100 //z-index value for DHTML window: starts at 0, increments whenever a window has focus
	var t=document.getElementById(t)
	var divs=t.getElementsByTagName("div")
	for (var i=0; i<divs.length; i++){ //go through divs inside dhtml window and extract all those with class="drag-" prefix
		if (/drag-/.test(divs[i].className))
			t[divs[i].className.replace(/drag-/, "")]=divs[i] //take out the "drag-" prefix for shorter access by name
	}
	t.style.zIndex=this.zIndexvalue //set z-index of this dhtml window
	t.handle._parent=t //store back reference to dhtml window
	t.controls._parent=t //same
	t.onclose=function(){return true} //custom event handler "onclose"
	t.onmousedown=function(){dhtmlwindow.zIndexvalue++; this.style.zIndex=dhtmlwindow.zIndexvalue} //Increase z-index of window when focus is on it
	t.handle.onmousedown=dhtmlwindow.setupdrag //set up drag behavior when mouse down on handle div
	t.controls.onclick=dhtmlwindow.enablecontrols
	t.show=function(){dhtmlwindow.show(this)} //public function for showing dhtml window
	t.hide=function(){dhtmlwindow.close(this)} //public function for hiding dhtml window
	t.setSize=function(w, h){dhtmlwindow.setSize(this, w, h)} //public function for setting window dimensions

	//
	//
	t.moveTo=function(x, y){dhtmlwindow.moveTo(this, x, y)} //public function for moving dhtml window (relative to viewpoint)
	if(typeof recalonload != "undefined" && ( recalonload == 'history'|| recalonload == 'webnote'|| recalonload == 'training'|| recalonload == 'downloaded')){
	t.contentarea.style.overflowX="hidden";
	t.contentarea.style.overflowY="auto";
	}
	else
	{
	t.isScrolling=function(bol){dhtmlwindow.isScrolling(this, bol)} 
	}//public function for specifying if window content contains scrollbars
	/* modifications for 56853 */
	t.load=function(contentsource, title,contenttype){dhtmlwindow.load(this, contentsource, title,contenttype)} //public function for loading content into window
	//t.load=function(contentsource, title){dhtmlwindow.load(this, contentsource, title)} //public function for loading content into window
	/* modifications for 56853 */

	this.tobjects[this.tobjects.length]=t
	return t //return reference to dhtml window div
},

/* modifications for 56853 */
//open:function(t, contentsource, title, attr, recalonload){
open:function(t, contentsource, title, attr, recalonload1,contenttype){
/* modifications for 56853 */
/* WOW: params for adding addthis widget : start*/
	recalonload = recalonload1;
/* WOW: params for adding addthis widget : end*/

	var d=dhtmlwindow //reference dhtml window object
	function getValue(Name){
		var config=new RegExp(Name+"=([^,]+)", "i") //get name/value config pair (ie: width=400px,)
		return (config.test(attr))? parseInt(RegExp.$1) : 0 //return value portion (int), or 0 (false) if none found
	}
	if (document.getElementById(t)==null) //if window doesn't exist yet, create it
		t=this.init(t) //return reference to dhtml window div
	else
		t=document.getElementById(t)
	t.setSize(getValue(("width")), (getValue("height"))) //Set dimensions of window
	var xpos=getValue("center")? "middle" : getValue("left") //Get x coord of window
	var ypos=getValue("center")? "middle" : getValue("top") //Get y coord of window
	t.moveTo(xpos, ypos) //Position window
	if (typeof recalonload!="undefined" && recalonload=="recal" && this.scroll_top==0){ //reposition window when page fully loads with updated window viewpoints?
		if (window.attachEvent && !window.opera) //In IE, add another 400 milisecs on page load (viewpoint properties may return 0 b4 then)
			this.addEvent(window, function(){setTimeout(function(){t.moveTo(xpos, ypos)}, 400)}, "load")
		else
			this.addEvent(window, function(){t.moveTo(xpos, ypos)}, "load")
	}
			if(typeof recalonload != "undefined" && ( recalonload == 'history'|| recalonload == 'webnote'|| recalonload == 'training'|| recalonload == 'downloaded'))
				{
	t.contentarea.style.overflowX="hidden";
	t.contentarea.style.overflowY="auto";
			}
			else
	{
	t.isScrolling(getValue("scrolling")) 
	}//Set whether window should contain scrollbars
	t.style.visibility="visible"
	t.style.display="block"
	t.contentarea.style.display="block"
	
	/* Modified for Online Feedback - */
   /* Modified for search history - */
   
	
	
	
if(typeof recalonload != "undefined" && ( recalonload == 'history'|| recalonload == 'webnote'|| recalonload == 'training'|| recalonload == 'downloaded')){
//alert(recalonload);
var div_id="progressid"+recalonload;
         document.getElementById(recalonload).innerHTML="<div id='"+div_id+"'></div>";
    progressdiv=document.getElementById(div_id);
	if(typeof progressdiv != "undefined" && progressdiv != null)
	{//alert("progressdiv");
	progressdiv.style.visibility="visible";
	progressdiv.innerHTML=" <img src=\"/shared/images/fs_anilogo.gif\" />";
    progressdiv.style.position="absolute";
	progressdiv.style.left="250px";
    progressdiv.style.top="150px";
	progressdiv.style.width="150px";
	
}

}	/*Modified for Online Feedback end*/
	//t.load(contentsource, title)
	t.load(contentsource, title,contenttype)
	

	/* WOW: params for adding addthis widget : start*/
	if(typeof recalonload != "undefined" && recalonload == 'video'){
		if (window.copyInnerHTML){
			copyInnerHTML("addThis",videoURL,videoTitle);
		}
	}
	/* WOW: params for adding addthis widget : end*/
	return t
},

setSize:function(t, w, h){ //set window size (min is 150px wide by 100px tall)
	t.style.width=Math.max(parseInt(w), 150)+"px"
	t.contentarea.style.height=Math.max(parseInt(h), 100)+"px"
},

moveTo:function(t, x, y){ //move window. Position includes current viewpoint of document
	this.getviewpoint() //Get current viewpoint numbers
	t.style.left=(x=="middle")? this.scroll_left+(this.docwidth-t.offsetWidth)/2+"px" : this.scroll_left+parseInt(x)+"px"
	t.style.top=(y=="middle")? this.scroll_top+(this.docheight-t.offsetHeight)/2+"px" : this.scroll_top+parseInt(y)+"px"
},

isScrolling:function(t, bol){ //set whether loaded content contains scrollbars
	t.contentarea.style.overflow=(bol)? "auto" : "hidden"
},

	
load:function(t, contentsource, title,contenttype){ //loads content into window plus set its title (3 content types: "inline", "iframe", or "ajax")
	if( (typeof contenttype!="undefined") && (contenttype=="inline") ){
		t.handle.firstChild.nodeValue=title
		t.contentarea.innerHTML=contentsource
	}else{
		t.handle.firstChild.nodeValue=title
		this.ajax_connect(contentsource, t) //populate window with external contents fetched via Ajax
	}
},
/* modifications for 56853 */

setupdrag:function(e){
	var d=dhtmlwindow //reference dhtml window object
	var t=this._parent //reference dhtml window div
	d.etarget=this //remember div mouse is currently held down on ("handle" or "resize" div)
	var e=window.event || e
	d.initmousex=e.clientX //store x position of mouse onmousedown
	d.initmousey=e.clientY
	d.initx=parseInt(t.offsetLeft) //store offset x of window div onmousedown
	d.inity=parseInt(t.offsetTop)
	d.width=parseInt(t.offsetWidth) //store width of window div
	d.contentheight=parseInt(t.contentarea.offsetHeight) //store height of window div's content div
	if (t.contentarea.datatype=="iframe"){ //if content of this window div is "iframe"
		t.style.backgroundColor="#F8F8F8" //colorize and hide content div (while window is being dragged)
		t.contentarea.style.visibility="hidden"
	}
	document.onmousemove=d.getdistance //get distance travelled by mouse as it moves
	document.onmouseup=function(){
		if (t.contentarea.datatype=="iframe"){ //restore color and visibility of content div onmouseup
			t.contentarea.style.backgroundColor="white"
			t.contentarea.style.visibility="visible"
		}
	d.stop()
	}
	return false
},

getdistance:function(e){
	var d=dhtmlwindow
	var etarget=d.etarget
	var e=window.event || e
	d.distancex=e.clientX-d.initmousex //horizontal distance travelled relative to starting point
	d.distancey=e.clientY-d.initmousey
	if (etarget.className=="drag-handle") //if target element is "handle" div
		d.move(etarget._parent, e)
	else if (etarget.className=="drag-resizearea") //if target element is "resize" div
		d.resize(etarget._parent, e)
	return false //cancel default dragging behavior
},

getviewpoint:function(){ //get window viewpoint numbers
	var ie=document.all && !window.opera
	var domclientWidth=document.documentElement && parseInt(document.documentElement.clientWidth) || 100000 //Preliminary doc width in non IE browsers
	this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
	this.scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset
	this.scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset
	this.docwidth=(ie)? this.standardbody.clientWidth : (/Safari/i.test(navigator.userAgent))? window.innerWidth : Math.min(domclientWidth, window.innerWidth-16)
	this.docheight=(ie)? this.standardbody.clientHeight: window.innerHeight
},

rememberattrs:function(t){ //remember certain attributes of the window when it's minimized or closed, such as dimensions, position on page
	this.getviewpoint() //Get current window viewpoint numbers
	t.lastx=parseInt((t.style.left || t.offsetLeft))-dhtmlwindow.scroll_left //store last known x coord of window just before minimizing
	t.lasty=parseInt((t.style.top || t.offsetTop))-dhtmlwindow.scroll_top
	t.lastwidth=t.style.width //store last known width of window just before minimizing
},

move:function(t, e){
	t.style.left=dhtmlwindow.distancex+dhtmlwindow.initx+"px"
	t.style.top=dhtmlwindow.distancey+dhtmlwindow.inity+"px"
},

enablecontrols:function(e){
	var d=dhtmlwindow
	var sourceobj=window.event? window.event.srcElement : e.target //Get element within "handle" div mouse is currently on (the controls)
	if (/Close/i.test(sourceobj.getAttribute("title"))) //if this is the "close" control
		d.close(this._parent)
	return false
},

//changes for CCT56853 start
close:function(t){
	
//changes for CCT56853	end
/* Modified by b12874 for Online Feedback - WOW on 20-10-2008 START*/
if(document.getElementById('feedBackajaxbox')!=null && document.getElementById('feedBackajaxbox').style.zIndex!=-1){
	prehideBlock();
	return;
}
/* Modified by b12874 for Online Feedback - WOW on 20-10-2008 end*/
	t.contentarea.innerHTML ="";

	try{
		var closewinbol=t.onclose()
	}
	catch(err){ //In non IE browsers, all errors are caught, so just run the below
		alert(err)
		var closewinbol=true
 }
	finally{ //In IE, not all errors are caught, so check if variable isn't defined in IE in those cases
		if (typeof closewinbol=="undefined"){
			alert("An error has occured somwhere inside your \"onclose\" event handler")
			var closewinbol=true
		}
	}
	if (closewinbol){ //if custom event handler function returns true
		if (t.state!="minimized") //if this window isn't currently minimized
			dhtmlwindow.rememberattrs(t) //remember window's dimensions/position on the page before closing
		t.style.display="none"
	}
	return closewinbol
},

show:function(t){
	if (t.lastx) //If there exists previously stored information such as last x position on window attributes (meaning it's been minimized or closed)
		dhtmlwindow.restore(t.controls.firstChild, t) //restore the window using that info
	else
		t.style.display="block"
	t.state="fullview" //indicate the state of the window as being "fullview"
},

ajax_connect:function(url, t){
	var page_request = false
	var bustcacheparameter=""
	if (window.XMLHttpRequest) // if Mozilla, IE7, Safari etc
		page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE6 or below
		try {
		page_request = new ActiveXObject("Msxml2.XMLHTTP")
		} 
		catch (e){
			try{
			page_request = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){}
		}
	}
	else
		return false
	page_request.onreadystatechange=function(){dhtmlwindow.ajax_loadpage(page_request, t)}
	if (this.ajaxbustcache) //if bust caching of external page
		bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
	page_request.open('GET', url+bustcacheparameter, true)
	page_request.send(null)
},

ajax_loadpage:function(page_request, t){
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
		
		if(typeof recalonload != "undefined" && recalonload == 'webnote')
		{
		var unsText=unescape(page_request.responseText);
	t.contentarea.innerHTML=unsText;
	var notesCnt = document.getElementById('totalNotesCnt').value;
			//alert('notesCnt:'+notesCnt);
			for(i=0;i<notesCnt; i++){
				var noteId = 'noteBody'+i;
				
				if(document.getElementById(noteId).innerHTML.length>30)
				{//alert("length is <25")
				document.getElementById(noteId).innerHTML=document.getElementById(noteId).innerHTML.substring(0,29)+"...";
				}
				

				var anchId = 'anch'+i;
				
				if(document.getElementById(anchId).title>250)
				{//alert("length is >250")
				document.getElementById(anchId).title = document.getElementById(anchId).title.substring(0,249);
				}
				//alert(document.getElementById(noteId).innerHTML);
			}
		} else {
			t.contentarea.innerHTML=page_request.responseText;
		}
	
	if(typeof progressdiv != "undefined" && progressdiv != null)
		{
		progressdiv.style.visibility="hidden";
		}
       //  t.removeChild(progressdiv);
	}
},


stop:function(){
	dhtmlwindow.etarget=null //clean up
	document.onmousemove=null
	document.onmouseup=null
},

addEvent:function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
	var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false)
	else if (target.attachEvent)
		target.attachEvent(tasktype, functionref)
},

cleanup:function(){
	window.onload=null
}

} //End dhtmlwindow object

document.write('<div id="dhtmlwindowholder"><span style="display:none">.</span></div>') //container that holds all dhtml window divs on page
window.onunload=dhtmlwindow.cleanup

function explainDiagram(text){
var explainBox = document.getElementById('blockDetails');
explainBox.innerHTML = text;
}
function explainPhoto(text){
var explainBox = document.getElementById('photoDetails');
explainBox.innerHTML = text;
}
function changePhoto(img){
var imgBox = document.getElementById('photoDiagram');
imgBox.innerHTML = "<img src='"+img+"'>";
}
/** Add START by B17090 on 14-Oct-2009 For CCT68841  **/
function playVideo(content,title,width,height){
    openVideoFile(content,title,'','','',width,height);
}
function openVideo(content,title,duration,recrdVideoUrl,width,height){
	openVideoFile(content,title,duration,'',recrdVideoUrl,width,height); 
}
/** Add END by B17090 on 14-Oct-2009 For CCT68841  **/
// This will not be used After clients have modified functions in collaterals to call new methods
// that will also track the video history
/** Add START by B17090 on 14-Oct-2009 For CCT68841  **/
function openVideoFile(content,title,duration,flashPlayer,recrdVideoUrl,width,height){

	if (!width) { width = 425; }
	if (!height) { height = 350; }
	windowWidth = width;
	windowHeight = parseInt(height) + 50;
	if (!flashPlayer) {flashPlayer = "/files/multimedia/player.swf";}
	var defaultSwfExpressInstall =  "/files/ajax/flvplayer/expressInstall.swf"
	var requiredSwfVersion = "9.0.28";
	
	if(content != undefined && content!=null && content  != '' ) { 
		
		recordVideoHistory(content,'WATCH_VIDEO');
	}
	/** Add END by B17090 on 14-Oct-2009 For CCT68841  **/

	var time = 0;
	youtube_metrics(content,title,duration,time);
	var flashplayer_path= flashPlayer;
	if ( content.length < 4 ){
		alert("Incorrect Video Format");
		return false;
	}
	
	videoURL=content;
	videoTitle=title;

	var video_extn = content.substring( (content.length - 4) );
	
	if ( video_extn != '' ){
		video_extn = video_extn.toLowerCase(); 
	}
	
	if(video_extn.indexOf(".swf")!=-1){
		content1 ="<div id='flshc'></div>";
		ajaxwin=dhtmlwindow.open('ajaxbox',content1,title, 'width='+windowWidth+'px,height='+windowHeight+'px,left=250px,top=100px,resize=0,scrolling=0','video','inline');
		var flashvars = { autoplay: true };	
//		var params = { scale: "noscale", allowfullscreen: "true", salign: "tl", bgcolor: "#ffffff"};
		var params = { allowfullscreen: "true", salign: "tl", bgcolor: "#ffffff"};
		var attributes = { align: "left", base: "." };
		swfobject.embedSWF(content, "flshc", width, height, requiredSwfVersion, defaultSwfExpressInstall, flashvars, params, attributes);
	} else if (video_extn.indexOf(".flv")!=-1){
		content1 ="<div id='flshc'></div>";
		ajaxwin=dhtmlwindow.open('ajaxbox',content1,title, 'width='+windowWidth+'px,height='+windowHeight+'px,left=250px,top=100px,resize=0,scrolling=0','video','inline');
//		var flashvars = {video: content, autoplay: true};	
		var flashvars = {file: content, autostart: true};	
		var params = { allowfullscreen: "true", salign: "tl", bgcolor: "#ffffff"};
		var attributes = { align: "left", base: "." };
		swfobject.embedSWF(flashPlayer, "flshc", width, height, requiredSwfVersion, defaultSwfExpressInstall, flashvars, params, attributes);
	} else if (video_extn.indexOf(".gif")!=-1){
		content='<img src=\''+content+'\' width=\''+width+'\' height=\''+height+'\'>';
		ajaxwin=dhtmlwindow.open('ajaxbox',content,title, 'width='+windowWidth+'px,height='+windowHeight+'px,left=250px,top=100px,resize=0,scrolling=0','video','inline');
	
	} else if ( isVideoType( video_extn ) ){
		if ( video_extn != '.mov' ){
			content='&nbsp;<object id=\'mediaplayer\' width=\''+width+'\' height=\''+height+'\' standby=\'Freescale Videos\' type=\''+ getFileType(video_extn) +'\'><param name=\'freescalevideos\' value=\''+ content +'\'><embed type=\''+ getFileType(video_extn) +'\' src=\''+ content +'\' name=\'mediaplayer\' width=\''+width+'\' height=\''+heigth+'\' autoplay=\'true\'></embed></object>';
		} else {
			content='&nbsp;<object height=\''+height+'\' width=\''+width+'\' codebase=\'http://www.apple.com/qtactivex/qtplugin.cab\'> <param name=\'src\' value=\''+ content +'\' ><param name=\'autoplay\' value=\'true\'> <param name=\'control\' value=\'StatusField\'><param name=\'console\' value=\'video\'><embed height=\''+height+'\' width=\''+width+'\' type=\''+ getFileType(video_extn) +'\' pluginspage=\'http://www.apple.com/quicktime/download/\' src=\''+content+'\' controls=\'statusfield\' console=\'video\' autoplay=\'true\'/></object>';
		}
		ajaxwin=dhtmlwindow.open('ajaxbox',content,title, 'width='+windowWidth+'px,height='+windowHeight+'px,left=250px,top=100px,resize=0,scrolling=0','video','inline');
	} else {
		content = '&nbsp;<object width=\''+width+'\' height=\''+height+'\'><param name=\'movie\' value=\''+content+'\' ></param><embed src=\''+content+'&autoplay=1\' type=\'application/x-shockwave-flash\' width=\'100%\' height=\'96%\' ></embed></object>';
		ajaxwin=dhtmlwindow.open('ajaxbox',content,title, 'width='+windowWidth+'px,height='+windowHeight+'px,left=250px,top=100px,resize=0,scrolling=0','video','inline');
	}
	ajaxwin.style.zIndex=1000;
	return false;
}




/* WOW: params for adding addthis widget : end*/

function isVideoType( file_extn ){
	var flg = false;

	if ( ( file_extn.indexOf(".mov")!=-1) || ( file_extn.indexOf(".wmv")!=-1) || ( file_extn.indexOf(".mpg")!=-1) || ( file_extn.indexOf(".avi")!=-1) ){
		flg = true;
	}
	return flg;
}
function getFileType(file_extn){
	
	var filetype='';
	
	switch (file_extn){
		case '.flv': 
			filetype='application/x-shockwave-flash';
		case '.wmv':
			filetype='audio/x-pn-realaudio-plugin';
			break; 
		case '.mov': 
			filetype='video/quicktime';
			break; 
		case '.mpg':	
			filetype='application/x-oleobject';
			break; 
		case '.gif':	
			filetype='image/gif';
			break; 
		case '.avi':	
			filetype='application/x-oleobject';
			break; 
		default :
			filetype='none';
	}
	return filetype;
}

/* modified for video cct end */

/* modifications for 56853 */

function displayBlockForHistory(){
	//////////alert("loading displayBlockForHistory");
		openHistoryBlock('My History', '', '','','750','440','');
	}
	function displayBlockForDownload(){
	//////////alert("loading displayBlockForHistory");
		openDownloadBlock('My History', '', '','','750','440','');
	}
	function displayBlockForTraining(){
	//////////alert("loading displayBlockForHistory");
		opentrainingBlock('My History', '', '','','750','440','');
	}
	function displayBlockForNotes(){
	//////////alert("loading displayBlockForHistory");
		openNotesBlock('My History', '', '','','750','440','');
	}

function openHistoryBlock(window_title,blockDiagUrl,code,psp_URL,width,height,fastpreview){
				var url = "/webapp/history/fetchHistory.sp";
			//////alert("loading openHistoryBlock");
			if(document.getElementById('historyajaxbox')!=null)
	     {
			document.getElementById("dhtmlwindowholder").removeChild(document.getElementById('historyajaxbox'));
			
			
			}
		ajaxwinhistory=dhtmlwindow.open('historyajaxbox',url,window_title, 'width='+width+'px,height='+height+'px,left=83px,top=64px','history');
		//////alert(document.getElementbyId('ajaxbox').style.zIndex);
		//ajaxwinhistory.style.overflowX="hidden";
	//ajaxwinhistory.style.overflowY="auto";
		ajaxwinhistory.style.zIndex=51;
		//ajaxwinhistory.style.overflowY ="auto";
		//ajaxwinhistory.style.overflowX="hidden";
		/* dcsMultiTrack('DCS.dcsuri',blockDiagUrl,'WT.ti','Block Diagram View','DCS.dcsref',psp_URL,'WT.dl','1'); */
		return ajaxwinhistory ;
	}
	function openDownloadBlock(window_title,blockDiagUrl,code,psp_URL,width,height,fastpreview){
				var url = "/webapp/history/fetchHistory.sp?commandID=FETCH_DOWNLOAD";
			//	////////alert("loading openHistoryBlock");
			if(document.getElementById('historyajaxbox')!=null)
	     {
			document.getElementById("dhtmlwindowholder").removeChild(document.getElementById('historyajaxbox'));
			
			
			}
		ajaxwinhistory=dhtmlwindow.open('historyajaxbox',url,window_title, 'width='+width+'px,height='+height+'px,left=83px,top=64px','downloaded');
		/* dcsMultiTrack('DCS.dcsuri',blockDiagUrl,'WT.ti','Block Diagram View','DCS.dcsref',psp_URL,'WT.dl','1'); */
		ajaxwinhistory.style.zIndex=51;
		return ajaxwinhistory ;
	}
	function opentrainingBlock(window_title,blockDiagUrl,code,psp_URL,width,height,fastpreview){
				var url = "/webapp/history/fetchHistory.sp?commandID=FETCH_LAUNCH_TRNG";
			//	////////alert("loading openHistoryBlock");
			if(document.getElementById('historyajaxbox')!=null)
	     {
			document.getElementById("dhtmlwindowholder").removeChild(document.getElementById('historyajaxbox'));
			
			}
		ajaxwinhistory=dhtmlwindow.open('historyajaxbox',url,window_title, 'width='+width+'px,height='+height+'px,left=83px,top=64px','training');
		/* dcsMultiTrack('DCS.dcsuri',blockDiagUrl,'WT.ti','Block Diagram View','DCS.dcsref',psp_URL,'WT.dl','1'); */
		ajaxwinhistory.style.zIndex=51;
		return ajaxwinhistory ;
	}
	function openNotesBlock(window_title,blockDiagUrl,code,psp_URL,width,height,fastpreview){
				var url = "/webapp/history/fetchHistory.sp?commandID=FETCH_WEBNOTES_HISTORY";
			//	////////alert("loading openHistoryBlock");
			if(document.getElementById('historyajaxbox')!=null)
	     {
			document.getElementById("dhtmlwindowholder").removeChild(document.getElementById('historyajaxbox'));
			
			
			}
		ajaxwinhistory=dhtmlwindow.open('historyajaxbox',url,window_title, 'width='+width+'px,height='+height+'px,left=83px,top=64px','webnote');
		/* dcsMultiTrack('DCS.dcsuri',blockDiagUrl,'WT.ti','Block Diagram View','DCS.dcsref',psp_URL,'WT.dl','1'); */
		ajaxwinhistory.style.zIndex=51;
		return ajaxwinhistory ;
	}


//////////////alert("request ajax js");

var Request = new Object();

Request.queue = [];

Request.readyState = true;

Request.timeOut = null;

Request.processQueue = function() {
	if (Request.queue.length > 0) {
		if (Request.readyState == true) {
			var params = Request.queue.shift();
			Request.readyState = false;
			Request.send (params.url, params.method, params.callback, params.data, params.urlencoded, params.name);
			Request.timeOut = setTimeout(Request.processQueue, 20);
		} else {
			Request.timeOut = setTimeout(Request.processQueue, 20);
		}
	} else {
		Request.timeOut = null;
	}
}

Request.queueUrl = function(url, method, data, callback, args, urlencoded, name) {
	var params = new Object();
	params.url = url;
	params.method = method;
	params.callback = callback;
	params.data = data;
	params.urlencoded = urlencoded;
	params.name = name;
	Request.queue.push(params);
	if (Request.timeOut == null) {
		Request.timeOut = setTimeout(Request.processQueue, 20);
	}
	return params;
}

Request.send = function(url, method, data, callback, args, urlencoded, name) {
	 //////////////alert('requesting : ' + url);
	var req;
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (typeof name == "undefined") {
		name = "";
	} else {
		name += "\n";
	}




	var readychange = function() {
		if (req.readyState == 4) {// only if req shows "loaded"
			if (req.status < 400) {// only if "OK"
					callback(req,args);
					delete callback;
			} else if (typeof req == "undefined" || typeof req.status == "undefined") {
				// don't do anything. user has navigated away
				delete callback;
			} else if (req.status == 401) { // unauthorized
				////////////alert(_("Session Expired. You would need to relogin"));
				delete callback;
				//window.location.href = "/webapp/";
			} else if (req.status == 404) {
				// should not happen, but ignore it for now
			} else {
				switch(req.status) {
					// windows error codes
					case 12002: // server timeout
					case 12029: case 12030: case 12031: // dropped connection
					case 12152: // connection closed by server
					case 13030:
						////////////alert(name + _("There was a network problem. Please reload the page."));
						break;
					case 500: case 503:
						////////////alert(name + _("There was an internal server error. Please try later."));
						break;
					default:
						////////////alert(_("There was a problem loading data:") + "\nstatus: " + req.status+ "/" + req.statusText + "\n" + url);

				}
				delete callback;
			}
			Request.readyState = true;
		}
	};
	function do_request() {
		if (method=="POST") {
			req.open("POST", url, true);
			if (urlencoded) req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			req.onreadystatechange = readychange;
			req.send(data);
		} else {
			req.open("GET", url, true);
			req.onreadystatechange = readychange;
			req.send(null);
		}
	};
	//do_request();
	return req;
}

Request.sendRawPOST = function(url, data, callback, args, name) {
	Request.send(url, "POST", data, callback, args, false, name);
}
Request.sendPOST = function(url, data, callback, args, name) {
	Request.send(url, "POST", data, callback, args, true, name);
}
Request.sendGET = function(url,  callback, args, name) {
	// ////////////alert('within sendGET');
	return Request.send(url, "GET", '', callback, args, name);
}
function getKey(varName){
	var varName_a = new Array();
	varName_a = varName.split('<;>');
	////////alert(varName_a[0]);
	////////alert(""+varName_a[1]);

	
	return varName_a;
}
function callbackBROWSE_WEBPAGE(response)
{
var mdiv = document.getElementById('BROWSE_WEBPAGE');
var mdiv1=document.getElementById('button_WEBPAGE');
var key=getKey(response.responseText);
if(typeof key[1] != 'undefined' && key[1] != null)
	{////////alert(" key[1] != 'undefined'");
mdiv.innerHTML=key[0];
mdiv.style.height="22.1em";
mdiv1.innerHTML=key[1];
	}
 else
	{
     ////////alert(" key[1] =undefined'");
	mdiv.innerHTML=key[0];
 mdiv1.style.display='none';
	}
};
function callbackDownLoad(response)
{var mdiv = document.getElementById('DOWNLOAD');
var mdiv1=document.getElementById('button_undefined');
var key=getKey(response.responseText);
if(typeof key[1] != 'undefined' && key[1] != null)
	{////////alert(" key[1] != 'undefined'");
mdiv.innerHTML=key[0];
mdiv.style.height="27.2em";
mdiv1.innerHTML=key[1];
	}
 else
	{
     ////////alert(" key[1] =undefined'");
	mdiv.innerHTML=key[0];
 mdiv1.style.display='none';
	}
}
function callbackWATCH_VIDEO(response)
{var mdiv = document.getElementById('WATCH_VIDEO');
var mdiv1=document.getElementById('button_VIDEO');
var key=getKey(response.responseText);
if(typeof key[1] != 'undefined' && key[1] != null)
	{////////alert(" key[1] != 'undefined'");
mdiv.innerHTML=key[0];
mdiv.style.height="22.1em";
mdiv1.innerHTML=key[1];
	}
 else
	{
     ////////alert(" key[1] =undefined'");
	mdiv.innerHTML=key[0];
 mdiv1.style.display='none';
	}

}
function callbackWEBNOTES_HISTORY(response)
{
	var mdiv = document.getElementById('WEBNOTES_HISTORY');
var mdiv1=document.getElementById('button_HISTORY');
var key=getKey(unescape(response.responseText));
if(typeof key[1] != 'undefined' && key[1] != null)
	{////////alert(" key[1] != 'undefined'");
mdiv.innerHTML=key[0];
mdiv.style.height="23.4em";
mdiv1.innerHTML=key[1];
	}
 else
	{
     ////////alert(" key[1] =undefined'");
	mdiv.innerHTML=key[0];
 mdiv1.style.display='none';
	}
	var notesCnt = document.getElementById('totalNotesCnt').value;
			//////alert('notesCnt:'+notesCnt);
			for(i=0;i<notesCnt; i++){
				var noteId = 'noteBody'+i;
				////alert(noteId);
				////alert(document.getElementById(noteId).innerHTML);
             
				//var unesc=document.getElementById(noteId).innerHTML;
				if(document.getElementById(noteId).innerHTML.length>30)
				{////alert("length is >25")
				document.getElementById(noteId).innerHTML=document.getElementById(noteId).innerHTML.substring(0,29)+"...";
				}
				

				var anchId = 'anch'+i;
				////alert(noteId);
				////alert(document.getElementById(noteId).innerHTML);
				if(document.getElementById(anchId).title>250)
				{////alert("length is >250")
				document.getElementById(anchId).title = document.getElementById(anchId).title.substring(0,249);
				}

}


}
function callbackLAUNCH_TRNG(response)
{var mdiv = document.getElementById('LAUNCH_TRNG');
var mdiv1=document.getElementById('button_TRNG');
var key=getKey(response.responseText);
if(typeof key[1] != 'undefined' && key[1] != null)
	{////////alert(" key[1] != 'undefined'");
mdiv.innerHTML=key[0];
mdiv.style.height="22.1em";
mdiv1.innerHTML=key[1];
	}
 else
	{
    mdiv.innerHTML=key[0];
 mdiv1.style.display='none';
	}
}
function ajaxcallforBROWSE_WEBPAGE(commandID,img_id,td_id,fid,buttonid){
	 
	minmax(commandID,img_id,td_id,fid,buttonid);
	var nObj = document.getElementById(commandID);
if(nObj!=null&&nObj.innerHTML=='')
	 {
	progressbar(commandID,nObj);
	 Request.sendPOST('/webapp/history/fetchHistory.sp','commandID=FETCH_'+commandID+'&sectionView=true',callbackBROWSE_WEBPAGE); 
	 }
 }
 function ajaxcallforDownLoad(commandID,img_id,td_id,fid,buttonid){
minmax(commandID,img_id,td_id,fid,buttonid);
var nObj = document.getElementById(commandID);
if(nObj!=null&&nObj.innerHTML=='')
	 {
	progressbar(commandID,nObj);
Request.sendPOST('/webapp/history/fetchHistory.sp','commandID=FETCH_'+commandID+'&sectionView=true',callbackDownLoad);  
	 }
 }
 function ajaxcallforWATCH_VIDEO(commandID,img_id,td_id,fid,buttonid){
minmax(commandID,img_id,td_id,fid,buttonid);
var nObj = document.getElementById(commandID);
if(nObj!=null&&nObj.innerHTML=='')
	 {
	progressbar(commandID,nObj);
Request.sendPOST('/webapp/history/fetchHistory.sp','commandID=FETCH_'+commandID+'&sectionView=true',callbackWATCH_VIDEO);
}
 }

 function ajaxcallforWEBNOTES_HISTORY(commandID,img_id,td_id,fid,buttonid){
minmax(commandID,img_id,td_id,fid,buttonid);
var nObj = document.getElementById(commandID);
if(nObj!=null&&nObj.innerHTML=='')
	 {
	progressbar(commandID,nObj);
Request.sendPOST('/webapp/history/fetchHistory.sp','commandID=FETCH_'+commandID+'&sectionView=true',callbackWEBNOTES_HISTORY);
 }
 }
 function ajaxcallforLAUNCH_TRNG(commandID,img_id,td_id,fid,buttonid){
	 	minmax(commandID,img_id,td_id,fid,buttonid);
		var nObj = document.getElementById(commandID);
if(nObj!=null&&nObj.innerHTML=='')
	 {
	progressbar(commandID,nObj);
Request.sendPOST('/webapp/history/fetchHistory.sp','commandID=FETCH_'+commandID+'&sectionView=true',callbackLAUNCH_TRNG);
	}
 }
function minmax(div_id,img_id,td_id,fid,buttonid)
{
   if(document.getElementById(div_id).style.display=='none')
	{
	document.getElementById(img_id).src="/shared/images/minus.JPG";
        document.getElementById(td_id).setAttribute("bgColor","#535E7C");
		document.getElementById(fid).setAttribute("color","#BDCDDA");
		document.getElementById(div_id).style.display="block";
		if(document.getElementById(buttonid) != 'undefined' && document.getElementById(buttonid) != null)
		{
		document.getElementById(buttonid).style.display="block";
		}

	}
	else
	{
	 document.getElementById(img_id).src="/shared/images/plus.JPG";
	 document.getElementById(td_id).setAttribute("bgColor","#E6EBEF");
	 document.getElementById(fid).setAttribute("color","#657B90");
     document.getElementById(div_id).style.display='none';
    if(document.getElementById(buttonid) != 'undefined' && document.getElementById(buttonid) != null)
		{
	 document.getElementById(buttonid).style.display='none';
		}
	}


}

function progressbar(commandID,nObj)
{
var div_id="progressid"+commandID;
        nObj.innerHTML="<div id='"+div_id+"'></div>";
   var progressdiv=document.getElementById(div_id);
	if(typeof progressdiv != "undefined" && progressdiv != null)
	{
		//alert("progressdiv");
	progressdiv.style.visibility="visible";
	progressdiv.innerHTML=" <img style=\"padding-left:200px\" src=\"/shared/images/fs_anilogo.gif\" />";
    progressdiv.style.position="relative";
	}
}


function displayHistoryHelp(code){ 
		var url = "/webapp/shared/components/inc_collateral.jsp?code="+code;
		var window_title = "FAQ"
		var width = "550";
		var height = "300";
		historyHelpPopup=dhtmlwindow.open('HistoryHelp',url,window_title, 'width='+width+'px,height='+height+'px,left=100px,top=100px,resize=0,scrolling=1');
		if(typeof ajaxwinhistory != "undefined" && ajaxwinhistory != null)
		historyHelpPopup.style.zIndex=ajaxwinhistory.style.zIndex+2;
		return historyHelpPopup ;
}trueWindowOpen = window.open;
window.open = proxyWindowOpen;
function proxyWindowOpen(url, type, attributes){
    //Add logic to check if the URL	being opened i.e. param1 is download, if yes trigger download recording

	var parentId= document.getElementById("pageNodeId")?document.getElementById("pageNodeId").value : "";
	var parentPageType= document.getElementById("pageType")?document.getElementById("pageType").value : "";
	var commandID= "DOWNLOAD" ;
	
	var unreg_dl = dcsCheckDownload(url);

	var reg_dl = url.indexOf("webapp/Download");
	var mod_dl = url.indexOf("download/mod_download.jsp");
    var lic_dl = url.indexOf("download/license.jsp");	

	if (reg_dl != -1 || mod_dl != -1 || lic_dl != -1 ){
		url = url + '&Parent_nodeId='+ parentId +'&Parent_pageType='+parentPageType;
	}

	if(unreg_dl){
		recordDwnldHistory(parentId,parentPageType,url,commandID);		
	}

    //invoke the real window.open
    return trueWindowOpen(url, type, attributes);
}

var e=(navigator.appVersion.indexOf("MSIE")!=-1)?"click":"mousedown";
eventClickBind(e,"downloadClicked");

// added by r1051z on 2/20/2009 for History proeject Start
// captured event if user right clicked and downloaded collateral
eventClickBind("contextmenu","downloadRightClicked");
// added by r1051z on 2/20/2009 for History proeject End

function eventClickBind(event,func){
	 if ((typeof(window[func])=="function")&&document.body){
		 if (document.body.addEventListener){
		 document.body.addEventListener(event, window[func], true);
		   }
		 else if(document.body.attachEvent){
		document.body.attachEvent("on"+event, window[func]);
		   }
	 }
}

// it matches if the link clicked
// have the list of files extensions
function fileTypeMatch(path, typelist){	
	 var type=path.substring(path.lastIndexOf(".")+1,path.length);
	 var types=typelist.split(","); 
	 var lower_type = type.toLowerCase();
	 for (var i=0;i<types.length;i++){
	  if (lower_type==types[i]){	
	     return true;
	   }
	 }
	 return false;
}


function anchorEvt(evt,tag){
	 var e=evt.target||evt.srcElement;
	 while (e.tagName&&(e.tagName!=tag)){
	   e=e.parentElement||e.parentNode;
	 }
	 return e;
}
function dcsCheckDownload(pth){		
  if(pth.indexOf("/")!=-1){	
	  var link_path = new Array();
      link_path = pth.split('/'); 
      if(link_path[1].toUpperCase().indexOf("FILES")!=-1){		
	  return true;					         
	}	
 }
 return false;
}

//This function checks that the hostname of the link
//matches the list of freescale hostnames 
function IsOnsite(hostname){
	 var doms="www.freescale.com";
	 var doms="@@ONSITEDOMAINS@@";
	 var aDoms=doms.split(',');
	 for (var i=0;i<aDoms.length;i++){ 
	   if (aDoms[i].indexOf(hostname)!=-1){
	     return 1;
	    }
	 }
	 return 1;           //change it ro return 0 
}

function recordWebpageHistory(pageId, pageType,commandID){	
 Request.sendPOST('http://www.freescale.com/webapp/history/recordHistory.sp','assetID='+pageId+'&assetType='+pageType+'&commandID='+commandID, checkSuccessHistory);
 }
 function checkSuccessHistory(){	
 }
/** Add start by B17090 on 14-Oct-2009 For CCT68841  **/
 function recordVideoHistory(video_url,commandID){	
  Request.sendPOST('http://www.freescale.com/webapp/history/recordHistory.sp','assetID='+video_url +'&assetType=video&commandID='+commandID, checkSuccessHistory);
 }
/** Add END by B17090 on 14-Oct-2009 For CCT68841  **/
 function recordDwnldHistory(parentId,parentPageType,download_url,commandID,historyPopup){
    Request.sendPOST('http://www.freescale.com/webapp/history/recordHistory.sp','downloadLink='+download_url +'&parentID='+parentId +'&parentType='+parentPageType+'&commandID='+commandID+'&assetType=download'+'&fromHistoryPopUp='+historyPopup, checkSuccessHistory);
 }

function dcsEvt(evt,tag){
	var e=evt.target||evt.srcElement;
	while (e.tagName&&(e.tagName!=tag)){
		e=e.parentElement||e.parentNode;
	}
	return e;
}

//This function executes onClick of Anchor Tag
// it checks whether download has been clecked or not
function downloadClicked(evt){		
   evt=evt||(window.event||"");
   if (evt&&((typeof(evt.which)!="number")||(evt.which==1))){		
      var e=anchorEvt(evt,"A");	
	 if(e.hostname && IsOnsite(e.hostname)){	
	  //var types="xls,doc,ppt,tgz,rar,tar,pdf,txt,csv,zip,exe";    
      var reg_dl = e.pathname.indexOf("webapp/Download");
	  var faq_click = e.pathname.indexOf("TransformXMLServlet");
	  var unreg_dl = e.pathname.indexOf("webapp/files");
	  var mod_dl = e.pathname.indexOf("download/mod_download.jsp");
      var lic_dl = e.pathname.indexOf("download/license.jsp");	
	  var page_nodeId = document.getElementById("pageNodeId")?document.getElementById("pageNodeId").value : "";
	  var page_typeName= document.getElementById("pageType")?document.getElementById("pageType").value : "";
	  //var commandId = document.getElementById("recrdHistDwnlodComnd")?document.getElementById("recrdHistDwnlodComnd").value : "";
	  var commandId = "DOWNLOAD" ;
	  var pth=e.pathname?((e.pathname.indexOf("/")!=0)?"/"+e.pathname:e.pathname):"/";
	  var qry=e.search?e.search.substring(e.search.indexOf("?")+1,e.search.length):"";
	  var is_unsecure_download = dcsCheckDownload(pth);
	  //var typeMatched = dcsTypeMatch(e.pathname,types);
	     if (is_unsecure_download ||(reg_dl != -1)||(lic_dl != -1) || (mod_dl != -1) ){				 
			   if (reg_dl != -1){			
					 e.search= e.search +'&Parent_nodeId='+ page_nodeId +'&Parent_pageType='+page_typeName;
				   }			   
			   else if (lic_dl != -1){
			         e.search= e.search +'&Parent_nodeId='+ page_nodeId +'&Parent_pageType='+page_typeName;					
				  }
			   else if (mod_dl != -1){
			         e.search= e.search +'&Parent_nodeId='+ page_nodeId +'&Parent_pageType='+page_typeName;					
				  }
			   else if(is_unsecure_download){
						var history_popup = 0;
						refer = anchorEvt(evt ,"DIV");
						if(refer != null || refer != "undefined"){
							if (refer.nodeType == 1){
								if ((String(refer.nodeName)=="DIV") && (String(refer.id) == "DOWNLOAD")){
									while (!history_popup){
										refer = refer.parentNode;
										if (refer.nodeType==1){ //check that the node is a tag, not text (type=3)
											if ((String(refer.nodeName)=="DIV") && (String(refer.id) == "historyajaxbox")){
												history_popup = 1;
												break;
											} // end of div and historyajaxbox check
											else if (String(refer.nodeName)=="BODY") {
												break;	
											} //end of else if
										} // end of nodeType = 1 check
									} // end of while loop*/
								}
							}
						}
						if(history_popup){
							recordDwnldHistory(page_nodeId,page_typeName,pth,commandId,history_popup);
						}else{
							recordDwnldHistory(page_nodeId,page_typeName,pth,commandId);
						}	
				   }				
				}			 
		   }
		}
 }

// added by r1051z on 2/20/2009 for History proeject Start
// captured event if user right clicked and downloaded collateral
//This function executes onRightClick of Anchor Tag
// it checks whether download has been clicked or not by right clicking of mouse
function downloadRightClicked(evt){
	evt=evt||(window.event||"");
	 if (evt){
		 var btn=evt.which||evt.button;
		 if ((btn!=1)||(navigator.userAgent.indexOf("Safari")!=-1)){
			 // this function will return anchor tag if clicked on any other element, will traverse backwards
			 e = anchorEvt(evt,"A");
				 if ((typeof(e.href)!="undefined")&&e.href){
					 if ((typeof(e.protocol)!="undefined")&&e.protocol&&(e.protocol.indexOf("http")!=-1)){
						 if(e.hostname && IsOnsite(e.hostname)){
							  //var types="xls,doc,ppt,tgz,rar,tar,pdf,txt,csv,zip,exe";    
							  var reg_dl = e.pathname.indexOf("webapp/Download");
							  var faq_click = e.pathname.indexOf("TransformXMLServlet");
							  var unreg_dl = e.pathname.indexOf("webapp/files");
							  var mod_dl = e.pathname.indexOf("download/mod_download.jsp");
							  var lic_dl = e.pathname.indexOf("download/license.jsp");	
							  var page_nodeId = document.getElementById("pageNodeId")?document.getElementById("pageNodeId").value : "";
							  var page_typeName= document.getElementById("pageType")?document.getElementById("pageType").value : "";
							  //var commandId = document.getElementById("recrdHistDwnlodComnd")?document.getElementById("recrdHistDwnlodComnd").value : "";
							  var commandId = "DOWNLOAD" ;
							  var pth=e.pathname?((e.pathname.indexOf("/")!=0)?"/"+e.pathname:e.pathname):"/";
							  var qry=e.search?e.search.substring(e.search.indexOf("?")+1,e.search.length):"";
							  var is_unsecure_download = dcsCheckDownload(pth);
							  //var typeMatched = dcsTypeMatch(e.pathname,types);
								 if (is_unsecure_download ||(reg_dl != -1)||(lic_dl != -1) || (mod_dl != -1) ){				 
									   if (reg_dl != -1){			
											 e.search= e.search +'&Parent_nodeId='+ page_nodeId +'&Parent_pageType='+page_typeName;
										   }			   
									   else if (lic_dl != -1){
											 e.search= e.search +'&Parent_nodeId='+ page_nodeId +'&Parent_pageType='+page_typeName;					
										  }
									   else if (mod_dl != -1){
											 e.search= e.search +'&Parent_nodeId='+ page_nodeId +'&Parent_pageType='+page_typeName;					
										  }
									   else if(is_unsecure_download){				     
											var history_popup = 0;
											refer = anchorEvt(evt ,"DIV");
											if(refer != null || refer != "undefined"){
												if (refer.nodeType == 1){
													if ((String(refer.nodeName)=="DIV") && (String(refer.id) == "DOWNLOAD")){
														while (!history_popup){
															refer = refer.parentNode;
															if (refer.nodeType==1){ //check that the node is a tag, not text (type=3)
																if ((String(refer.nodeName)=="DIV") && (String(refer.id) == "historyajaxbox")){
																	history_popup = 1;
																	break;
																} // end of div and historyajaxbox check
																else if (String(refer.nodeName)=="BODY") {
																	break;	
																} //end of else if
															} // end of nodeType = 1 check
														} // end of while loop*/
													}
												}
											}
											if(history_popup){
												recordDwnldHistory(page_nodeId,page_typeName,pth,commandId,history_popup);
											}else{
												recordDwnldHistory(page_nodeId,page_typeName,pth,commandId);
											}				
										 }				
									}	
										
							}
					 }
				 }
		 }			 
	 }
 } // end of function
// added by r1051z on 2/20/2009 for History proeject end


 

 // This function will be called from flash version of mainserp, when datasheet is clicked. 
 function recordDwnldHistoryFromFlash(path){
	var index  = path.toUpperCase().indexOf("/FILES");
	if (index != -1 )
	{
		var linkurl  = path.substring(index);
		var page_nodeId = document.getElementById("pageNodeId")?document.getElementById("pageNodeId").value : "";
		var page_typeName= document.getElementById("pageType")?document.getElementById("pageType").value : "";
		var commandId =  "DOWNLOAD" ;
		recordDwnldHistory(page_nodeId,page_typeName,linkurl,commandId);
	}
 }

 function recordTrngHistory(training_id,page_Type,commandID){
 Request.sendPOST('/webapp/history/recordHistory.sp','assetID='+training_id +'&assetType='+page_Type+'&commandID='+commandID, checkSuccessHistory);
 }// JavaScript Document

//JS DETECT
function addLoadEvent(func){
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
var BrowserDetect = {
	init: function () {
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

// MORE LESS FUNCTIONALITY
function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
	var element = arguments[i];
	if (typeof element == 'string')
	element = document.getElementById(element);
	if (arguments.length == 1)
	return element;
	elements.push(element);
	}
	return elements;
}


function addEvent( obj, type, fn ) {
	if (obj.addEventListener) {
		obj.addEventListener( type, fn, false );
		EventCache.add(obj, type, fn);
	}
	else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
		EventCache.add(obj, type, fn);
	}
	else {
		obj["on"+type] = obj["e"+type+fn];
	}
}


var EventCache = function(){
	var listEvents = [];
	return {
		listEvents : listEvents,
		add : function(node, sEventName, fHandler){
			listEvents.push(arguments);
		},
		flush : function(){
			var i, item;
			for(i = listEvents.length - 1; i >= 0; i = i - 1){
				item = listEvents[i];
				if(item[0].removeEventListener){
					item[0].removeEventListener(item[1], item[2], item[3]);
				};
				if(item[1].substring(0, 2) != "on"){
					item[1] = "on" + item[1];
				};
				if(item[0].detachEvent){
					item[0].detachEvent(item[1], item[2]);
				};
				item[0][item[1]] = null;
			};
		}
	};
}();

function getUniKeyHistory(varName){
	var varName_a = new Array();
	varName_a = varName.split('_');
	//alert("varName_a   "+varName_a);
	//alert("varName_a[1]  "+varName_a[1]);
	return varName_a[1];
}


function moreLessButtonHistory(targetId,minSize,type,more) {
	//alert("targetId "+ targetId);
	var buttonelement='button_'+getUniKeyHistory(targetId);
	//alert("buttonelement "+buttonelement);
		if(more == 1){
		var linkLabel = "See all";
		var imgLink = "/shared/images/seeMore.gif";	
		var title = "See More" ; //added by b05535 for cct43571 on 23 Apr 2007
	} else {
		var linkLabel = "See less";
		var imgLink = "/shared/images/seeLess.gif";
		var title = "See Less" ; //added by b05535 for cct43571 on 23 Apr 2007
	}
//changed by b05535 for metrics calculation(cct43571) start : 23 Apr 2007
//	var linkContent = "<a href=\"Javascript:resizeBoxHistory('"+targetElement+"','"+minSize+"','"+type+"','"+more+"');\">"+linkLabel+" <img src='"+imgLink+"'></a>";
	var linkContent = "<a href=\"Javascript:resizeBoxHistory('"+targetId+"','"+minSize+"','"+type+"','"+more+"','"+title+"');\">"+linkLabel+" <img src='"+imgLink+"'></a>";
//changed by b05535 for metrics calculation(cct43571) end : 23 Apr 2007
	var divBox = document.getElementById(buttonelement);
	//alert("linkContent  "+linkContent);
	//alert("divbox"+divBox);
	if(typeof divBox != 'undefined' && divBox != null){	
		//alert(" inside divbox"+divBox);
		divBox.innerHTML = linkContent;
	}
}




//addEvent(window,'load',pageLoad);
addEvent(window,'unload',EventCache.flush);

function resizeBoxHistory(targetId,minSize,type,more){
//alert("resizeBoxHistory targetId,minSize,type,more   "+targetId+minSize+type+more);
//set up static variables
	var baseVal = 3.6;
	var bulletBaseVal = 4;
	var linesCorrection = 0.2;

	
	if(BrowserDetect.OS == "Mac"){
		var lineMultiplier = 1.15;
		var bulletMultiplier = 1.3;
	} else if(BrowserDetect.OS == "Linux") {
		var lineMultiplier = 1.15;
		var bulletMultiplier = 1.3;
	} else {
		var bulletBaseVal = 3.7;
		var lineMultiplier = 1.25;
		var bulletMultiplier = 1.4;
	}

if(more == 1){
	var newMore = 0;
	var newHeight = "auto";
} else {
	var newMore = 1;
	if(type > 0){ //lines or bullets
		if(type == 1){
			//alert("type=1");
			var baseVal = baseVal;
			var lineMultiplier = lineMultiplier;
		} else {
			var baseVal = bulletBaseVal;
			var lineMultiplier = bulletMultiplier;
		}
		var actualSize = (minSize-linesCorrection)
		var newHeight = baseVal+(lineMultiplier*actualSize);
		newHeight = newHeight+"em";
		//alert("type="+type+"minSize="+minSize+"corrected to "+newHeight);
	} else { //em values
		var newHeight = minSize+"em";
		//alert("type="+type+"minSize="+minSize+"corrected to "+newHeight)
	
	}
}
	nObj = document.getElementById(targetId);
	if(nObj!=null)
	{
		//alert("nObj  "+nObj);
		//alert("newHeight  "+newHeight);

		nObj.style.height = newHeight;
		
		//alert("targetElement "+targetId+"minSize "+minSize+"type"+type+"newMore"+newMore);
		moreLessButtonHistory(targetId,minSize,type,newMore);
	}
	
}

function hideselectsHistory() { 
for(i=0;i<document.forms.length;i++){ // if there are forms on the page
		frm = document.forms[i];
		var inputs = frm.getElementsByTagName("SELECT");
		
		for (j=0;j<inputs.length;j++){
			if(inputs[j].style.display !='none')
			{
			inputs[j].style.display = 'none';
			}
			else 
			{
              inputs[j].style.display= 'inline';
			}
		}
	}
}
function buynow(part) 
{   
	window.open('../../shoppingcart/popup.jsp?partnumber=' + part, 'Freescale','location=no,toolbar=no,scrollbars=yes,resizable,width=750,height=500');
}

<!-- WR2995 - changed by r9188z dt 01/12/2004 [start] -->
<!-- New function added for obsolete part -->
function buynow_obsoletepart(part){
	var url = '/shoppingcart/popup.jsp?partnumber=' + part;
	var tmp = webURLPrefix();
	url = tmp+url;
	window.open(url, 'Freescale','location=no,toolbar=no,scrollbars=yes,resizable,width=750,height=500');
}
<!-- WR2995 - changed by r9188z dt 01/12/2004 [end] -->

<!-- Added By RZ106C For CCT37858 Start 11-July-2006 -->
function infoImage(code){
	var url = '../../collateralDescription.jsp?code=' + code;
	window.open(url, 'Description','location=no,toolbar=no,scrollbars=yes,resizable,width=500,height=300');
}
<!-- Added By RZ106C For CCT37858 End 11-July-2006 -->

function infoImageSearch(code){
	var url = '../../collateralDescription.jsp?code=' + code;
	window.open(url, 'Description','location=no,toolbar=no,scrollbars=yes,resizable,width=500,height=300');
}


function infoImageSearchMain(code){
	var url = '../collateralDescription.jsp?code=' + code;
	window.open(url, 'Description','location=no,toolbar=no,scrollbars=yes,resizable,width=500,height=300');
}


function ordernow(id)
{
	window.open('shoppingcart.recordmetrics.framework?fivecode=HIBRT&partnumber=' + id + '&distyname=Hibbert', 'Hibbert');
}

function search4Product(thePage)
{
	window.open(thePage);
	parent.close();
	
}

function showDistrib()
{
	var val = document.countryForm.countries[document.countryForm.countries.selectedIndex].value;
	if(val != "")
	{
		document.countryForm.country.value = val;
		document.countryForm.submit();
	}
}

function wheretobuy()  
{
	window.open('/webapp/shoppingcart/wtbpopup.jsp', 'WhereToBuy','location=no,toolbar=no,scrollbars=yes,resizable,width=500,height=390');
}