<!--//
var bw = new checkBrowser();
var template = new Array();
var widthtotal=0;
var heighttotal=0;

// Setup values for Topics Page Template Layers
// TOC Iframe
var tocFrameWidthMin = 34;
var tocFrameWidthMax = 273;
var tocFrameHeight = 263;
// Dashboard Iframe
var dashFrameHeight = 76;

// Content Iframe
var contentFramestartX = 287;    
var contentFrameWidthMin = 705;
var contentFrameWidthMax = 960;
var contentHeight = 430;

// Text Mode Spacer Img
var spacerImgWidthMin = 430;
var spacerImgWidthMax = 698;
var textModeHeight = contentHeight - dashFrameHeight - 16;
// Flow Mode Flash Movie
var flowMapWidthMin = 701;
var flowMapWidthMax = 954;
var flowMapHeight = 350;

//Resize Right-Hand iFrame
function resizeFrame(i,w) {
	var iframe = document.getElementById(i);
	iframe.width = w;
}

//Resize Topics iFrame
function resizeNestedFrame(i,w) {
	var nestedIframe = parent.window.frames['content_frame'].document.getElementById(i);
	nestedIframe.width = w; 
}

//Resize Scrollable Layers
function resizeScrollingDiv(i,w) {
	if (parent.window.frames['content_frame'].window.frames.length >= 1) {
		var div = parent.window.frames['content_frame'].window.frames['qa_frame'].document.getElementById(i);
	} else {
		var div = parent.window.frames['content_frame'].document.getElementById(i);
	}
    div.style.width = w + "px";
}

//Resize Spacer Images
function resizeSpacerImg(i,w) {
	if (parent.window.frames['content_frame'].window.frames.length >= 1) {
		var image = parent.window.frames['content_frame'].window.frames['qa_frame'].document.images[i];
	} else {
		var image = parent.window.frames['content_frame'].document.images[i];
	}
	image.width = w;
}

//Resize Flash Map
function resizeMap(f,w) {
	var flowMap = parent.window.frames['content_frame'].document.flashMap;
	flowMap.width = w;
}

//Minimize Topics List
function minimizeTopics() {
    parent.window.document.forms['viewTOC'].elements['changeTOC'].value = "closed";
    eraseCookie('cookieTOC');
    saveState('cookieTOC');
    //readIt('cookieTOC');
    document.getElementById('content_frame').style.visibility = 'hidden';
    document.getElementById('cellToc').style.display = 'none';
    document.getElementById('cellTocTab').style.display = 'block';
    resizeFrame('content_frame',contentFrameWidthMax);
    if (parent.window.frames['content_frame'].window.frames.length >= 1) {
        resizeNestedFrame('qa_frame',contentFrameWidthMax,(contentHeight - dashFrameHeight));
        resizeMap('flashMap',flowMapWidthMax);
        resizeScrollingDiv('scrolling_div',contentFrameWidthMax);
    } else {
        resizeScrollingDiv('scrolling_div',(contentFrameWidthMax - 15));
    }
    resizeSpacerImg('spacer_img',spacerImgWidthMax);
    setTimeout("document.getElementById('content_frame').style.visibility = 'visible';", 1);
}

//Maximize Topics List 
function maximizeTopics() {
    parent.window.document.forms['viewTOC'].elements['changeTOC'].value = "open";
    eraseCookie('cookieTOC');
    saveState('cookieTOC');
    //readIt('cookieTOC');
    document.getElementById('content_frame').style.visibility = 'hidden';
    document.getElementById('cellTocTab').style.display = 'none';
    document.getElementById('cellToc').style.display = 'block';
    resizeFrame('content_frame',contentFrameWidthMin);
    if (parent.window.frames['content_frame'].window.frames.length >= 1) {
        resizeNestedFrame('qa_frame',contentFrameWidthMin,(contentHeight - dashFrameHeight));
        resizeMap('flashMap',flowMapWidthMin);
        resizeScrollingDiv('scrolling_div',contentFrameWidthMin);
    } else {
        resizeScrollingDiv('scrolling_div',(contentFrameWidthMin - 15));
    }
    resizeSpacerImg('spacer_img',spacerImgWidthMin);
    setTimeout("document.getElementById('content_frame').style.visibility = 'visible';", 1);
}

//Runs Query on Selected Topics & Forwards to Confirmation Page 
function generateReport() {
	parent.window.frames['toc_frame'].document.forms['topicForm'].target = parent.window.frames['content_frame'].name;
	parent.window.frames['toc_frame'].document.forms['topicForm'].submit();
}

//Print Topic View (used w/ 'Print Page' button)
function printPage(){
	if (bw.ie5 || bw.ie6) {
    var body = parent.window.frames['content_frame'].window.frames['qa_frame'].document.getElementById('qa').innerHTML;
    var loc = "<html><link rel=\"stylesheet\" href=\"/includes/print.css\" type=\"text/css\" /><body><div style=\"float: right;\"><a href=\"javascript:window.print();\">print page</a></div>" + body + "</body></html>";
    printWin = window.open('', "printWindow","status=0,resizable=no,width=500,height=400");
    printWin.document.writeln(loc);
    printWin.document.close();
    printWin.print();
    if (!bw.opr) {
      printWin.close();
    }  
  } else {
    parent.window.frames['content_frame'].window.frames['qa_frame'].print();
  }
}

//Toggle TOC between Open & Closed views 
function toggleTOC(state) {
  //alert(state);
  if(state == 'closed') {
    //resizeNestedFrame('qa_frame',contentFrameWidthMin,(contentHeight - dashFrameHeight));
		//resizeMap('flashMap',flowMapWidthMin);
		//resizeScrollingDiv('scrolling_div',contentFrameWidthMin);
    //resizeSpacerImg('spacer_img',spacerImgWidthMin);
  }
}

//Toggle between Text & Process Flow views 
function toggleMode(lyr) {
	//alert(document.forms.length);
  var topicLyr = parent.window.frames['content_frame'].document.getElementById("topic");
	var flowLyr = parent.window.frames['content_frame'].document.getElementById("processFlow");
  var txt = parent.window.frames['content_frame'].document.getElementById("textModeButton");
	var flw = parent.window.frames['content_frame'].document.getElementById("flowModeButton");
	if(document.getElementById){
		if (lyr == 'text') {
			document.forms['viewState'].elements['changeState'].value = "text";
      //flowLyr.displayOff();
      //topicLyr.displayOn();
      topicLyr.style.display = 'block';
      flowLyr.style.display = 'none';
      txt.className = 'textModeButtonOn';
			flw.className = 'flowModeButtonOff';
      eraseCookie('cookieState');
      saveIt('cookieState');
      //readIt('cookieState');
		} else {
			document.forms['viewState'].elements['changeState'].value = "flow";
      //topicLyr.displayOff();
			//flowLyr.displayOn();
      topicLyr.style.display = 'none';
      flowLyr.style.display = 'block';
      txt.className = 'textModeButtonOff';
			flw.className = 'flowModeButtonOn';
      eraseCookie('cookieState');
      saveIt('cookieState');
      //readIt('cookieState');
		}
	}
}

//Display Process Flow view (sidebar link)
function showProcessFlow() {
	var topicLyr = parent.window.document.getElementById("topic");
	var flowLyr = parent.window.document.getElementById("processFlow");
  var txt = parent.window.document.getElementById("textModeButton");
	var flw = parent.window.document.getElementById("flowModeButton");
	if(document.getElementById){
		topicLyr.style.display = 'none';
    flowLyr.style.display = 'block';
    txt.className = 'textModeButtonOff';
		flw.className = 'flowModeButtonOn';
    eraseCookie('cookieState');
    saveIt('cookieState');
    //readIt('cookieState');
	}
}

//Generic Form Submit Action
function submitForm() {
	document.forms[0].submit();
}

//Load selected Topic on Reports page from Homepage link
function loadGenerator(i) {
	parent.window.location = '/reports/index.php?id=' + i;
}

//Load Topics in Right-Hand iFrame
function loadTopics(i) {
	eraseCookie('cookieState');
  saveIt('cookieState');
  //readIt('cookieState');
  parent.window.frames['content_frame'].location='/reports/generate/index.php?id=' + i;
}

//Swap Related Video Image in Related Sidebar
function showVideoThumb(n) {
  if(document.getElementById){
    document.getElementById('videoThumb').src= "/library/video_thumbs/" + n;
  }
}

//Open Video Browser
function openVideoBrowser(topicID,videoID) {
    videoBrowser = window.open('/library/browser/index.php?topicID=' + topicID + '&videoID=' + videoID, "vidBrowser","status=yes,resizable=no,width=658,height=470");
    videoBrowser.focus();
}
//-->