// JavaScript Document
		
		

		var directory_state = 0;
		var currentQuery = '';
		var dirTimeoutid = '';
		var dirTimeoutInterval = 100;
		
		/**
			puts queries on a short delay so they can be cancelled if a new query is made  within the timeout window
		**/
		function startQueryManager(query, numResultsRequested)
		{
			cancelPreviousQuery();
			if(numResultsRequested < 0 )
			{
			dirTimeoutid = setTimeout(function(){retrive_directory(query)},dirTimeoutInterval);
			} else {
			dirTimeoutid = setTimeout(function(){retrive_directory_incomplete(query)},dirTimeoutInterval);
			}
		}
		
		/**
			Cancels query currently queued so that only the newest query is used
		**/
		function cancelPreviousQuery()
		{
			try{
			clearTimeout(dirTimeoutid);
			} catch(err) {
				// fall through, no special handling needed
				}
		}
		
		/**
			Resets the text field, search instructions, and current query obj
		**/		
		function resetDirectorySearch(textFieldObj)
		{
			if( textFieldObj.value == "Search Faculty / Staff" ){textFieldObj.value='';}

			if( textFieldObj.length < 2 )
			{$(".directory_response").html('<div style="text-align:center; width: 100%;"><br /><br />Please type the name of the Faculty,<br /> Staff that you are looking for.</div>');}
			
			currentQuery='';

			//textFieldObj.value='';
//			currentQuery='';
//			$(".directory_response").html('<div style="text-align:center; width: 100%;"><br /><br />Please type the name of the Faculty,<br /> Staff that you are looking for.</div>');
			
		}		
				
		
		function retrive_directory(query){
				
				query = $.trim(query);
				if(currentQuery == query)
				{
					return;	// don't perform a new request if the query has not changed
					}
					currentQuery = query;
				if(query.length > 1 ){
					directory_state = 1;  
					$.ajax({ url: "http://www.utpa.edu/lib/json-content.cfc?method=Directory&key="+query+"&callback=?",dataType: "jsonp", success: 
        			function(data){

				if(currentQuery != query)
				{
					return;	// don't perform a new write if the query has changed since this was requested
					}

					if(data.DATA.length > 1){
						$(".directory_response").html('<br />');
						$.each(data.DATA,function(i,data){ $(".directory_response").append("<div><a href='javascript:retrive_directory_usr("+'"'+data[0]+'"'+");'>" +data[1]+"</a></div>"); });
					}else if(data.DATA.length == 1){
						
						$.each(data.DATA,function(i,data){
												  
						var card = '<table border="1" cellpadding="0" cellspacing="0" style=" width: 406px; height: 118px; background: transparent url(http://www.utpa.edu/images/business-card.png) 0px 0px no-repeat !important; margin: 1px auto; color:#444"><tr><td style="width: 175px; margin: 0 0 0 8px; padding-top: 12px; vertical-align: top;"><div style="width: 166px; height: 61px; float: left; margin-left: 8px;"><span style="font-size: 14px; font-weight: bold;">'+data[1]+'</span><br /><span style="font-size: 10px; font-weight: normal; margin-top: 4px;">'+data[6]+'</span></div></td><td style="padding-top: 12px; margin-right: 6px;"><div style="width: 210px; height: 92px; float: right; font-weight: normal; font-size: 11px;">'+data[4]+'<br />';
						
						if(data[10].length > 0){ card = card + data[10];}
						card = card + "<br />Dept. "+data[11];
						if(data[11] != data[8] ){ card = card + "<br />Office. " +data[8];}
						if(data[12].length > 0){ card = card + "<br />Fax. " +data[12];}
						
						card = card + '<br /><a style="color:#444" href="mailto:' + data[0] + '@utpa.edu">'+data[0]+'@utpa.edu</a></div>'						
						
						$(".directory_response").html(card);
						
						});																	
					}else{
						$(".directory_response").html("<br />No user was found.");
					}	
					directory_state = 0;
        		  } });									
				}else{
					$(".directory_response").html(" ");
					if(query == ""){$(".directory_response").html('<div style="text-align:center; width: 100%;"><br /><br />Please type the name of the Faculty,<br /> Staff that you are looking for.</div>');} 
				}
			
										

		};
		
		function retrive_directory_incomplete(query){
				//alert(query);
				query = $.trim(query);
				if(currentQuery == query)
				{
					return;
					}
					currentQuery = query;
				if(query.length > 1 ){
					directory_state = 1;  
					$.ajax({ url: "http://www.utpa.edu/lib/json-content.cfc?method=DirectoryInc&key="+query+"&callback=?",dataType: "jsonp", success: 
        			function(data){
						
				if(currentQuery != query)
				{
					return;	// don't perform a new write if the query has changed since this was requested
					}						
						
					if(data.DATA.length > 1){
						$(".directory_response").html('<br />');
						$.each(data.DATA,function(i,data){ $(".directory_response").append("<div><a href='javascript:retrive_directory_usr("+'"'+data[0]+'"'+");'>" +data[1]+"</a></div>"); });
						if(data.DATA.length > 9)
						{
							$(".directory_response").append('<div style="padding-left:50px; line-height:20px; text-decoration:underline;"><a href="/directory/?results='+query+'">View complete List</a></div>')
						}
					}else if(data.DATA.length == 1){
						
						$.each(data.DATA,function(i,data){
												  
						var card = '<table border="1" cellpadding="0" cellspacing="0" style=" width: 406px; height: 118px; background: transparent url(http://www.utpa.edu/images/business-card.png) 0px 0px no-repeat !important; margin: 1px auto; color:#444"><tr><td style="width: 175px; margin: 0 0 0 8px; padding-top: 12px; vertical-align: top;"><div style="width: 166px; height: 61px; float: left; margin-left: 8px;"><span style="font-size: 14px; font-weight: bold;">'+data[1]+'</span><br /><span style="font-size: 10px; font-weight: normal; margin-top: 4px;">'+data[6]+'</span></div></td><td style="padding-top: 12px; margin-right: 6px;"><div style="width: 210px; height: 92px; float: right; font-weight: normal; font-size: 11px;">'+data[4]+'<br />';
						
						if(data[10].length > 0){ card = card + data[10];}
						card = card + "<br />Dept. "+data[11];
						if(data[11] != data[8] ){ card = card + "<br />Office. " +data[8];}
						if(data[12].length > 0){ card = card + "<br />Fax. " +data[12];}
						
						card = card + '<br /><a style="color:#444" href="mailto:' + data[0] + '@utpa.edu">' +data[0]+'@utpa.edu</a></div>'
						
						
						$(".directory_response").html(card);
						
						});					
						
						
					}else{
						$(".directory_response").html("<br />No user was found.");
					}	
					directory_state = 0;
        		  } });
					
				
				}else{
					$(".directory_response").html(" ");
					if(query == ""){$(".directory_response").html('<div style="text-align:center; width: 100%;"><br /><br />Please type the name of the Faculty,<br /> Staff that you are looking for.</div>');} 
				}
		};
		
		
		function retrive_directory_usr(query){ $.get("http://www.utpa.edu/lib/directory.cfm", { usr: query }, function(data){ $(".directory_response").html(data);});		
  		};
		
		function retrive_siteindex(query){
				//$.get("/lib/az-index.cfm", { qry: query }, function(data){ $("#content-slider").html(data); });
				
				 $.ajax({
				type: "get",
				url: "http://www.utpa.edu/lib/az-index.cfm?qry="+query,
				success: function(html){ $("#content-slider").html(html);
		 				s = parseInt(document.getElementById('content-slider').offsetHeight)-100;
						st = (s/100);				
						}
			});
				
  		};
		
		$(document).ready(function(){
			
			// ROTATION TOP CONTENT NEWS	
			function tick(){
						$(".hidden-news div:first").before($(".top-content news-headlines div:last").clone());
						
						$(".news-headlines div:last").remove();
						
						$(".news-headlines div:first").before($(".hidden-news div:last").clone());
						
						$(".hidden-news div:last").remove();
					};
            
	


					newstick = setInterval(tick, 4000);
			
			
								   
			//// TOP CONTENT CONTAINER -					   
			var opener = "";
			function top(caller, name){
					
			        if($("#top-content-container").css("height") == '190px' && opener == caller){					
					
					$("#top-content").css("display","none");
					$("#close-icon").css("display","none");					
					$("#top-menu li a").css({ 'background-image' : 'url(./images/top-menu-btn.png)', 'background-color' : 'transparent', 'background-position' : 'center', 'background-repeat' : 'no-repeat' });
					$("#top-content-container").animate({ height:"0px"}, 800);
					
					if(($("#banner-float-left").css("display") != "none"))
					{


						$("#banner-float-left").css({"display":"none" ,  "height":"0px"}, 800);
						$("#banner-float-right").css({"display":"none" , "height":"0px"}, 800);
					}
				}else{
					opener = caller;
					$("#top-content").css("display","block");
					$("#top-content-container").animate({ height:"190px"}, 800);
					
					$("#top-menu li a").css({ 'background-image' : 'url(./images/top-menu-btn.png)', 'background-color' : 'transparent', 'background-position' : 'center', 'background-repeat' : 'no-repeat' });
					
					$("#"+name).css({ 'background-image' : 'url(./images/top-menu-btn-up.png)', 'background-color' : 'transparent', 'background-position' : 'center', 'background-repeat' : 'no-repeat' });
					
						//if('$(#az-index).click'){scrollbarf();};
					
					
					$("#close-icon").css("display","block");
					
					//if(screen.width != null && screen.width < 1280)
					//if(screen.width < 1280)
					if(screen.availWidth < 1280)
					{					
						$('#top-content-container-banner').css({'background-image':'url(./images/banner-1024.jpg)'});
					}else{
						$("#banner-float-left").css({"display":"block" ,"height":"268px"});
						$("#banner-float-right").css({"display":"block","height":"268px"});
					}
				}
			};

			function tclose(){
				$("#top-content").empty();
				
				$("#top-menu li a").css({'background-image' : 'url(./images/top-menu-btn.png)', 'background-color' : 'transparent', 'background-position' : 'center', 'background-repeat' : 'no-repeat'});
				
				$("#banner-float-left").slideUp("fast");
				$("#banner-float-right").animate({ height:"0px"}, 800);
				
				$("#top-content-container").animate({ height:"0px"}, 800, function(){				
					$("#close-icon").css("display","none");
					
				});
			};
			
			 
			
			
			function content(a){
				 $.ajax({
						type: "get",
						url: "http://www.utpa.edu/lib/top-content-content.cfm?element="+a,
						success: function(html){ $("#top-content").html(html); }
				});
				
			};
			<!-- content($(this).attr("rel")) -->
			$("#close-icon").click( function(){ tclose(); } );
			$("#news-events").click( function(){ top("news",$(this).attr("id")); content($(this).attr("rel")) });
			$("#az-index").click( function(){ top("index",$(this).attr("id")); aztop(); } );
			$("#directory").click( function(){ top("dir",$(this).attr("id")); content( $(this).attr("rel")) } );
			$("#quick-links").click( function(){ top("links",$(this).attr("id")); content($(this).attr("rel")); } );


		});
		
		function aztop(){
		
			 $.ajax({
				type: "get",
				url: "http://www.utpa.edu/lib/top-content-content.cfm?element=az-index-div",
				success: function(html){ $("#top-content").html(html);
		 				scrollbarf();
						}
			});

		
		
		}
		var s = 0;
		var st = (s/100);
		function scrollbarf(){
			        //alert("DD");
					//var d = document.getElementById("content-slider");
					//alert('dd');
					//var s = 6000;
					s = parseInt(document.getElementById('content-slider').offsetHeight); 
					s = s - 100;
					 //var s = d.clientHeight;
					st = (s/100);

					var headerElem = $("#content-slider");

					
						$("#slider-vertical").slider({
							orientation: "vertical",
							range: "min",
							min: 0,
							max: 100,
							value: 100,
							slide: function(event, ui) {
								 
								$("#content-slider").css("top",(s-ui.value*st)*-1);
							}
						});
					



					$(".features").mousewheel(function(event, delta) {

								$("#content-slider").css("top",(s-deltao*st)*-1);

								event.stopPropagation();
								event.preventDefault();
					});
					
			}
						 
