﻿// JScript File
function toggleLayer1( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
  toggleLayer1( "commentForm1" )
}

function bookmark_us(url, title) {
    title = "HOTA - " + title
    if (window.sidebar) { // firefox
        window.sidebar.addPanel(title, url, "");
    }
    else if (window.opera && window.print) { // opera
        var elem = document.createElement('a');
        elem.setAttribute('href', url);
        elem.setAttribute('title', title);
        elem.setAttribute('rel', 'sidebar');
        elem.click();
    }
    else if (document.all)// ie
        window.external.AddFavorite(url, title);

    else {
        var ua = navigator.userAgent.toLowerCase();
        var isSafari = (ua.indexOf('webkit') != -1);
        var isMac = (ua.indexOf('mac') != -1);
        var buttonStr = isMac ? 'Command/Cmd' : 'CTRL';
        if (isSafari) {
            alert('You need to press ' + buttonStr + ' + D to bookmark this page.');
        }
    }
}

function swpIMG(id,src) {
    try {
        if (strhml1selectedid==id) 
        {
            return true;
        } 
    } catch(errC){
    } 
    document.getElementById(id).src=src; return true; 
} 


function increaseFontSize() {
	
	var max = 18;
	
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s1 = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s1 = 12;
      }
      if(s1 < max) {
         s1++;
      }
      p[i].style.fontSize = s1+"px";
   }
   
   var li = document.getElementsByTagName('li');
   for(i=0;i<li.length;i++) {
      if(li[i].style.fontSize) {
         var s2 = parseInt(li[i].style.fontSize.replace("px",""));
      } else {
         var s2 = 12;
      }
      if(s2 < max) {
         s2++;
      }
      li[i].style.fontSize = s2+"px";
   }
   
   var em = document.getElementsByTagName('em');
   for(i=0;i<em.length;i++) {
      if(em[i].style.fontSize) {
         var s3 = parseInt(em[i].style.fontSize.replace("px",""));
      } else {
         var s3 = 12;
      }
      if(s3 < max) {
         s3++;
      }
      em[i].style.fontSize = s3+"px";
   }
   
   var td = document.getElementsByTagName('td');
   for(i=0;i<td.length;i++) {
      if(td[i].style.fontSize) {
         var s4 = parseInt(td[i].style.fontSize.replace("px",""));
      } else {
         var s4 = 12;
      }
      if(s4 < max) {
         s4++;
      }
      td[i].style.fontSize = s4+"px";
   }
   
   var su = document.getElementsByTagName('sup');
   for(i=0;i<su.length;i++) {
      if(su[i].style.fontSize) {
         var s6 = parseInt(su[i].style.fontSize.replace("px",""));
      } else {
         var s6 = 12;
      }
      if(s6 < max) {
         s6++;
      }
      su[i].style.fontSize = s6+"px";
   }
   var h2 = document.getElementsByTagName('h2');
   for(i=0;i<h2.length;i++) {
      if(h2[i].style.fontSize) {
         var s5 = parseInt(h2[i].style.fontSize.replace("px",""));
      } else {
         var s5 = 14;
      }
      if(s5 < 20) {
         s5++;
      }
      h2[i].style.fontSize = s5+"px";
   }      
}


function decreaseFontSize() {
	
	var min = 8;
	
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s1 = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s1 = 12;
      }
      if(s1 > min) {
         s1--;
      }
      p[i].style.fontSize = s1+"px";
   }   
   
   var li = document.getElementsByTagName('li');
   for(i=0;i<li.length;i++) {
      if(li[i].style.fontSize) {
         var s2 = parseInt(li[i].style.fontSize.replace("px",""));
      } else {
         var s2 = 12;
      }
      if(s2 > min) {
         s2--;
      }
      li[i].style.fontSize = s2+"px";
   }
   
   var em = document.getElementsByTagName('em');
   for(i=0;i<em.length;i++) {
      if(em[i].style.fontSize) {
         var s3 = parseInt(em[i].style.fontSize.replace("px",""));
      } else {
         var s3 = 12;
      }
      if(s3 > min) {
         s3--;
      }
      em[i].style.fontSize = s3+"px";
   }
      
   var td = document.getElementsByTagName('td');
   for(i=0;i<td.length;i++) {
      if(td[i].style.fontSize) {
         var s4 = parseInt(td[i].style.fontSize.replace("px",""));
      } else {
         var s4 = 12;
      }
      if(s4 > min) {
         s4--;
      }
      td[i].style.fontSize = s4+"px";
   }
   
   var su = document.getElementsByTagName('sup');
   for(i=0;i<su.length;i++) {
      if(su[i].style.fontSize) {
         var s6 = parseInt(su[i].style.fontSize.replace("px",""));
      } else {
         var s6 = 12;
      }
      if(s6 > min) {
         s6--;
      }
      su[i].style.fontSize = s6+"px";
   }
   
   var h2 = document.getElementsByTagName('h2');
   for(i=0;i<h2.length;i++) {
      if(h2[i].style.fontSize) {
         var s5 = parseInt(h2[i].style.fontSize.replace("px",""));
      } else {
         var s5= 14;
      }
      if(s5 > 10) {
         s5--;
      }
      h2[i].style.fontSize = s5+"px";
   }
         
}

function printContent(id){
	str=document.getElementById(id).innerHTML
	newwin=window.open('','printwin','left=100,top=100,width=650,height=400,scrollBars=1')
	newwin.document.write('<HTML>\n<HEAD>\n')
	newwin.document.write('<TITLE>Print Page</TITLE>\n')
	newwin.document.write('<script>\n')
	newwin.document.write('function chkstate(){\n')
	newwin.document.write('if(document.readyState=="complete"){\n')
	newwin.document.write('window.close()\n')
	newwin.document.write('}\n')
	newwin.document.write('else{\n')
	newwin.document.write('setTimeout("chkstate()",2000)\n')
	newwin.document.write('}\n')
	newwin.document.write('}\n')
	newwin.document.write('function print_win(){\n')
	newwin.document.write('window.print();\n')
	newwin.document.write('chkstate();\n')
	newwin.document.write('}\n')
	newwin.document.write('<\/script>\n')
	newwin.document.write('</HEAD>\n')
	newwin.document.write('<BODY bgcolor="#ffffff" onload="print_win()" >\n')
	newwin.document.write(str)
	newwin.document.write('</BODY>\n')
	newwin.document.write('</HTML>\n')
	newwin.document.close()
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

function openWin( windowURL, windowName, windowFeatures ) { 
	return window.open( windowURL, windowName, windowFeatures ) ; 
} 

function openNewWindow(URLtoOpen, windowName, windowFeatures) { newWindow=window.open(URLtoOpen, windowName, windowFeatures); }

function printWindow() {
bV = parseInt(navigator.appVersion);
if (bV >= 4) window.print();
}

function openWindow(url,w,h){
var windowprops = "width=" + w + ",height=" + h;
popup = window.open(url,'remote',windowprops);
}

function IsEmailValid(strEmail)
{
    //var emailExp = new RegExp("[A-Za-z0-9\-\_\+\.][A-Za-z0-9]+@[A-Za-z0-9\-\_][A-Za-z0-9\-\_]+\.[A-Za-z][A-Za-z\-\.]*$");
    
    var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
    if (strEmail.search(emailRegEx) == -1)
    {
        alert("Please ensure all email addresses are entered correctly");
        return false;
    }
    else
    {
        return true;
    }
}

function IsEmpty(sText,fieldName)
{
	if ((sText.value.length==0) ||(sText.value==null)) 
	{
	      alert('Please enter your ' + fieldName);
	      sText.focus();
	      return true;
	}
   	else 
   	{ 
   		return false; 
   	}
}

function showalldiv(){
	var x = document.getElementsByTagName('div');
	for (var i=0;i<x.length;i++)
	{
			
			if (x[i].id.indexOf("Ans") > 0) x[i].style.display = '';
			
	}

}
function hidealldiv(){
	var x = document.getElementsByTagName('div');
	for (var i=0;i<x.length;i++)
	{
			if (x[i].id.indexOf("Ans") > 0) x[i].style.display = 'none';
			
	}

}


var IFrameObj; // our IFrame object
function callToServer(ptype, pfaqsysid) {
  if (!document.createElement) {return true};
  var IFrameDoc;
  var URL = 'fcd_updatehits.aspx?_strFAQSysID=' + pfaqsysid + '&_strpType=' + ptype;
  if (!IFrameObj && document.createElement) {
    // create the IFrame and assign a reference to the
    // object to our global variable IFrameObj.
    // this will only happen the first time 
    // callToServer() is called
   try {
      var tempIFrame=document.createElement('iframe');
      tempIFrame.setAttribute('id','RSIFrame');
      tempIFrame.style.border='0px';
      tempIFrame.style.width='0px';
      tempIFrame.style.height='0px';
      IFrameObj = document.body.appendChild(tempIFrame);
      
      if (document.frames) {
        // this is for IE5 Mac, because it will only
        // allow access to the document object
        // of the IFrame if we access it through
        // the document.frames array
        IFrameObj = document.frames['RSIFrame'];
      }
    } catch(exception) {
      // This is for IE5 PC, which does not allow dynamic creation
      // and manipulation of an iframe object. Instead, we'll fake
      // it up by creating our own objects.
      iframeHTML='\<iframe id="RSIFrame" style="';
      iframeHTML+='border:0px;';
      iframeHTML+='width:0px;';
      iframeHTML+='height:0px;';
      iframeHTML+='"><\/iframe>';
      document.body.innerHTML+=iframeHTML;
      IFrameObj = new Object();
      IFrameObj.document = new Object();
      IFrameObj.document.location = new Object();
      IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
      IFrameObj.document.location.replace = function(location) {
        this.iframe.src = location;
      }
    }
  }
  
  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
    // we have to give NS6 a fraction of a second
    // to recognize the new IFrame
    setTimeout('callToServer()',10);
    //return false;
  }
  
  if (IFrameObj.contentDocument) {
    // For NS6
    IFrameDoc = IFrameObj.contentDocument; 
  } else if (IFrameObj.contentWindow) {
    // For IE5.5 and IE6
    IFrameDoc = IFrameObj.contentWindow.document;
  } else if (IFrameObj.document) {
    // For IE5
    IFrameDoc = IFrameObj.document;
  } else {
   // return true;
  }
  
  IFrameDoc.location.replace(URL);
  //return false;
}

function toggle(strID, strfaqsysid) {
    if( document.getElementById(strID).style.display=='none' ){
        document.getElementById(strID).style.display = '';
    }else{
        document.getElementById(strID).style.display = 'none';
    }
}

