function openNewWindow(url){
	window.open(url,"","height=400,width=500,resizable=yes,scrollbars=yes,menubar=no,location=no,toolbar=no");
}

function openNewWindow2(url){
   var ht = (2 * window.screen.availHeight) / 3;
   var wd = (2 * window.screen.availWidth) / 3;
   var targetwindow = window.open(url,"chp","height=" + ht + ",width=" + wd + ",resizable=yes,scrollbars=yes,menubar=no,location=no,toolbar=no");
   targetwindow.focus();
}

function fnClose(){
	window.close();
}

function fnOver(object, srcVal, index) {
	object.src = srcVal;	
}

function fnOut(object, srcVal, index) {
	object.src = srcVal;	
}

function fnOverDiv(index) {
	document.getElementById('menuDiv_'+index).className = 'current';
}

function fnOutDiv(index) {
	if(index != selIndex) {
		document.getElementById('menuDiv_'+index).className = 'elem';
	}
}	

function fnChangeMenu(label, docLink, popup, rootIndex, type, imgBase) {
	
	if(imgBase == 'true') {
		var imgObject 	= document.getElementById('menuImage_'+selIndex);
		if(eval(imgObject)){
			imgObject.src = images[selIndex][0];
			imgObject.onmouseover=function() {             
				this.src=images[selIndex][1];           
			}; 
			imgObject.onmouseout=function() {             
				this.src=images[selIndex][0];           
			};          
		}
		var selectedRoot = document.getElementById('menuImage_'+rootIndex);
		if(eval(selectedRoot)){
			selectedRoot.src = images[rootIndex][1];
			selectedRoot.onmouseover=function() {};
			selectedRoot.onmouseout=function() {};         
		}
	} else {
		
		document.getElementById('menuDiv_'+selIndex).className = 'elem';
		document.getElementById('menuDiv_'+rootIndex).className = 'current';
	}
	selIndex = rootIndex;
	
	if(popup == true || type != "HTML") {
		window.open(docLink);
	} else {
		
		pLinkTrail = new Array();
		addTrail(docLink, label);
		document.location.hash = 'content='+docLink +','+selIndex+','+label;
		openContent(docLink, label);
	}
}

function openContent(docLink, label){
	
	document.getElementById('loader').style.display= "block";
	if(label != '' ) {
		document.title = ChpViewerBean.getLabel(label, setTitle);
	}
	docLink = basePath + docLink; 
	ChpViewerBean.getContent(docLink, errFilePath, brandId, renderContent);
}

function openContentPLink(docLink, label){
	openContent(docLink, label);
	addTrail(docLink, label);
}

function addTrail(docLink, label) {
	var size 		= pLinkTrail.length;
	var trailItem 	= new Array();
	trailItem[0] 	= docLink;
	trailItem[1] 	= label;
	pLinkTrail[size]= trailItem;
	if(eval(document.getElementById('back'))){
		document.getElementById('back').style.display= size >0?"block":"none";
	}
}

function backTrail(){
	
	var newPLinkTrail = new Array();
	for(var i=0; i< pLinkTrail.length-1; i++){
		newPLinkTrail[i] = pLinkTrail[i];
	}
	pLinkTrail 		= newPLinkTrail;
	var size 		= pLinkTrail.length-1
	var trailItem 	= pLinkTrail[size];
	docLink = trailItem[0];
	label 	= trailItem[1];
	openContent(docLink, label);
	document.getElementById('back').style.display= size >0?"block":"none";
}

function setTitle(title) {   
	document.title = title;
	document.getElementById('title').innerHTML= title;
}

function renderContent(jspData) {   
	document.getElementById('mainContent').innerHTML = jspData;
	document.getElementById('loader').style.display= "none";
}

function fnRedirect() {
   var docHash = document.location.hash;
   if(docHash.indexOf("#content")>-1){
   	   var docLink = docHash.substring(docHash.indexOf('=')+1,docHash.indexOf(','));
   	   docHash 	   = docHash.substring(docHash.indexOf(',')+1,docHash.length);
   	   var index   = docHash.substring(0,docHash.indexOf(','));
   	   docHash 	   = docHash.substring(docHash.indexOf(',')+1,docHash.length);
   	   var label   = docHash.substring(0,docHash.length);
   	   for(var i=0; i<6; i++) {
   	   	if(eval(document.getElementById('menuDiv_'+i))){
   	   		document.getElementById('menuDiv_'+i).className = 'elem';
   	   	}
   	   }
   	   document.getElementById('menuDiv_'+index).className = 'current';
   	   pLinkTrail = new Array();
	   addTrail(docLink, label);
	   openContent(docLink,label);	
   }
}


sfHover = function() {
	if(eval(document.getElementById("nav"))){
		var sfEls = document.getElementById("nav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}

if(navigator.appName =="Netscape" || navigator.appName =="Safari")
{
window.onload = sfHover;
window.onload = fnRedirect;
}
else{
if (window.attachEvent) window.attachEvent("onload", sfHover);
if (window.attachEvent) window.attachEvent("onload", fnRedirect);
}

var selObject = '';
function fnChangeFont(fontObject) {
	var fontId	= fontObject.id;
	fontObject.className= fontId+"_on";
	if(eval(selObject)){
		selObject.className = selObject.id +'_off';	
	}
	selObject = fontObject;
	document.getElementById('mainContent').className = fontId;
}
