Website = "http://www.google.com/u/FIUMIAMI?q=";
Library = "http://library.fiu.edu";
Internet = "http://www.google.com/search?q=";
var got=0;
var url = "";
var plus="";
var mag="";
function search4(item){
	stringPlus();
	resultsWindow=window.open();
	resultsWindow.document.open();
	resultsWindow.document.write("<head><title>Close this window "
	+ "to return to Search Page</title></head>"
	+ "<FRAMESET ROWS=50%,50%><FRAMESET COLS=50%,50%>"
	+ "<FRAME NAME='frame0' SRC='" + computeFrameSrc(0) + "'>"
	+ "<FRAME NAME='frame1' SRC='" + computeFrameSrc(1) + "'>"
	+ "</FRAMESET><FRAMESET COLS=50%,50%><FRAME NAME='frame2' "
	+ "SRC='" + computeFrameSrc(2) + "'><FRAME NAME='frame3' "
	+ "SRC='" + computeFrameSrc(3) + "'></FRAMESET></FRAMESET>");
	resultsWindow.document.close();
	got = 0;
}
function search2(item){
	stringPlus();
	resultsWindow=window.open();
	resultsWindow.document.open();
	resultsWindow.document.write("<head><title>Close this window "
	+ "to return to Total search</title></head><FRAMESET ROWS=50%,50%>"
	+ "<FRAME NAME='frame0' SRC='" + computeFrameSrc(0) + "'><FRAME "
	+ "NAME='frame1' SRC='" + computeFrameSrc(1) + "'></FRAMESET>");
	resultsWindow.document.close();
	got = 0;
}

function stringPlus() {
	for (var j=0; j < window.document.choose4.text.value.length; j++) {
	if (window.document.choose4.text.value.charAt(j) == " ")
	mag += "+";
	else mag += window.document.choose4.text.value.charAt(j);}
}

function numChecked(item) {
	plus = escape(item.text.value);
	var h=0;
	num=0;
	for (var l=0; l < item.check1.length; l++) {
	if (item.check1[l].checked) {
	h++;
	if (h++ <= 4){
	if (l == "0"){
	num = 1;}
	else if (l == "1") num = 2;
	else if (l == "2") num = 3;
	else if (l == "3") num = 4;
	else if (l == "4") num = 5;
      }
   }
}

if (h == 2)
Results(num-1);
else if (h == 4)
search2(item);
else
search4(item);
}
function computeFrameSrc(num) 
{
	var k=-1;
	for (var j=got; j < document.choose4.check1.length; j++) 
	{
		if (document.choose4.check1[j].checked)
		{
		k++;
			if (k++ <= num)
			{
				if (j == "0")
				{
					url = Library + plus + "/RO1/RP33/CM33/P11";
					got = 1;
				}
				else if (j == "1")
				{
					url = Internet + plus;
					got = 3;
				}
				else if (j == "2")
				{
					url = Internet + plus;
					got = 3;
				}
				return url;
   			}
   		}
	}
	url = "javascript:void(0)";
	return url;
}

function Results(place)
{
	stringPlus();
	resultsWin = window.open("","results");
	if (place == "0")
	url = Library + plus + "/RO1/RP33/CM33/P11";
	else if (place == "1")
	url = Internet + plus;
	else if (place == "2")
	url = Internet + plus;
	resultsWin.location = url;
}

function imgChange()
{
	//Script to select random images
	//n is the total # of images
	//n = the amount in the last bracket [10] which is 10 then add 1
	var n = 4;

	//ImageArray_val is the name of the array which holds the images with capacity of n
	//LinksArray is the name of the array which holds the links with capacity of n
	//WinArray is the name of the array which holds the value for opening a new window (eg. target=_blank)
	ImageArray_val = new Array(n);
	LinksArray = new Array(n);
	NumArray = new Array(n);
	WinArray = new Array(n);

		
	//Math function to get random numbers
	var rannum1, rannum2, rannum3;
	
	//Get first random number
	NumArray[1] = Math.floor(Math.random()*n);
	//Get second random number (loop until rannum1 and rannum2 are not equal)
	do
	{
		NumArray[2] = Math.floor(Math.random()*n);
	}while (NumArray[2] == NumArray[1]);
	
	//Get second random number (loop until (rannum3 and rannum1) and (rannum3 and rannum2) are not equal)
	do
	{
		NumArray[3] = Math.floor(Math.random()*n);
	}while ((NumArray[3] == NumArray[1]) || (NumArray[3] == NumArray[2]));
	
	//do
	//{
		//NumArray[4] = Math.floor(Math.random()*n);
	//}while ( (NumArray[4] == NumArray[1]) || (NumArray[4] == NumArray[2]) || (NumArray[4] == NumArray[3]) );
	
	//Declare by ImageArray_val[0] = "Image location"
	//Declare by LinksArray[0] = "Link location"	
	
	//Image 1	
	ImageArray_val[0] = "images/in_focus/june_9_webcam.gif";
	LinksArray[0] = "http://cam.fiu.edu/";
	WinArray[0] = "";		
	
	//Image 2
	ImageArray_val[1] = "images/in_focus/focus-medschool.gif";
	LinksArray[1] = "http://health.fiu.edu/";
	WinArray[1] = "";
	
	//Image 3
	ImageArray_val[2] = "images/in_focus/focus-pls.jpg";
	LinksArray[2] = "http://www.fiu.edu/pres/newsletter/index.htm";
	WinArray[2] = "";
	
	//Image 4
	ImageArray_val[3] = "images/in_focus/counseling_may28.gif";
	LinksArray[3] = "http://www.fiu.edu/docs/documents/psych_may27_2005.pdf";
	WinArray[3] = "";	
	

	/*Archive	
	ImageArray_val[1] = "images/in_focus/provost_lecture_series.gif";
	LinksArray[1] = "http://academic.fiu.edu/docs/lectures/";
	WinArray[1] = "";
	
	ImageArray_val[1] = "images/in_focus/june_9_pls.gif";
	LinksArray[1] = "http://www.fiu.edu/pls";
	WinArray[1] = "";
	
	ImageArray_val[3] = "images/in_focus/hurricane_experts.jpg";
	LinksArray[3] = "http://news.fiu.edu/releases/2004/06-24_hurricanes.htm";
	WinArray[3] = "";
	
	//Image x
	ImageArray_val[1] = "images/in_focus/tag.jpg";
	WinArray[1] = "";
	LinksArray[1] = "http://www.fiu.edu/fiuplate/";
	
	//Image x
	ImageArray_val[5] = "images/in_focus/consumers_digest.gif";
	LinksArray[5] = "http://news.fiu.edu/releases/2004/07-28_best_value.htm";
	WinArray[5] = "";
	
	//Image x
	ImageArray_val[3] = "images/in_focus/in_focus_geb2011.gif";
	LinksArray[3] = "http://news.fiu.edu/releases/2004/04-27_business.htm";
	WinArray[3] = "";
	
	//Image x
	ImageArray_val[4] = "images/in_focus/in_focus_global.gif";
	LinksArray[4] = "http://www.entrepreneurship.fiu.edu/";
	WinArray[4] = "target=_blank";
	
	//Image x
	ImageArray_val[2] = "images/in_focus/bballtix.gif";
	LinksArray[2] = "http://www.fiusports.com/tickets/index.htm";
	
	//Image x
	ImageArray_val[0] = "images/in_focus/june_9_study_abroad.gif";
	LinksArray[0] = "http://ois.fiu.edu/";

	
	//Image x
	ImageArray_val[5] = "images/in_focus/tutoring_03.gif";
	LinksArray[5] = "http://www.fiu.edu/%7Esuccess/main.htm";
		
	*/
}
imgChange();

//Used to open new browser window
function openWin(page, w, h) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	win = window.open(page, "video", 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=no,resizable=yes')
}