// -------------------------------------------------------
// JScript File
// GlobalFunctions.js for collegeinvest.org
// Version 1.4 - June 2007
// -------------------------------------------------------
function createPopUpDiv(pageSource, fHeight, fWidth) 
{
	var uA = navigator.userAgent;
	
	// Let IE do it the old-fashioned way
	if (uA.indexOf('MSIE') > -1)
	{
		window.open(pageSource, '', 'resizable=1,HEIGHT=' + fHeight + ',WIDTH=' + fWidth); 
	}
	else // Let modern browsers do it the modern way
	{
	    var div = document.createElement('div');
	    var iFrame = document.createElement('iframe');
	    var lineBreak = document.createElement('br');
	    var button = document.createElement('input');
	    
	    var theLeft;
	    var theTop;
	    
	    if (document.documentElement)
	    {
	    	theLeft = document.documentElement.scrollLeft;
	    	theTop = document.documentElement.scrollTop;
	    }
	    else
	    {
	    	theLeft = document.body.scrollLeft;
			theTop = document.body.scrollTop;
	    }
	    
	    theLeft += 100;
	    theTop += 100;
	    
	    button.setAttribute('id', 'btnClose');
	    button.setAttribute('type', 'button');
	    button.setAttribute('class', 'popUpButton');
	    button.setAttribute('value', 'Close');
	    button.setAttribute('onClick', 'this.parentNode.parentNode.removeChild(this.parentNode);');
	    button.style.marginLeft = ((theLeft + fWidth) - button.style.width);
	
	    div.setAttribute('class', 'popUp');
	    div.style.left = theLeft + 'px';
	    div.style.top = theTop + 'px';
	    div.appendChild(button);
	    div.appendChild(lineBreak);
	    div.appendChild(iFrame);
	    
	    iFrame.setAttribute('src', pageSource);
	    iFrame.setAttribute('scrolling', 'no');
	    iFrame.style.height = fHeight;
	    iFrame.style.width = fWidth;
	    document.body.appendChild(div);
    }
}

function printPage()
{      
    var printPageID = location.href.lastIndexOf("?");
    if(printPageID == -1)
    {
        if(location.host == "collegeinvestwyoming.org")
        {
            mynewURL = "?pageID=12";
            //document.write(location.host);
        }
        else
        {
            mynewURL = "?pageID=7";
        }
    }
    else
    {
        mynewURL = location.href.substring(printPageID);
    }
    window.open("PrintPage.aspx" + mynewURL, "", "width=700,left=10,top=10,scrollbars=yes","","");
}

function mailpage()
{
    mail_str = "mailto:?subject=Check out the " + document.title +" page on the CollegeInvest.org Web site";
    mail_str += "&body=I thought you might be interested in the " + document.title + " page on CollegeInvest's Web site";
    mail_str += ". You can view it at, " + location.href; 
    location.href = mail_str;
}

// -------------------------------------------------------
// This is the implementation of SimpleSwap
// by Jehiah Czebotar
// Version 1.1 - June 10, 2005
// Distributed under Creative Commons
//
// Include this script on your page
// then make image rollovers simple like:
// <img src="/images/ss_img.gif" oversrc="/images/ss_img_over.gif">
//
// http://jehiah.com/archive/simple-swap
// 
// -------------------------------------------------------

function SimpleSwap(el,which){
  el.src=el.getAttribute(which || "origsrc");
}

function SimpleSwapSetup(){
  var x = document.getElementsByTagName("img");
  for (var i=0;i<x.length;i++){
    var oversrc = x[i].getAttribute("oversrc");
    if (!oversrc) continue;
      
    // preload image
    // comment the next two lines to disable image pre-loading
    x[i].oversrc_img = new Image();
    x[i].oversrc_img.src=oversrc;
    // set event handlers
    x[i].onmouseover = new Function("SimpleSwap(this,'oversrc');");
    x[i].onmouseout = new Function("SimpleSwap(this);");
    // save original src
    x[i].setAttribute("origsrc",x[i].src);
  }
}

var PreSimpleSwapOnload =(window.onload)? window.onload : function(){};
window.onload = function(){PreSimpleSwapOnload(); SimpleSwapSetup();}

function SearchValue(){
          //window.alert(document.getElementById("tbSearchKeyword").value);
        if(document.getElementById("tbSearchKeyword").value == "")
        {
            window.alert("Please enter a keyword to search.");
            return false;
        }
}

