// Main JavaScript

//  External disclaimer Script 
function disclaimer( lid ) {
	var msg = "Please be aware you are about to leave PHCC.edu and enter another website operated by a third party.\n";
	msg    += "The owners of external websites that are linked from the PHCC website are responsible for their content, including their links to other sites on the World Wide Web. PHCC has not necessarily reviewed these sites and assumes no responsibility for the content, nor do these \"links\" imply endorsement of the sites.\n\n";
	msg    += "Please be aware when you travel from the PHCC site to another site, you will be subject to the privacy policies (or lack thereof) of such other sites. PHCC cautions you to use good judgment and to determine the privacy policy of such sites before you provide any personal information.\n\n";
	msg    += "Click \"OK\" to continue to the third party site. If you do not wish to leave the PHCC site, click \"Cancel.\"\n\n";
	msg    += "You must have any pop-up blockers on your computer disabled in order to continue on to the external site.";
	if (confirm ( msg ) == true ) {	window.open( lid ); }
}

//  External disclaimer Script for documents containing external links
function dislink( lid ) {
	var msg = "You are about to view a PDF document that contains links external to PHCC.\n";
	msg    += "The owners of external websites that are linked from this document are responsible for their content, including their links to other sites on the World Wide Web. PHCC has not necessarily reviewed these sites and assumes no responsibility for the content, nor do these \"links\" imply endorsement of the sites.\n\n";
	msg    += "Please be aware when you travel from the PHCC site to another site, you will be subject to the privacy policies (or lack thereof) of such other sites. PHCC cautions you to use good judgment and to determine the privacy policy of such sites before you provide any personal information.\n\n";
	msg    += "Click \"OK\" to continue to the third party site. If you do not wish to leave the PHCC site, click \"Cancel.\"\n\n";
	msg    += "You must have any pop-up blockers on your computer disabled in order to continue.";
	if (confirm ( msg ) == true ) {	window.open( lid ); }
}

//  External disclaimer Script for TIP - eCashier
function ecdisclaimer( ) {
	var msg = "Please be aware you are about to leave PHCC.edu and enter another website operated by a third party.\n";
	msg    += "The owners of external websites that are linked from the PHCC website are responsible for their content, including their links to other sites on the World Wide Web. PHCC has not necessarily reviewed these sites and assumes no responsibility for the content, nor do these \"links\" imply endorsement of the sites.\n\n";
	msg    += "Please be aware when you travel from the PHCC site to another site, you will be subject to the privacy policies (or lack thereof) of such other sites. PHCC cautions you to use good judgment and to determine the privacy policy of such sites before you provide any personal information.\n\n";
	msg    += "Click \"OK\" to continue to the third party site. If you do not wish to leave the PHCC site, click \"Cancel.\"\n\n";
	msg    += "You must allow pop-ups in order to continue on to TIP.";
	if (confirm ( msg ) == true ) {	
		window.open("http://www.factstuition.com/ecashier/Index?OpenForm&query=pascohernando","remote",'toolbar=no,location=no,directories=no,status=yes,menubar=no,width=795,height=520,resizable=yes,scrollbars=yes,screenx=0,screeny=0,top=0,left=0')	
	 }
}

//  External disclaimer Script  for TIP - MyFACTS
function myfactsdisclaimer( ) {
	var msg = "Please be aware you are about to leave PHCC.edu and enter another website operated by a third party.\n";
	msg    += "The owners of external websites that are linked from the PHCC website are responsible for their content, including their links to other sites on the World Wide Web. PHCC has not necessarily reviewed these sites and assumes no responsibility for the content, nor do these \"links\" imply endorsement of the sites.\n\n";
	msg    += "Please be aware when you travel from the PHCC site to another site, you will be subject to the privacy policies (or lack thereof) of such other sites. PHCC cautions you to use good judgment and to determine the privacy policy of such sites before you provide any personal information.\n\n";
	msg    += "Click \"OK\" to continue to the third party site. If you do not wish to leave the PHCC site, click \"Cancel.\"\n\n";
	msg    += "You must allow pop-ups in order to continue on to the external website.";
	if (confirm ( msg ) == true ) {	
		window.open("https://secure.factstuition.com/facts/myfacts")	
	 }
}

//  External disclaimer Script  for myPHCC
function myphccdisclaimer( ) {

var msg = "You are about to visit a PHCC website that contains links external to PHCC.\n";
	msg    += "The owners of external websites that are linked from the PHCC website are responsible for their content, including their links to other sites on the World Wide Web. PHCC has not necessarily reviewed these sites and assumes no responsibility for the content, nor do these \"links\" imply endorsement of the sites.\n\n";
	msg    += "Please be aware when you travel from the PHCC site to another site, you will be subject to the privacy policies (or lack thereof) of such other sites. PHCC cautions you to use good judgment and to determine the privacy policy of such sites before you provide any personal information.\n\n";
	msg    += "Click \"OK\" to continue to the third party site. If you do not wish to leave the PHCC site, click \"Cancel.\"\n\n";
	msg    += "You must allow pop-ups in order to continue on to myPHCC.";
	if (confirm ( msg ) == true ) {	
		window.open("http://my.phcc.edu/")	
	 }
}



// JUMP menu function
function jumpto(x){
if (document.jump.jumpmenu.value != "null") {
	document.location.href = x;
	}
}

// MANGLE email addresses so spambots cannot harvest
// <BODY onLoad="mangle()">
// <span class="change">userid at phcc dot edu</span>
function mangle() {
  if (!document.getElementsByTagName && !document.createElement &&
    !document.createTextNode) return;
  var nodes = document.getElementsByTagName("span");
  for(var i=nodes.length-1;i>=0;i--) {
    if (nodes[i].className=="change") {
      var at = /at/;
      var dot = /dot/g;
      //var address = nodes[i].firstChild.nodeValue.split(" ").join("");
      var address = nodes[i].firstChild.nodeValue;
      var node = document.createElement("a");

      address = address.replace(" at ", "@");
      address = address.replace(" dot ", ".");
      node.setAttribute("href", "mailto:"+address);
      node.appendChild(document.createTextNode(address));

      var parent = nodes[i].parentNode;
      for(var j=0;j<parent.childNodes.length;j++)
        if (parent.childNodes[j] == nodes[i]) {
          if (!parent.replaceChild) return;
          parent.replaceChild(node, parent.childNodes[j]);
          break;
        }
    }
  }
}

function openisis() {
	window.open('https://cpnta.phcc.edu/csrs/English/WEBON.asp', 'isiswin', 'top=0, left=0, menubar=0, scrollbars=1, location=0, toolbar=0,  resizable=0, status=1');
	//window.open('https://cpnta.phcc.edu/csrs/English/WEBON.asp', 'isiswin', 'width=scrx, height=scry top=0, left=0, menubar=0, scrollbars=1, location=0, toolbar=0,  resizable=0, status=1');
}

function opengrades() {
	window.open('https://cpnta.phcc.edu/webgrades/ENGLISH/WFLON.asp', 'isiswin', 'top=0, left=0, menubar=0, scrollbars=1, location=0, toolbar=0,  resizable=0, status=1');
}


// Open new window

function jsNewWindow(jsTarget, jsWidth, jsHeight) {
	if (jsWidth == null) {
		jsWidth = 450;
	}
	if (jsHeight == null) {
		jsHeight = 500;
	}
	window.open(jsTarget,"","width=" + jsWidth + ",height=" + jsHeight + ",location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,left=100,top=100");
}

// Prevent any page from opening in a frame

if (window != top) top.location.href = location.href;

//top.location.target="_top"
   //if(window.location.target != "_top") {
      //top.location.href=window.location.href
   //}
   
//if (parent.frames.length > 0) { parent.location.href = self.document.location; }

// Auto stripe tables from a list apart

// USAGE-Requires: 
		// <body onload="stripe('stripeit', '#fff', '#edf3fe');"> - in /t/main.html
		// <table id="stripeit" ... - in each striped table
		
// this function is needed to work around 
// a bug in IE related to element attributes
  function hasClass(obj) {
     var result = false;
     if (obj.getAttributeNode("class") != null) {
         result = obj.getAttributeNode("class").value;
     }
     return result;
  }   

 function stripe(id) {

    // the flag we'll use to keep track of 
    // whether the current row is odd or even
    var even = false;
  
    // if arguments are provided to specify the colours
    // of the even & odd rows, then use the them;
    // otherwise use the following defaults:
    var evenColor = arguments[1] ? arguments[1] : "#fff";
    var oddColor = arguments[2] ? arguments[2] : "#eee";
  
    // obtain a reference to the desired table
    // if no such table exists, abort
    var table = document.getElementById(id);
    if (! table) { return; }
    
    // by definition, tables can have more than one tbody
    // element, so we'll have to get the list of child
    // &lt;tbody&gt;s 
    var tbodies = table.getElementsByTagName("tbody");

    // and iterate through them...
    for (var h = 0; h < tbodies.length; h++) {
    
     // find all the &lt;tr&gt; elements... 
      var trs = tbodies[h].getElementsByTagName("tr");
      
      // ... and iterate through them
      for (var i = 0; i < trs.length; i++) {

        // avoid rows that have a class attribute
        // or backgroundColor style
        if (! hasClass(trs[i]) &&
            ! trs[i].style.backgroundColor) {
 		  
          // get all the cells in this row...
          var tds = trs[i].getElementsByTagName("td");
        
          // and iterate through them...
          for (var j = 0; j < tds.length; j++) {
        
            var mytd = tds[j];

            // avoid cells that have a class attribute
            // or backgroundColor style
            if (! hasClass(mytd) &&
                ! mytd.style.backgroundColor) {
        
              mytd.style.backgroundColor =
                even ? evenColor : oddColor;
            
            }
          }
        }
        // flip from odd to even, or vice-versa
        even =  ! even;
      }
    }
  }
  
  
// Flash JS for EPI demo
function writeDocument(s){document.write(s);}