function hidediv(Element) {
if (GE)
	{ // DOM3 = IE5, NS6
		try{GE(Element).style.display=1?'none':'';}catch(err){}
	}else {
		if (document.layers) { // Netscape 4
	try{document.Element.visibility = 'hidden';}catch(err){}
	}
	else { // IE 4
	try{document.all.Element.style.visibility = 'hidden';}catch(err){}
	}
	}
	}
function showdiv(Element) {
	if (GE) { // DOM3 = IE5, NS6
	try{GE(Element).style.display=0?'none':'';}catch(err){}
	}
	else {
	if (document.layers) { // Netscape 4
	try{document.Element.visibility = 'visible';}catch(err){}
	}
	else { // IE 4
	try{document.all.Element.style.visibility = 'visible';}catch(err){}
	}
	}
}

var QuickLinksVisible = 1

function ToggleQuickLinks(){
	if (QuickLinksVisible==1){
		QuickLinksVisible=0;
		hidediv('QuickLinksPopup');
		
	}else{
		QuickLinksVisible=1;
		showdiv('QuickLinksPopup');
	}	
}
function HideQuickLinks(){
	QuickLinksVisible=0;
	hidediv('QuickLinksPopup');	
}

var sorry="This content is copyrighted."

isNN = document.layers ? 1 : 0; 

function noContext(){return false;}

function noContextKey(e) {
    if(isNN){
        if (e.keyCode == 96){ return (false);}
    } else {
        if (event.keyCode == 96){ return (false);}
    }
}

function noClick(e){
    if(isNN){
        if(e.which > 1) {alert(sorry); return false;}
    } else { 
        if(event.button > 1){alert(sorry); return false;}
    }
}

if(isNN){ 
//    document.captureEvents(Event.MOUSEDOWN);
}

//document.oncontextmenu = noContext;
//document.onkeypress    = noContextKey;
//document.onmousedown   = noClick;
//document.onmouseup     = noClick;

function _DatePickerOpener(varfn,vartn,CalPath)
	{
	var OpenCal;
	OpenCal=CalPath+"?fn="+varfn+"&tn="+vartn
	window.open (OpenCal,"Noname", 'location=no,scrollbars=yes,status=yes,width=275,height=220,resizable=yes,top=0')
	}

function openHelp(page) {
	var fullPage ='../../Public/Help/' + page;
	mywindow=window.open(fullPage,'_new','width=350,height=400,resizable=yes,toolbar=no,status=yes,scrollbars=yes');
	}
	
function popUpWin(url, type, strWidth, strHeight){
	var tools="";
	if (type == "standard" || type == "fullScreen") tools = "status=yes,resizable,toolbar=no,location=no,scrollbars=yes,menubar=no,width="+strWidth+",height="+strHeight;
	if (type == "console") tools = "status=yes,resizable,toolbar=no,location=no,scrollbars=yes,width="+strWidth+",height="+strHeight+",left=0,top=0";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}
function getPosition(element)
{
  var elem=element,tagname="",x=0,y=0;

  while ((typeof(elem)=="object")&&(typeof(elem.tagName)!="undefined"))
  {
    y+=elem.offsetTop;
    x+=elem.offsetLeft;
    tagname=elem.tagName.toUpperCase();

    if (tagname=="BODY")
      elem=0;

    if (typeof(elem)=="object")
      if (typeof(elem.offsetParent)=="object")
        elem=elem.offsetParent;
  }

  position=new Object();
  position.x=x;
  position.y=y;
  return position;
}

var donthide=0;
function showPopup(url,width,height,scrolling){
	HideQuickLinks();
	fillElement(url,width,height,scrolling);
	setPopupStyles();
}
function hidePopup(){
	//if(donthide==0){
	unsetPopupStyles();
	//}else{
	//donthide=0;	
	//}
}

function CurrentScrollTop() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }
  return scrOfY;
}

window.onscroll=MovePopup;
function MovePopup(){
try
  {
    var el = GE('popupdiv');
  el.style.paddingTop="" + (CurrentScrollTop()+55) + "px"
  }
catch(err)
  {
  //Handle errors here
 alert(err); 
  }
}

function fillElement(url,width,height,scrolling) {

	image2 = new Image();
	image2.src = ImagePath + 'popuptl.png';
	image3 = new Image();
	image3.src = ImagePath + 'popuptr.png';
	image4 = new Image();
	image4.src = ImagePath + 'popupbl.png';
	image5 = new Image();
	image5.src = ImagePath + 'popupbr.png';
	image6 = new Image();
	image6.src = ImagePath + 'popupborder.png';
MovePopup();
	scrolling = typeof(scrolling) != 'undefined' ? scrolling : 'yes'
	var fullwidth = width + 28;
	var el = GE('popupdiv');
	var DivStr = '';
	DivStr += '<center><div id="divPopupWindow" style="margin-left:auto;margin-right:auto;">';
	DivStr += '<center><table width=' + fullwidth + 'px cellpadding=0 cellspacing=0 onClick="donthide=1;" onClick="donthide=1;">';
	DivStr += '		<tr>';
	DivStr += '			<td class="popuptl"></td>';
	DivStr += '			<td class="popuphorizontal"></td>';
	DivStr += '			<td class="popuptr"></td>';
	DivStr += '		</tr>';
	DivStr += '		<tr>';
	DivStr += '			<td class="popupvertical"></td>';
	DivStr += '			<td class="popupmain"><iframe style="border: solid 2px #ffffff;" # FRAMEBORDER=0 scrolling = ' + scrolling + ' src="' + url + '" width=' + width + ' height=' + height + '></iframe></td>';
	DivStr += '			<td class="popupvertical"></td>';
	DivStr += '		</tr>';
	DivStr += '		<tr>';
	DivStr += '			<td class="popupvertical"></td>';
	DivStr += '			<td class="popupmainbutton"><input type=button onClick="hidePopup();" value="Close"></td>';
	DivStr += '			<td class="popupvertical"></td>';
	DivStr += '		</tr>';
	DivStr += '		<tr>';
	DivStr += '			<td class="popupbl"></td>';
	DivStr += '			<td class="popuphorizontal"></td>';
	DivStr += '			<td class="popupbr"></td>';
	DivStr += '		</tr>';
	DivStr += '</table></center>';
	DivStr += '</div></center>';
	el.innerHTML = DivStr;
}
function setPopupStyles() {
	GE('popupdiv').setAttribute("class", "popupdivparent");
	GE('popupdiv').setAttribute("className", "popupdivparent"); 
	GE('popupdiv').style.height = maxHeight() + 'px';
}
function maxHeight() {
    var h=0; 
    if (window.document.innerHeight>h)
        h=window.document.innerHeight;
    if (window.document.documentElement.clientHeight>h)
        h=window.document.documentElement.clientHeight;
    if (window.document.body.clientHeight>h)
        h=window.document.body.clientHeight;
    return h;
}
function unsetPopupStyles() {
	GE('popupdiv').setAttribute("class", "popupdivparentNone");
	GE('popupdiv').setAttribute("className", "popupdivparentNone"); 
}function openFeedback(Question,User){	showPopup('/Secure/Exams/Feedback.aspx?QuestionId=' + Question + '&UserId=' + User,400,340,'no');} var min=8;
var max=18;
function increaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function decreaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}

function setFocus(obj){
	GE(obj).focus();
}
image1 = new Image();
image1.src = "/images/bg-links-hover.gif";


		var QBSelected='QBQuickExam';
		function QBOver(item){
			if(item.id!=QBSelected){
				item.className=item.id + 'Over';
			}
		}
		function QBOut(item){
			if(item.id!=QBSelected){
				item.className=item.id;
			}
		}
		function QBClick(item){
			if(item.id!=QBSelected){
				GE(QBSelected).className=QBSelected;
				hidediv(QBSelected + 'Content');
				QBSelected=item.id;
				item.className=item.id + 'Click';
				showdiv(QBSelected + 'Content');
			}
		}
					function toggleFlag(whichFlag,whichCheck) 
			{				
				if (whichFlag.src.indexOf("_off") == -1)
				{
					whichFlag.src='../../images/answersheet_flag_off.gif'
					GE("myCheck" + whichCheck).checked = false;
				}
				else
				{
					whichFlag.src='../../images/answersheet_flag.gif';
					GE("myCheck" + whichCheck).checked = true;
				}
			}
			
			function adjustBoxHeights() { 
        var maxHeight = 0; 
        $('a#windowLink a').each(function(){ 
                $(this).height('auto'); 
                if (maxHeight < $(this).height()) {maxHeight = $(this).height()} 
        }); 
        $('a#windowLink a').each(function(){ 
                $(this).height(maxHeight); 
        }); 
} 
