﻿// JavaScript Document
document.getElementsByClassName = function(cl) {
var retnode = [];
var myclass = new RegExp('\\b'+cl+'\\b');
var elem = this.getElementsByTagName('*');
for (var i = 0; i < elem.length; i++) {
var classes = elem[i].className;
if (myclass.test(classes)) retnode.push(elem[i]);
}
return retnode;
}; 

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function doClick(buttonName,e) {
//the purpose of this function is to allow the enter key to 
//point to the correct button to click.
     var key;
     if(window.event)
          key = window.event.keyCode;     //IE
     else {
          key = e.which;     //firefox     
     }

    if (key == 13)
    {
        //Get the button the user wants to have clicked
        var btn = document.getElementById(buttonName);
        if (btn != null)
        { //If we find the button click it
            
            if(window.event){
                event.keyCode = 0;
                btn.click();

            }
            else{
                var textBox = document.getElementById('searchField');
                
               // textBox.value = 'hi';
                //e.keyCode = 0;
                
                // return false;                
                window.location = "/searchResults.aspx?search_text="+textBox.value;
//                var evObj = document.createEvent('MouseEvents');
//                evObj.initEvent( 'mousemove', true, false );
//                btn.dispatchEvent(evObj);
                
            }
        }
    }
 }

/* */


 
 function submitSearch (){
    window.location.href='/SearchResults.aspx?search_text=' + document.getElementById('searchField').value;
 }
 
 function search() {
         
          window.location="http://google.cc.ucf.edu/search?q=" + document.getElementById('keyword').value +" site%3Ahttp%3A%2F%2Fwww.graduatecatalog.ucf.edu&btnG=Google+Search&entqr=0&output=xml_no_dtd&lr=&client=UCF_Main&ud=1&oe=UTF-8&ie=UTF-8&proxystylesheet=UCF_Main&site=UCF_Main";

        } 
        
         function doClick(e)
          {
   
         var key;
       
           if(window.event)
             key = window.event.keyCode;
                   //IE
           else {
            key = e.which;     //firefox     
                 }
           if (key == 13)
            { 
                //Get the button the user wants to have clicked
                  window.location="http://google.cc.ucf.edu/search?q=" + document.getElementById('keyword').value +" site%3Ahttp%3A%2F%2Fwww.graduatecatalog.ucf.edu&btnG=Google+Search&entqr=0&output=xml_no_dtd&lr=&client=UCF_Main&ud=1&oe=UTF-8&ie=UTF-8&proxystylesheet=UCF_Main&site=UCF_Main";

            }
        }
 

function hideAll() {
	for (i=0; i<arguments.length; i++){
		showHide(arguments[i]);
	}
	
}





function todayStr() {
    var today = new Date();
    return 'today.getDate()';
}
//function prefillForm()
//{
//    var objElem = document.forms[0].elements['url'];
//    if (objElem)objElem.value = window.location.href;
//}



function toggleTextSize() {
    var el = document.getElementById("rightContent");
    el.className = "rightContent1";
}


//POP-UP DIV ON CENTER OF PAGE
function popup(obj){
	//find center of page
	var myTop = (window.innerHeight/2) - 200 +'px';
	var myLeft = (window.innerWidth/2) - 150 + 'px';
	var myPosition = 'fixed';
	if (browser.isIE){
	    var myTop = (document.documentElement.clientHeight/2) - 200 +'px';
	    var myLeft = (document.documentElement.clientWidth/2) - 150 + 'px';
	    if(browser.version < '7'){
	        var myPosition = 'absolute';
	    }
	}
	document.getElementById(obj).style.display='block';
	document.getElementById(obj).style.position= myPosition;
	document.getElementById(obj).style.left = myLeft;
	document.getElementById(obj).style.top = myTop;
}

function EkFmValidate(formObj){ 
	var strError=''; var e=null;
    if (strError=='' && 'function' == typeof design_validateHtmlForm) {
        e = design_validateHtmlForm(formObj);
        if (e) { strError = e.title; }
    }
	if (strError==''){return true;}
	else {
		alert(strError);
		if ('function' == typeof e.scrollIntoView || 'object' == typeof e.scrollIntoView) e.scrollIntoView();
	    if ('function' == typeof design_canElementReceiveFocus) {
            if (design_canElementReceiveFocus(e)) e.focus();
        } else { e.focus(); }
		return false;
	}
}


//DRAG-N-DROP DIV

/**/
//<![CDATA[
//*****************************************************************************
// Do not remove this notice.
//
// Copyright 2001 by Mike Hall.
// See http://www.brainjar.com for terms of use.
//*****************************************************************************

// Determine browser and version.

function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

// Global object to hold drag information.

var dragObj = new Object();
dragObj.zIndex = 0;

function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  //dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
  
}


//function closeIframe() {

//   var iframe = document.getElementById('anotherform');
//   iframe.parentNode.removeChild(iframe);
//}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function closeIframe() {
document.getElementById('emailBox').style.display='none'; 
createCookie('survey','1','1'); 
//alert('surveyTest');
return false;
}
