function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.display.MM_pgW=innerWidth; document.display.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.display.MM_pgW || innerHeight!=document.display.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
function MWJ_findObj( oName, oFrame, oDoc ) {
	if( !oDoc ) { if( oFrame ) { oDoc = oFrame.document; } else { oDoc = window.document; } }
	if( oDoc[oName] ) { return oDoc[oName]; } if( oDoc.all && oDoc.all[oName] ) { return oDoc.all[oName]; }
	if( oDoc.getElementById && oDoc.getElementById(oName) ) { return oDoc.getElementById(oName); }
	for( var x = 0; x < oDoc.forms.length; x++ ) { if( oDoc.forms[x][oName] ) { return oDoc.forms[x][oName]; } }
	for( var x = 0; x < oDoc.anchors.length; x++ ) { if( oDoc.anchors[x].name == oName ) { return oDoc.anchors[x]; } }
	for( var x = 0; document.display.layers && x < oDoc.layers.length; x++ ) {
		var theOb = MWJ_findObj( oName, null, oDoc.layers[x].document ); if( theOb ) { return theOb; } }
	if( !oFrame && window[oName] ) { return window[oName]; } if( oFrame && oFrame[oName] ) { return oFrame[oName]; }
	for( var x = 0; oFrame && oFrame.frames && x < oFrame.frames.length; x++ ) {
		var theOb = MWJ_findObj( oName, oFrame.frames[x], oFrame.frames[x].document ); if( theOb ) { return theOb; } }
	return null;
	}

function swapTab(i) {
	var j;
	for (j=1;j<7;++j) { 	
		MWJ_findObj("tab" + j).className = "tab"
		}
		i.className = "tabOn";
		document.display.download.value='';
	}  

function getRefToDiv(divID,oDoc) {
    if( !oDoc ) { oDoc = document; }
    if( document.layers ) {
        if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
            //repeatedly run through all child layers
            for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
                //on success, return that layer, else return nothing
                y = getRefToDiv(divID,oDoc.layers[x].document); }
            return y; } }
    if( document.getElementById ) {
        return document.getElementById(divID); }
    if( document.all ) {
        return document.all[divID]; }
    return false;
}

function swapLayers(layer_to_show) {

	var layers = new Array(5);
	layers[0] = 'help';
	layers[1] = 'dload';
	layers[2] = 'BC';
	layers[3] = 'II';
	layers[4] = 'FT';

// firstly hide all
	for (i=0;i<5;++i) {
	    myReference = getRefToDiv(layers[i]);	
	    if( myReference.style ) { //DOM & proprietary DOM 
	        myReference.style.visibility = 'hidden';
	    	} 
	    else {
	        if( myReference.visibility ) { //Netscape
	            myReference.visibility = 'hide';
	        	} 
	        else {
	            window.alert('Nothing works in this browser');
	            return false; //don't go any further
	        	}
	    	}
	}

// now show layer
	    myReference = getRefToDiv(layer_to_show);	
	    if( myReference.style ) { //DOM & proprietary DOM 
	        myReference.style.visibility = 'visible';
	    	} 
	    else {
	        if( myReference.visibility ) { //Netscape    
	            myReference.visibility = 'show';
	        	} 
	        else {
	            window.alert('Nothing works in this browser');
	            return false; //don't go any further
	        	}
	    	}
	}
	
function filters(option) { 

if (option == 'show') {     
	document.display.show_filter.value = "1";
	document.display.save_filters.value = "0";
	}

if (option == 'hide') {
	document.display.show_filter.value = "0";
	document.display.save_filters.value = "0";
	}

if (option == 'apply') {
	document.display.filters_on.value = "1";
	document.display.default_filters.value = "0";
	document.display.WON.value = "0";
	document.display.save_filters.value = "0";
	}

if (option == 'default' ) {
	document.display.filters_on.value = "1";
	document.display.show_filter.value = "1";
	document.display.default_filters.value = "1"; 
	document.display.WON.values = "0";
	document.display.save_filters.value = "0";
	}

if (option == 'all') {
	document.display.filters_on.value = "0";
	document.display.default_filters.value = "0";
	document.display.WON.value = "0";
	document.display.save_filters.value = "0";
	}	

if (option == 'WON') {
	document.display.show_filter.value = "1";
	document.display.filters_on.value = "1";
	document.display.default_filters.value = "0";
	document.display.WON.value = "1";
	document.display.save_filters.value = "0";
	document.display.tab.value = "tab4";
	}		

if (option == 'save' ) {
	document.display.filters_on.value = "1";
	document.display.default_filters.value = "1"; 
	document.display.WON.value = "0";
	document.display.save_filters.value = "1";
	}

document.display.download.value='';
document.display.submit();
}

function popUp(type, query_string) {
        var domain = "http://www.breakoutwatch.com/";
	var script = new Array(3);
	script['chart'] = domain + "charts/cache/";
	script['fbchart'] = domain + "charts/fbcache/";
	script['IL'] = domain + "industry/industry_list.php?";
	script['CE'] = domain + "CANTATA/newCE.php?"; 
	script['IC'] = domain + "industry/industry_chart.php?";
	script['HTML'] = domain;

	var width = new Array(3);
	width['chart'] = 798;
	width['IL'] = 550;
	width['CE'] = 630;
	width['IC'] = 630;
	width['HTML'] = 630;	
	var url = script[type] + query_string     
	
	var popup = window.open(url,type,"menubar,scrollbars,resizable,width=" + width[type] + ",height=600");
	popup.focus();
	
	}   

function replace_HTML(target,source) {

//	MWJ_findObj(target).innerHTML = MWJ_findObj(source).innerHTML
	getRefToDiv(target).innerHTML = getRefToDiv(source).innerHTML
	
}

	
